libram 0.3.1 → 0.4.1

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.
Files changed (46) hide show
  1. package/dist/Kmail.d.ts +10 -6
  2. package/dist/Kmail.js +17 -7
  3. package/dist/combat.d.ts +2 -1
  4. package/dist/combat.js +3 -2
  5. package/dist/diet/index.d.ts +16 -0
  6. package/dist/diet/index.js +439 -0
  7. package/dist/diet/knapsack.d.ts +7 -0
  8. package/dist/diet/knapsack.js +116 -0
  9. package/dist/freerun.d.ts +11 -0
  10. package/dist/freerun.js +103 -0
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.js +38 -1
  13. package/dist/lib.d.ts +41 -0
  14. package/dist/lib.js +144 -2
  15. package/dist/maximize.d.ts +29 -12
  16. package/dist/maximize.js +264 -94
  17. package/dist/modifier.d.ts +13 -0
  18. package/dist/modifier.js +46 -0
  19. package/dist/modifierTypes.d.ts +16 -0
  20. package/dist/modifierTypes.js +23 -0
  21. package/dist/propertyTypes.d.ts +9 -0
  22. package/dist/propertyTypes.js +0 -0
  23. package/dist/propertyTyping.d.ts +2 -9
  24. package/dist/resources/2010/CrownOfThrones.d.ts +9 -0
  25. package/dist/resources/2010/CrownOfThrones.js +374 -0
  26. package/dist/resources/2013/Florist.d.ts +60 -0
  27. package/dist/resources/2013/Florist.js +219 -0
  28. package/dist/resources/2015/MayoClinic.d.ts +12 -0
  29. package/dist/resources/2015/MayoClinic.js +71 -0
  30. package/dist/resources/2019/BeachComb.d.ts +2 -0
  31. package/dist/resources/2019/BeachComb.js +44 -0
  32. package/dist/resources/index.d.ts +16 -11
  33. package/dist/resources/index.js +45 -25
  34. package/dist/ring-buffer.d.ts +24 -0
  35. package/dist/ring-buffer.js +135 -0
  36. package/dist/utils.d.ts +14 -0
  37. package/dist/utils.js +34 -0
  38. package/package.json +4 -2
  39. package/dist/libram-example-briefcase.js +0 -16073
  40. package/dist/libram-example-clan.js +0 -8898
  41. package/dist/libram-example-consult.js +0 -6179
  42. package/dist/libram-example-item.js +0 -3248
  43. package/dist/libram-example-kmail.js +0 -2065
  44. package/dist/libram-example-lib.js +0 -7608
  45. package/dist/libram-example-props.js +0 -4770
  46. package/dist/libram-example-resources.js +0 -12226
package/dist/maximize.js CHANGED
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", {
13
13
  });
14
14
  exports.setDefaultMaximizeOptions = setDefaultMaximizeOptions;
15
15
  exports.maximizeCached = maximizeCached;
16
- exports.maximizeRequirementsCached = maximizeRequirementsCached;
17
16
  exports.Requirement = void 0;
18
17
 
19
18
  require("core-js/modules/es.array.iterator.js");
@@ -22,69 +21,71 @@ require("core-js/modules/es.object.to-string.js");
22
21
 
23
22
  require("core-js/modules/es.object.assign.js");
24
23
 
25
- require("core-js/modules/es.array.map.js");
24
+ require("core-js/modules/es.array.sort.js");
25
+
26
+ require("core-js/modules/es.array.concat.js");
26
27
 
27
28
  require("core-js/modules/es.array.filter.js");
28
29
 
29
- require("core-js/modules/es.array.concat.js");
30
+ require("core-js/modules/es.array.splice.js");
31
+
32
+ require("core-js/modules/es.array.map.js");
30
33
 
31
34
  require("core-js/modules/es.array.includes.js");
32
35
 
33
36
  require("core-js/modules/es.string.includes.js");
34
37
 
35
- require("core-js/modules/es.array.sort.js");
36
-
37
38
  var _kolmafia = require("kolmafia");
38
39
 
39
40
  var _templateString = require("./template-string");
40
41
 
41
42
  var _logger = _interopRequireDefault(require("./logger"));
42
43
 
43
- var _merge2 = _interopRequireDefault(require("lodash/merge"));
44
+ var _utils = require("./utils");
44
45
 
45
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37;
46
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38, _templateObject39, _templateObject40, _templateObject41, _templateObject42, _templateObject43, _templateObject44;
46
47
 
