libram 0.7.11 → 0.7.14

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 -2
  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 +32 -4
  16. package/dist/challengePaths/2015/CommunityService.d.ts +7 -0
  17. package/dist/challengePaths/2015/CommunityService.js +12 -1
  18. package/dist/combat.d.ts +55 -0
  19. package/dist/combat.js +85 -0
  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 +3 -7
  27. package/dist/index.js +1 -3
  28. package/dist/lib.d.ts +101 -33
  29. package/dist/lib.js +132 -42
  30. package/dist/logger.d.ts +24 -11
  31. package/dist/logger.js +38 -12
  32. package/dist/maximize.d.ts +20 -1
  33. package/dist/maximize.js +30 -3
  34. package/dist/modifier.d.ts +13 -1
  35. package/dist/modifier.js +87 -3
  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 +5 -5
  41. package/dist/propertyTypes.js +5 -5
  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 +8 -1
  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 +23 -1
  77. package/dist/resources/2015/DeckOfEveryCard.js +24 -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 +42 -21
  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 +388 -0
  98. package/dist/resources/2018/LatteLoversMembersMug.js +294 -4
  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 +100 -29
  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 +5 -0
  129. package/dist/resources/index.d.ts +2 -1
  130. package/dist/resources/index.js +2 -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 +90 -6
  138. package/dist/utils.js +108 -0
  139. package/package.json +4 -8
  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
@@ -10,4 +10,9 @@ export declare function expectedLibramSummon(summonSkill: Skill): Map<Item, numb
10
10
  * @returns map containing the chance of items to be summoned for each libram summoning skill available
11
11
  */
12
12
  export declare function possibleLibramSummons(): Map<Skill, Map<Item, number>>;
13
+ /**
14
+ * Determines the best libram to cast, based on expected meat value in mall
15
+ *
16
+ * @returns The best libram to cast, based on expected meat value in mall
17
+ */
13
18
  export declare function bestLibramToCast(): Skill | null;
@@ -60,6 +60,11 @@ export function possibleLibramSummons() {
60
60
  }
61
61
  return results;
62
62
  }
