libram 0.7.10 → 0.7.13

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 (147) hide show
  1. package/dist/Clan.d.ts +34 -6
  2. package/dist/Clan.js +33 -6
  3. package/dist/Copier.d.ts +5 -5
  4. package/dist/Dungeon.d.ts +45 -0
  5. package/dist/Dungeon.js +115 -0
  6. package/dist/Kmail.d.ts +8 -5
  7. package/dist/Kmail.js +8 -5
  8. package/dist/actions/ActionSource.d.ts +5 -0
  9. package/dist/actions/ActionSource.js +20 -1
  10. package/dist/actions/FreeKill.d.ts +2 -0
  11. package/dist/actions/FreeKill.js +2 -0
  12. package/dist/actions/FreeRun.d.ts +2 -0
  13. package/dist/actions/FreeRun.js +2 -0
  14. package/dist/ascend.d.ts +20 -4
  15. package/dist/ascend.js +38 -10
  16. package/dist/challengePaths/2015/CommunityService.d.ts +7 -0
  17. package/dist/challengePaths/2015/CommunityService.js +17 -5
  18. package/dist/combat.d.ts +63 -2
  19. package/dist/combat.js +99 -5
  20. package/dist/counter.d.ts +3 -0
  21. package/dist/counter.js +3 -0
  22. package/dist/diet/index.d.ts +2 -0
  23. package/dist/diet/index.js +27 -8
  24. package/dist/diet/knapsack.d.ts +1 -0
  25. package/dist/diet/knapsack.js +11 -3
  26. package/dist/index.d.ts +2 -4
  27. package/dist/index.js +1 -3
  28. package/dist/lib.d.ts +101 -34
  29. package/dist/lib.js +133 -42
  30. package/dist/logger.d.ts +24 -11
  31. package/dist/logger.js +38 -12
  32. package/dist/maximize.d.ts +25 -0
  33. package/dist/maximize.js +31 -4
  34. package/dist/modifier.d.ts +1 -1
  35. package/dist/modifier.js +9 -1
  36. package/dist/mood.d.ts +15 -1
  37. package/dist/mood.js +15 -1
  38. package/dist/property.d.ts +52 -17
  39. package/dist/property.js +64 -7
  40. package/dist/propertyTypes.d.ts +6 -6
  41. package/dist/propertyTypes.js +6 -6
  42. package/dist/propertyTyping.d.ts +54 -0
  43. package/dist/propertyTyping.js +54 -0
  44. package/dist/resources/2008/Stickers.d.ts +28 -0
  45. package/dist/resources/2008/Stickers.js +28 -0
  46. package/dist/resources/2009/Bandersnatch.d.ts +17 -7
  47. package/dist/resources/2009/Bandersnatch.js +17 -7
  48. package/dist/resources/2009/SpookyPutty.d.ts +25 -0
  49. package/dist/resources/2009/SpookyPutty.js +25 -0
  50. package/dist/resources/2010/CrownOfThrones.d.ts +23 -0
  51. package/dist/resources/2010/CrownOfThrones.js +31 -15
  52. package/dist/resources/2010/LookingGlass.d.ts +4 -0
  53. package/dist/resources/2010/LookingGlass.js +5 -0
  54. package/dist/resources/2011/ObtuseAngel.d.ts +8 -6
  55. package/dist/resources/2011/ObtuseAngel.js +8 -6
  56. package/dist/resources/2011/StompingBoots.d.ts +9 -15
  57. package/dist/resources/2011/StompingBoots.js +9 -15
  58. package/dist/resources/2012/RainDoh.d.ts +20 -0
  59. package/dist/resources/2012/RainDoh.js +20 -0
  60. package/dist/resources/2012/ReagnimatedGnome.d.ts +18 -0
  61. package/dist/resources/2012/ReagnimatedGnome.js +18 -0
  62. package/dist/resources/2012/Resolutions.d.ts +2 -2
  63. package/dist/resources/2012/Resolutions.js +2 -2
  64. package/dist/resources/2013/Florist.d.ts +15 -0
  65. package/dist/resources/2013/Florist.js +21 -0
  66. package/dist/resources/2014/CrimboShrub.d.ts +12 -0
  67. package/dist/resources/2014/CrimboShrub.js +22 -1
  68. package/dist/resources/2014/DNALab.d.ts +10 -2
  69. package/dist/resources/2014/DNALab.js +10 -2
  70. package/dist/resources/2014/WinterGarden.d.ts +15 -0
  71. package/dist/resources/2014/WinterGarden.js +15 -0
  72. package/dist/resources/2015/BarrelShrine.d.ts +6 -0
  73. package/dist/resources/2015/BarrelShrine.js +6 -0
  74. package/dist/resources/2015/ChateauMantegna.d.ts +35 -0
  75. package/dist/resources/2015/ChateauMantegna.js +35 -0
  76. package/dist/resources/2015/DeckOfEveryCard.d.ts +30 -0
  77. package/dist/resources/2015/DeckOfEveryCard.js +122 -0
  78. package/dist/resources/2015/Dinseylandfill.d.ts +1 -0
  79. package/dist/resources/2015/Dinseylandfill.js +2 -0
  80. package/dist/resources/2015/MayoClinic.d.ts +8 -1
  81. package/dist/resources/2015/MayoClinic.js +8 -1
  82. package/dist/resources/2016/SourceTerminal.d.ts +42 -21
  83. package/dist/resources/2016/SourceTerminal.js +44 -23
  84. package/dist/resources/2016/Witchess.d.ts +12 -0
  85. package/dist/resources/2016/Witchess.js +12 -0
  86. package/dist/resources/2017/AsdonMartin.d.ts +11 -3
  87. package/dist/resources/2017/AsdonMartin.js +44 -7
  88. package/dist/resources/2017/MummingTrunk.d.ts +1 -0
  89. package/dist/resources/2017/MummingTrunk.js +8 -1
  90. package/dist/resources/2017/Pantogram.d.ts +9 -0
  91. package/dist/resources/2017/Pantogram.js +33 -0
  92. package/dist/resources/2017/Robortender.d.ts +1 -0
  93. package/dist/resources/2017/Robortender.js +1 -0
  94. package/dist/resources/2017/Spacegate.js +1 -0
  95. package/dist/resources/2017/TunnelOfLove.d.ts +19 -0
  96. package/dist/resources/2017/TunnelOfLove.js +37 -0
  97. package/dist/resources/2018/LatteLoversMembersMug.d.ts +9 -0
  98. package/dist/resources/2018/LatteLoversMembersMug.js +9 -0
  99. package/dist/resources/2018/SongBoom.d.ts +9 -4
  100. package/dist/resources/2018/SongBoom.js +9 -4
  101. package/dist/resources/2019/BeachComb.d.ts +38 -1
  102. package/dist/resources/2019/BeachComb.js +39 -2
  103. package/dist/resources/2019/Snapper.d.ts +4 -0
  104. package/dist/resources/2019/Snapper.js +4 -0
  105. package/dist/resources/2020/Cartography.d.ts +13 -0
  106. package/dist/resources/2020/Cartography.js +13 -0
  107. package/dist/resources/2020/Guzzlr.d.ts +89 -23
  108. package/dist/resources/2020/Guzzlr.js +103 -34
  109. package/dist/resources/2020/RetroCape.d.ts +4 -0
  110. package/dist/resources/2020/RetroCape.js +4 -0
  111. package/dist/resources/2021/CrystalBall.d.ts +6 -0
  112. package/dist/resources/2021/CrystalBall.js +13 -1
  113. package/dist/resources/2021/DaylightShavings.d.ts +6 -0
  114. package/dist/resources/2021/DaylightShavings.js +6 -0
  115. package/dist/resources/2022/AutumnAton.d.ts +15 -0
  116. package/dist/resources/2022/AutumnAton.js +21 -0
  117. package/dist/resources/2022/CombatLoversLocket.d.ts +9 -0
  118. package/dist/resources/2022/CombatLoversLocket.js +10 -2
  119. package/dist/resources/2022/GreyGoose.d.ts +46 -0
  120. package/dist/resources/2022/GreyGoose.js +47 -1
  121. package/dist/resources/2022/JuneCleaver.d.ts +20 -0
  122. package/dist/resources/2022/JuneCleaver.js +20 -0
  123. package/dist/resources/2022/TrainSet.d.ts +48 -0
  124. package/dist/resources/2022/TrainSet.js +54 -0
  125. package/dist/resources/2023/ClosedCircuitPayphone.d.ts +75 -0
  126. package/dist/resources/2023/ClosedCircuitPayphone.js +117 -0
  127. package/dist/resources/LibramSummon.d.ts +5 -0
  128. package/dist/resources/LibramSummon.js +10 -3
  129. package/dist/resources/index.d.ts +3 -1
  130. package/dist/resources/index.js +3 -1
  131. package/dist/resources/putty-likes.d.ts +15 -0
  132. package/dist/resources/putty-likes.js +15 -0
  133. package/dist/session.d.ts +12 -0
  134. package/dist/session.js +20 -17
  135. package/dist/since.d.ts +3 -2
  136. package/dist/since.js +4 -2
  137. package/dist/utils.d.ts +96 -5
  138. package/dist/utils.js +106 -11
  139. package/package.json +10 -11
  140. package/dist/dungeons/Dreadsylvania.d.ts +0 -5
  141. package/dist/dungeons/Dreadsylvania.js +0 -14
  142. package/dist/dungeons/Dungeon.d.ts +0 -29
  143. package/dist/dungeons/Dungeon.js +0 -99
  144. package/dist/dungeons/Hobopolis.d.ts +0 -5
  145. package/dist/dungeons/Hobopolis.js +0 -14
  146. package/dist/dungeons/SlimeTube.d.ts +0 -5
  147. package/dist/dungeons/SlimeTube.js +0 -14
