libram 0.4.1 → 0.4.5

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 (91) hide show
  1. package/dist/Clan.js +271 -485
  2. package/dist/Copier.js +15 -48
  3. package/dist/Dungeon.js +77 -157
  4. package/dist/Kmail.d.ts +3 -1
  5. package/dist/Kmail.js +99 -244
  6. package/dist/Path.js +77 -120
  7. package/dist/ascend.js +153 -172
  8. package/dist/combat.d.ts +98 -3
  9. package/dist/combat.js +349 -387
  10. package/dist/console.js +13 -36
  11. package/dist/diet/index.d.ts +32 -8
  12. package/dist/diet/index.js +420 -426
  13. package/dist/diet/knapsack.d.ts +1 -1
  14. package/dist/diet/knapsack.js +104 -100
  15. package/dist/dungeons/Dreadsylvania.d.ts +4 -0
  16. package/dist/dungeons/Dreadsylvania.js +14 -0
  17. package/dist/dungeons/Dungeon.d.ts +28 -0
  18. package/dist/dungeons/Dungeon.js +99 -0
  19. package/dist/dungeons/Hobopolis.d.ts +4 -0
  20. package/dist/dungeons/Hobopolis.js +14 -0
  21. package/dist/dungeons/SlimeTube.d.ts +4 -0
  22. package/dist/dungeons/SlimeTube.js +14 -0
  23. package/dist/freerun.d.ts +16 -4
  24. package/dist/freerun.js +92 -99
  25. package/dist/index.d.ts +5 -1
  26. package/dist/index.js +22 -300
  27. package/dist/lib.d.ts +4 -0
  28. package/dist/lib.js +284 -515
  29. package/dist/logger.js +21 -63
  30. package/dist/maximize.js +289 -562
  31. package/dist/modifier.js +35 -46
  32. package/dist/modifierTypes.js +8 -22
  33. package/dist/mood.d.ts +5 -0
  34. package/dist/mood.js +268 -551
  35. package/dist/property.d.ts +2 -0
  36. package/dist/property.js +100 -242
  37. package/dist/propertyTypes.d.ts +5 -4
  38. package/dist/propertyTypes.js +1 -0
  39. package/dist/propertyTyping.d.ts +4 -3
  40. package/dist/propertyTyping.js +52 -59
  41. package/dist/resources/2007/CandyHearts.d.ts +9 -0
  42. package/dist/resources/2007/CandyHearts.js +24 -0
  43. package/dist/resources/2008/DivineFavors.d.ts +9 -0
  44. package/dist/resources/2008/DivineFavors.js +27 -0
  45. package/dist/resources/2009/Bandersnatch.js +37 -112
  46. package/dist/resources/2009/LoveSongs.d.ts +9 -0
  47. package/dist/resources/2009/LoveSongs.js +24 -0
  48. package/dist/resources/2009/SpookyPutty.js +20 -46
  49. package/dist/resources/2010/Brickos.d.ts +9 -0
  50. package/dist/resources/2010/Brickos.js +21 -0
  51. package/dist/resources/2010/CrownOfThrones.d.ts +9 -0
  52. package/dist/resources/2010/CrownOfThrones.js +550 -374
  53. package/dist/resources/2011/Gygaxian.d.ts +9 -0
  54. package/dist/resources/2011/Gygaxian.js +24 -0
  55. package/dist/resources/2011/ObtuseAngel.js +21 -63
  56. package/dist/resources/2012/RainDoh.js +14 -40
  57. package/dist/resources/2012/Resolutions.d.ts +9 -0
  58. package/dist/resources/2012/Resolutions.js +28 -0
  59. package/dist/resources/2013/Florist.d.ts +1 -0
  60. package/dist/resources/2013/Florist.js +142 -207
  61. package/dist/resources/2013/PulledTaffy.d.ts +9 -0
  62. package/dist/resources/2013/PulledTaffy.js +33 -0
  63. package/dist/resources/2014/DNALab.d.ts +47 -0
  64. package/dist/resources/2014/DNALab.js +154 -0
  65. package/dist/resources/2014/WinterGarden.js +15 -43
  66. package/dist/resources/2015/ChateauMantegna.js +52 -86
  67. package/dist/resources/2015/MayoClinic.d.ts +3 -0
  68. package/dist/resources/2015/MayoClinic.js +36 -65
  69. package/dist/resources/2016/SourceTerminal.d.ts +1 -0
  70. package/dist/resources/2016/SourceTerminal.js +114 -237
  71. package/dist/resources/2016/Witchess.js +33 -59
  72. package/dist/resources/2017/AsdonMartin.d.ts +27 -0
  73. package/dist/resources/2017/AsdonMartin.js +80 -0
  74. package/dist/resources/2017/TunnelOfLove.js +62 -111
  75. package/dist/resources/2018/SongBoom.js +32 -68
  76. package/dist/resources/2019/BeachComb.js +26 -44
  77. package/dist/resources/2019/Snapper.d.ts +28 -0
  78. package/dist/resources/2019/Snapper.js +69 -0
  79. package/dist/resources/2020/Guzzlr.d.ts +3 -0
  80. package/dist/resources/2020/Guzzlr.js +92 -163
  81. package/dist/resources/LibramSummon.d.ts +12 -0
  82. package/dist/resources/LibramSummon.js +66 -0
  83. package/dist/resources/index.d.ts +5 -1
  84. package/dist/resources/index.js +21 -105
  85. package/dist/resources/putty-likes.js +15 -30
  86. package/dist/since.d.ts +1 -0
  87. package/dist/since.js +56 -112
  88. package/dist/template-string.js +40 -132
  89. package/dist/utils.d.ts +5 -0
  90. package/dist/utils.js +47 -134
  91. package/package.json +15 -9