47
48
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
48
49
 
49
- 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); } }
50
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
50
51
 
51
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
52
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
52
53
 
53
- function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
54
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
54
55
 
55
- function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
56
+ 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."); }
56
57
 
57
- function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
58
+ 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; }
58
59
 
59
- function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
60
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
60
61
 
61
- function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
62
+ 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; } } }; }
62
63
 
63
64
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
64
65
 
65
66
  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."); }
66
67
 
68
+ 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); }
69
+
67
70
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
68
71
 
69
72
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
70
73
 
71
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
72
-
73
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
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; }
74
75
 
75
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
76
+ 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); } }
76
77
 
77
- 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."); }
78
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
78
79
 
79
- 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; }
80
+ function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
80
81
 
81
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
82
+ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
82
83
 
83
- 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; } } }; }
84
+ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
84
85
 
85
- 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); }
86
+ function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
86
87
 
87
- 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; }
88
+ function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
88
89
 
89
90
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
90
91
 
@@ -95,6 +96,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
95
96
  var defaultMaximizeOptions = {
96
97
  updateOnFamiliarChange: true,
97
98
  updateOnCanEquipChanged: true,
99
+ useOutfitCaching: true,
98
100
  forceEquip: [],
99
101
  preventEquip: [],
100
102
  bonusEquip: new Map(),
@@ -133,10 +135,107 @@ var CacheEntry = function CacheEntry(equipment, rider, familiar, canEquipItemCou
133
135
  this.rider = rider;
134
136
  this.familiar = familiar;
135
137
  this.canEquipItemCount = canEquipItemCount;
136
- }; // Objective cache entries.
138
+ };
139
+
140
+ var _outfitSlots = /*#__PURE__*/new WeakMap();
137
141
 
142
+ var _useHistory = /*#__PURE__*/new WeakMap();
138
143
 
139
- var cachedObjectives = {}; // Cache to prevent rescanning all items unnecessarily
144
+ var _maxSize = /*#__PURE__*/new WeakMap();
145
+
146
+ var OutfitLRUCache = /*#__PURE__*/function () {
147
+ // Current outfits allocated
148
+ // Array of indices into #outfitSlots in order of use. Most recent at the front.
149
+ function OutfitLRUCache(maxSize) {
150
+ _classCallCheck(this, OutfitLRUCache);
151
+
152
+ _outfitSlots.set(this, {
153
+ writable: true,
154
+ value: []
155
+ });
156
+
157
+ _useHistory.set(this, {
158
+ writable: true,
159
+ value: []
160
+ });
161
+
162
+ _maxSize.set(this, {
163
+ writable: true,
164
+ value: void 0
165
+ });
166
+
167
+ _classPrivateFieldSet(this, _maxSize, maxSize);
168
+ }
169
+
170
+ _createClass(OutfitLRUCache, [{
171
+ key: "checkConsistent",
172
+ value: function checkConsistent() {
173
+ if (_classPrivateFieldGet(this, _useHistory).length !== _classPrivateFieldGet(this, _outfitSlots).length || !_toConsumableArray(_classPrivateFieldGet(this, _useHistory)).sort().every((value, index) => value === index)) {
174
+ throw new Error("Outfit cache consistency failed.");
175
+ }
176
+ }
177
+ }, {
178
+ key: "promote",
179
+ value: function promote(index) {
180
+ _classPrivateFieldSet(this, _useHistory, [index].concat(_toConsumableArray(_classPrivateFieldGet(this, _useHistory).filter(i => i !== index))));
181
+
182
+ this.checkConsistent();
183
+ }
184
+ }, {
185
+ key: "get",
186
+ value: function get(key) {
187
+ var index = _classPrivateFieldGet(this, _outfitSlots).indexOf(key);
188
+
189
+ if (index < 0) return undefined;
190
+ this.promote(index);
191
+ return "".concat(OutfitLRUCache.OUTFIT_PREFIX, " ").concat(index);
192
+ }
193
+ }, {
194
+ key: "insert",
195
+ value: function insert(key) {
196
+ var lastUseIndex = undefined;
197
+
198
+ if (_classPrivateFieldGet(this, _outfitSlots).length >= _classPrivateFieldGet(this, _maxSize)) {
199
+ lastUseIndex = _classPrivateFieldGet(this, _useHistory).pop();
200
+
201
+ if (lastUseIndex === undefined) {
202
+ throw new Error("Outfit cache consistency failed.");
203
+ }
204
+
205
+ _classPrivateFieldGet(this, _useHistory).splice(0, 0, lastUseIndex);
206
+
207
+ _classPrivateFieldGet(this, _outfitSlots)[lastUseIndex] = key;
208
+ this.checkConsistent();
209
+ return "".concat(OutfitLRUCache.OUTFIT_PREFIX, " ").concat(lastUseIndex);
210
+ } else {
211
+ var index = _classPrivateFieldGet(this, _outfitSlots).push(key) - 1;
212
+
213
+ _classPrivateFieldGet(this, _useHistory).splice(0, 0, index);
214
+
215
+ this.checkConsistent();
216
+ return "".concat(OutfitLRUCache.OUTFIT_PREFIX, " ").concat(index);
217
+ }
218
+ }
219
+ }]);
220
+
221
+ return OutfitLRUCache;
222
+ }();
223
+ /**
224
+ * Save current equipment as KoL-native outfit.
225
+ * @param name Name of new outfit.
226
+ */
227
+
228
+
229
+ _defineProperty(OutfitLRUCache, "OUTFIT_PREFIX", "Script Outfit");
230
+
231
+ function saveOutfit(name) {
232
+ (0, _kolmafia.cliExecute)("outfit save ".concat(name));
233
+ } // Objective cache entries.
234
+
235
+
236
+ var cachedObjectives = {}; // Outfit cache entries. Keep 6 by default to avoid cluttering list.
237
+
238
+ var outfitCache = new OutfitLRUCache(6); // Cache to prevent rescanning all items unnecessarily
140
239
 
