libram 0.8.27 → 0.8.28

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 (195) hide show
  1. package/package.json +9 -8
  2. package/dist/Clan.d.ts +0 -128
  3. package/dist/Clan.js +0 -300
  4. package/dist/Copier.d.ts +0 -9
  5. package/dist/Copier.js +0 -15
  6. package/dist/Dungeon.d.ts +0 -45
  7. package/dist/Dungeon.js +0 -115
  8. package/dist/Kmail.d.ts +0 -104
  9. package/dist/Kmail.js +0 -182
  10. package/dist/actions/ActionSource.d.ts +0 -131
  11. package/dist/actions/ActionSource.js +0 -177
  12. package/dist/actions/Banish.d.ts +0 -16
  13. package/dist/actions/Banish.js +0 -121
  14. package/dist/actions/FreeKill.d.ts +0 -16
  15. package/dist/actions/FreeKill.js +0 -94
  16. package/dist/actions/FreeRun.d.ts +0 -16
  17. package/dist/actions/FreeRun.js +0 -77
  18. package/dist/actions/index.d.ts +0 -4
  19. package/dist/actions/index.js +0 -4
  20. package/dist/ascend.d.ts +0 -83
  21. package/dist/ascend.js +0 -268
  22. package/dist/challengePaths/2014/HeavyRains.d.ts +0 -22
  23. package/dist/challengePaths/2014/HeavyRains.js +0 -75
  24. package/dist/challengePaths/2015/CommunityService.d.ts +0 -125
  25. package/dist/challengePaths/2015/CommunityService.js +0 -334
  26. package/dist/challengePaths/2016/NuclearAutumn.d.ts +0 -13
  27. package/dist/challengePaths/2016/NuclearAutumn.js +0 -21
  28. package/dist/challengePaths/index.d.ts +0 -4
  29. package/dist/challengePaths/index.js +0 -4
  30. package/dist/combat.d.ts +0 -414
  31. package/dist/combat.js +0 -711
  32. package/dist/console.d.ts +0 -12
  33. package/dist/console.js +0 -14
  34. package/dist/counter.d.ts +0 -22
  35. package/dist/counter.js +0 -37
  36. package/dist/diet/index.d.ts +0 -80
  37. package/dist/diet/index.js +0 -662
  38. package/dist/diet/knapsack.d.ts +0 -8
  39. package/dist/diet/knapsack.js +0 -128
  40. package/dist/index.d.ts +0 -29
  41. package/dist/index.js +0 -26
  42. package/dist/lib.d.ts +0 -497
  43. package/dist/lib.js +0 -958
  44. package/dist/logger.d.ts +0 -35
  45. package/dist/logger.js +0 -62
  46. package/dist/maximize.d.ts +0 -121
  47. package/dist/maximize.js +0 -525
  48. package/dist/modifier.d.ts +0 -41
  49. package/dist/modifier.js +0 -160
  50. package/dist/modifierTypes.d.ts +0 -16
  51. package/dist/modifierTypes.js +0 -9
  52. package/dist/mood.d.ts +0 -105
  53. package/dist/mood.js +0 -349
  54. package/dist/moonSign.d.ts +0 -13
  55. package/dist/moonSign.js +0 -25
  56. package/dist/overlappingNames.d.ts +0 -3
  57. package/dist/overlappingNames.js +0 -42
  58. package/dist/property.d.ts +0 -222
  59. package/dist/property.js +0 -385
  60. package/dist/propertyTypes.d.ts +0 -19
  61. package/dist/propertyTypes.js +0 -10
  62. package/dist/propertyTyping.d.ts +0 -65
  63. package/dist/propertyTyping.js +0 -91
  64. package/dist/resources/2007/CandyHearts.d.ts +0 -9
  65. package/dist/resources/2007/CandyHearts.js +0 -24
  66. package/dist/resources/2008/DivineFavors.d.ts +0 -9
  67. package/dist/resources/2008/DivineFavors.js +0 -27
  68. package/dist/resources/2008/Stickers.d.ts +0 -49
  69. package/dist/resources/2008/Stickers.js +0 -84
  70. package/dist/resources/2009/Bandersnatch.d.ts +0 -56
  71. package/dist/resources/2009/Bandersnatch.js +0 -93
  72. package/dist/resources/2009/LoveSongs.d.ts +0 -9
  73. package/dist/resources/2009/LoveSongs.js +0 -24
  74. package/dist/resources/2009/SpookyPutty.d.ts +0 -31
  75. package/dist/resources/2009/SpookyPutty.js +0 -49
  76. package/dist/resources/2010/Brickos.d.ts +0 -9
  77. package/dist/resources/2010/Brickos.js +0 -21
  78. package/dist/resources/2010/CrownOfThrones.d.ts +0 -68
  79. package/dist/resources/2010/CrownOfThrones.js +0 -418
  80. package/dist/resources/2010/LookingGlass.d.ts +0 -29
  81. package/dist/resources/2010/LookingGlass.js +0 -89
  82. package/dist/resources/2011/Gygaxian.d.ts +0 -9
  83. package/dist/resources/2011/Gygaxian.js +0 -24
  84. package/dist/resources/2011/ObtuseAngel.d.ts +0 -33
  85. package/dist/resources/2011/ObtuseAngel.js +0 -51
  86. package/dist/resources/2011/StompingBoots.d.ts +0 -37
  87. package/dist/resources/2011/StompingBoots.js +0 -57
  88. package/dist/resources/2012/RainDoh.d.ts +0 -25
  89. package/dist/resources/2012/RainDoh.js +0 -37
  90. package/dist/resources/2012/ReagnimatedGnome.d.ts +0 -31
  91. package/dist/resources/2012/ReagnimatedGnome.js +0 -46
  92. package/dist/resources/2012/Resolutions.d.ts +0 -9
  93. package/dist/resources/2012/Resolutions.js +0 -28
  94. package/dist/resources/2013/Florist.d.ts +0 -81
  95. package/dist/resources/2013/Florist.js +0 -245
  96. package/dist/resources/2013/JungMan.d.ts +0 -33
  97. package/dist/resources/2013/JungMan.js +0 -69
  98. package/dist/resources/2013/PulledTaffy.d.ts +0 -9
  99. package/dist/resources/2013/PulledTaffy.js +0 -33
  100. package/dist/resources/2014/CrimboShrub.d.ts +0 -42
  101. package/dist/resources/2014/CrimboShrub.js +0 -89
  102. package/dist/resources/2014/DNALab.d.ts +0 -56
  103. package/dist/resources/2014/DNALab.js +0 -162
  104. package/dist/resources/2014/WinterGarden.d.ts +0 -23
  105. package/dist/resources/2014/WinterGarden.js +0 -35
  106. package/dist/resources/2015/BarrelShrine.d.ts +0 -8
  107. package/dist/resources/2015/BarrelShrine.js +0 -25
  108. package/dist/resources/2015/ChateauMantegna.d.ts +0 -52
  109. package/dist/resources/2015/ChateauMantegna.js +0 -99
  110. package/dist/resources/2015/DeckOfEveryCard.d.ts +0 -29
  111. package/dist/resources/2015/DeckOfEveryCard.js +0 -122
  112. package/dist/resources/2015/Dinseylandfill.d.ts +0 -89
  113. package/dist/resources/2015/Dinseylandfill.js +0 -205
  114. package/dist/resources/2015/MayoClinic.d.ts +0 -23
  115. package/dist/resources/2015/MayoClinic.js +0 -49
  116. package/dist/resources/2016/GingerBread.d.ts +0 -32
  117. package/dist/resources/2016/GingerBread.js +0 -73
  118. package/dist/resources/2016/SourceTerminal.d.ts +0 -181
  119. package/dist/resources/2016/SourceTerminal.js +0 -275
  120. package/dist/resources/2016/Witchess.d.ts +0 -17
  121. package/dist/resources/2016/Witchess.js +0 -47
  122. package/dist/resources/2017/AsdonMartin.d.ts +0 -59
  123. package/dist/resources/2017/AsdonMartin.js +0 -238
  124. package/dist/resources/2017/Horsery.d.ts +0 -19
  125. package/dist/resources/2017/Horsery.js +0 -42
  126. package/dist/resources/2017/MummingTrunk.d.ts +0 -8
  127. package/dist/resources/2017/MummingTrunk.js +0 -33
  128. package/dist/resources/2017/Pantogram.d.ts +0 -92
  129. package/dist/resources/2017/Pantogram.js +0 -174
  130. package/dist/resources/2017/Robortender.d.ts +0 -30
  131. package/dist/resources/2017/Robortender.js +0 -90
  132. package/dist/resources/2017/Spacegate.d.ts +0 -86
  133. package/dist/resources/2017/Spacegate.js +0 -178
  134. package/dist/resources/2017/TunnelOfLove.d.ts +0 -39
  135. package/dist/resources/2017/TunnelOfLove.js +0 -120
  136. package/dist/resources/2018/LatteLoversMembersMug.d.ts +0 -392
  137. package/dist/resources/2018/LatteLoversMembersMug.js +0 -303
  138. package/dist/resources/2018/SongBoom.d.ts +0 -33
  139. package/dist/resources/2018/SongBoom.js +0 -55
  140. package/dist/resources/2019/BeachComb.d.ts +0 -72
  141. package/dist/resources/2019/BeachComb.js +0 -118
  142. package/dist/resources/2019/CampAway.d.ts +0 -39
  143. package/dist/resources/2019/CampAway.js +0 -72
  144. package/dist/resources/2019/Snapper.d.ts +0 -33
  145. package/dist/resources/2019/Snapper.js +0 -73
  146. package/dist/resources/2020/Cartography.d.ts +0 -16
  147. package/dist/resources/2020/Cartography.js +0 -48
  148. package/dist/resources/2020/Guzzlr.d.ts +0 -160
  149. package/dist/resources/2020/Guzzlr.js +0 -275
  150. package/dist/resources/2020/RetroCape.d.ts +0 -51
  151. package/dist/resources/2020/RetroCape.js +0 -115
  152. package/dist/resources/2021/CrystalBall.d.ts +0 -14
  153. package/dist/resources/2021/CrystalBall.js +0 -39
  154. package/dist/resources/2021/DaylightShavings.d.ts +0 -40
  155. package/dist/resources/2021/DaylightShavings.js +0 -74
  156. package/dist/resources/2022/AutumnAton.d.ts +0 -78
  157. package/dist/resources/2022/AutumnAton.js +0 -182
  158. package/dist/resources/2022/CombatLoversLocket.d.ts +0 -44
  159. package/dist/resources/2022/CombatLoversLocket.js +0 -82
  160. package/dist/resources/2022/GreyGoose.d.ts +0 -59
  161. package/dist/resources/2022/GreyGoose.js +0 -90
  162. package/dist/resources/2022/JuneCleaver.d.ts +0 -47
  163. package/dist/resources/2022/JuneCleaver.js +0 -69
  164. package/dist/resources/2022/TrainSet.d.ts +0 -146
  165. package/dist/resources/2022/TrainSet.js +0 -228
  166. package/dist/resources/2023/AugustScepter.d.ts +0 -25
  167. package/dist/resources/2023/AugustScepter.js +0 -40
  168. package/dist/resources/2023/BurningLeaves.d.ts +0 -25
  169. package/dist/resources/2023/BurningLeaves.js +0 -74
  170. package/dist/resources/2023/CinchoDeMayo.d.ts +0 -25
  171. package/dist/resources/2023/CinchoDeMayo.js +0 -45
  172. package/dist/resources/2023/ClosedCircuitPayphone.d.ts +0 -80
  173. package/dist/resources/2023/ClosedCircuitPayphone.js +0 -129
  174. package/dist/resources/2023/CursedMonkeyPaw.d.ts +0 -46
  175. package/dist/resources/2023/CursedMonkeyPaw.js +0 -113
  176. package/dist/resources/2024/AprilingBandHelmet.d.ts +0 -57
  177. package/dist/resources/2024/AprilingBandHelmet.js +0 -118
  178. package/dist/resources/2024/ChestMimic.d.ts +0 -35
  179. package/dist/resources/2024/ChestMimic.js +0 -108
  180. package/dist/resources/LibramSummon.d.ts +0 -18
  181. package/dist/resources/LibramSummon.js +0 -74
  182. package/dist/resources/index.d.ts +0 -54
  183. package/dist/resources/index.js +0 -54
  184. package/dist/resources/putty-likes.d.ts +0 -21
  185. package/dist/resources/putty-likes.js +0 -33
  186. package/dist/session.d.ts +0 -169
  187. package/dist/session.js +0 -284
  188. package/dist/since.d.ts +0 -51
  189. package/dist/since.js +0 -108
  190. package/dist/template-string.d.ts +0 -324
  191. package/dist/template-string.js +0 -265
  192. package/dist/url.d.ts +0 -35
  193. package/dist/url.js +0 -67
  194. package/dist/utils.d.ts +0 -178
  195. package/dist/utils.js +0 -255