package/dist/combat.js CHANGED
@@ -6,6 +6,7 @@ const MACRO_NAME = "Script Autoattack Macro";
6
6
  /**
7
7
  * Get the KoL native ID of the macro with name name.
8
8
  *
9
+ * @param name Name of the macro
9
10
  * @category Combat
10
11
  * @returns {number} The macro ID.
11
12
  */
@@ -20,11 +21,25 @@ export function getMacroId(name = MACRO_NAME) {
20
21
  return parseInt(macroMatches[0], 10);
21
22
  }
22
23
  }
24
+ /**
25
+ * Converts an item name to a Item, or passes through an existing instance of Item
26
+ *
27
+ * @param itemOrName Item name or Item instance
28
+ * @returns KoLmafia Item instance
29
+ */
23
30
  function itemOrNameToItem(itemOrName) {
24
31
  return typeof itemOrName === "string" ? Item.get(itemOrName) : itemOrName;
25
32
  }
26
- const substringCombatItems = $items `spider web, really sticky spider web, dictionary, NG, Cloaca-Cola, yo-yo, top, ball, kite, yo, red potion, blue potion, adder, red button, pile of sand, mushroom, deluxe mushroom`;
27
- const substringCombatSkills = $skills `Shoot, Thrust-Smack, Headbutt, Toss, Sing, Disarm, LIGHT, BURN, Extract, Meteor Shower, Cleave, Boil, Slice, Rainbow`;
33
+ // The list of all combat items whose name is a strict substring of another combat item
34
+ const substringCombatItems = $items `spider web, really sticky spider web, dictionary, NG, Cloaca-Cola, yo-yo, top, ball, kite, yo, red potion, blue potion, bowling ball, adder, red button, pile of sand, mushroom, deluxe mushroom`;
35
+ // The list of all combat skills whose name is a strict substring of another combat skill
36
+ const substringCombatSkills = $skills `Shoot, Thrust-Smack, Headbutt, Toss, Sing, Disarm, LIGHT, BURN, Extract, Meteor Shower, Snipe, Cleave, Boil, Slice, Rainbow`;
37
+ /**
38
+ * Create a string of the item or items provided that is compatible with BALLS syntax and is non-ambiguous
39
+ *
40
+ * @param itemOrItems Item name, item instance, or 2-tuple of item name or item instance
41
+ * @returns BALLS macro-compatible value for item or items provided
42
+ */
28
43
  function itemOrItemsBallsMacroName(itemOrItems) {
29
44
  if (Array.isArray(itemOrItems)) {
30
45
  return itemOrItems.map(itemOrItemsBallsMacroName).join(", ");
@@ -36,6 +51,12 @@ function itemOrItemsBallsMacroName(itemOrItems) {
36
51
  : toInt(item).toString();
37
52
  }
38
53
  }
54
+ /**
55
+ * Generate a BALLS macro condition to check wither the player has either a single or a 2-tuple of combat items
56
+ *
57
+ * @param itemOrItems Single or 2-tuple of combat items
58
+ * @returns BALLS macro condition
59
+ */
39
60
  function itemOrItemsBallsMacroPredicate(itemOrItems) {
40
61
  if (Array.isArray(itemOrItems)) {
41
62
  return itemOrItems.map(itemOrItemsBallsMacroPredicate).join(" && ");
@@ -44,6 +65,12 @@ function itemOrItemsBallsMacroPredicate(itemOrItems) {
44
65
  return `hascombatitem ${itemOrItems}`;
45
66
  }
46
67
  }
68
+ /**
69
+ * Converts a skill name to a Skill, or passes through an existing instance of Skill
70
+ *
71
+ * @param skillOrName Skill name or Skill instance
72
+ * @returns KoLmafia Skill instance
73
+ */
47
74
  function skillOrNameToSkill(skillOrName) {
48
75
  if (typeof skillOrName === "string") {
49
76
  return Skill.get(skillOrName);
@@ -52,6 +79,12 @@ function skillOrNameToSkill(skillOrName) {
52
79
  return skillOrName;
53
80
  }
54
81
  }
82
+ /**
83
+ * Get a skill name in a form that is appropriate for BALLS macros
84
+ *
85
+ * @param skillOrName Skill name or Skill instance
86
+ * @returns BALLS macro-suitable skill name
87
+ */
55
88
  function skillBallsMacroName(skillOrName) {
56
89
  const skill = skillOrNameToSkill(skillOrName);
57
90
  return skill.name.match(/^[A-Za-z ]+$/) &&
@@ -76,19 +109,30 @@ export class Macro {
76
109
  name = MACRO_NAME;
77
110
  /**
78
111
  * Convert macro to string.
112
+ *
113
+ * @returns BALLS macro
79
114
  */
80
115
  toString() {
81
116
  return (this.components.join(";") + ";").replace(/;;+/g, ";");
82
117
  }
83
118
  /**
84
119
  * Gives your macro a new name to be used when saving an autoattack.
120
+ *
85
121
  * @param name The name to be used when saving as an autoattack.
86
- * @returns The previous name assigned to this macro.
122
+ * @returns The macro in question
87
123
  */
88
124
  rename(name) {
89
- const returnValue = this.name;
90
125
  this.name = name;
91
- return returnValue;
126
+ return this;
127
+ }
128
+ /**
129
+ * Creates a new Macro with a name other than the default name.
130
+ *
131
+ * @param name The name to assign this macro.
132
+ * @returns A new Macro with the assigned name.
133
+ */
134
+ static rename(name) {
135
+ return new this().rename(name);
92
136
  }
93
137
  /**
94
138
  * Save a macro to a Mafia property for use in a consult script.
@@ -98,6 +142,8 @@ export class Macro {
98
142
  }
99
143
  /**
100
144
  * Load a saved macro from the Mafia property.
145
+ *
146
+ * @returns Loaded macro text
101
147
  */
102
148
  static load() {
103
149
  return new this().step(...get(Macro.SAVED_MACRO_PROPERTY).split(";"));
@@ -110,6 +156,7 @@ export class Macro {
110
156
  }
111
157
  /**
112
158
  * Statefully add one or several steps to a macro.
159
+ *
113
160
  * @param nextSteps The steps to add to the macro.
114
161
  * @returns {Macro} This object itself.
115
162
  */
@@ -120,6 +167,7 @@ export class Macro {
120
167
  }
121
168
  /**
122
169
  * Statefully add one or several steps to a macro.
170
+ *
123
171
  * @param nextSteps The steps to add to the macro.
124
172
  * @returns {Macro} This object itself.
125
173
  */
@@ -128,6 +176,8 @@ export class Macro {
128
176
  }
129
177
  /**
130
178
  * Submit the built macro to KoL. Only works inside combat.
179
+ *
180
+ * @returns Contents of the fight page after macro submission
131
181
  */
132
182
  submit() {
133
183
  const final = this.toString();
@@ -153,6 +203,7 @@ export class Macro {
153
203
  }
154
204
  /**
155
205
  * Renames the macro, then sets it as an autoattack.
206
+ *
156
207
  * @param name The name to save the macro under as an autoattack.
157
208
  */
158
209
  setAutoAttackAs(name) {
@@ -172,6 +223,7 @@ export class Macro {
172
223
  }
173
224
  /**
174
225
  * Add an "abort" step to this macro.
226
+ *
175
227
  * @returns {Macro} This object itself.
176
228
  */
177
229
  abort() {
@@ -179,6 +231,7 @@ export class Macro {
179
231
  }
180
232
  /**
181
233
  * Create a new macro with an "abort" step.
234
+ *
182
235
  * @returns {Macro} This object itself.
183
236
  */
184
237
  static abort() {
@@ -186,6 +239,7 @@ export class Macro {
186
239
  }
187
240
  /**
188
241
  * Add a "runaway" step to this macro.
242
+ *
189
243
  * @returns {Macro} This object itself.
190
244
  */
191
245
  runaway() {
@@ -193,6 +247,7 @@ export class Macro {
193
247
  }
194
248
  /**
195
249
  * Create a new macro with an "runaway" step.
250
+ *
196
251
  * @returns {Macro} This object itself.
197
252
  */
198
253
  static runaway() {
@@ -244,6 +299,7 @@ export class Macro {
244
299
  }
245
300
  /**
246
301
  * Add an "if" statement to this macro.
302
+ *
247
303
  * @param condition The BALLS condition for the if statement.
248
304
  * @param ifTrue Continuation if the condition is true.
249
305
  * @returns {Macro} This object itself.
@@ -255,6 +311,7 @@ export class Macro {
255
311
  }
256
312
  /**
257
313
  * Create a new macro with an "if" statement.
314
+ *
258
315
  * @param condition The BALLS condition for the if statement.
259
316
  * @param ifTrue Continuation if the condition is true.
260
317
  * @returns {Macro} This object itself.
@@ -264,6 +321,7 @@ export class Macro {
264
321
  }
265
322
  /**
266
323
  * Add an "if" statement to this macro, inverting the condition.
324
+ *
267
325
  * @param condition The BALLS condition for the if statement.
268
326
  * @param ifTrue Continuation if the condition is true.
269
327
  * @returns {Macro} This object itself.
@@ -275,6 +333,7 @@ export class Macro {
275
333
  }
276
334
  /**
277
335
  * Create a new macro with an "if" statement, inverting the condition.
336
+ *
278
337
  * @param condition The BALLS condition for the if statement.
279
338
  * @param ifTrue Continuation if the condition is true.
280
339
  * @returns {Macro} This object itself.
@@ -284,6 +343,7 @@ export class Macro {
284
343
  }
285
344
  /**
286
345
  * Add a "while" statement to this macro.
346
+ *
287
347
  * @param condition The BALLS condition for the if statement.
288
348
  * @param contents Loop to repeat while the condition is true.
289
349
  * @returns {Macro} This object itself.
@@ -293,6 +353,7 @@ export class Macro {
293
353
  }
294
354
  /**
295
355
  * Create a new macro with a "while" statement.
356
+ *
296
357
  * @param condition The BALLS condition for the if statement.
297
358
  * @param contents Loop to repeat while the condition is true.
298
359
  * @returns {Macro} This object itself.
@@ -302,6 +363,7 @@ export class Macro {
302
363
  }
303
364
  /**
304
365
  * Conditionally add a step to a macro based on a condition evaluated at the time of building the macro.
366
+ *
305
367
  * @param condition The JS condition.
306
368
  * @param ifTrue Continuation to add if the condition is true.
307
369
  * @param ifFalse Optional input to turn this into an if...else statement.
@@ -317,6 +379,7 @@ export class Macro {
317
379
  }
318
380
  /**
319
381
  * Create a new macro with a condition evaluated at the time of building the macro.
382
+ *
320
383
  * @param condition The JS condition.
321
384
  * @param ifTrue Continuation to add if the condition is true.
322
385
  * @param ifFalse Optional input to turn this into an if...else statement.
@@ -327,6 +390,7 @@ export class Macro {
327
390
  }
328
391
  /**
329
392
  * Add a repeat step to the macro.
393
+ *
330
394
  * @returns {Macro} This object itself.
331
395
  */
332
396
  repeat() {
@@ -334,6 +398,7 @@ export class Macro {
334
398
  }
335
399
  /**
336
400
  * Add one or more skill cast steps to the macro.
401
+ *
337
402
  * @param skills Skills to cast.
338
403
  * @returns {Macro} This object itself.
339
404
  */
@@ -344,6 +409,7 @@ export class Macro {
344
409
  }
345
410
  /**
346
411
  * Create a new macro with one or more skill cast steps.
412
+ *
347
413
  * @param skills Skills to cast.
348
414
  * @returns {Macro} This object itself.
349
415
  */
@@ -352,6 +418,7 @@ export class Macro {
352
418
  }
353
419
  /**
354
420
  * Add one or more skill cast steps to the macro, where each step checks if you have the skill first.
421
+ *
355
422
  * @param skills Skills to try casting.
356
423
  * @returns {Macro} This object itself.
357
424
  */
@@ -362,6 +429,7 @@ export class Macro {
362
429
  }
363
430
  /**
364
431
  * Create a new macro with one or more skill cast steps, where each step checks if you have the skill first.
432
+ *
365
433
  * @param skills Skills to try casting.
366
434
  * @returns {Macro} This object itself.
367
435
  */
@@ -370,6 +438,7 @@ export class Macro {
370
438
  }
371
439
  /**
372
440
  * Add one or more skill-cast-and-repeat steps to the macro, where each step checks if you have the skill first.
441
+ *
373
442
  * @param skills Skills to try repeatedly casting.
374
443
  * @returns {Macro} This object itself.
375
444
  */
@@ -380,6 +449,7 @@ export class Macro {
380
449
  }
381
450
  /**
382
451
  * Create a new macro with one or more skill-cast-and-repeat steps, where each step checks if you have the skill first.
452
+ *
383
453
  * @param skills Skills to try repeatedly casting.
384
454
  * @returns {Macro} This object itself.
385
455
  */
@@ -388,6 +458,7 @@ export class Macro {
388
458
  }
389
459
  /**
390
460
  * Add one or more item steps to the macro.
461
+ *
391
462
  * @param items Items to use. Pass a tuple [item1, item2] to funksling.
392
463
  * @returns {Macro} This object itself.
393
464
  */
@@ -398,6 +469,7 @@ export class Macro {
398
469
  }
399
470
  /**
400
471
  * Create a new macro with one or more item steps.
472
+ *
401
473
  * @param items Items to use. Pass a tuple [item1, item2] to funksling.
402
474
  * @returns {Macro} This object itself.
403
475
  */
@@ -406,6 +478,7 @@ export class Macro {
406
478
  }
407
479
  /**
408
480
  * Add one or more item steps to the macro, where each step checks to see if you have the item first.
481
+ *
409
482
  * @param items Items to try using. Pass a tuple [item1, item2] to funksling.
410
483
  * @returns {Macro} This object itself.
411
484
  */
@@ -416,6 +489,7 @@ export class Macro {
416
489
  }
417
490
  /**
418
491
  * Create a new macro with one or more item steps, where each step checks to see if you have the item first.
492
+ *
419
493
  * @param items Items to try using. Pass a tuple [item1, item2] to funksling.
420
494
  * @returns {Macro} This object itself.
421
495
  */
@@ -424,6 +498,7 @@ export class Macro {
424
498
  }
425
499
  /**
426
500
  * Add an attack step to the macro.
501
+ *
427
502
  * @returns {Macro} This object itself.
428
503
  */
429
504
  attack() {
@@ -431,6 +506,7 @@ export class Macro {
431
506
  }
432
507
  /**
433
508
  * Create a new macro with an attack step.
509
+ *
434
510
  * @returns {Macro} This object itself.
435
511
  */
436
512
  static attack() {
@@ -438,7 +514,9 @@ export class Macro {
438
514
  }
439
515
  /**
440
516
  * Create an if_ statement based on what holiday of loathing it currently is. On non-holidays, returns the original macro, unmutated.
517
+ *
441
518
  * @param macro The macro to place in the if_ statement
519
+ * @returns This macro with supplied macro wapped in if statement matching holiday wanderers
442
520
  */
443
521
  ifHolidayWanderer(macro) {
444
522
  const todaysWanderers = getTodaysHolidayWanderers();
@@ -448,14 +526,18 @@ export class Macro {
448
526
  }
449
527
  /**
450
528
  * Create a new macro starting with an ifHolidayWanderer step.
529
+ *
451
530
  * @param macro The macro to place inside the if_ statement
531
+ * @returns New macro with supplied macro wrapped in if statement matching holiday wanderers
452
532
  */
453
533
  static ifHolidayWanderer(macro) {
454
534
  return new this().ifHolidayWanderer(macro);
455
535
  }
456
536
  /**
457
537
  * Create an if_ statement based on what holiday of loathing it currently is. On non-holidays, returns the original macro, with the input macro appended.
538
+ *
458
539
  * @param macro The macro to place in the if_ statement.
540
+ * @returns This macro with supplied macro wrapped in if statement matching monsters that are not holiday wanderers
459
541
  */
460
542
  ifNotHolidayWanderer(macro) {
461
543
  const todaysWanderers = getTodaysHolidayWanderers();
@@ -465,7 +547,9 @@ export class Macro {
465
547
  }
466
548
  /**
467
549
  * Create a new macro starting with an ifNotHolidayWanderer step.
550
+ *
468
551
  * @param macro The macro to place inside the if_ statement
552
+ * @returns New macro with supplied macro wrapped in if statement matching monsters that are not holiday wanderers
469
553
  */
470
554
  static ifNotHolidayWanderer(macro) {
471
555
  return new this().ifNotHolidayWanderer(macro);
@@ -522,6 +606,7 @@ export function adventureMacroAuto(loc, autoMacro, nextMacro = null) {
522
606
  export class StrictMacro extends Macro {
523
607
  /**
524
608
  * Add one or more skill cast steps to the macro.
609
+ *
525
610
  * @param skills Skills to cast.
526
611
  * @returns {StrictMacro} This object itself.
527
612
  */
@@ -530,6 +615,7 @@ export class StrictMacro extends Macro {
530
615
  }
531
616
  /**
532
617
  * Create a new macro with one or more skill cast steps.
618
+ *
533
619
  * @param skills Skills to cast.
534
620
  * @returns {StrictMacro} This object itself.
535
621
  */
@@ -538,6 +624,7 @@ export class StrictMacro extends Macro {
538
624
  }
539
625
  /**
540
626
  * Add one or more item steps to the macro.
627
+ *
541
628
  * @param items Items to use. Pass a tuple [item1, item2] to funksling.
542
629
  * @returns {StrictMacro} This object itself.
543
630
  */
@@ -546,6 +633,7 @@ export class StrictMacro extends Macro {
546
633
  }
547
634
  /**
548
635
  * Create a new macro with one or more item steps.
636
+ *
549
637
  * @param items Items to use. Pass a tuple [item1, item2] to funksling.
550
638
  * @returns {StrictMacro} This object itself.
551
639
  */
@@ -554,6 +642,7 @@ export class StrictMacro extends Macro {
554
642
  }
555
643
  /**
556
644
  * Add one or more skill cast steps to the macro, where each step checks if you have the skill first.
645
+ *
557
646
  * @param skills Skills to try casting.
558
647
  * @returns {StrictMacro} This object itself.
559
648
  */
@@ -562,6 +651,7 @@ export class StrictMacro extends Macro {
562
651
  }
563
652
  /**
564
653
  * Create a new macro with one or more skill cast steps, where each step checks if you have the skill first.
654
+ *
565
655
  * @param skills Skills to try casting.
566
656
  * @returns {StrictMacro} This object itself.
567
657
  */
@@ -570,6 +660,7 @@ export class StrictMacro extends Macro {
570
660
  }
571
661
  /**
572
662
  * Add one or more item steps to the macro, where each step checks to see if you have the item first.
663
+ *
573
664
  * @param items Items to try using. Pass a tuple [item1, item2] to funksling.
574
665
  * @returns {StrictMacro} This object itself.
575
666
  */
@@ -578,6 +669,7 @@ export class StrictMacro extends Macro {
578
669
  }
579
670
  /**
580
671
  * Create a new macro with one or more item steps, where each step checks to see if you have the item first.
672
+ *
581
673
  * @param items Items to try using. Pass a tuple [item1, item2] to funksling.
582
674
  * @returns {StrictMacro} This object itself.
583
675
  */
@@ -586,6 +678,7 @@ export class StrictMacro extends Macro {
586
678
  }
587
679
  /**
588
680
  * Add one or more skill-cast-and-repeat steps to the macro, where each step checks if you have the skill first.
681
+ *
589
682
  * @param skills Skills to try repeatedly casting.
590
683
  * @returns {StrictMacro} This object itself.
591
684
  */
@@ -594,6 +687,7 @@ export class StrictMacro extends Macro {
594
687
  }
595
688
  /**
596
689
  * Create a new macro with one or more skill-cast-and-repeat steps, where each step checks if you have the skill first.
690
+ *
597
691
  * @param skills Skills to try repeatedly casting.
598
692
  * @returns {StrictMacro} This object itself.
599
693
  */
package/dist/counter.d.ts CHANGED
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * Returns Infinity for counters that do not exist, and otherwise returns the duration of the counter
3
+ *
3
4
  * @param counter The name of the counter in question
4
5
  * @returns Infinity if the counter does not exist; otherwise returns the duration of the counter
5
6
  */
6
7
  export declare function get(counter: string): number;
7
8
  /**
8
9
  * The world is everything that is the case. This determines which counters are the case.
10
+ *
9
11
  * @param counter The name of the counter in question
10
12
  * @returns True for counters which currently exist; false for those which do not
11
13
  */
12
14
  export declare function exists(counter: string): boolean;
13
15
  /**
14
16
  * Creates a manual counter with specified name and duration
17
+ *
15
18
  * @param counter Name of the counter to manually create
16
19
  * @param duration Duration of counter to manually set
17
20
  * @returns Whether the counter was successfully set
package/dist/counter.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { cliExecute, getCounter, getCounters } from "kolmafia";
2
2
  /**
3
3
  * Returns Infinity for counters that do not exist, and otherwise returns the duration of the counter
4
+ *
4
5
  * @param counter The name of the counter in question
5
6
  * @returns Infinity if the counter does not exist; otherwise returns the duration of the counter
6
7
  */
@@ -16,6 +17,7 @@ export function get(counter) {
16
17
  }
17
18
  /**
18
19
  * The world is everything that is the case. This determines which counters are the case.
20
+ *
19
21
  * @param counter The name of the counter in question
20
22
  * @returns True for counters which currently exist; false for those which do not
21
23
  */
@@ -24,6 +26,7 @@ export function exists(counter) {
24
26
  }
25
27
  /**
26
28
  * Creates a manual counter with specified name and duration
29
+ *
27
30
  * @param counter Name of the counter to manually create
28
31
  * @param duration Duration of counter to manually set
29
32
  * @returns Whether the counter was successfully set
@@ -26,7 +26,9 @@ export declare class MenuItem<T> {
26
26
  static defaultOptions<T>(): Map<Item, MenuItemOptions<T>>;
27
27
  /**
28
28
  * Construct a new menu item, possibly with extra properties. Items in MenuItem.defaultOptions have intelligent defaults.
29
+ *
29
30
  * @param item Item to add to menu.
31
+ * @param options Options for this menu item
30
32
  * @param options.organ Designate item as belonging to a specific organ.
31
33
  * @param options.size Override item organ size. Necessary for any non-food/booze/spleen item.
32
34
  * @param options.maximum Maximum uses remaining today, or "auto" to check dailyusesleft Mafia property.
@@ -4,13 +4,20 @@ import { get as getModifier } from "../modifier";
4
4
  import { get } from "../property";
5
5
  import { Mayo, installed as mayoInstalled } from "../resources/2015/MayoClinic";
6
6
  import { $effect, $item, $items, $skill, $stat } from "../template-string";
7
- import { sum, sumNumbers } from "../utils";
7
+ import { sum } from "../utils";
8
8
  import { knapsack } from "./knapsack";
9
9
  function isMonday() {
10
10
  // Checking Tuesday's ruby is a hack to see if it's Monday in Arizona.
11
11
  return getModifier("Muscle Percent", $item `Tuesday's ruby`) > 0;
12
12
  }
13
- // TODO: Include Salty Mouth and potentially other modifiers.
13
+ /**
14
+ * Expected adventures from an item given a specified state
15
+ *
16
+ * @todo Include Salty Mouth and potentially other modifiers.
17
+ * @param item Item to consider
18
+ * @param modifiers Consumption modifiers to consider
19
+ * @returns Adventures expected
20
+ */
14
21
  function expectedAdventures(item, modifiers) {
15
22
  if (item.adventures === "")
16
23
  return 0;
@@ -118,7 +125,9 @@ export class MenuItem {
118
125
  }
119
126
  /**
120
127
  * Construct a new menu item, possibly with extra properties. Items in MenuItem.defaultOptions have intelligent defaults.
128
+ *
121
129
  * @param item Item to add to menu.
130
+ * @param options Options for this menu item
122
131
  * @param options.organ Designate item as belonging to a specific organ.
123
132
  * @param options.size Override item organ size. Necessary for any non-food/booze/spleen item.
124
133
  * @param options.maximum Maximum uses remaining today, or "auto" to check dailyusesleft Mafia property.
@@ -165,6 +174,10 @@ export class MenuItem {
165
174
  }
166
175
  }
167
176
  const organs = ["food", "booze", "spleen item"];
177
+ /**
178
+ * @param x Name of thing that might be an organ
179
+ * @returns Whether the string supplied is the name of an organ
180
+ */
168
181
  function isOrgan(x) {
169
182
  return organs.includes(x);
170
183
  }
@@ -210,6 +223,7 @@ class DietPlanner {
210
223
  }
211
224
  /**
212
225
  * Determine the value of consuming a menu item with any profitable helpers.
226
+ *
213
227
  * @param menuItem Menu item to check.
214
228
  * @returns Value for consuming that menu item.
215
229
  */
@@ -218,6 +232,7 @@ class DietPlanner {
218
232
  }
219
233
  /**
220
234
  * Determine which helpers will be used with a menu item and its resulting value.
235
+ *
221
236
  * @param menuItem Menu item to check.
222
237
  * @param overrideModifiers Overrides for consumption modifiers, if any.
223
238
  * @returns Pair [array of helpers and base menu item, value].
@@ -285,6 +300,8 @@ class DietPlanner {
285
300
  }
286
301
  /**
287
302
  * Plan an individual organ.
303
+ *
304
+ * @param organ Organ to plan
288
305
  * @param capacity Organ capacity.
289
306
  * @param overrideModifiers Overrides for consumption modifiers, if any.
290
307
  * @returns Pair of [value, menu items and quantities].
@@ -300,6 +317,7 @@ class DietPlanner {
300
317
  }
301
318
  /**
302
319
  * Plan organs.
320
+ *
303
321
  * @param organCapacities Organ capacities.
304
322
  * @param overrideModifiers Overrides for consumption modifiers, if any.
305
323
  * @returns Pair of [value, menu items and quantities].
@@ -314,6 +332,7 @@ class DietPlanner {
314
332
  /**
315
333
  * Plan organs, retrying with and without each trial item. Runtime is
316
334
  * proportional to 2 ^ trialItems.length.
335
+ *
317
336
  * @param organCapacities Organ capacities.
318
337
  * @param trialItems Items to rerun solver with and without.
319
338
  * @param overrideModifiers Overrides for consumption modifiers, if any.
@@ -408,6 +427,7 @@ const interactingItems = [
408
427
  ];
409
428
  /**
410
429
  * Plan out an optimal diet using a knapsack algorithm.
430
+ *
411
431
  * @param mpa Meat per adventure value.
412
432
  * @param menu Array of MenuItems to consider for diet purposes.
413
433
  * @param organCapacities Optional override of each organ's capacity.
@@ -518,7 +538,7 @@ class DietEntry {
518
538
  expectedValue(mpa, diet, method = "gross") {
519
539
  const gross = mpa * this.expectedAdventures(diet) +
520
540
  this.quantity *
521
- sumNumbers(this.menuItems.map((menuItem) => menuItem.additionalValue ?? 0));
541
+ sum(this.menuItems, (menuItem) => menuItem.additionalValue ?? 0);
522
542
  if (method === "gross") {
523
543
  return gross;
524
544
  }
@@ -527,8 +547,7 @@ class DietEntry {
527
547
  }
528
548
  }
529
549
  expectedPrice() {
530
- return (this.quantity *
531
- sumNumbers(this.menuItems.map((menuItem) => menuItem.price())));
550
+ return this.quantity * sum(this.menuItems, (menuItem) => menuItem.price());
532
551
  }
533
552
  }
534
553
  /**
@@ -559,13 +578,13 @@ export class Diet {
559
578
  return have($item `mafia pinky ring`) && canEquip($item `mafia pinky ring`);
560
579
  }
561
580
  expectedAdventures() {
562
- return sumNumbers(this.entries.map((dietEntry) => dietEntry.expectedAdventures(this)));
581
+ return sum(this.entries, (dietEntry) => dietEntry.expectedAdventures(this));
563
582
  }
564
583
  expectedValue(mpa, method = "gross") {
565
- return sumNumbers(this.entries.map((dietEntry) => dietEntry.expectedValue(mpa, this, method)));
584
+ return sum(this.entries, (dietEntry) => dietEntry.expectedValue(mpa, this, method));
566
585
  }
567
586
  expectedPrice() {
568
- return sumNumbers(this.entries.map((dietEntry) => dietEntry.expectedPrice()));
587
+ return sum(this.entries, (dietEntry) => dietEntry.expectedPrice());
569
588
  }
570
589
  copy() {
571
590
  return new Diet([...this.entries]);
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Solve the knapsack problem.
3
+ *
3
4
  * @param values Array of {[item, value, weight, maximum]} tuples for knapsack parameter.
4
5
  * @param capacity Capacity of knapsack.
5
6
  * @returns Tuple {[totalValue, items]} of selected items and total value of those items.
@@ -5,8 +5,14 @@ class Not {
5
5
  this.thing = thing;
6
6
  }
7
7
  }
8
- // Assuming list is already sorted, count adjacent items.
9
- // Effectively run-length encoding.
8
+ /**
9
+ * Assuming list is already sorted, count adjacent items.
10
+ * Effectively run-length encoding.
11
+ *
12
+ * @param list List to count
13
+ * @param isEqual Function that determines item equality
14
+ * @returns List of 2-tuples relating item to count
15
+ */
10
16
  function aggregate(list, isEqual) {
11
17
  const aggregatedList = [];
12
18
  for (const item of list) {
@@ -28,6 +34,7 @@ function aggregate(list, isEqual) {
28
34
  }
29
35
  /**
30
36
  * Solve the knapsack problem.
37
+ *
31
38
  * @param values Array of {[item, value, weight, maximum]} tuples for knapsack parameter.
32
39
  * @param capacity Capacity of knapsack.
33
40
  * @returns Tuple {[totalValue, items]} of selected items and total value of those items.
@@ -92,11 +99,12 @@ export function knapsack(values, capacity) {
92
99
  }
93
100
  /**
94
101
  * Find the best solution to a knapsack subproblem.
102
+ *
95
103
  * @param memoizationTable Memoization table for dynamic programming approach.
96
104
  * @param values Array of {[item, value, weight, maximum]} tuples for knapsack parameter.
97
105
  * @param currentIndex Current index into values array - only add items before this index.
98
106
  * @param remainingCapacity Remaining capacity of knapsack.
99
- * @returns
107
+ * @returns Tuple of value to item
100
108
  */
101
109
  function bestSolution(memoizationTable, values, currentIndex, remainingCapacity) {
102
110
  // If we've used all our capacity, this solution is no good.