141
240
  var cachedStats = [0, 0, 0];
142
241
  var cachedCanEquipItemCount = 0;
@@ -165,20 +264,20 @@ function canEquipItemCount() {
165
264
  */
166
265
 
167
266
 
168
- function checkCache(cacheKey, updateOnFamiliarChange, updateOnCanEquipChanged) {
267
+ function checkCache(cacheKey, options) {
169
268
  var entry = cachedObjectives[cacheKey];
170
269
 
171
270
  if (!entry) {
172
271
  return null;
173
272
  }
174
273
 
175
- if (updateOnFamiliarChange && (0, _kolmafia.myFamiliar)() !== entry.familiar) {
274
+ if (options.updateOnFamiliarChange && (0, _kolmafia.myFamiliar)() !== entry.familiar) {
176
275
  _logger.default.warning("Equipment found in maximize cache but familiar is different.");
177
276
 
178
277
  return null;
179
278
  }
180
279
 
181
- if (updateOnCanEquipChanged && entry.canEquipItemCount !== canEquipItemCount()) {
280
+ if (options.updateOnCanEquipChanged && entry.canEquipItemCount !== canEquipItemCount()) {
182
281
  _logger.default.warning("Equipment found in maximize cache but equippable item list is out of date.");
183
282
 
184
283
  return null;
@@ -192,55 +291,79 @@ function checkCache(cacheKey, updateOnFamiliarChange, updateOnCanEquipChanged) {
192
291
  */
193
292
 
194
293
 
195
- function applyCached(entry) {
196
- var _iterator = _createForOfIteratorHelper(entry.equipment),
197
- _step;
294
+ function applyCached(entry, options) {
295
+ var outfitName = options.useOutfitCaching ? outfitCache.get(entry) : undefined;
198
296
 
199
- try {
200
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
201
- var _step$value = _slicedToArray(_step.value, 2),
202
- slot = _step$value[0],
203
- item = _step$value[1];
297
+ if (outfitName) {
298
+ if (!(0, _kolmafia.isWearingOutfit)(outfitName)) {
299
+ (0, _kolmafia.outfit)(outfitName);
300
+ }
204
301
 
205
- if ((0, _kolmafia.equippedItem)(slot) !== item && (0, _kolmafia.availableAmount)(item) > 0) {
206
- (0, _kolmafia.equip)(slot, item);
302
+ var familiarEquip = entry.equipment.get((0, _templateString.$slot)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["familiar"]))));
303
+ if (familiarEquip) (0, _kolmafia.equip)(familiarEquip);
304
+ } else {
305
+ var _iterator = _createForOfIteratorHelper(entry.equipment),
306
+ _step;
307
+
308
+ try {
309
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
310
+ var _step$value = _slicedToArray(_step.value, 2),
311
+ slot = _step$value[0],
312
+ item = _step$value[1];
313
+
314
+ if ((0, _kolmafia.equippedItem)(slot) !== item && (0, _kolmafia.availableAmount)(item) > 0) {
315
+ (0, _kolmafia.equip)(slot, item);
316
+ }
207
317
  }
318
+ } catch (err) {
319
+ _iterator.e(err);
320
+ } finally {
321
+ _iterator.f();
322
+ }
323
+
324
+ if (verifyCached(entry) && options.useOutfitCaching) {
325
+ var _outfitName = outfitCache.insert(entry);
326
+
327
+ _logger.default.info("Saving equipment to outfit ".concat(_outfitName, "."));
328
+
329
+ saveOutfit(_outfitName);
208
330
  }
209
- } catch (err) {
210
- _iterator.e(err);
211
- } finally {
212
- _iterator.f();
213
331
  }
214
332
 
215
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Crown of Thrones"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Crown of Thrones"]))))) {
216
- (0, _kolmafia.enthroneFamiliar)(entry.rider.get((0, _templateString.$item)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Crown of Thrones"])))) || (0, _templateString.$familiar)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["none"]))));
333
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Crown of Thrones"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Crown of Thrones"]))))) {
334
+ (0, _kolmafia.enthroneFamiliar)(entry.rider.get((0, _templateString.$item)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Crown of Thrones"])))) || (0, _templateString.$familiar)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["none"]))));
217
335
  }
218
336
 
219
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Buddy Bjorn"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Buddy Bjorn"]))))) {
220
- (0, _kolmafia.bjornifyFamiliar)(entry.rider.get((0, _templateString.$item)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Buddy Bjorn"])))) || (0, _templateString.$familiar)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["none"]))));
337
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Buddy Bjorn"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Buddy Bjorn"]))))) {
338
+ (0, _kolmafia.bjornifyFamiliar)(entry.rider.get((0, _templateString.$item)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Buddy Bjorn"])))) || (0, _templateString.$familiar)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["none"]))));
221
339
  }
222
340
  }
341
+
342
+ var slotStructure = [(0, _templateString.$slots)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["hat"]))), (0, _templateString.$slots)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["back"]))), (0, _templateString.$slots)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["shirt"]))), (0, _templateString.$slots)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["weapon, off-hand"]))), (0, _templateString.$slots)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["pants"]))), (0, _templateString.$slots)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["acc1, acc2, acc3"]))), (0, _templateString.$slots)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["familiar"])))];
223
343
  /**
224
344
  * Verifies that a CacheEntry was applied successfully.
225
345
  * @param entry The CacheEntry to verify
226
346
  * @returns If all desired equipment was appliedn in the correct slots.
227
347
  */