package/dist/session.js DELETED
@@ -1,284 +0,0 @@
1
- import { todayToString, myName, bufferToFile, fileToBuffer, mySessionItems, mySessionMeat, toItem, getCampground, getCloset, getDisplay, getStorage, myClosetMeat, myStorageMeat, totalTurnsPlayed, } from "kolmafia";
2
- import { getFoldGroup } from "./lib";
3
- import { $item, $items } from "./template-string";
4
- import { sum } from "./utils";
5
- /**
6
- * Return a mapping of the session items, mapping foldable items to a single of their forms
7
- *
8
- * @param sessionOnly should closet, DC, and storage be ignored for the session calculation
9
- * @returns the item session results, with foldables mapped to a single of their folding forms
10
- */
11
- function mySessionItemsWrapper(sessionOnly = false) {
12
- const manyToOne = (primary, mapped) => mapped.map((target) => [target, primary]);
13
- const foldable = (item) => manyToOne(item, getFoldGroup(item));
14
- const itemMappings = new Map([
15
- ...foldable($item `liar's pants`),
16
- ...foldable($item `ice pick`),
17
- ...manyToOne($item `Spooky Putty sheet`, [
18
- $item `Spooky Putty monster`,
19
- ...getFoldGroup($item `Spooky Putty sheet`),
20
- ]),
21
- ...foldable($item `stinky cheese sword`),
22
- ...foldable($item `naughty paper shuriken`),
23
- ...foldable($item `Loathing Legion knife`),
24
- ...foldable($item `deceased crimbo tree`),
25
- ...foldable($item `makeshift turban`),
26
- ...foldable($item `turtle wax shield`),
27
- ...foldable($item `metallic foil bow`),
28
- ...foldable($item `ironic moustache`),
29
- ...foldable($item `bugged balaclava`),
30
- ...foldable($item `toggle switch (Bartend)`),
31
- ...foldable($item `mushroom cap`),
32
- ...manyToOne($item `can of Rain-Doh`, $items `empty Rain-Doh can`),
33
- ...manyToOne($item `meteorite fragment`, $items `meteorite earring, meteorite necklace, meteorite ring`),
34
- ...manyToOne($item `Sneaky Pete's leather jacket`, $items `Sneaky Pete's leather jacket (collar popped)`),
35
- ...manyToOne($item `Boris's Helm`, $items `Boris's Helm (askew)`),
36
- ...manyToOne($item `Jarlsberg's pan`, $items `Jarlsberg's pan (Cosmic portal mode)`),
37
- ...manyToOne($item `tiny plastic sword`, $items `grogtini, bodyslam, dirty martini, vesper, cherry bomb, sangria del diablo`),
38
- ...manyToOne($item `earthenware muffin tin`, $items `blueberry muffin, bran muffin, chocolate chip muffin`),
39
- ...manyToOne($item `ChibiBuddy™ (on)`, $items `ChibiBuddy™ (off)`),
40
- ]);
41
- const inventory = new Map();
42
- const invLocations = sessionOnly
43
- ? [mySessionItems]
44
- : [mySessionItems, getCloset, getDisplay, getStorage];
45
- if (!sessionOnly) {
46
- for (const [itemStr, quantity] of Object.entries(getCampground())) {
47
- if (!quantity)
48
- continue;
49
- const item = toItem(itemStr);
50
- if (item === $item `big rock`)
51
- continue; // Used to represent an empty house slot
52
- const mappedItem = itemMappings.get(item) ?? item;
53
- inventory.set(mappedItem, quantity + (inventory.get(mappedItem) ?? 0));
54
- }
55
- }
56
- for (const inventoryFunc of invLocations) {
57
- for (const [itemStr, quantity] of Object.entries(inventoryFunc())) {
58
- if (!quantity)
59
- continue;
60
- const item = toItem(itemStr);
61
- const mappedItem = itemMappings.get(item) ?? item;
62
- inventory.set(mappedItem, quantity + (inventory.get(mappedItem) ?? 0));
63
- if (inventory.get(mappedItem) === 0)
64
- inventory.delete(mappedItem);
65
- }
66
- }
67
- return inventory;
68
- }
69
- /**
70
- * Perform a binary element-wise operation on two inventories
71
- *
72
- * @param a The LHS inventory to perform the operation on
73
- * @param b The RHS inventory to perform the operation on
74
- * @param op an operator to compute between the sets
75
- * @returns a new map representing the combined inventories
76
- */
77
- function inventoryOperation(a, b, op) {
78
- // return every entry that is in a and not in b
79
- const difference = new Map();
80
- for (const item of new Set([...a.keys(), ...b.keys()])) {
81
- difference.set(item, op(a.get(item) ?? 0, b.get(item) ?? 0));
82
- }
83
- const diffEntries = [...difference.entries()];
84
- return new Map(diffEntries.filter(([, value]) => value !== 0));
85
- }
86
- /**
87
- * A wrapper around tracking items and meat gained from this session
88
- * Smartly handles foldables being added/removed based on their state
89
- * Provides operations to add sessions and subtract Sessions so you can isolate the value of each Session using a baseline
90
- *
91
- * @member meat the raw meat associated with this Session
92
- * @member items a map representing the items gained/lost during this Session
93
- */
94
- export class Session {
95
- meat;
96
- items;
97
- totalTurns;
98
- /**
99
- * Construct a new session
100
- *
101
- * @param meat the amount of meat associated with this session
102
- * @param items the items associated with this session
103
- * @param totalTurns the number of turns associated with this session
104
- */
105
- constructor(meat, items, totalTurns) {
106
- this.meat = meat;
107
- this.items = items;
108
- this.totalTurns = totalTurns;
109
- }
110
- /**
111
- * Register session results that do not get tracked natively
112
- *
113
- * @param target either the Item or a string saying "meat" of what quantity to modify
114
- * @param quantity How much to modify the tracked amount by
115
- */
116
- register(target, quantity) {
117
- if (target === "meat") {
118
- this.meat += quantity;
119
- }
120
- else {
121
- this.items.set(target, (this.items.get(target) ?? 0) + quantity);
122
- }
123
- }
124
- /**
125
- * Value this session
126
- *
127
- * @param itemValue a function that, when given an item, will give a meat value of the item
128
- * @returns ItemResult with the full value of this session given the input function
129
- */
130
- value(itemValue) {
131
- // TODO: add garbo specific pricing (sugar equipment for synth, etc.)
132
- const turns = this.totalTurns;
133
- const meat = Math.floor(this.meat);
134
- const itemDetails = [...this.items.entries()].map(([item, quantity]) => {
135
- return {
136
- item,
137
- quantity,
138
- // only run itemValue if quantity is nonzero
139
- value: quantity ? itemValue(item) * quantity : 0,
140
- };
141
- });
142
- const items = Math.floor(sum(itemDetails, "value"));
143
- return { meat, items, total: meat + items, itemDetails, turns };
144
- }
145
- /**
146
- * Subtract the contents of another session from this one, removing any items that have a resulting quantity of 0
147
- * (this will ignore elements in b but not in a)
148
- *
149
- * @param other the session from which to pull values to remove from this session
150
- * @returns a new session representing the difference between this session and the other session
151
- */
152
- diff(other) {
153
- return new Session(this.meat - other.meat, inventoryOperation(this.items, other.items, (a, b) => a - b), this.totalTurns - other.totalTurns);
154
- }
155
- /**
156
- * Subtract the contents of snasphot b from session a, removing any items that have a resulting quantity of 0
157
- * (this will ignore elements in b but not in a)
158
- *
159
- * @param a the session from which to subtract elements
160
- * @param b the session from which to add elements
161
- * @returns a new session representing the difference between a and b
162
- */
163
- static diff(a, b) {
164
- return a.diff(b);
165
- }
166
- /**
167
- * Generate a new session combining multiple sessions together
168
- *
169
- * @param other the session from which to add elements to this set
170
- * @returns a new session representing the addition of other to this
171
- */
172
- add(other) {
173
- return new Session(this.meat + other.meat, inventoryOperation(this.items, other.items, (a, b) => a + b), this.totalTurns + other.totalTurns);
174
- }
175
- /**
176
- * Combine the contents of sessions
177
- *
178
- * @param sessions the set of sessions to combine together
179
- * @returns a new session representing the difference between a and b
180
- */
181
- static add(...sessions) {
182
- return sessions.reduce((previousSession, currentSession) => previousSession.add(currentSession));
183
- }
184
- static getFilepath(filename) {
185
- return filename.endsWith(".json")
186
- ? filename
187
- : `snapshots/${myName()}/${todayToString()}_${filename}.json`;
188
- }
189
- /**
190
- * Export this session to a file in the data/ directory. Conventionally this file should end in ".json"
191
- *
192
- * @param filename The file into which to export
193
- */
194
- toFile(filename) {
195
- const val = {
196
- meat: this.meat,
197
- items: Object.fromEntries(this.items),
198
- totalTurns: this.totalTurns,
199
- };
200
- bufferToFile(JSON.stringify(val), Session.getFilepath(filename));
201
- }
202
- /**
203
- * Import a session from a file in the data/ directory. Conventionally the file should end in ".json"
204
- *
205
- * @param filename The file from which to import
206
- * @returns the session represented by the file
207
- */
208
- static fromFile(filename) {
209
- const fileValue = fileToBuffer(Session.getFilepath(filename));
210
- // fileToBuffer returns empty string for files that don't exist
211
- if (fileValue.length > 0) {
212
- const val = JSON.parse(fileValue);
213
- const parsedItems = Object.entries(val.items).map(([itemStr, quantity]) => [toItem(itemStr), quantity]);
214
- return new Session(val.meat, new Map(parsedItems), val.totalTurns ?? 0);
215
- }
216
- else {
217
- // if the file does not exist, return an empty session
218
- return new Session(0, new Map(), 0);
219
- }
220
- }
221
- /**
222
- * Return the meat and items for the current session
223
- *
224
- * @param sessionOnly should closet, DC, and storage be ignored for the session calculation
225
- * @returns current session
226
- */
227
- static current(sessionOnly = false) {
228
- const meat = sessionOnly
229
- ? [mySessionMeat]
230
- : [mySessionMeat, myClosetMeat, myStorageMeat];
231
- return new Session(sum(meat, (f) => f()), mySessionItemsWrapper(sessionOnly), totalTurnsPlayed());
232
- }
233
- /**
234
- * @param baseline the base session to use when computing MPA
235
- * @param full the full session to use when computing MPA
236
- * @param options options for computing MPA
237
- * @param options.value a function to compute the meat value of a given item
238
- * @param options.isOutlier a function to compute if an item is considered an outlier. By default, no items are outliers
239
- * @param options.excludeValue meat values to exclude when calculating specific portions of the MPA
240
- * @param options.excludeValue.meat how much meat to exclude when calculating the meat portion of MPA
241
- * @param options.excludeValue.item how much meat to exclude when calculating hte item portion of MPA
242
- * @returns an analysis of the effective MPA for the given session
243
- */
244
- static computeMPA(baseline, full, options) {
245
- const value = options.value;
246
- const excludeValue = options.excludeValue ?? { meat: 0, item: 0 };
247
- const isOutlier = options.isOutlier;
248
- const result = full.diff(baseline).value(value);
249
- const meatValue = result.meat - (excludeValue.meat ?? 0);
250
- const outlierItems = isOutlier ? result.itemDetails.filter(isOutlier) : [];
251
- const outliersValue = sum(outlierItems, (detail) => detail.value);
252
- const itemValue = result.items - outliersValue - (excludeValue.item ?? 0);
253
- const { turns } = result;
254
- return {
255
- mpa: {
256
- effective: (meatValue + itemValue) / turns,
257
- total: (meatValue + itemValue + outliersValue) / turns,
258
- meat: meatValue / turns,
259
- items: itemValue / turns,
260
- },
261
- values: {
262
- effective: meatValue + itemValue,
263
- total: meatValue + itemValue + outliersValue,
264
- meat: meatValue,
265
- items: itemValue,
266
- },
267
- outlierItems: outlierItems,
268
- turns: turns,
269
- };
270
- }
271
- /**
272
- * @param other the session to diff against this session when computing MPA
273
- * @param options options for computing MPA
274
- * @param options.value a function to compute the meat value of a given item
275
- * @param options.isOutlier a function to compute if an item is considered an outlier. By default, no items are outliers
276
- * @param options.excludeValue meat values to exclude when calculating specific portions of the MPA
277
- * @param options.excludeValue.meat how much meat to exclude when calculating the meat portion of MPA
278
- * @param options.excludeValue.item how much meat to exclude when calculating hte item portion of MPA
279
- * @returns an analysis of the effective MPA for the given session
280
- */
281
- computeMPA(other, options) {
282
- return Session.computeMPA(this, other, options);
283
- }
284
- }
package/dist/since.d.ts DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * Provides functions for checking KoLmafia's version and revision.
3
- *
4
- * @packageDocumentation
5
- */
6
- /**
7
- * Represents an exception thrown when the current KoLmafia version does not
8
- * match an expected condition.
9
- */
10
- export declare class KolmafiaVersionError extends Error {
11
- constructor(message?: string);
12
- }
13
- /**
14
- * If KoLmafia's revision number is less than `revision`, throws an exception.
15
- * Otherwise, does nothing.
16
- *
17
- * This behaves like the `since rXXX;` statement in ASH.
18
- *
19
- * @param revision Revision number
20
- * @throws {KolmafiaVersionError}
21
- * If KoLmafia's revision number is less than `revision`.
22
- * @throws {TypeError} If `revision` is not an integer
23
- * @example
24
- * ```ts
25
- * // Throws if KoLmafia revision is less than r20500
26
- * sinceKolmafiaRevision(20500);
27
- * ```
28
- */
29
- export declare function sinceKolmafiaRevision(revision: number): void;
30
- /**
31
- * If KoLmafia's version is less than `majorVersion.minorVersion`, throws an
32
- * exception.
33
- * Otherwise, does nothing.
34
- *
35
- * This behaves like the `since X.Y;` statement in ASH.
36
- *
37
- * @param majorVersion Major version number
38
- * @param minorVersion Minor version number
39
- * @deprecated Point versions are no longer released by KoLmafia
40
- * @throws {KolmafiaVersionError}
41
- * If KoLmafia's major version is less than `majorVersion`, or if the major
42
- * versions are equal but the minor version is less than `minorVersion`
43
- * @throws {TypeError}
44
- * If either `majorVersion` or `minorVersion` are not integers
45
- * @example
46
- * ```ts
47
- * // Throws if KoLmafia version is less than 20.7
48
- * sinceKolmafiaVersion(20, 7);
49
- * ```
50
- */
51
- export declare function sinceKolmafiaVersion(majorVersion: number, minorVersion: number): void;
package/dist/since.js DELETED
@@ -1,108 +0,0 @@
1
- /**
2
- * Provides functions for checking KoLmafia's version and revision.
3
- *
4
- * @packageDocumentation
5
- */
6
- import { getRevision, getVersion } from "kolmafia";
7
- /**
8
- * Represents an exception thrown when the current KoLmafia version does not
9
- * match an expected condition.
10
- */
11
- export class KolmafiaVersionError extends Error {
12
- constructor(message) {
13
- super(message);
14
- // Explicitly set the prototype, so that 'instanceof' still works in Node.js
15
- // even when the class is transpiled down to ES5
16
- // See: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
17
- // Note that this code isn't needed for Rhino.
18
- Object.setPrototypeOf(this, KolmafiaVersionError.prototype);
19
- }
20
- }
21
- // Manually set class name, so that the stack trace shows proper name in Rhino
22
- KolmafiaVersionError.prototype.name = "KolmafiaVersionError";
23
- /**
24
- * Returns the currently executing script name, suitable for embedding in an
25
- * error message.
26
- *
27
- * @returns Path of the main script wrapped in single-quotes, or `"This script"`
28
- * if the path cannot be determined
29
- */
30
- function getScriptName() {
31
- // In Rhino, the current script name is available in require.main.id
32
- const scriptName = require.main?.id;
33
- return scriptName ? `'${scriptName}'` : "This script";
34
- }
35
- /**
36
- * If KoLmafia's revision number is less than `revision`, throws an exception.
37
- * Otherwise, does nothing.
38
- *
39
- * This behaves like the `since rXXX;` statement in ASH.
40
- *
41
- * @param revision Revision number
42
- * @throws {KolmafiaVersionError}
43
- * If KoLmafia's revision number is less than `revision`.
44
- * @throws {TypeError} If `revision` is not an integer
45
- * @example
46
- * ```ts
47
- * // Throws if KoLmafia revision is less than r20500
48
- * sinceKolmafiaRevision(20500);
49
- * ```
50
- */
51
- export function sinceKolmafiaRevision(revision) {
52
- if (!Number.isInteger(revision)) {
53
- throw new TypeError(`Invalid revision number ${revision} (must be an integer)`);
54
- }
55
- // Based on net.sourceforge.kolmafia.textui.Parser.sinceException()
56
- const currentRevision = getRevision();
57
- if (currentRevision > 0 && currentRevision < revision) {
58
- throw new KolmafiaVersionError(`${getScriptName()} requires revision r${revision} of kolmafia or higher (current: ${getRevision()}). Up-to-date builds can be found at https://ci.kolmafia.us/.`);
59
- }
60
- }
61
- /**
62
- * If KoLmafia's version is less than `majorVersion.minorVersion`, throws an
63
- * exception.
64
- * Otherwise, does nothing.
65
- *
66
- * This behaves like the `since X.Y;` statement in ASH.
67
- *
68
- * @param majorVersion Major version number
69
- * @param minorVersion Minor version number
70
- * @deprecated Point versions are no longer released by KoLmafia
71
- * @throws {KolmafiaVersionError}
72
- * If KoLmafia's major version is less than `majorVersion`, or if the major
73
- * versions are equal but the minor version is less than `minorVersion`
74
- * @throws {TypeError}
75
- * If either `majorVersion` or `minorVersion` are not integers
76
- * @example
77
- * ```ts
78
- * // Throws if KoLmafia version is less than 20.7
79
- * sinceKolmafiaVersion(20, 7);
80
- * ```
81
- */
82
- export function sinceKolmafiaVersion(majorVersion, minorVersion) {
83
- if (getRevision() >= 25720) {
84
- return;
85
- }
86
- if (!Number.isInteger(majorVersion)) {
87
- throw new TypeError(`Invalid major version number ${majorVersion} (must be an integer)`);
88
- }
89
- if (!Number.isInteger(minorVersion)) {
90
- throw new TypeError(`Invalid minor version number ${minorVersion} (must be an integer)`);
91
- }
92
- if (majorVersion > 21 || (majorVersion === 20 && minorVersion > 9)) {
93
- throw new Error(`There were no versions released after 21.09. This command will always fail`);
94
- }
95
- const versionStr = getVersion();
96
- const versionStrMatch = /v(\d+)\.(\d+)/.exec(versionStr);
97
- if (!versionStrMatch) {
98
- // This is not something the user should handle
99
- throw new Error(`Unexpected KoLmafia version string: "${versionStr}". You may need to update the script.`);
100
- }
101
- const currentMajorVersion = Number(versionStrMatch[1]);
102
- const currentMinorVersion = Number(versionStrMatch[2]);
103
- // Based on net.sourceforge.kolmafia.textui.Parser.sinceException()
104
- if (currentMajorVersion < majorVersion ||
105
- (currentMajorVersion === majorVersion && currentMinorVersion < minorVersion)) {
106
- throw new KolmafiaVersionError(`${getScriptName()} requires version ${majorVersion}.${minorVersion} of kolmafia or higher (current: ${currentMajorVersion}.${currentMinorVersion}). Up-to-date builds can be found at https://ci.kolmafia.us/.`);
107
- }
108
- }