63
+ /**
64
+ * Determines the best libram to cast, based on expected meat value in mall
65
+ *
66
+ * @returns The best libram to cast, based on expected meat value in mall
67
+ */
63
68
  export function bestLibramToCast() {
64
69
  const arr = Array.from(possibleLibramSummons().entries());
65
70
  if (!arr.length)
@@ -37,6 +37,7 @@ import * as CombatLoversLocket from "./2022/CombatLoversLocket";
37
37
  import * as GreyGoose from "./2022/GreyGoose";
38
38
  import * as JuneCleaver from "./2022/JuneCleaver";
39
39
  import * as TrainSet from "./2022/TrainSet";
40
- export { AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BeachComb, Cartography, ChateauMantegna, CombatLoversLocket, CrimboShrub, CrownOfThrones, CrystalBall, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, FloristFriar, GreyGoose, Guzzlr, JuneCleaver, Latte, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StompingBoots, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
40
+ import * as ClosedCircuitPayphone from "./2023/ClosedCircuitPayphone";
41
+ export { AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BeachComb, Cartography, ChateauMantegna, ClosedCircuitPayphone, CombatLoversLocket, CrimboShrub, CrownOfThrones, CrystalBall, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, FloristFriar, GreyGoose, Guzzlr, JuneCleaver, Latte, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StompingBoots, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
41
42
  export * from "./putty-likes";
42
43
  export * from "./LibramSummon";
@@ -37,6 +37,7 @@ import * as CombatLoversLocket from "./2022/CombatLoversLocket";
37
37
  import * as GreyGoose from "./2022/GreyGoose";
38
38
  import * as JuneCleaver from "./2022/JuneCleaver";
39
39
  import * as TrainSet from "./2022/TrainSet";
40
- export { AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BeachComb, Cartography, ChateauMantegna, CombatLoversLocket, CrimboShrub, CrownOfThrones, CrystalBall, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, FloristFriar, GreyGoose, Guzzlr, JuneCleaver, Latte, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StompingBoots, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
40
+ import * as ClosedCircuitPayphone from "./2023/ClosedCircuitPayphone";
41
+ export { AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BeachComb, Cartography, ChateauMantegna, ClosedCircuitPayphone, CombatLoversLocket, CrimboShrub, CrownOfThrones, CrystalBall, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, FloristFriar, GreyGoose, Guzzlr, JuneCleaver, Latte, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StompingBoots, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
41
42
  export * from "./putty-likes";
42
43
  export * from "./LibramSummon";
@@ -1,6 +1,21 @@
1
1
  import { Copier } from "../Copier";
2
+ /**
3
+ * Get total putty-like copies made
4
+ *
5
+ * @returns Total copies made
6
+ */
2
7
  export declare function getTotalPuttyLikeCopiesMade(): number;
8
+ /**
9
+ * Determine if Rain-Doh black box can be used
10
+ *
11
+ * @returns Whether it can be used
12
+ */
3
13
  export declare function couldUseRainDohBlackBox(): boolean;
4
14
  export declare const RainDohBlackBox: Copier;
15
+ /**
16
+ * Determines whether you can still use a spooky putty sheet
17
+ *
18
+ * @returns Whether you can still use a spooky putty sheet
19
+ */
5
20
  export declare function couldUseSpookyPuttySheet(): boolean;
6
21
  export declare const SpookyPuttySheet: Copier;
@@ -1,15 +1,30 @@
1
1
  import { Copier } from "../Copier";
2
2
  import { getSpookyPuttySheetCopiesMade, getSpookyPuttySheetMonster, have as haveSpookyPutty, prepareSpookyPuttySheet, useSpookyPuttySheet, } from "./2009/SpookyPutty";
3
3
  import { getRainDohBlackBoxCopiesMade, getRainDohBlackBoxMonster, have as haveRainDoh, useRainDohBlackBox, } from "./2012/RainDoh";
4
+ /**
5
+ * Get total putty-like copies made
6
+ *
7
+ * @returns Total copies made
8
+ */
4
9
  export function getTotalPuttyLikeCopiesMade() {
5
10
  return getSpookyPuttySheetCopiesMade() + getRainDohBlackBoxCopiesMade();
6
11
  }
12
+ /**
13
+ * Determine if Rain-Doh black box can be used
14
+ *
15
+ * @returns Whether it can be used
16
+ */
7
17
  export function couldUseRainDohBlackBox() {
8
18
  return (haveRainDoh() &&
9
19
  getRainDohBlackBoxCopiesMade() < 5 &&
10
20
  getTotalPuttyLikeCopiesMade() < 6);
11
21
  }
12
22
  export const RainDohBlackBox = new Copier(() => couldUseRainDohBlackBox(), null, () => couldUseRainDohBlackBox(), () => getRainDohBlackBoxMonster(), () => useRainDohBlackBox());
23
+ /**
24
+ * Determines whether you can still use a spooky putty sheet
25
+ *
26
+ * @returns Whether you can still use a spooky putty sheet
27
+ */
13
28
  export function couldUseSpookyPuttySheet() {
14
29
  return (haveSpookyPutty() &&
15
30
  getSpookyPuttySheetCopiesMade() < 5 &&
package/dist/session.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Item } from "kolmafia";
2
2
  /**
3
3
  * An entry showing the value of each Item in a session
4
+ *
4
5
  * @member item the item associated with this detail
5
6
  * @member value the numeric value of the full quantity of items (to get value of each item, do value / quantity) (can be negative)
6
7
  * @member quantity the number of items for this detail
@@ -12,6 +13,7 @@ interface ItemDetail {
12
13
  }
13
14
  /**
14
15
  * The full value (in meat) results of a session
16
+ *
15
17
  * @member meat the value of this session in pure meat
16
18
  * @member items the value of the items in this session in meat
17
19
  * @member total sum of meat and items
@@ -27,6 +29,7 @@ interface ItemResult {
27
29
  * A wrapper around tracking items and meat gained from this session
28
30
  * Smartly handles foldables being added/removed based on their state
29
31
  * Provides operations to add sessions and subtract Sessions so you can isolate the value of each Session using a baseline
32
+ *
30
33
  * @member meat the raw meat associated with this Session
31
34
  * @member items a map representing the items gained/lost during this Session
32
35
  */
@@ -35,18 +38,21 @@ export declare class Session {
35
38
  items: Map<Item, number>;
36
39
  /**
37
40
  * Construct a new session
41
+ *
38
42
  * @param meat the amount of meat associated with this session
39
43
  * @param items the items associated with this session
40
44
  */
41
45
  private constructor();
42
46
  /**
43
47
  * Register session results that do not get tracked natively
48
+ *
44
49
  * @param target either the Item or a string saying "meat" of what quantity to modify
45
50
  * @param quantity How much to modify the tracked amount by
46
51
  */
47
52
  register(target: Item | "meat", quantity: number): void;
48
53
  /**
49
54
  * Value this session
55
+ *
50
56
  * @param itemValue a function that, when given an item, will give a meat value of the item
51
57
  * @returns ItemResult with the full value of this session given the input function
52
58
  */
@@ -54,6 +60,7 @@ export declare class Session {
54
60
  /**
55
61
  * Subtract the contents of another session from this one, removing any items that have a resulting quantity of 0
56
62
  * (this will ignore elements in b but not in a)
63
+ *
57
64
  * @param other the session from which to pull values to remove from this session
58
65
  * @returns a new session representing the difference between this session and the other session
59
66
  */
@@ -61,6 +68,7 @@ export declare class Session {
61
68
  /**
62
69
  * Subtract the contents of snasphot b from session a, removing any items that have a resulting quantity of 0
63
70
  * (this will ignore elements in b but not in a)
71
+ *
64
72
  * @param a the session from which to subtract elements
65
73
  * @param b the session from which to add elements
66
74
  * @returns a new session representing the difference between a and b
@@ -68,12 +76,14 @@ export declare class Session {
68
76
  static diff(a: Session, b: Session): Session;
69
77
  /**
70
78
  * Generate a new session combining multiple sessions together
79
+ *
71
80
  * @param other the session from which to add elements to this set
72
81
  * @returns a new session representing the addition of other to this
73
82
  */
74
83
  add(other: Session): Session;
75
84
  /**
76
85
  * Combine the contents of sessions
86
+ *
77
87
  * @param sessions the set of sessions to combine together
78
88
  * @returns a new session representing the difference between a and b
79
89
  */
@@ -81,11 +91,13 @@ export declare class Session {
81
91
  static getFilepath(filename: string): string;
82
92
  /**
83
93
  * Export this session to a file in the data/ directory. Conventionally this file should end in ".json"
94
+ *
84
95
  * @param filename The file into which to export
85
96
  */
86
97
  toFile(filename: string): void;
87
98
  /**
88
99
  * Import a session from a file in the data/ directory. Conventionally the file should end in ".json"
100
+ *
89
101
  * @param filename The file from which to import
90
102
  * @returns the session represented by the file
91
103
  */
package/dist/session.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { todayToString, myName, bufferToFile, fileToBuffer, mySessionItems, mySessionMeat, toItem, } from "kolmafia";
2
2
  import { getFoldGroup } from "./lib";
3
3
  import { $item, $items } from "./template-string";
4
- import { sumNumbers } from "./utils";
4
+ import { sum } from "./utils";
5
5
  /**
6
6
  * Return a mapping of the session items, mapping foldable items to a single of their forms
7
+ *
7
8
  * @returns the item session results, with foldables mapped to a single of their folding forms
8
9
  */
9
10
  function mySessionItemsWrapper() {
@@ -44,26 +45,18 @@ function mySessionItemsWrapper() {
44
45
  return inventory;
45
46
  }
46
47
  /**
47
- * Performa a binary element-wise operation on two inventories
48
+ * Perform a binary element-wise operation on two inventories
49
+ *
48
50
  * @param a The LHS inventory to perform the operation on
49
51
  * @param b The RHS inventory to perform the operation on
50
52
  * @param op an operator to compute between the sets
51
- * @param commutative if true use the value of b for any items not in a. if false, ignore values not in a
52
53
  * @returns a new map representing the combined inventories
53
54
  */
54
- function inventoryOperation(a, b, op, commutative) {
55
+ function inventoryOperation(a, b, op) {
55
56
  // return every entry that is in a and not in b
56
57
  const difference = new Map();
57
- for (const [item, quantity] of a.entries()) {
58
- const combinedQuantity = op(quantity, b.get(item) ?? 0);
59
- difference.set(item, combinedQuantity);
60
- }
61
- if (commutative) {
62
- for (const [item, quantity] of b.entries()) {
63
- if (!a.has(item)) {
64
- difference.set(item, quantity);
65
- }
66
- }
58
+ for (const item of new Set([...a.keys(), ...b.keys()])) {
59
+ difference.set(item, op(a.get(item) ?? 0, b.get(item) ?? 0));
67
60
  }
68
61
  const diffEntries = [...difference.entries()];
69
62
  return new Map(diffEntries.filter((value) => value[1] !== 0));
@@ -72,6 +65,7 @@ function inventoryOperation(a, b, op, commutative) {
72
65
  * A wrapper around tracking items and meat gained from this session
73
66
  * Smartly handles foldables being added/removed based on their state
74
67
  * Provides operations to add sessions and subtract Sessions so you can isolate the value of each Session using a baseline
68
+ *
75
69
  * @member meat the raw meat associated with this Session
76
70
  * @member items a map representing the items gained/lost during this Session
77
71
  */
@@ -80,6 +74,7 @@ export class Session {
80
74
  items;
81
75
  /**
82
76
  * Construct a new session
77
+ *
83
78
  * @param meat the amount of meat associated with this session
84
79
  * @param items the items associated with this session
85
80
  */
@@ -89,6 +84,7 @@ export class Session {
89
84
  }
90
85
  /**
91
86
  * Register session results that do not get tracked natively
87
+ *
92
88
  * @param target either the Item or a string saying "meat" of what quantity to modify
93
89
  * @param quantity How much to modify the tracked amount by
94
90
  */
@@ -102,6 +98,7 @@ export class Session {
102
98
  }
103
99
  /**
104
100
  * Value this session
101
+ *
105
102
  * @param itemValue a function that, when given an item, will give a meat value of the item
106
103
  * @returns ItemResult with the full value of this session given the input function
107
104
  */
@@ -111,21 +108,23 @@ export class Session {
111
108
  const itemDetails = [...this.items.entries()].map(([item, quantity]) => {
112
109
  return { item, quantity, value: itemValue(item) * quantity };
113
110
  });
114
- const items = Math.floor(sumNumbers(itemDetails.map((detail) => detail.value)));
111
+ const items = Math.floor(sum(itemDetails, "value"));
115
112
  return { meat, items, total: meat + items, itemDetails };
116
113
  }
117
114
  /**
118
115
  * Subtract the contents of another session from this one, removing any items that have a resulting quantity of 0
119
116
  * (this will ignore elements in b but not in a)
117
+ *
120
118
  * @param other the session from which to pull values to remove from this session
121
119
  * @returns a new session representing the difference between this session and the other session
122
120
  */
123
121
  diff(other) {
124
- return new Session(this.meat - other.meat, inventoryOperation(this.items, other.items, (a, b) => a - b, false));
122
+ return new Session(this.meat - other.meat, inventoryOperation(this.items, other.items, (a, b) => a - b));
125
123
  }
126
124
  /**
127
125
  * Subtract the contents of snasphot b from session a, removing any items that have a resulting quantity of 0
128
126
  * (this will ignore elements in b but not in a)
127
+ *
129
128
  * @param a the session from which to subtract elements
130
129
  * @param b the session from which to add elements
131
130
  * @returns a new session representing the difference between a and b
@@ -135,14 +134,16 @@ export class Session {
135
134
  }
136
135
  /**
137
136
  * Generate a new session combining multiple sessions together
137
+ *
138
138
  * @param other the session from which to add elements to this set
139
139
  * @returns a new session representing the addition of other to this
140
140
  */
141
141
  add(other) {
142
- return new Session(this.meat + other.meat, inventoryOperation(this.items, other.items, (a, b) => a + b, true));
142
+ return new Session(this.meat + other.meat, inventoryOperation(this.items, other.items, (a, b) => a + b));
143
143
  }
144
144
  /**
145
145
  * Combine the contents of sessions
146
+ *
146
147
  * @param sessions the set of sessions to combine together
147
148
  * @returns a new session representing the difference between a and b
148
149
  */
@@ -156,6 +157,7 @@ export class Session {
156
157
  }
157
158
  /**
158
159
  * Export this session to a file in the data/ directory. Conventionally this file should end in ".json"
160
+ *
159
161
  * @param filename The file into which to export
160
162
  */
161
163
  toFile(filename) {
@@ -167,6 +169,7 @@ export class Session {
167
169
  }
168
170
  /**
169
171
  * Import a session from a file in the data/ directory. Conventionally the file should end in ".json"
172
+ *
170
173
  * @param filename The file from which to import
171
174
  * @returns the session represented by the file
172
175
  */
package/dist/since.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Provides functions for checking KoLmafia's version and revision.
3
+ *
3
4
  * @packageDocumentation
4
5
  */
5
6
  /**
@@ -14,11 +15,11 @@ export declare class KolmafiaVersionError extends Error {
14
15
  * Otherwise, does nothing.
15
16
  *
16
17
  * This behaves like the `since rXXX;` statement in ASH.
18
+ *
17
19
  * @param revision Revision number
18
20
  * @throws {KolmafiaVersionError}
19
21
  * If KoLmafia's revision number is less than `revision`.
20
22
  * @throws {TypeError} If `revision` is not an integer
21
- *
22
23
  * @example
23
24
  * ```ts
24
25
  * // Throws if KoLmafia revision is less than r20500
@@ -32,6 +33,7 @@ export declare function sinceKolmafiaRevision(revision: number): void;
32
33
  * Otherwise, does nothing.
33
34
  *
34
35
  * This behaves like the `since X.Y;` statement in ASH.
36
+ *
35
37
  * @param majorVersion Major version number
36
38
  * @param minorVersion Minor version number
37
39
  * @deprecated Point versions are no longer released by KoLmafia
@@ -40,7 +42,6 @@ export declare function sinceKolmafiaRevision(revision: number): void;
40
42
  * versions are equal but the minor version is less than `minorVersion`
41
43
  * @throws {TypeError}
42
44
  * If either `majorVersion` or `minorVersion` are not integers
43
- *
44
45
  * @example
45
46
  * ```ts
46
47
  * // Throws if KoLmafia version is less than 20.7
package/dist/since.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Provides functions for checking KoLmafia's version and revision.
3
+ *
3
4
  * @packageDocumentation
4
5
  */
5
6
  import { getRevision, getVersion } from "kolmafia";
@@ -22,6 +23,7 @@ KolmafiaVersionError.prototype.name = "KolmafiaVersionError";
22
23
  /**
23
24
  * Returns the currently executing script name, suitable for embedding in an
24
25
  * error message.
26
+ *
25
27
  * @returns Path of the main script wrapped in single-quotes, or `"This script"`
26
28
  * if the path cannot be determined
27
29
  */
@@ -35,11 +37,11 @@ function getScriptName() {
35
37
  * Otherwise, does nothing.
36
38
  *
37
39
  * This behaves like the `since rXXX;` statement in ASH.
40
+ *
38
41
  * @param revision Revision number
39
42
  * @throws {KolmafiaVersionError}
40
43
  * If KoLmafia's revision number is less than `revision`.
41
44
  * @throws {TypeError} If `revision` is not an integer
42
- *
43
45
  * @example
44
46
  * ```ts
45
47
  * // Throws if KoLmafia revision is less than r20500
@@ -62,6 +64,7 @@ export function sinceKolmafiaRevision(revision) {
62
64
  * Otherwise, does nothing.
63
65
  *
64
66
  * This behaves like the `since X.Y;` statement in ASH.
67
+ *
65
68
  * @param majorVersion Major version number
66
69
  * @param minorVersion Minor version number
67
70
  * @deprecated Point versions are no longer released by KoLmafia
@@ -70,7 +73,6 @@ export function sinceKolmafiaRevision(revision) {
70
73
  * versions are equal but the minor version is less than `minorVersion`
71
74
  * @throws {TypeError}
72
75
  * If either `majorVersion` or `minorVersion` are not integers
73
- *
74
76
  * @example
75
77
  * ```ts
76
78
  * // Throws if KoLmafia version is less than 20.7
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,16 @@
1
+ /**
2
+ * Type guard against null value
3
+ *
4
+ * @param value Value that can be null
5
+ * @returns Whether the value is not null or... not
6
+ */
1
7
  export declare function notNull<T>(value: T | null): value is T;
8
+ /**
9
+ * Parse string to number, stripping commas
10
+ *
11
+ * @param n Numberical string to parse
12
+ * @returns Numerical value of string
13
+ */
2
14
  export declare function parseNumber(n: string): number;
3
15
  /**
4
16
  * Clamp a number between lower and upper bounds.
@@ -6,6 +18,7 @@ export declare function parseNumber(n: string): number;
6
18
  * @param n Number to clamp.
7
19
  * @param min Lower bound.
8
20
  * @param max Upper bound.
21
+ * @returns Clamped value
9
22
  */
10
23
  export declare function clamp(n: number, min: number, max: number): number;
11
24
  /**
@@ -13,28 +26,58 @@ export declare function clamp(n: number, min: number, max: number): number;
13
26
  *
14
27
  * @param array Array to split
15
28
  * @param chunkSize Size of chunk
29
+ * @returns Split array
16
30
  */
17
31
  export declare function chunk<T>(array: T[], chunkSize: number): T[][];
32
+ /**
33
+ * Count distinct values in an array
34
+ *
35
+ * @param array Array of values
36
+ * @returns Map of distinct values to count
37
+ */
18
38
  export declare function arrayToCountedMap<T>(array: T[] | Map<T, number>): Map<T, number>;
39
+ /**
40
+ * Turn map of distinct values to count into array of values
41
+ *
42
+ * @param map Map to turn into array
43
+ * @returns Array of values
44
+ */
19
45
  export declare function countedMapToArray<T>(map: Map<T, number>): T[];
46
+ /**
47
+ * Stringify a counted map
48
+ *
49
+ * @param map Map of counted values
50
+ * @returns String representing map of counted values
51
+ */
20
52
  export declare function countedMapToString<T>(map: Map<T, number>): string;
21
53
  /**
22
54
  * Sum an array of numbers.
55
+ *
23
56
  * @param addends Addends to sum.
24
57
  * @param property Property of the elements to be summing
58
+ * @returns Sum of numbers
25
59
  */
26
60
  export declare function sum<S extends string | number | symbol, T extends {
27
61
  [s in S]: number;
28
62
  }>(addends: T[], property: S): number;
29
63
  /**
30
64
  * Sum an array of numbers.
65
+ *
31
66
  * @param addends Addends to sum.
32
67
  * @param mappingFunction Mapping function to turn addends into actual numbers.
68
+ * @returns Sum of numbers
33
69
  */
34
70
  export declare function sum<T>(addends: T[], mappingFunction: (element: T) => number): number;
71
+ /**
72
+ * Sum array of numbers
73
+ *
74
+ * @param addends Numbers to sum
75
+ * @returns Sum of numbers
76
+ */
35
77
  export declare function sumNumbers(addends: number[]): number;
36
78
  /**
37
79
  * Checks if a given item is in a readonly array, acting as a typeguard.
80
+ *
38
81
  * @param item Needle
39
82
  * @param array Readonly array haystack
40
83
  * @returns Whether the item is in the array, and narrows the type of the item.
@@ -42,6 +85,7 @@ export declare function sumNumbers(addends: number[]): number;
42
85
  export declare function arrayContains<T, A extends T>(item: T, array: ReadonlyArray<A>): item is A;
43
86
  /**
44
87
  * Checks if two arrays contain the same elements in the same quantity.
88
+ *
45
89
  * @param a First array for comparison
46
90
  * @param b Second array for comparison
47
91
  * @returns Whether the two arrays are equal, irrespective of order.
@@ -49,26 +93,66 @@ export declare function arrayContains<T, A extends T>(item: T, array: ReadonlyAr
49
93
  export declare function setEqual<T>(a: T[], b: T[]): boolean;
50
94
  /**
51
95
  * Reverses keys and values for a given map
96
+ *
52
97
  * @param map Map to invert
98
+ * @returns Inverted map
53
99
  */
54
100
  export declare function invertMap<T1, T2>(map: Map<T1, T2>): Map<T2, T1>;
55
101
  /**
56
102
  * Splits a string by commas while also respecting escaping commas with a backslash
103
+ *
57
104
  * @param str String to split
58
105
  * @returns List of tokens
59
106
  */
60
107
  export declare function splitByCommasWithEscapes(str: string): string[];
61
- /**
62
- * Find the best element of an array, where "best" is defined by some given criteria.
63
- * @param array The array to traverse and find the best element of.
64
- * @param optimizer Either a key on the objects we're looking at that corresponds to numerical values, or a function for mapping these objects to numbers. Essentially, some way of assigning value to the elements of the array.
65
- * @param reverse Make this true to find the worst element of the array, and false to find the best. Defaults to false.
66
- */
67
108
  export declare function maxBy<T>(array: T[] | readonly T[], optimizer: (element: T) => number, reverse?: boolean): T;
68
109
  export declare function maxBy<S extends string | number | symbol, T extends {
69
110
  [x in S]: number;
70
111
  }>(array: T[] | readonly T[], key: S, reverse?: boolean): T;
71
112
  export declare type Tuple<T, N extends number> = N extends N ? number extends N ? T[] : _tupleOf<T, N, []> : never;
72
113
  declare type _tupleOf<T, N extends number, R extends unknown[]> = R["length"] extends N ? R : _tupleOf<T, N, [T, ...R]>;
114
+ /**
115
+ * Compare arrays shallowly
116
+ *
117
+ * @param left One array to compare
118
+ * @param right The other array to compare
119
+ * @returns Whether the two arrays are shallowly equal
120
+ */
73
121
  export declare function arrayEquals<T>(left: T[] | readonly T[], right: T[] | readonly T[]): boolean;
122
+ /**
123
+ * Type that extends any non-function entity--like a string, number, or array--into a itself and a no-input function that returns it.
124
+ * Used to interact with objects that could either be functions or static values.
125
+ */
126
+ export declare type Delayed<T> = [T] extends [(...args: any) => any] ? never : T | (() => T);
127
+ /**
128
+ * Used to collapse a Delayed<T> object into an entity of type "T" as represented by the object.
129
+ *
130
+ * @param delayedObject Object of type Delayed<T> that represents either a value of type T or a function returning a value of type T.
131
+ * @returns The return value of the function, if delayedObject is a function. Otherwise, this returns the original element.
132
+ */
133
+ export declare function undelay<T>(delayedObject: Delayed<T>): T;
134
+ /**
135
+ * An object keyed by string type T, with values of S.
136
+ * or contains a 'default' parameter to use as a fallback.
137
+ */
138
+ export declare type Switch<T extends string, S> = Record<T, S> | (Partial<{
139
+ [x in T]: S;
140
+ }> & {
141
+ default: S;
142
+ });
143
+ /**
144
+ * Makes a byX function, like byStat or byClass
145
+ *
146
+ * @param source A method for finding your stat, or class, or whatever X is in this context
147
+ * @returns A function akin to byStat or byClass; it accepts an object that either is "complete" in the sense that it has a key for every conceivable value, or contains a `default` parameter. If an inappropriate input is provided, returns undefined.
148
+ */
149
+ export declare function makeByXFunction<T extends string>(source: Delayed<T>): <S>(options: Switch<T, S>) => S;
150
+ /**
151
+ * Flattens an array. Basically replacing Array.prototype.flat for which Rhino doesn't yet have an implementation
152
+ *
153
+ * @param arr Array to flatten
154
+ * @param depth Level to flatten
155
+ * @returns Flattened array
156
+ */
157
+ export declare function flat<A extends any[], D extends number = 1>(arr: A, depth?: number): FlatArray<A, D>[];
74
158
  export {};