228
348
 
229
-
230
349
  function verifyCached(entry) {
231
350
  var success = true;
232
351
 
233
- var _iterator2 = _createForOfIteratorHelper(entry.equipment),
352
+ var _iterator2 = _createForOfIteratorHelper(slotStructure),
234
353
  _step2;
235
354
 
236
355
  try {
237
356
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
238
- var _step2$value = _slicedToArray(_step2.value, 2),
239
- slot = _step2$value[0],
240
- item = _step2$value[1];
357
+ var slotGroup = _step2.value;
358
+ var desiredSet = slotGroup.map(slot => {
359
+ var _entry$equipment$get;
360
+
361
+ return (_entry$equipment$get = entry.equipment.get(slot)) !== null && _entry$equipment$get !== void 0 ? _entry$equipment$get : (0, _templateString.$item)(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["none"])));
362
+ });
363
+ var equippedSet = slotGroup.map(slot => (0, _kolmafia.equippedItem)(slot));
241
364
 
242
- if ((0, _kolmafia.equippedItem)(slot) !== item) {
243
- _logger.default.warning("Failed to apply cached ".concat(item, " in ").concat(slot, "."));
365
+ if (!(0, _utils.setEqual)(desiredSet, equippedSet)) {
366
+ _logger.default.warning("Failed to apply cached ".concat(desiredSet.join(", "), " in ").concat(slotGroup.join(", "), "."));
244
367
 
245
368
  success = false;
246
369
  }
@@ -251,17 +374,17 @@ function verifyCached(entry) {
251
374
  _iterator2.f();
252
375
  }
253
376
 
254
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Crown of Thrones"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Crown of Thrones"]))))) {
255
- if (entry.rider.get((0, _templateString.$item)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["Crown of Thrones"])))) !== (0, _kolmafia.myEnthronedFamiliar)()) {
256
- _logger.default.warning("Failed to apply ".concat(entry.rider.get((0, _templateString.$item)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["Crown of Thrones"])))), " in ").concat((0, _templateString.$item)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Crown of Thrones"]))), "."));
377
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["Crown of Thrones"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["Crown of Thrones"]))))) {
378
+ if (entry.rider.get((0, _templateString.$item)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["Crown of Thrones"])))) !== (0, _kolmafia.myEnthronedFamiliar)()) {
379
+ _logger.default.warning("Failed to apply ".concat(entry.rider.get((0, _templateString.$item)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["Crown of Thrones"])))), " in ").concat((0, _templateString.$item)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["Crown of Thrones"]))), "."));
257
380
 