@@ -1,3 +1,5 @@
1
+ import "core-js/modules/es.object.entries";
2
+ import "core-js/modules/es.object.from-entries";
1
3
  import { KnownProperty, PropertyValue } from "./propertyTyping";
2
4
  export declare const getString: (property: string, default_?: string | undefined) => string;
3
5
  export declare const getCommaSeparated: (property: string, default_?: string[] | undefined) => string[];
package/dist/property.js CHANGED
@@ -1,255 +1,113 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.symbol.js");
4
-
5
- require("core-js/modules/es.symbol.description.js");
6
-
7
- require("core-js/modules/es.array.slice.js");
8
-
9
- Object.defineProperty(exports, "__esModule", {
10
- value: true
11
- });
12
- exports.get = get;
13
- exports.set = _set;
14
- exports.setProperties = setProperties;
15
- exports.withProperties = withProperties;
16
- exports.withProperty = withProperty;
17
- exports.withChoices = withChoices;
18
- exports.withChoice = withChoice;
19
- exports.PropertiesManager = exports.getThrall = exports.getStat = exports.getSlot = exports.getSkill = exports.getServant = exports.getPhylum = exports.getMonster = exports.getLocation = exports.getItem = exports.getFamiliar = exports.getElement = exports.getEffect = exports.getCoinmaster = exports.getClass = exports.getBounty = exports.getNumber = exports.getBoolean = exports.getCommaSeparated = exports.getString = void 0;
20
-
21
- require("core-js/modules/es.regexp.exec.js");
22
-
23
- require("core-js/modules/es.string.split.js");
24
-
25
- require("core-js/modules/es.object.to-string.js");
26
-
27
- require("core-js/modules/es.regexp.to-string.js");
28
-
29
- require("core-js/modules/es.object.entries.js");
30
-
31
- require("core-js/modules/es.array.iterator.js");
32
-
33
- require("core-js/modules/es.object.from-entries.js");
34
-
35
- require("core-js/modules/es.array.map.js");
36
-
37
- var _kolmafia = require("kolmafia");
38
-
39
- var _propertyTyping = require("./propertyTyping");
40
-
41
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42
-
43
- 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); } }
44
-
45
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
46
-
47
- 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; }
48
-
49
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
50
-
51
- 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."); }
52
-
53
- 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); }
54
-
55
- 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; }
56
-
57
- 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
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
60
-
61
- var createPropertyGetter = transform => (property, default_) => {
62
- var value = (0, _kolmafia.getProperty)(property);
63
-
64
- if (default_ !== undefined && value === "") {
65
- return default_;
66
- }
67
-
68
- return transform(value, property);
1
+ import "core-js/modules/es.object.entries";
2
+ import "core-js/modules/es.object.from-entries";
3
+ import { getProperty, setProperty } from "kolmafia";
4
+ import { isBooleanProperty, isLocationProperty, isMonsterProperty, isNumericProperty, isPhylumProperty, } from "./propertyTyping";
5
+ const createPropertyGetter = (transform) => (property, default_) => {
6
+ const value = getProperty(property);
7
+ if (default_ !== undefined && value === "") {
8
+ return default_;
9
+ }
10
+ return transform(value, property);
69
11
  };
70
-
71
- var createMafiaClassPropertyGetter = Type => createPropertyGetter(value => {
72
- if (value === "") return null;
73
- var v = Type.get(value);
74
- return v === Type.get("none") ? null : v;
12
+ const createMafiaClassPropertyGetter = (Type) => createPropertyGetter((value) => {
13
+ if (value === "")
14
+ return null;
15
+ const v = Type.get(value);
16
+ return v === Type.get("none") ? null : v;
75
17
  });
76
-
77
- var getString = createPropertyGetter(value => value);
78
- exports.getString = getString;
79
- var getCommaSeparated = createPropertyGetter(value => value.split(/, ?/));
80
- exports.getCommaSeparated = getCommaSeparated;
81
- var getBoolean = createPropertyGetter(value => value === "true");
82
- exports.getBoolean = getBoolean;
83
- var getNumber = createPropertyGetter(value => Number(value));
84
- exports.getNumber = getNumber;
85
- var getBounty = createMafiaClassPropertyGetter(Bounty);
86
- exports.getBounty = getBounty;
87
- var getClass = createMafiaClassPropertyGetter(Class);
88
- exports.getClass = getClass;
89
- var getCoinmaster = createMafiaClassPropertyGetter(Coinmaster);
90
- exports.getCoinmaster = getCoinmaster;
91
- var getEffect = createMafiaClassPropertyGetter(Effect);
92
- exports.getEffect = getEffect;
93
- var getElement = createMafiaClassPropertyGetter(Element);
94
- exports.getElement = getElement;
95
- var getFamiliar = createMafiaClassPropertyGetter(Familiar);
96
- exports.getFamiliar = getFamiliar;
97
- var getItem = createMafiaClassPropertyGetter(Item);
98
- exports.getItem = getItem;
99
- var getLocation = createMafiaClassPropertyGetter(Location);
100
- exports.getLocation = getLocation;
101
- var getMonster = createMafiaClassPropertyGetter(Monster);
102
- exports.getMonster = getMonster;
103
- var getPhylum = createMafiaClassPropertyGetter(Phylum);
104
- exports.getPhylum = getPhylum;
105
- var getServant = createMafiaClassPropertyGetter(Servant);
106
- exports.getServant = getServant;
107
- var getSkill = createMafiaClassPropertyGetter(Skill);
108
- exports.getSkill = getSkill;
109
- var getSlot = createMafiaClassPropertyGetter(Slot);
110
- exports.getSlot = getSlot;
111
- var getStat = createMafiaClassPropertyGetter(Stat);
112
- exports.getStat = getStat;
113
- var getThrall = createMafiaClassPropertyGetter(Thrall);
114
- /**
115
- * Returns the value of a mafia property, either built in or custom
116
- * @param property Name of the property
117
- * @param _default Default value for the property to take if not set
118
- */
119
-
120
- exports.getThrall = getThrall;
121
-
122
- function get(property, _default) {
123
- var value = getString(property);
124
-
125
- if ((0, _propertyTyping.isMonsterProperty)(property)) {
126
- return getMonster(property, _default);
127
- }
128
-
129
- if ((0, _propertyTyping.isLocationProperty)(property)) {
130
- return getLocation(property, _default);
131
- }
132
-
133
- if (value === "") {
134
- return _default === undefined ? "" : _default;
135
- }
136
-
137
- if ((0, _propertyTyping.isBooleanProperty)(property, value)) {
138
- return getBoolean(property, _default);
139
- }
140
-
141
- if ((0, _propertyTyping.isNumericProperty)(property, value)) {
142
- return getNumber(property, _default);
143
- }
144
-
145
- return value;
18
+ export const getString = createPropertyGetter((value) => value);
19
+ export const getCommaSeparated = createPropertyGetter((value) => value.split(/, ?/));
20
+ export const getBoolean = createPropertyGetter((value) => value === "true");
21
+ export const getNumber = createPropertyGetter((value) => Number(value));
22
+ export const getBounty = createMafiaClassPropertyGetter(Bounty);
23
+ export const getClass = createMafiaClassPropertyGetter(Class);
24
+ export const getCoinmaster = createMafiaClassPropertyGetter(Coinmaster);
25
+ export const getEffect = createMafiaClassPropertyGetter(Effect);
26
+ export const getElement = createMafiaClassPropertyGetter(Element);
27
+ export const getFamiliar = createMafiaClassPropertyGetter(Familiar);
28
+ export const getItem = createMafiaClassPropertyGetter(Item);
29
+ export const getLocation = createMafiaClassPropertyGetter(Location);
30
+ export const getMonster = createMafiaClassPropertyGetter(Monster);
31
+ export const getPhylum = createMafiaClassPropertyGetter(Phylum);
32
+ export const getServant = createMafiaClassPropertyGetter(Servant);
33
+ export const getSkill = createMafiaClassPropertyGetter(Skill);
34
+ export const getSlot = createMafiaClassPropertyGetter(Slot);
35
+ export const getStat = createMafiaClassPropertyGetter(Stat);
36
+ export const getThrall = createMafiaClassPropertyGetter(Thrall);
37
+ export function get(property, _default) {
38
+ const value = getString(property);
39
+ if (isMonsterProperty(property)) {
40
+ return getMonster(property, _default);
41
+ }
42
+ if (isLocationProperty(property)) {
43
+ return getLocation(property, _default);
44
+ }
45
+ if (value === "") {
46
+ return _default === undefined ? "" : _default;
47
+ }
48
+ if (isBooleanProperty(property, value)) {
49
+ return getBoolean(property, _default);
50
+ }
51
+ if (isNumericProperty(property, value)) {
52
+ return getNumber(property, _default);
53
+ }
54
+ if (isPhylumProperty(property)) {
55
+ return getPhylum(property);
56
+ }
57
+ return value;
146
58
  }
147
- /**
148
- * Sets the value of a mafia property, either built in or custom
149
- * @param property Name of the property
150
- * @param value Value to give the property
151
- */
152
-
153
-
154
- function _set(property, value) {
155
- var stringValue = value === null ? "" : value.toString();
156
- (0, _kolmafia.setProperty)(property, stringValue);
59
+ export function set(property, value) {
60
+ const stringValue = value === null ? "" : value.toString();
61
+ setProperty(property, stringValue);
157
62
  }
158
-
159
- function setProperties(properties) {
160
- for (var _i = 0, _Object$entries = Object.entries(properties); _i < _Object$entries.length; _i++) {
161
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
162
- prop = _Object$entries$_i[0],
163
- _value = _Object$entries$_i[1];
164
-
165
- _set(prop, _value);
166
- }
63
+ export function setProperties(properties) {
64
+ for (const [prop, value] of Object.entries(properties)) {
65
+ set(prop, value);
66
+ }
167
67
  }
168
-
169
- function withProperties(properties, callback) {
170
- var propertiesBackup = Object.fromEntries(Object.entries(properties).map(_ref => {
171
- var _ref2 = _slicedToArray(_ref, 1),
172
- prop = _ref2[0];
173
-
174
- return [prop, get(prop)];
175
- }));
176
- setProperties(properties);
177
-
178
- try {
179
- callback();
180
- } finally {
181
- setProperties(propertiesBackup);
182
- }
68
+ export function withProperties(properties, callback) {
69
+ const propertiesBackup = Object.fromEntries(Object.entries(properties).map(([prop]) => [prop, get(prop)]));
70
+ setProperties(properties);
71
+ try {
72
+ callback();
73
+ }
74
+ finally {
75
+ setProperties(propertiesBackup);
76
+ }
183
77
  }
184
-
185
- function withProperty(property, value, callback) {
186
- withProperties(_defineProperty({}, property, value), callback);
78
+ export function withProperty(property, value, callback) {
79
+ withProperties({ [property]: value }, callback);
187
80
  }
188
-
189
- function withChoices(choices, callback) {
190
- var properties = Object.fromEntries(Object.entries(choices).map(_ref3 => {
191
- var _ref4 = _slicedToArray(_ref3, 2),
192
- choice = _ref4[0],
193
- option = _ref4[1];
194
-
195
- return ["choiceAdventure".concat(choice), option];
196
- }));
197
- withProperties(properties, callback);
81
+ export function withChoices(choices, callback) {
82
+ const properties = Object.fromEntries(Object.entries(choices).map(([choice, option]) => [
83
+ `choiceAdventure${choice}`,
84
+ option,
85
+ ]));
86
+ withProperties(properties, callback);
198
87
  }
199
-
200
- function withChoice(choice, value, callback) {
201
- withChoices(_defineProperty({}, choice, value), callback);
88
+ export function withChoice(choice, value, callback) {
89
+ withChoices({ [choice]: value }, callback);
202
90
  }
203
-
204
- var PropertiesManager = /*#__PURE__*/function () {
205
- function PropertiesManager() {
206
- _classCallCheck(this, PropertiesManager);
207
-
208
- _defineProperty(this, "properties", void 0);
209
-
210
- this.properties = {};
211
- }
212
-
213
- _createClass(PropertiesManager, [{
214
- key: "set",
215
- value: function set(propertiesToSet) {
216
- for (var _i2 = 0, _Object$entries2 = Object.entries(propertiesToSet); _i2 < _Object$entries2.length; _i2++) {
217
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
218
- propertyName = _Object$entries2$_i[0],
219
- propertyValue = _Object$entries2$_i[1];
220
-
221
- if (this.properties[propertyName] === undefined) {
222
- this.properties[propertyName] = get(propertyName);
91
+ export class PropertiesManager {
92
+ properties;
93
+ constructor() {
94
+ this.properties = {};
95
+ }
96
+ set(propertiesToSet) {
97
+ for (const [propertyName, propertyValue] of Object.entries(propertiesToSet)) {
98
+ if (this.properties[propertyName] === undefined) {
99
+ this.properties[propertyName] = get(propertyName);
100
+ }
101
+ set(propertyName, propertyValue);
223
102
  }
224
-
225
- _set(propertyName, propertyValue);
226
- }
227
103
  }
228
- }, {
229
- key: "setChoices",
230
- value: function setChoices(choicesToSet) {
231
- this.set(Object.fromEntries(Object.entries(choicesToSet).map(_ref5 => {
232
- var _ref6 = _slicedToArray(_ref5, 2),
233
- choiceNumber = _ref6[0],
234
- choiceValue = _ref6[1];
235
-
236
- return ["choiceAdventure".concat(choiceNumber), choiceValue];
237
- })));
104
+ setChoices(choicesToSet) {
105
+ this.set(Object.fromEntries(Object.entries(choicesToSet).map(([choiceNumber, choiceValue]) => [
106
+ `choiceAdventure${choiceNumber}`,
107
+ choiceValue,
108
+ ])));
238
109
  }
239
- }, {
240
- key: "resetAll",
241
- value: function resetAll() {
242
- Object.entries(this.properties).forEach(_ref7 => {
243
- var _ref8 = _slicedToArray(_ref7, 2),
244
- propertyName = _ref8[0],
245
- propertyValue = _ref8[1];
246
-
247
- return _set(propertyName, propertyValue);
248
- });
110
+ resetAll() {
111
+ Object.entries(this.properties).forEach(([propertyName, propertyValue]) => set(propertyName, propertyValue));
249
112
  }
250
- }]);
251
-
252
- return PropertiesManager;
253
- }();
254
-
255
- exports.PropertiesManager = PropertiesManager;
113
+ }