libram 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Clan.js +268 -485
- package/dist/Copier.js +11 -48
- package/dist/Dungeon.js +77 -157
- package/dist/Kmail.d.ts +3 -1
- package/dist/Kmail.js +92 -243
- package/dist/Path.js +68 -120
- package/dist/ascend.js +153 -172
- package/dist/combat.d.ts +84 -0
- package/dist/combat.js +294 -387
- package/dist/console.js +13 -36
- package/dist/diet/index.d.ts +23 -8
- package/dist/diet/index.js +320 -426
- package/dist/diet/knapsack.d.ts +1 -1
- package/dist/diet/knapsack.js +90 -100
- package/dist/dungeons/Dreadsylvania.d.ts +4 -0
- package/dist/dungeons/Dreadsylvania.js +14 -0
- package/dist/dungeons/Dungeon.d.ts +28 -0
- package/dist/dungeons/Dungeon.js +99 -0
- package/dist/dungeons/Hobopolis.d.ts +4 -0
- package/dist/dungeons/Hobopolis.js +14 -0
- package/dist/dungeons/SlimeTube.d.ts +4 -0
- package/dist/dungeons/SlimeTube.js +14 -0
- package/dist/freerun.d.ts +16 -4
- package/dist/freerun.js +88 -99
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -300
- package/dist/lib.d.ts +2 -0
- package/dist/lib.js +264 -515
- package/dist/logger.js +23 -63
- package/dist/maximize.js +289 -562
- package/dist/modifier.js +35 -46
- package/dist/modifierTypes.js +8 -22
- package/dist/mood.js +220 -531
- package/dist/property.d.ts +2 -0
- package/dist/property.js +96 -242
- package/dist/propertyTypes.d.ts +2 -2
- package/dist/propertyTypes.js +1 -0
- package/dist/propertyTyping.js +42 -53
- package/dist/resources/2007/CandyHearts.d.ts +9 -0
- package/dist/resources/2007/CandyHearts.js +24 -0
- package/dist/resources/2008/DivineFavors.d.ts +9 -0
- package/dist/resources/2008/DivineFavors.js +27 -0
- package/dist/resources/2009/Bandersnatch.js +37 -112
- package/dist/resources/2009/LoveSongs.d.ts +9 -0
- package/dist/resources/2009/LoveSongs.js +24 -0
- package/dist/resources/2009/SpookyPutty.js +20 -46
- package/dist/resources/2010/Brickos.d.ts +9 -0
- package/dist/resources/2010/Brickos.js +21 -0
- package/dist/resources/2010/CrownOfThrones.d.ts +9 -0
- package/dist/resources/2010/CrownOfThrones.js +550 -374
- package/dist/resources/2011/Gygaxian.d.ts +9 -0
- package/dist/resources/2011/Gygaxian.js +24 -0
- package/dist/resources/2011/ObtuseAngel.js +21 -63
- package/dist/resources/2012/RainDoh.js +14 -40
- package/dist/resources/2012/Resolutions.d.ts +9 -0
- package/dist/resources/2012/Resolutions.js +28 -0
- package/dist/resources/2013/Florist.d.ts +1 -0
- package/dist/resources/2013/Florist.js +137 -207
- package/dist/resources/2013/PulledTaffy.d.ts +9 -0
- package/dist/resources/2013/PulledTaffy.js +33 -0
- package/dist/resources/2014/WinterGarden.js +15 -43
- package/dist/resources/2015/ChateauMantegna.js +52 -86
- package/dist/resources/2015/MayoClinic.d.ts +1 -0
- package/dist/resources/2015/MayoClinic.js +30 -65
- package/dist/resources/2016/SourceTerminal.d.ts +1 -0
- package/dist/resources/2016/SourceTerminal.js +114 -237
- package/dist/resources/2016/Witchess.js +33 -59
- package/dist/resources/2017/TunnelOfLove.js +62 -111
- package/dist/resources/2018/SongBoom.js +32 -68
- package/dist/resources/2019/BeachComb.js +26 -44
- package/dist/resources/2019/Snapper.d.ts +28 -0
- package/dist/resources/2019/Snapper.js +70 -0
- package/dist/resources/2020/Guzzlr.js +79 -163
- package/dist/resources/LibramSummon.d.ts +12 -0
- package/dist/resources/LibramSummon.js +66 -0
- package/dist/resources/index.d.ts +3 -1
- package/dist/resources/index.js +19 -105
- package/dist/resources/putty-likes.js +15 -30
- package/dist/since.d.ts +1 -0
- package/dist/since.js +56 -112
- package/dist/template-string.js +40 -132
- package/dist/utils.js +36 -134
- package/package.json +2 -2
package/dist/Clan.js
CHANGED
|
@@ -1,531 +1,314 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.slice.js");
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "__esModule", {
|
|
22
|
-
value: true
|
|
23
|
-
});
|
|
24
|
-
exports.Clan = exports.ClanError = void 0;
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.array.includes.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.string.includes.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.string.match.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.array.filter.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/es.array.map.js");
|
|
37
|
-
|
|
38
|
-
require("core-js/modules/es.number.parse-int.js");
|
|
39
|
-
|
|
40
|
-
require("core-js/modules/es.array.find.js");
|
|
41
|
-
|
|
42
|
-
require("core-js/modules/es.array.sort.js");
|
|
43
|
-
|
|
44
|
-
require("core-js/modules/es.array.concat.js");
|
|
45
|
-
|
|
46
|
-
var _kolmafia = require("kolmafia");
|
|
47
|
-
|
|
48
|
-
var _lib = require("./lib");
|
|
49
|
-
|
|
50
|
-
var _logger = _interopRequireDefault(require("./logger"));
|
|
51
|
-
|
|
52
|
-
var _utils = require("./utils");
|
|
53
|
-
|
|
54
|
-
var _class;
|
|
55
|
-
|
|
56
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
57
|
-
|
|
58
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
59
|
-
|
|
60
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
61
|
-
|
|
62
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
63
|
-
|
|
64
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
65
|
-
|
|
66
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
67
|
-
|
|
68
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
69
|
-
|
|
70
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
71
|
-
|
|
72
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
73
|
-
|
|
74
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
75
|
-
|
|
76
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
77
|
-
|
|
78
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
79
|
-
|
|
80
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
81
|
-
|
|
82
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
83
|
-
|
|
84
|
-
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
85
|
-
|
|
86
|
-
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); _groups.set(_this, groups || _groups.get(re)); return _setPrototypeOf(_this, BabelRegExp.prototype); } _inherits(BabelRegExp, RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; if (typeof args[args.length - 1] !== "object") { args = [].slice.call(args); args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
|
|
87
|
-
|
|
88
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
89
|
-
|
|
90
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
91
|
-
|
|
92
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
93
|
-
|
|
94
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
95
|
-
|
|
96
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
97
|
-
|
|
98
|
-
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
99
|
-
|
|
100
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
101
|
-
|
|
102
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
103
|
-
|
|
104
|
-
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
105
|
-
|
|
106
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
107
|
-
|
|
108
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
109
|
-
|
|
110
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
111
|
-
|
|
112
|
-
var ClanError = /*#__PURE__*/function (_Error) {
|
|
113
|
-
_inherits(ClanError, _Error);
|
|
114
|
-
|
|
115
|
-
var _super = _createSuper(ClanError);
|
|
116
|
-
|
|
117
|
-
function ClanError(message, reason) {
|
|
118
|
-
var _this;
|
|
119
|
-
|
|
120
|
-
_classCallCheck(this, ClanError);
|
|
121
|
-
|
|
122
|
-
_this = _super.call(this, message);
|
|
123
|
-
|
|
124
|
-
_defineProperty(_assertThisInitialized(_this), "reason", void 0);
|
|
125
|
-
|
|
126
|
-
_this.reason = reason;
|
|
127
|
-
Object.setPrototypeOf(_assertThisInitialized(_this), ClanError.prototype);
|
|
128
|
-
return _this;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return ClanError;
|
|
132
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error)); // It would be fantastic to have this function properly typed
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { availableAmount, cliExecute, getClanId, getClanName, getPlayerId, putStash, refreshStash, retrieveItem, stashAmount, takeStash, visitUrl, xpath, } from "kolmafia";
|
|
8
|
+
import { getFoldGroup } from "./lib";
|
|
9
|
+
import logger from "./logger";
|
|
10
|
+
import { arrayToCountedMap, countedMapToArray, countedMapToString, notNull, parseNumber, } from "./utils";
|
|
11
|
+
export class ClanError extends Error {
|
|
12
|
+
constructor(message, reason) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.reason = reason;
|
|
15
|
+
Object.setPrototypeOf(this, ClanError.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// It would be fantastic to have this function properly typed
|
|
133
19
|
// But until someone can work out how to do it, it gets the
|
|
134
20
|
// comment blocks of shame
|
|
135
|
-
|
|
136
21
|
/* eslint-disable */
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
exports.ClanError = ClanError;
|
|
140
|
-
|
|
141
22
|
function validate(target, propertyName, descriptor) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
descriptor.value = function () {
|
|
23
|
+
if (!descriptor?.value)
|
|
24
|
+
return;
|
|
25
|
+
const method = descriptor.value;
|
|
146
26
|
// @ts-ignore
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return method.apply(this, args);
|
|
156
|
-
};
|
|
27
|
+
descriptor.value = function (...args) {
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
if (this.id !== getClanId()) {
|
|
30
|
+
throw new Error("You are no longer a member of this clan");
|
|
31
|
+
}
|
|
32
|
+
return method.apply(this, args);
|
|
33
|
+
};
|
|
157
34
|
}
|
|
158
35
|
/* eslint-enable */
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
var WHITELIST_DEGREE_PATTERN = /*#__PURE__*/_wrapRegExp(/(.*?) \(\xB0([0-9]+)\)/, {
|
|
170
|
-
name: 1,
|
|
171
|
-
degree: 2
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
var Clan = (_class = /*#__PURE__*/function () {
|
|
175
|
-
function Clan(id, name) {
|
|
176
|
-
_classCallCheck(this, Clan);
|
|
177
|
-
|
|
178
|
-
_defineProperty(this, "id", void 0);
|
|
179
|
-
|
|
180
|
-
_defineProperty(this, "name", void 0);
|
|
181
|
-
|
|
182
|
-
this.id = id;
|
|
183
|
-
this.name = name;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Join clan
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
_createClass(Clan, [{
|
|
191
|
-
key: "join",
|
|
192
|
-
value: function join() {
|
|
193
|
-
return Clan._join(this.id);
|
|
36
|
+
const clanIdCache = {};
|
|
37
|
+
const toPlayerId = (player) => typeof player === "string" ? getPlayerId(player) : player;
|
|
38
|
+
const LOG_FAX_PATTERN = /(\d{2}\/\d{2}\/\d{2}, \d{2}:\d{2}(?:AM|PM): )<a [^>]+>([^<]+)<\/a>(?: faxed in a (?<monster>.*?))<br>/;
|
|
39
|
+
const WHITELIST_DEGREE_PATTERN = /(?<name>.*?) \(°(?<degree>\d+)\)/;
|
|
40
|
+
export class Clan {
|
|
41
|
+
constructor(id, name) {
|
|
42
|
+
this.id = id;
|
|
43
|
+
this.name = name;
|
|
194
44
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
45
|
+
static _join(id) {
|
|
46
|
+
const result = visitUrl(`showclan.php?recruiter=1&whichclan=${id}&pwd&whichclan=${id}&action=joinclan&apply=Apply+to+this+Clan&confirm=on`);
|
|
47
|
+
if (!result.includes("clanhalltop.gif")) {
|
|
48
|
+
throw new Error("Could not join clan");
|
|
49
|
+
}
|
|
50
|
+
return Clan.get();
|
|
199
51
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
52
|
+
static _withStash(borrowFn,
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
returnFn,
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
callback) {
|
|
57
|
+
const borrowed = borrowFn();
|
|
58
|
+
const map = arrayToCountedMap(borrowed);
|
|
59
|
+
try {
|
|
60
|
+
return callback(borrowed);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (map.size > 0) {
|
|
64
|
+
const returned = arrayToCountedMap(returnFn(borrowed));
|
|
65
|
+
map.forEach((quantity, item) => {
|
|
66
|
+
const remaining = quantity - (returned.get(item) || 0);
|
|
67
|
+
if (remaining > 0) {
|
|
68
|
+
map.set(item, remaining);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
map.delete(item);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (map.size > 0) {
|
|
75
|
+
logger.error(`Failed to return <b>${countedMapToString(map)}</b> to <b>${this.name}</b> stash`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
216
79
|
}
|
|
217
80
|
/**
|
|
218
|
-
*
|
|
81
|
+
* Join a clan and return its instance
|
|
82
|
+
* @param clanIdOrName Clan id or name
|
|
219
83
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
84
|
+
static join(clanIdOrName) {
|
|
85
|
+
let clanId;
|
|
86
|
+
if (typeof clanIdOrName === "string") {
|
|
87
|
+
const clanName = clanIdOrName.toLowerCase();
|
|
88
|
+
if (clanName === getClanName().toLowerCase()) {
|
|
89
|
+
return Clan.get();
|
|
90
|
+
}
|
|
91
|
+
if (!(clanName in clanIdCache)) {
|
|
92
|
+
const clan = Clan.getWhitelisted().find((c) => c.name.toLowerCase() === clanName);
|
|
93
|
+
if (!clan) {
|
|
94
|
+
throw new Error("Player is not whitelisted to clan");
|
|
95
|
+
}
|
|
96
|
+
clanIdCache[clanName] = clan.id;
|
|
97
|
+
}
|
|
98
|
+
clanId = clanIdCache[clanName];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
clanId = clanIdOrName;
|
|
102
|
+
if (clanId === getClanId()) {
|
|
103
|
+
return Clan.get();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Clan._join(clanId);
|
|
241
107
|
}
|
|
242
108
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* @param
|
|
246
|
-
* @param rankName Rank to give the player. If not provided they will be given the lowest rank
|
|
247
|
-
* @param title Title to give the player. If not provided, will be blank
|
|
109
|
+
* Execute callback as a member of a clan
|
|
110
|
+
* and then restore prior membership
|
|
111
|
+
* @param clanIdOrName Clan id or name
|
|
248
112
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
var result = (0, _kolmafia.visitUrl)("clan_whitelist.php?action=add&pwd&addwho=".concat(playerId, "&level=").concat(rank.id, "&title=").concat(title));
|
|
259
|
-
return result.includes("added to whitelist.") || result.includes("That player is already on the whitelist");
|
|
113
|
+
static with(clanIdOrName, callback) {
|
|
114
|
+
const startingClan = Clan.get();
|
|
115
|
+
const clan = Clan.join(clanIdOrName);
|
|
116
|
+
try {
|
|
117
|
+
return callback(clan);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
startingClan.join();
|
|
121
|
+
}
|
|
260
122
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}, {
|
|
267
|
-
key: "removePlayerFromWhitelist",
|
|
268
|
-
value: function removePlayerFromWhitelist(player) {
|
|
269
|
-
var playerId = toPlayerId(player);
|
|
270
|
-
var result = (0, _kolmafia.visitUrl)("clan_whitelist.php?action=updatewl&pwd&who=".concat(playerId, "&remove=Remove"));
|
|
271
|
-
return result.includes("Whitelist updated.");
|
|
123
|
+
static withStash(clanIdOrName, items, // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
124
|
+
callback // eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
125
|
+
) {
|
|
126
|
+
return Clan._withStash(() => Clan.with(clanIdOrName, (clan) => clan.take(items)), (borrowed) => Clan.with(clanIdOrName, (clan) => clan.put(borrowed)), callback);
|
|
272
127
|
}
|
|
273
128
|
/**
|
|
274
|
-
* Return
|
|
129
|
+
* Return player's current Clan
|
|
275
130
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
key: "getMeatInCoffer",
|
|
279
|
-
value: function getMeatInCoffer() {
|
|
280
|
-
var page = (0, _kolmafia.visitUrl)("clan_stash.php");
|
|
281
|
-
|
|
282
|
-
var _ref = page.match(/Your <b>Clan Coffer<\/b> contains ([\d,]+) Meat./) || ["0", "0"],
|
|
283
|
-
_ref2 = _slicedToArray(_ref, 2),
|
|
284
|
-
meat = _ref2[1];
|
|
285
|
-
|
|
286
|
-
return (0, _utils.parseNumber)(meat);
|
|
131
|
+
static get() {
|
|
132
|
+
return new Clan(getClanId(), getClanName());
|
|
287
133
|
}
|
|
288
134
|
/**
|
|
289
|
-
*
|
|
290
|
-
* @param amount Amount of meat to put in coffer
|
|
135
|
+
* Get list of clans to which the player is whitelisted
|
|
291
136
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
137
|
+
static getWhitelisted() {
|
|
138
|
+
const page = visitUrl("clan_signup.php");
|
|
139
|
+
return xpath(page, '//select[@name="whichclan"]//option').map((option) => {
|
|
140
|
+
const validHtml = `<select>${option}</select>`;
|
|
141
|
+
const id = Number.parseInt(xpath(validHtml, "//@value")[0]);
|
|
142
|
+
const name = xpath(validHtml, "//text()")[0];
|
|
143
|
+
return new Clan(id, name);
|
|
144
|
+
});
|
|
298
145
|
}
|
|
299
146
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* This function will also take equivalent foldables if the original item cannot be found
|
|
303
|
-
*
|
|
304
|
-
* @param items Items to take
|
|
305
|
-
* @returns Items successfully taken
|
|
147
|
+
* Join clan
|
|
306
148
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
key: "take",
|
|
310
|
-
value: function take(items) {
|
|
311
|
-
var map = (0, _utils.arrayToCountedMap)(items);
|
|
312
|
-
map.forEach((quantity, item) => {
|
|
313
|
-
var needed = Math.max(0, quantity - (0, _kolmafia.availableAmount)(item));
|
|
314
|
-
|
|
315
|
-
if (needed === 0) {
|
|
316
|
-
return map.set(item, 0);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
var foldGroup = (0, _lib.getFoldGroup)(item);
|
|
320
|
-
|
|
321
|
-
var _iterator = _createForOfIteratorHelper(foldGroup),
|
|
322
|
-
_step;
|
|
323
|
-
|
|
324
|
-
try {
|
|
325
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
326
|
-
var foldable = _step.value;
|
|
327
|
-
var quantityToFold = Math.min(needed, (0, _kolmafia.availableAmount)(foldable));
|
|
328
|
-
|
|
329
|
-
for (var _i3 = 0; _i3 < quantityToFold; _i3++) {
|
|
330
|
-
(0, _kolmafia.cliExecute)("fold ".concat(item.name));
|
|
331
|
-
needed--;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return map.set(item, needed);
|
|
335
|
-
}
|
|
336
|
-
} catch (err) {
|
|
337
|
-
_iterator.e(err);
|
|
338
|
-
} finally {
|
|
339
|
-
_iterator.f();
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
(0, _kolmafia.refreshStash)();
|
|
343
|
-
|
|
344
|
-
for (var _i2 = 0, _arr2 = [item].concat(_toConsumableArray(foldGroup)); _i2 < _arr2.length; _i2++) {
|
|
345
|
-
var matchingItem = _arr2[_i2];
|
|
346
|
-
var quantityToTake = Math.min(needed, (0, _kolmafia.stashAmount)(matchingItem));
|
|
347
|
-
if (quantityToTake === 0) continue; // If we can't take from the stash, there's no sense in iterating through the whole fold group
|
|
348
|
-
|
|
349
|
-
if (!(0, _kolmafia.takeStash)(quantityToTake, matchingItem)) return;
|
|
350
|
-
|
|
351
|
-
if (matchingItem === item) {
|
|
352
|
-
needed -= quantityToTake;
|
|
353
|
-
} else {
|
|
354
|
-
for (var i = 0; i < quantityToTake; i++) {
|
|
355
|
-
(0, _kolmafia.cliExecute)("fold ".concat(matchingItem.name));
|
|
356
|
-
needed--;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
return Array.isArray(items) ? (0, _utils.countedMapToArray)(map) : map;
|
|
149
|
+
join() {
|
|
150
|
+
return Clan._join(this.id);
|
|
362
151
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
* @param items Items to put in the stash
|
|
366
|
-
* @returns Items successfully put in the stash
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
}, {
|
|
370
|
-
key: "put",
|
|
371
|
-
value: function put(items) {
|
|
372
|
-
var map = (0, _utils.arrayToCountedMap)(items);
|
|
373
|
-
if (!this.check()) throw new Error("Wanted to return ".concat((0, _utils.countedMapToString)(map), " to ").concat(this.name, " but KoLmafia's clan data is out of sync"));
|
|
374
|
-
map.forEach((quantity, item) => {
|
|
375
|
-
(0, _kolmafia.retrieveItem)(quantity, item);
|
|
376
|
-
var returned = Math.min(quantity, (0, _kolmafia.availableAmount)(item));
|
|
377
|
-
(0, _kolmafia.putStash)(returned, item);
|
|
378
|
-
map.set(item, quantity - returned);
|
|
379
|
-
});
|
|
380
|
-
return Array.isArray(items) ? (0, _utils.countedMapToArray)(map) : map;
|
|
152
|
+
check() {
|
|
153
|
+
return visitUrl("clan_hall.php").includes(`<b>${this.name}</b>`);
|
|
381
154
|
}
|
|
382
155
|
/**
|
|
383
156
|
* Return the monster that is currently in the current clan's fax machine if any
|
|
384
157
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
value: function _join(id) {
|
|
395
|
-
var result = (0, _kolmafia.visitUrl)("showclan.php?recruiter=1&whichclan=".concat(id, "&pwd&whichclan=").concat(id, "&action=joinclan&apply=Apply+to+this+Clan&confirm=on"));
|
|
396
|
-
|
|
397
|
-
if (!result.includes("clanhalltop.gif")) {
|
|
398
|
-
throw new Error("Could not join clan");
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return Clan.get();
|
|
402
|
-
}
|
|
403
|
-
}, {
|
|
404
|
-
key: "_withStash",
|
|
405
|
-
value: function _withStash(borrowFn, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
406
|
-
returnFn, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
407
|
-
callback) {
|
|
408
|
-
var borrowed = borrowFn();
|
|
409
|
-
var map = (0, _utils.arrayToCountedMap)(borrowed);
|
|
410
|
-
|
|
411
|
-
try {
|
|
412
|
-
return callback(borrowed);
|
|
413
|
-
} finally {
|
|
414
|
-
if (map.size > 0) {
|
|
415
|
-
var returned = (0, _utils.arrayToCountedMap)(returnFn(borrowed));
|
|
416
|
-
map.forEach((quantity, item) => {
|
|
417
|
-
var remaining = quantity - (returned.get(item) || 0);
|
|
418
|
-
|
|
419
|
-
if (remaining > 0) {
|
|
420
|
-
map.set(item, remaining);
|
|
421
|
-
} else {
|
|
422
|
-
map.delete(item);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
if (map.size > 0) {
|
|
427
|
-
_logger.default.error("Failed to return <b>".concat((0, _utils.countedMapToString)(map), "</b> to <b>").concat(this.name, "</b> stash"));
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
158
|
+
getCurrentFax() {
|
|
159
|
+
const logs = visitUrl("clan_log.php");
|
|
160
|
+
const lastFax = logs.match(LOG_FAX_PATTERN);
|
|
161
|
+
if (!lastFax)
|
|
162
|
+
return null;
|
|
163
|
+
const [, , , monsterName] = lastFax;
|
|
164
|
+
if (!monsterName)
|
|
165
|
+
return null;
|
|
166
|
+
return Monster.get(monsterName);
|
|
431
167
|
}
|
|
432
168
|
/**
|
|
433
|
-
*
|
|
434
|
-
* @param clanIdOrName Clan id or name
|
|
169
|
+
* List available ranks (name, degree and id) from the current clan
|
|
435
170
|
*/
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
throw new Error("Player is not whitelisted to clan");
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
clanIdCache[_clanName] = clan.id;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
clanId = clanIdCache[_clanName];
|
|
460
|
-
} else {
|
|
461
|
-
clanId = clanIdOrName;
|
|
462
|
-
|
|
463
|
-
if (clanId === (0, _kolmafia.getClanId)()) {
|
|
464
|
-
return Clan.get();
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return Clan._join(clanId);
|
|
171
|
+
getRanks() {
|
|
172
|
+
const page = visitUrl("clan_whitelist.php");
|
|
173
|
+
return xpath(page, '//select[@name="level"]//option')
|
|
174
|
+
.map((option) => {
|
|
175
|
+
const validHtml = `<select>${option}</select>`;
|
|
176
|
+
const match = xpath(validHtml, "//text()")[0].match(WHITELIST_DEGREE_PATTERN);
|
|
177
|
+
const id = xpath(validHtml, "//@value")[0];
|
|
178
|
+
if (!match || !id)
|
|
179
|
+
return null;
|
|
180
|
+
const [, name, degree] = match;
|
|
181
|
+
return {
|
|
182
|
+
name,
|
|
183
|
+
degree: Number.parseInt(degree),
|
|
184
|
+
id: Number.parseInt(id),
|
|
185
|
+
};
|
|
186
|
+
})
|
|
187
|
+
.filter(notNull);
|
|
469
188
|
}
|
|
470
189
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @param
|
|
190
|
+
* Add a player to the current clan's whitelist.
|
|
191
|
+
* If the player is already in the whitelist this will change their rank or title.
|
|
192
|
+
* @param player Player id or name
|
|
193
|
+
* @param rankName Rank to give the player. If not provided they will be given the lowest rank
|
|
194
|
+
* @param title Title to give the player. If not provided, will be blank
|
|
474
195
|
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
196
|
+
addPlayerToWhitelist(player, rankName, title = "") {
|
|
197
|
+
const playerId = toPlayerId(player);
|
|
198
|
+
const ranks = this.getRanks();
|
|
199
|
+
const rank = rankName
|
|
200
|
+
? ranks.find((r) => r.name === rankName)
|
|
201
|
+
: ranks.sort((a, b) => a.degree - b.degree)[0];
|
|
202
|
+
if (!rank)
|
|
203
|
+
return false;
|
|
204
|
+
const result = visitUrl(`clan_whitelist.php?action=add&pwd&addwho=${playerId}&level=${rank.id}&title=${title}`);
|
|
205
|
+
return (result.includes("added to whitelist.") ||
|
|
206
|
+
result.includes("That player is already on the whitelist"));
|
|
487
207
|
}
|
|
488
208
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
* During the execution of the callback, player will not be in the stash clan
|
|
493
|
-
*
|
|
494
|
-
* @param clanIdOrName Clan id or name
|
|
209
|
+
* Remove a player from the current clan's whitelist
|
|
210
|
+
* @param player Player id or name
|
|
495
211
|
*/
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
callback) {
|
|
501
|
-
return Clan._withStash(() => Clan.with(clanIdOrName, clan => clan.take(items)), borrowed => Clan.with(clanIdOrName, clan => clan.put(borrowed)), callback);
|
|
212
|
+
removePlayerFromWhitelist(player) {
|
|
213
|
+
const playerId = toPlayerId(player);
|
|
214
|
+
const result = visitUrl(`clan_whitelist.php?action=updatewl&pwd&who=${playerId}&remove=Remove`);
|
|
215
|
+
return result.includes("Whitelist updated.");
|
|
502
216
|
}
|
|
503
217
|
/**
|
|
504
|
-
* Return
|
|
218
|
+
* Return the amount of meat in the current clan's coffer.
|
|
505
219
|
*/
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return new Clan((0, _kolmafia.getClanId)(), (0, _kolmafia.getClanName)());
|
|
220
|
+
getMeatInCoffer() {
|
|
221
|
+
const page = visitUrl("clan_stash.php");
|
|
222
|
+
const [, meat] = page.match(/Your <b>Clan Coffer<\/b> contains ([\d,]+) Meat./) || ["0", "0"];
|
|
223
|
+
return parseNumber(meat);
|
|
511
224
|
}
|
|
512
225
|
/**
|
|
513
|
-
*
|
|
226
|
+
* Add the given amount of meat to the current clan's coffer.
|
|
227
|
+
* @param amount Amount of meat to put in coffer
|
|
514
228
|
*/
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
229
|
+
putMeatInCoffer(amount) {
|
|
230
|
+
const result = visitUrl(`clan_stash.php?pwd&action=contribute&howmuch=${amount}`);
|
|
231
|
+
return result.includes("You contributed");
|
|
232
|
+
}
|
|
233
|
+
take(items) {
|
|
234
|
+
const map = arrayToCountedMap(items);
|
|
235
|
+
map.forEach((quantity, item) => {
|
|
236
|
+
let needed = Math.max(0, quantity - availableAmount(item));
|
|
237
|
+
if (needed === 0) {
|
|
238
|
+
return map.set(item, 0);
|
|
239
|
+
}
|
|
240
|
+
const foldGroup = getFoldGroup(item);
|
|
241
|
+
for (const foldable of foldGroup) {
|
|
242
|
+
const quantityToFold = Math.min(needed, availableAmount(foldable));
|
|
243
|
+
for (let i = 0; i < quantityToFold; i++) {
|
|
244
|
+
cliExecute(`fold ${item.name}`);
|
|
245
|
+
needed--;
|
|
246
|
+
}
|
|
247
|
+
return map.set(item, needed);
|
|
248
|
+
}
|
|
249
|
+
refreshStash();
|
|
250
|
+
for (const matchingItem of [item, ...foldGroup]) {
|
|
251
|
+
const quantityToTake = Math.min(needed, stashAmount(matchingItem));
|
|
252
|
+
if (quantityToTake === 0)
|
|
253
|
+
continue;
|
|
254
|
+
// If we can't take from the stash, there's no sense in iterating through the whole fold group
|
|
255
|
+
if (!takeStash(quantityToTake, matchingItem))
|
|
256
|
+
return;
|
|
257
|
+
if (matchingItem === item) {
|
|
258
|
+
needed -= quantityToTake;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
for (let i = 0; i < quantityToTake; i++) {
|
|
262
|
+
cliExecute(`fold ${matchingItem.name}`);
|
|
263
|
+
needed--;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return Array.isArray(items) ? countedMapToArray(map) : map;
|
|
269
|
+
}
|
|
270
|
+
put(items) {
|
|
271
|
+
const map = arrayToCountedMap(items);
|
|
272
|
+
if (!this.check())
|
|
273
|
+
throw new Error(`Wanted to return ${countedMapToString(map)} to ${this.name} but KoLmafia's clan data is out of sync`);
|
|
274
|
+
map.forEach((quantity, item) => {
|
|
275
|
+
retrieveItem(quantity, item);
|
|
276
|
+
const returned = Math.min(quantity, availableAmount(item));
|
|
277
|
+
putStash(returned, item);
|
|
278
|
+
map.set(item, quantity - returned);
|
|
279
|
+
});
|
|
280
|
+
return Array.isArray(items) ? countedMapToArray(map) : map;
|
|
526
281
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
282
|
+
withStash(items, callback // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
283
|
+
) {
|
|
284
|
+
const map = arrayToCountedMap(items);
|
|
285
|
+
return Clan._withStash(() => this.take(map), (borrowed) => this.put(borrowed), callback);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
__decorate([
|
|
289
|
+
validate
|
|
290
|
+
], Clan.prototype, "getCurrentFax", null);
|
|
291
|
+
__decorate([
|
|
292
|
+
validate
|
|
293
|
+
], Clan.prototype, "getRanks", null);
|
|
294
|
+
__decorate([
|
|
295
|
+
validate
|
|
296
|
+
], Clan.prototype, "addPlayerToWhitelist", null);
|
|
297
|
+
__decorate([
|
|
298
|
+
validate
|
|
299
|
+
], Clan.prototype, "removePlayerFromWhitelist", null);
|
|
300
|
+
__decorate([
|
|
301
|
+
validate
|
|
302
|
+
], Clan.prototype, "getMeatInCoffer", null);
|
|
303
|
+
__decorate([
|
|
304
|
+
validate
|
|
305
|
+
], Clan.prototype, "putMeatInCoffer", null);
|
|
306
|
+
__decorate([
|
|
307
|
+
validate
|
|
308
|
+
], Clan.prototype, "take", null);
|
|
309
|
+
__decorate([
|
|
310
|
+
validate
|
|
311
|
+
], Clan.prototype, "put", null);
|
|
312
|
+
__decorate([
|
|
313
|
+
validate
|
|
314
|
+
], Clan.prototype, "withStash", null);
|