258
381
  success = false;
259
382
  }
260
383
  }
261
384
 
262
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["Buddy Bjorn"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["Buddy Bjorn"]))))) {
263
- if (entry.rider.get((0, _templateString.$item)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["Buddy Bjorn"])))) !== (0, _kolmafia.myBjornedFamiliar)()) {
264
- _logger.default.warning("Failed to apply".concat(entry.rider.get((0, _templateString.$item)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["Buddy Bjorn"])))), " in ").concat((0, _templateString.$item)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["Buddy Bjorn"]))), "."));
385
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["Buddy Bjorn"])))) > 0 && entry.rider.get((0, _templateString.$item)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["Buddy Bjorn"]))))) {
386
+ if (entry.rider.get((0, _templateString.$item)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["Buddy Bjorn"])))) !== (0, _kolmafia.myBjornedFamiliar)()) {
387
+ _logger.default.warning("Failed to apply".concat(entry.rider.get((0, _templateString.$item)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["Buddy Bjorn"])))), " in ").concat((0, _templateString.$item)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["Buddy Bjorn"]))), "."));
265
388
 
266
389
  success = false;
267
390
  }
@@ -293,16 +416,16 @@ function saveCached(cacheKey, options) {
293
416
  _iterator3.f();
294
417
  }
295
418
 
296
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["card sleeve"])))) > 0) {
297
- equipment.set((0, _templateString.$slot)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["card-sleeve"]))), (0, _kolmafia.equippedItem)((0, _templateString.$slot)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["card-sleeve"])))));
419
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["card sleeve"])))) > 0) {
420
+ equipment.set((0, _templateString.$slot)(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["card-sleeve"]))), (0, _kolmafia.equippedItem)((0, _templateString.$slot)(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["card-sleeve"])))));
298
421
  }
299
422
 
300
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["Crown of Thrones"])))) > 0) {
301
- rider.set((0, _templateString.$item)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["Crown of Thrones"]))), (0, _kolmafia.myEnthronedFamiliar)());
423
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["Crown of Thrones"])))) > 0) {
424
+ rider.set((0, _templateString.$item)(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["Crown of Thrones"]))), (0, _kolmafia.myEnthronedFamiliar)());
302
425
  }
303
426
 
304
- if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["Buddy Bjorn"])))) > 0) {
305
- rider.set((0, _templateString.$item)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["Buddy Bjorn"]))), (0, _kolmafia.myBjornedFamiliar)());
427
+ if ((0, _kolmafia.equippedAmount)((0, _templateString.$item)(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["Buddy Bjorn"])))) > 0) {
428
+ rider.set((0, _templateString.$item)(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["Buddy Bjorn"]))), (0, _kolmafia.myBjornedFamiliar)());
306
429
  }
307
430
 
308
431
  if (options.preventSlot && options.preventSlot.length > 0) {
@@ -320,12 +443,12 @@ function saveCached(cacheKey, options) {
320
443
  _iterator4.f();
321
444
  }
322
445
 
323
- if (options.preventSlot.includes((0, _templateString.$slot)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["buddy-bjorn"]))))) {
324
- rider.delete((0, _templateString.$item)(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["Buddy Bjorn"]))));
446
+ if (options.preventSlot.includes((0, _templateString.$slot)(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["buddy-bjorn"]))))) {
447
+ rider.delete((0, _templateString.$item)(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["Buddy Bjorn"]))));
325
448
  }
326
449
 
327
- if (options.preventSlot.includes((0, _templateString.$slot)(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["crown-of-thrones"]))))) {
328
- rider.delete((0, _templateString.$item)(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["Crown of Thrones"]))));
450
+ if (options.preventSlot.includes((0, _templateString.$slot)(_templateObject39 || (_templateObject39 = _taggedTemplateLiteral(["crown-of-thrones"]))))) {
451
+ rider.delete((0, _templateString.$item)(_templateObject40 || (_templateObject40 = _taggedTemplateLiteral(["Crown of Thrones"]))));
329
452
  }
330
453
  }
331
454
 
@@ -347,16 +470,25 @@ function saveCached(cacheKey, options) {
347
470
  _iterator5.f();
348
471
  }
349
472
 
350
- if (!options.onlySlot.includes((0, _templateString.$slot)(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["buddy-bjorn"]))))) {
351
- rider.delete((0, _templateString.$item)(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["Buddy Bjorn"]))));
473
+ if (!options.onlySlot.includes((0, _templateString.$slot)(_templateObject41 || (_templateObject41 = _taggedTemplateLiteral(["buddy-bjorn"]))))) {
474
+ rider.delete((0, _templateString.$item)(_templateObject42 || (_templateObject42 = _taggedTemplateLiteral(["Buddy Bjorn"]))));
352
475
  }
353
476
 
354
- if (!options.onlySlot.includes((0, _templateString.$slot)(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["crown-of-thrones"]))))) {
355
- rider.delete((0, _templateString.$item)(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["Crown of Thrones"]))));
477
+ if (!options.onlySlot.includes((0, _templateString.$slot)(_templateObject43 || (_templateObject43 = _taggedTemplateLiteral(["crown-of-thrones"]))))) {
478
+ rider.delete((0, _templateString.$item)(_templateObject44 || (_templateObject44 = _taggedTemplateLiteral(["Crown of Thrones"]))));
356
479
  }
357
480
  }
358
481
 
359
- cachedObjectives[cacheKey] = new CacheEntry(equipment, rider, (0, _kolmafia.myFamiliar)(), canEquipItemCount());
482
+ var entry = new CacheEntry(equipment, rider, (0, _kolmafia.myFamiliar)(), canEquipItemCount());
483
+ cachedObjectives[cacheKey] = entry;
484
+
485
+ if (options.useOutfitCaching) {
486
+ var outfitName = outfitCache.insert(entry);
487
+
488
+ _logger.default.info("Saving equipment to outfit ".concat(outfitName, "."));
489
+
490
+ saveOutfit(outfitName);
491
+ }
360
492
  }
361
493
  /**
362
494
  * Run the maximizer, but only if the objective and certain pieces of game state haven't changed since it was last run.
@@ -373,17 +505,15 @@ function saveCached(cacheKey, options) {
373
505
  function maximizeCached(objectives) {
374
506
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
375
507
 
376
- var _defaultMaximizeOptio = _objectSpread(_objectSpread({}, defaultMaximizeOptions), options),
377
- updateOnFamiliarChange = _defaultMaximizeOptio.updateOnFamiliarChange,
378
- updateOnCanEquipChanged = _defaultMaximizeOptio.updateOnCanEquipChanged,
379
- forceEquip = _defaultMaximizeOptio.forceEquip,
380
- preventEquip = _defaultMaximizeOptio.preventEquip,
381
- bonusEquip = _defaultMaximizeOptio.bonusEquip,
382
- onlySlot = _defaultMaximizeOptio.onlySlot,
383
- preventSlot = _defaultMaximizeOptio.preventSlot; // Sort each group in objective to ensure consistent ordering in string
508
+ var fullOptions = _objectSpread(_objectSpread({}, defaultMaximizeOptions), options);
384
509
 
510
+ var forceEquip = fullOptions.forceEquip,
511
+ preventEquip = fullOptions.preventEquip,
512
+ bonusEquip = fullOptions.bonusEquip,
513
+ onlySlot = fullOptions.onlySlot,
514
+ preventSlot = fullOptions.preventSlot; // Sort each group in objective to ensure consistent ordering in string
385
515
 
386
- var objective = [].concat(_toConsumableArray(objectives.sort()), _toConsumableArray(forceEquip.map(item => "equip ".concat(item)).sort()), _toConsumableArray(preventEquip.map(item => "-equip ".concat(item)).sort()), _toConsumableArray(onlySlot.filter(slot => !(0, _templateString.$slots)(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["buddy-bjorn, crown-of-thrones"]))).includes(slot)).map(slot => "".concat(slot)).sort()), _toConsumableArray(preventSlot.filter(slot => !(0, _templateString.$slots)(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["buddy-bjorn, crown-of-thrones"]))).includes(slot)).map(slot => "-".concat(slot)).sort()), _toConsumableArray(Array.from(bonusEquip.entries()).filter(_ref => {
516
+ var objective = [].concat(_toConsumableArray(objectives.sort()), _toConsumableArray(forceEquip.map(item => "equip ".concat(item)).sort()), _toConsumableArray(preventEquip.map(item => "-equip ".concat(item)).sort()), _toConsumableArray(onlySlot.map(slot => "".concat(slot)).sort()), _toConsumableArray(preventSlot.map(slot => "-".concat(slot)).sort()), _toConsumableArray(Array.from(bonusEquip.entries()).filter(_ref => {
387
517
  var _ref2 = _slicedToArray(_ref, 2),
388
518
  bonus = _ref2[1];
389
519
 
@@ -395,12 +525,12 @@ function maximizeCached(objectives) {
395
525
 
396
526
  return "".concat(Math.round(bonus * 100) / 100, " bonus ").concat(item);
397
527
  }).sort())).join(", ");
398
- var cacheEntry = checkCache(objective, updateOnFamiliarChange, updateOnCanEquipChanged);
528
+ var cacheEntry = checkCache(objective, fullOptions);
399
529
 
400
530
  if (cacheEntry) {
401
531
  _logger.default.info("Equipment found in maximize cache, equipping...");
402
532
 
403
- applyCached(cacheEntry);
533
+ applyCached(cacheEntry, fullOptions);
404
534
 
405
535
  if (verifyCached(cacheEntry)) {
406
536
  _logger.default.info("Equipped cached ".concat(objective));
@@ -412,7 +542,7 @@ function maximizeCached(objectives) {
412
542
  }
413
543
 
414
544
  (0, _kolmafia.maximize)(objective, false);
415
- saveCached(objective, options);
545
+ saveCached(objective, fullOptions);
416
546
  }
417
547
 
418
548
  var _maximizeParameters = /*#__PURE__*/new WeakMap();
@@ -453,24 +583,64 @@ var Requirement = /*#__PURE__*/function () {
453
583
  get: function get() {
454
584
  return _classPrivateFieldGet(this, _maximizeOptions);
455
585
  }
586
+ /**
587
+ * Merges two requirements, concanating relevant arrays. Typically used in static form.
588
+ * @param other Requirement to merge with.
589
+ */
590
+
456
591
  }, {
457
592
  key: "merge",
458
593
  value: function merge(other) {
459
- return (0, _merge2.default)(this, other);
594
+ var _optionsA$forceEquip, _other$maximizeOption, _optionsA$preventEqui, _other$maximizeOption2, _optionsA$bonusEquip$, _optionsA$bonusEquip, _optionsB$bonusEquip$, _optionsB$bonusEquip, _optionsA$onlySlot, _optionsB$onlySlot, _optionsA$preventSlot, _optionsB$preventSlot;
595
+
596
+ var optionsA = this.maximizeOptions;
597
+ var optionsB = other.maximizeOptions;
598
+ return new Requirement([].concat(_toConsumableArray(this.maximizeParameters), _toConsumableArray(other.maximizeParameters)), {
599
+ updateOnFamiliarChange: optionsA.updateOnFamiliarChange || other.maximizeOptions.updateOnFamiliarChange,
600
+ updateOnCanEquipChanged: optionsA.updateOnCanEquipChanged || other.maximizeOptions.updateOnCanEquipChanged,
601
+ forceEquip: [].concat(_toConsumableArray((_optionsA$forceEquip = optionsA.forceEquip) !== null && _optionsA$forceEquip !== void 0 ? _optionsA$forceEquip : []), _toConsumableArray((_other$maximizeOption = other.maximizeOptions.forceEquip) !== null && _other$maximizeOption !== void 0 ? _other$maximizeOption : [])),
602
+ preventEquip: [].concat(_toConsumableArray((_optionsA$preventEqui = optionsA.preventEquip) !== null && _optionsA$preventEqui !== void 0 ? _optionsA$preventEqui : []), _toConsumableArray((_other$maximizeOption2 = other.maximizeOptions.preventEquip) !== null && _other$maximizeOption2 !== void 0 ? _other$maximizeOption2 : [])),
603
+ bonusEquip: new Map([].concat(_toConsumableArray((_optionsA$bonusEquip$ = (_optionsA$bonusEquip = optionsA.bonusEquip) === null || _optionsA$bonusEquip === void 0 ? void 0 : _optionsA$bonusEquip.entries()) !== null && _optionsA$bonusEquip$ !== void 0 ? _optionsA$bonusEquip$ : []), _toConsumableArray((_optionsB$bonusEquip$ = (_optionsB$bonusEquip = optionsB.bonusEquip) === null || _optionsB$bonusEquip === void 0 ? void 0 : _optionsB$bonusEquip.entries()) !== null && _optionsB$bonusEquip$ !== void 0 ? _optionsB$bonusEquip$ : []))),
604
+ onlySlot: [].concat(_toConsumableArray((_optionsA$onlySlot = optionsA.onlySlot) !== null && _optionsA$onlySlot !== void 0 ? _optionsA$onlySlot : []), _toConsumableArray((_optionsB$onlySlot = optionsB.onlySlot) !== null && _optionsB$onlySlot !== void 0 ? _optionsB$onlySlot : [])),
605
+ preventSlot: [].concat(_toConsumableArray((_optionsA$preventSlot = optionsA.preventSlot) !== null && _optionsA$preventSlot !== void 0 ? _optionsA$preventSlot : []), _toConsumableArray((_optionsB$preventSlot = optionsB.preventSlot) !== null && _optionsB$preventSlot !== void 0 ? _optionsB$preventSlot : []))
606
+ });
607
+ }
608
+ /**
609
+ * Merges a set of requirements together, starting with an empty requirement.
610
+ * @param allRequirements Requirements to merge
611
+ */
612
+
613
+ }, {
614
+ key: "maximize",
615
+ value:
616
+ /**
617
+ * Runs maximizeCached, using the maximizeParameters and maximizeOptions contained by this requirement.
618
+ */
619
+ function maximize() {
620
+ maximizeCached(this.maximizeParameters, this.maximizeOptions);
460
621
  }
622
+ /**
623
+ * Merges requirements, and then runs maximizeCached on the combined requirement.
624
+ * @param requirements Requirements to maximize on
625
+ */
626
+
461
627
  }], [{
462
628
  key: "merge",
463
629
  value: function merge(allRequirements) {
464
630
  return allRequirements.reduce((x, y) => x.merge(y), new Requirement([], {}));
465
631
  }
632
+ }, {
633
+ key: "maximize",
634
+ value: function maximize() {
635
+ for (var _len = arguments.length, requirements = new Array(_len), _key = 0; _key < _len; _key++) {
636
+ requirements[_key] = arguments[_key];
637
+ }
638
+
639
+ Requirement.merge(requirements).maximize();
640
+ }
466
641
  }]);
467
642
 
468
643
  return Requirement;
469
644
  }();
470
645
 
471
- exports.Requirement = Requirement;
472
-
473
- function maximizeRequirementsCached(requirements) {
474
- var compiledRequirements = Requirement.merge(requirements);
475
- maximizeCached(compiledRequirements.maximizeParameters, compiledRequirements.maximizeOptions);
476
- }
646
+ exports.Requirement = Requirement;
@@ -0,0 +1,13 @@
1
+ import { BooleanModifier, ClassModifier, EffectModifier, MonsterModifier, NumericModifier, SkillModifier, StatModifier, StringModifier } from "./modifierTypes";
2
+ export declare function get(name: BooleanModifier, subject?: string | Item | Effect): boolean;
3
+ export declare function get(name: ClassModifier, subject: string | Item): Class;
4
+ export declare function get(name: EffectModifier, subject: string | Item): Effect;
5
+ export declare function get(name: MonsterModifier, subject: Effect): Monster;
6
+ export declare function get(name: NumericModifier, subject?: string | Item | Effect | Skill | Familiar): number;
7
+ export declare function get(name: SkillModifier, subject: string | Item): Skill;
8
+ export declare function get(name: StringModifier, subject?: string | Effect | Item): string;
9
+ export declare function get(name: StatModifier, subject: Effect): Stat;
10
+ export declare type ModifierValue<T> = T extends BooleanModifier ? boolean : T extends ClassModifier ? Class : T extends EffectModifier ? Effect : T extends MonsterModifier ? Monster : T extends NumericModifier ? number : T extends SkillModifier ? Skill : T extends StatModifier ? Stat : T extends StringModifier ? string : string;
11
+ export declare type Modifiers = Partial<{
12
+ [T in BooleanModifier | ClassModifier | EffectModifier | MonsterModifier | NumericModifier | SkillModifier | StatModifier | StringModifier]: ModifierValue<T>;
13
+ }>;