libram 0.7.18 → 0.8.0

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.
@@ -1,24 +1,25 @@
1
- import { Familiar } from "kolmafia";
2
- import { Modifiers } from "../../modifier";
1
+ import { Familiar, Item } from "kolmafia";
2
+ import { NumericModifier } from "../../modifierTypes";
3
3
  export declare type FamiliarRider = {
4
4
  familiar: Familiar;
5
- meatVal: () => number;
5
+ drops: number | Item[] | Map<Item, number>;
6
6
  probability: number;
7
- modifier: Modifiers;
8
7
  dropPredicate?: () => boolean;
9
8
  };
10
- export declare const ridingFamiliars: FamiliarRider[];
9
+ export declare const ridingFamiliars: readonly FamiliarRider[];
11
10
  /**
12
11
  * Value a specified familiar Crown rider
13
12
  *
14
13
  * @param rider Familiar to value
15
- * @param modifierValueFunction Value of the extra modifiers the familiar provides
14
+ * @param modifierValueFunction Value of the extra modifiers the familiar provides,
15
+ * @param dropsValueFunction Value to assign the drops of the familiar gives
16
16
  * @param ignoreLimitedDrops Whether to ignore drops that are daily or otherwise limited
17
17
  * @returns Rider value (in meat)
18
18
  */
19
- export declare function valueRider(rider: FamiliarRider, modifierValueFunction: (modifiers: Modifiers) => number, ignoreLimitedDrops?: boolean): number;
19
+ export declare function valueRider(rider: FamiliarRider, modifierValueFunction: (familiar: Familiar) => number, dropsValueFunction: (drops: Item[] | Map<Item, number>) => number, ignoreLimitedDrops?: boolean): number;
20
20
  declare type RiderMode = {
21
- modifierValueFunction: (modifiers: Modifiers) => number;
21
+ modifierValueFunction: (familiar: Familiar) => number;
22
+ dropsValueFunction: (drops: Item[] | Map<Item, number>) => number;
22
23
  ignoreLimitedDrops: boolean;
23
24
  excludeCurrentFamiliar: boolean;
24
25
  };
@@ -26,12 +27,19 @@ declare type RiderMode = {
26
27
  * Creates a rider mode for this session
27
28
  *
28
29
  * @param name Rider mode name
29
- * @param modifierValueFunction Function to value modifiers of a rider
30
- * @param ignoreLimitedDrops Whether to ignore daily or otherwise limited drops
31
- * @param excludeCurrentFamiliar Whether to exclude the player's current familiar
30
+ * @param details An object consisting of various settings for the RiderMode:
31
+ * @param details.modifierValueFunction Function to value a familiar itself, often using modifiers,
32
+ * @param details.dropsValueFunction Function to value the drops of a familiar, which are stored as an `Item[]` or `Map<Item, number>`
33
+ * @param details.ignoreLimitedDrops Whether to ignore daily or otherwise limited drops
34
+ * @param details.excludeCurrentFamiliar Whether to exclude the player's current familiar
32
35
  * @returns Map of all rider modes created this session, including the one that was just made
33
36
  */
34
- export declare function createRiderMode(name: string, modifierValueFunction: (modifiers: Modifiers) => number, ignoreLimitedDrops?: boolean, excludeCurrentFamiliar?: boolean): Map<string, RiderMode>;
37
+ export declare function createRiderMode(name: string, details: Partial<RiderMode>): Map<string, RiderMode>;
38
+ /**
39
+ * @param name The name of the `RiderMode` to check
40
+ * @returns Whether or not said `RiderMode` exists
41
+ */
42
+ export declare function hasRiderMode(name: string): boolean;
35
43
  /**
36
44
  * Pick a rider
37
45
  *
@@ -39,4 +47,22 @@ export declare function createRiderMode(name: string, modifierValueFunction: (mo
39
47
  * @returns Picked faimiliar rider or null if no rider could be selected
40
48
  */
41
49
  export declare function pickRider(mode: string): FamiliarRider | null;
50
+ /**
51
+ * Find the associated NumericModifier for a given familiar when enthroned or bjornified
52
+ *
53
+ * @param modifier The NumericModifier in question
54
+ * @param familiar The Familiar in question
55
+ * @returns The value of the given numeric modifier for the Crown of Thrones (or buddy bjorn) when the given familiar is encromulated
56
+ */
57
+ export declare function getModifier(modifier: NumericModifier, familiar: Familiar): number;
58
+ /**
59
+ * Create a `modifierValueFunction` for a familiar.
60
+ *
61
+ * @param modifiers An array consisting of the `NumericModifier`s relevant to your valuation
62
+ * @param functions An object keyed by `NumericModifier`s whose values are functions that map the the result of a modifier to its corresponding valuation
63
+ * @returns A function that maps a familiar to the value of its modifiers in the crown of thrones or buddy bjorn.
64
+ */
65
+ export declare function createModifierValueFunction<T extends NumericModifier>(modifiers: T[], functions: {
66
+ [x in T]: (mod: number) => number;
67
+ }): (familiar: Familiar) => number;
42
68
  export {};
@@ -1,542 +1,370 @@
1
- import { Item, myFamiliar } from "kolmafia";
1
+ import { myFamiliar, numericModifier } from "kolmafia";
2
2
  import { getSaleValue, have } from "../../lib";
3
3
  import { get } from "../../property";
4
4
  import { $familiar, $item, $items } from "../../template-string";
5
+ import { sum } from "../../utils";
5
6
  export const ridingFamiliars = [
6
7
  {
7
8
  familiar: $familiar `Puck Man`,
8
- meatVal: () => getSaleValue($item `yellow pixel`),
9
+ drops: $items `yellow pixel`,
9
10
  probability: 0.25,
10
- modifier: {
11
- ["Muscle"]: 10,
12
- ["Mysticality"]: 10,
13
- ["Moxie"]: 10,
14
- },
15
11
  dropPredicate: () => get("_yellowPixelDropsCrown") < 25,
16
12
  },
17
13
  {
18
14
  familiar: $familiar `Ms. Puck Man`,
19
- meatVal: () => getSaleValue($item `yellow pixel`),
15
+ drops: $items `yellow pixel`,
20
16
  probability: 0.25,
21
- modifier: {
22
- ["Muscle"]: 10,
23
- ["Mysticality"]: 10,
24
- ["Moxie"]: 10,
25
- },
26
17
  dropPredicate: () => get("_yellowPixelDropsCrown") < 25,
27
18
  },
28
19
  {
29
20
  familiar: $familiar `Grimstone Golem`,
30
- meatVal: () => getSaleValue($item `grimstone mask`),
21
+ drops: $items `grimstone mask`,
31
22
  probability: 0.5,
32
- modifier: {
33
- ["Combat Rate"]: -5,
34
- },
35
23
  dropPredicate: () => get("_grimstoneMaskDropsCrown") < 1,
36
24
  },
37
25
  {
38
26
  familiar: $familiar `Knob Goblin Organ Grinder`,
39
- meatVal: () => 30,
27
+ drops: 30,
40
28
  probability: 1,
41
- modifier: {
42
- ["Meat Drop"]: 25,
43
- },
44
29
  },
45
30
  {
46
31
  familiar: $familiar `Happy Medium`,
47
- meatVal: () => 30,
32
+ drops: 30,
48
33
  probability: 1,
49
- modifier: {
50
- ["Meat Drop"]: 25,
51
- },
52
34
  },
53
35
  {
54
36
  familiar: $familiar `Garbage Fire`,
55
- meatVal: () => getSaleValue($item `burning newspaper`),
37
+ drops: $items `burning newspaper`,
56
38
  probability: 0.5,
57
- modifier: {
58
- ["Hot Spell Damage"]: 25,
59
- },
60
39
  dropPredicate: () => get("_garbageFireDropsCrown") < 3,
61
40
  },
62
41
  {
63
42
  familiar: $familiar `Machine Elf`,
64
- meatVal: () => getSaleValue(...$items `abstraction: sensation, abstraction: thought, abstraction: action, abstraction: category, abstraction: perception, abstraction: purpose`),
43
+ drops: $items `abstraction: sensation, abstraction: thought, abstraction: action, abstraction: category, abstraction: perception, abstraction: purpose`,
65
44
  probability: 0.2,
66
- modifier: {
67
- ["Muscle"]: 7,
68
- ["Mysticality"]: 7,
69
- ["Moxie"]: 7,
70
- },
71
45
  dropPredicate: () => get("_abstractionDropsCrown") < 25,
72
46
  },
73
47
  {
74
48
  familiar: $familiar `Trick-or-Treating Tot`,
75
- meatVal: () => getSaleValue($item `hoarded candy wad`),
49
+ drops: $items `hoarded candy wad`,
76
50
  probability: 0.5,
77
- modifier: {
78
- ["Muscle"]: 10,
79
- ["Mysticality"]: 10,
80
- ["Moxie"]: 10,
81
- },
82
51
  dropPredicate: () => get("_hoardedCandyDropsCrown") < 3,
83
52
  },
84
53
  {
85
54
  familiar: $familiar `Warbear Drone`,
86
- meatVal: () => getSaleValue($item `warbear whosit`),
55
+ drops: $items `warbear whosit`,
87
56
  probability: 1 / 4.5,
88
- modifier: {
89
- ["Maximum HP"]: 15,
90
- ["Maximum MP"]: 15,
91
- },
92
57
  },
93
58
  {
94
59
  familiar: $familiar `Li'l Xenomorph`,
95
- meatVal: () => getSaleValue($item `lunar isotope`),
60
+ drops: $items `lunar isotope`,
96
61
  probability: 0.05,
97
- modifier: {
98
- ["Item Drop"]: 15,
99
- },
100
62
  },
101
63
  {
102
64
  familiar: $familiar `Pottery Barn Owl`,
103
- meatVal: () => getSaleValue($item `volcanic ash`),
65
+ drops: $items `volcanic ash`,
104
66
  probability: 0.1,
105
- modifier: { ["Hot Damage"]: 10 },
106
67
  },
107
68
  {
108
69
  familiar: $familiar `Grim Brother`,
109
- meatVal: () => getSaleValue($item `grim fairy tale`),
70
+ drops: $items `grim fairy tale`,
110
71
  probability: 1,
111
- modifier: { ["Combat Rate"]: 5 },
112
72
  dropPredicate: () => get("_grimFairyTaleDropsCrown") < 2,
113
73
  },
114
74
  {
115
75
  familiar: $familiar `Optimistic Candle`,
116
- meatVal: () => getSaleValue($item `glob of melted wax`),
76
+ drops: $items `glob of melted wax`,
117
77
  probability: 1,
118
78
  dropPredicate: () => get("_optimisticCandleDropsCrown") < 3,
119
- modifier: {
120
- ["Item Drop"]: 15,
121
- },
122
79
  },
123
80
  {
124
81
  familiar: $familiar `Adventurous Spelunker`,
125
- meatVal: () => getSaleValue(...$items `teflon ore, velcro ore, vinyl ore, cardboard ore, styrofoam ore, bubblewrap ore`),
82
+ drops: $items `teflon ore, velcro ore, vinyl ore, cardboard ore, styrofoam ore, bubblewrap ore`,
126
83
  probability: 1,
127
84
  dropPredicate: () => get("_oreDropsCrown") < 6,
128
- modifier: {
129
- ["Item Drop"]: 15,
130
- },
131
85
  },
132
86
  {
133
87
  familiar: $familiar `Twitching Space Critter`,
134
- meatVal: () => getSaleValue($item `space beast fur`),
88
+ drops: $items `space beast fur`,
135
89
  probability: 1,
136
- modifier: {
137
- ["Hot Resistance"]: 2,
138
- ["Cold Resistance"]: 2,
139
- ["Spooky Resistance"]: 2,
140
- ["Sleaze Resistance"]: 2,
141
- ["Stench Resistance"]: 2,
142
- },
143
90
  dropPredicate: () => get("_spaceFurDropsCrown") < 1,
144
91
  },
145
92
  {
146
93
  familiar: $familiar `Party Mouse`,
147
- meatVal: (slow = false) => {
148
- if (!slow)
149
- return 50;
150
- // Party mouse is virtually never going to be worthwhile and this causes so many useless mall hits it isn't funny.
151
- return getSaleValue(...Item.all().filter((booze) => ["decent", "good"].includes(booze.quality) &&
152
- booze.inebriety > 0 &&
153
- booze.tradeable &&
154
- booze.discardable &&
155
- !$items `glass of "milk", cup of "tea", thermos of "whiskey", Lucky Lindy, Bee's Knees, Sockdollager, Ish Kabibble, Hot Socks, Phonus Balonus, Flivver, Sloppy Jalopy`.includes(booze)));
156
- },
94
+ drops: 50,
157
95
  probability: 0.05,
158
- modifier: {
159
- ["Booze Drop"]: 25,
160
- },
161
96
  },
162
97
  {
163
98
  familiar: $familiar `Yule Hound`,
164
- meatVal: () => getSaleValue($item `candy cane`),
99
+ drops: $items `candy cane`,
165
100
  probability: 1,
166
- modifier: { ["Candy Drop"]: 20 },
167
101
  },
168
102
  {
169
103
  familiar: $familiar `Gluttonous Green Ghost`,
170
- meatVal: () => getSaleValue(...$items `bean burrito, enchanted bean burrito, jumping bean burrito`),
104
+ drops: $items `bean burrito, enchanted bean burrito, jumping bean burrito`,
171
105
  probability: 1,
172
- modifier: { ["Food Drop"]: 15 },
173
106
  },
174
107
  {
175
108
  familiar: $familiar `Reassembled Blackbird`,
176
- meatVal: () => getSaleValue($item `blackberry`),
109
+ drops: $items `blackberry`,
177
110
  probability: 1,
178
- modifier: {
179
- ["Item Drop"]: 10,
180
- },
181
111
  },
182
112
  {
183
113
  familiar: $familiar `Reconstituted Crow`,
184
- meatVal: () => getSaleValue($item `blackberry`),
114
+ drops: $items `blackberry`,
185
115
  probability: 1,
186
- modifier: {
187
- ["Item Drop"]: 10,
188
- },
189
116
  },
190
117
  {
191
118
  familiar: $familiar `Hunchbacked Minion`,
192
- meatVal: () => 0.02 * getSaleValue($item `disembodied brain`) +
193
- 0.98 * getSaleValue($item `skeleton bone`),
119
+ drops: new Map([
120
+ [$item `disembodied brain`, 0.02],
121
+ [$item `skeleton bone`, 0.98],
122
+ ]),
194
123
  probability: 1,
195
- modifier: { ["Muscle Experience"]: 2 },
196
124
  },
197
125
  {
198
126
  familiar: $familiar `Reanimated Reanimator`,
199
- meatVal: () => getSaleValue(...$items `hot wing, broken skull`),
127
+ drops: $items `hot wing, broken skull`,
200
128
  probability: 1,
201
- modifier: { ["Mysticality Experience"]: 2 },
202
129
  },
203
130
  {
204
131
  familiar: $familiar `Attention-Deficit Demon`,
205
- meatVal: () => getSaleValue(...$items `chorizo brownies, white chocolate and tomato pizza, carob chunk noodles`),
132
+ drops: $items `chorizo brownies, white chocolate and tomato pizza, carob chunk noodles`,
206
133
  probability: 1,
207
- modifier: {
208
- ["Meat Drop"]: 20,
209
- },
210
134
  },
211
135
  {
212
136
  familiar: $familiar `Piano Cat`,
213
- meatVal: () => getSaleValue(...$items `beertini, papaya slung, salty slug, tomato daiquiri`),
137
+ drops: $items `beertini, papaya slung, salty slug, tomato daiquiri`,
214
138
  probability: 1,
215
- modifier: {
216
- ["Meat Drop"]: 20,
217
- },
218
139
  },
219
140
  {
220
141
  familiar: $familiar `Golden Monkey`,
221
- meatVal: () => getSaleValue($item `gold nuggets`),
142
+ drops: $items `gold nuggets`,
222
143
  probability: 0.5,
223
- modifier: {
224
- ["Meat Drop"]: 25,
225
- },
226
144
  },
227
145
  {
228
146
  familiar: $familiar `Robot Reindeer`,
229
- meatVal: () => getSaleValue(...$items `candy cane, eggnog, fruitcake, gingerbread bugbear`),
147
+ drops: $items `candy cane, eggnog, fruitcake, gingerbread bugbear`,
230
148
  probability: 0.3,
231
- modifier: {
232
- ["Muscle"]: 10,
233
- ["Mysticality"]: 10,
234
- ["Moxie"]: 10,
235
- },
236
149
  },
237
150
  {
238
151
  familiar: $familiar `Stocking Mimic`,
239
- meatVal: () => getSaleValue(...$items `Angry Farmer candy, Cold Hots candy, Rock Pops, Tasty Fun Good rice candy, Wint-O-Fresh mint`),
152
+ drops: getSaleValue(...$items `Angry Farmer candy, Cold Hots candy, Rock Pops, Tasty Fun Good rice candy, Wint-O-Fresh mint`),
240
153
  probability: 0.3,
241
- modifier: {
242
- ["Muscle"]: 10,
243
- ["Mysticality"]: 10,
244
- ["Moxie"]: 10,
245
- },
246
154
  },
247
155
  {
248
156
  familiar: $familiar `BRICKO chick`,
249
- meatVal: () => getSaleValue($item `BRICKO brick`),
157
+ drops: $items `BRICKO brick`,
250
158
  probability: 1,
251
- modifier: {
252
- ["Muscle Percent"]: 10,
253
- ["Mysticality Percent"]: 10,
254
- ["Moxie Percent"]: 10,
255
- },
256
159
  },
257
160
  {
258
161
  familiar: $familiar `Cotton Candy Carnie`,
259
- meatVal: () => getSaleValue($item `cotton candy pinch`),
162
+ drops: $items `cotton candy pinch`,
260
163
  probability: 1,
261
- modifier: { ["Initiative"]: 20 },
262
164
  },
263
165
  {
264
166
  familiar: $familiar `Untamed Turtle`,
265
- meatVal: () => getSaleValue(...$items `snailmail bits, turtlemail bits, turtle wax`),
167
+ drops: $items `snailmail bits, turtlemail bits, turtle wax`,
266
168
  probability: 0.35,
267
- modifier: { ["Initiative"]: 20 },
268
169
  },
269
170
  {
270
171
  familiar: $familiar `Astral Badger`,
271
- meatVal: () => 2 *
272
- getSaleValue(...$items `spooky mushroom, Knob mushroom, Knoll mushroom`),
172
+ drops: $items `spooky mushroom, Knob mushroom, Knoll mushroom`,
273
173
  probability: 1,
274
- modifier: { ["Maximum HP"]: 10, ["Maximum MP"]: 10 },
275
174
  },
276
175
  {
277
176
  familiar: $familiar `Green Pixie`,
278
- meatVal: () => getSaleValue($item `bottle of tequila`),
177
+ drops: $items `bottle of tequila`,
279
178
  probability: 0.2,
280
- modifier: { ["Maximum HP"]: 10, ["Maximum MP"]: 10 },
281
179
  },
282
180
  {
283
181
  familiar: $familiar `Angry Goat`,
284
- meatVal: () => getSaleValue($item `goat cheese pizza`),
182
+ drops: $items `goat cheese pizza`,
285
183
  probability: 1,
286
- modifier: { ["Muscle Percent"]: 15 },
287
184
  },
288
185
  {
289
186
  familiar: $familiar `Adorable Seal Larva`,
290
- meatVal: () => getSaleValue(...$items `stench nuggets, spooky nuggets, hot nuggets, cold nuggets, sleaze nuggets`),
187
+ drops: $items `stench nuggets, spooky nuggets, hot nuggets, cold nuggets, sleaze nuggets`,
291
188
  probability: 0.35,
292
- modifier: {
293
- ["HP Regen Min"]: 2,
294
- ["MP Regen Min"]: 2,
295
- ["HP Regen Max"]: 8,
296
- ["MP Regen Max"]: 8,
297
- },
298
189
  },
299
190
  {
300
191
  familiar: $familiar `Ancient Yuletide Troll`,
301
- meatVal: () => getSaleValue(...$items `candy cane, eggnog, fruitcake, gingerbread bugbear`),
192
+ drops: $items `candy cane, eggnog, fruitcake, gingerbread bugbear`,
302
193
  probability: 0.3,
303
- modifier: {
304
- ["HP Regen Min"]: 2,
305
- ["MP Regen Min"]: 2,
306
- ["HP Regen Max"]: 8,
307
- ["MP Regen Max"]: 8,
308
- },
309
194
  },
310
195
  {
311
196
  familiar: $familiar `Sweet Nutcracker`,
312
- meatVal: () => getSaleValue(...$items `candy cane, eggnog, fruitcake, gingerbread bugbear`),
197
+ drops: $items `candy cane, eggnog, fruitcake, gingerbread bugbear`,
313
198
  probability: 0.3,
314
- modifier: {
315
- ["HP Regen Min"]: 2,
316
- ["MP Regen Min"]: 2,
317
- ["HP Regen Max"]: 8,
318
- ["MP Regen Max"]: 8,
319
- },
320
199
  },
321
200
  {
322
201
  familiar: $familiar `Casagnova Gnome`,
323
- meatVal: () => 0,
202
+ drops: 0,
324
203
  probability: 0,
325
- modifier: {
326
- ["Meat Drop"]: 20,
327
- },
328
204
  },
329
205
  {
330
206
  familiar: $familiar `Coffee Pixie`,
331
- meatVal: () => 0,
207
+ drops: 0,
332
208
  probability: 0,
333
- modifier: {
334
- ["Meat Drop"]: 20,
335
- },
336
209
  },
337
210
  {
338
211
  familiar: $familiar `Dancing Frog`,
339
- meatVal: () => 0,
212
+ drops: 0,
340
213
  probability: 0,
341
- modifier: {
342
- ["Meat Drop"]: 20,
343
- },
344
214
  },
345
215
  {
346
216
  familiar: $familiar `Grouper Groupie`,
347
- meatVal: () => 0,
217
+ drops: 0,
348
218
  probability: 0,
349
- modifier: {
350
- ["Meat Drop"]: 20,
351
- },
352
219
  },
353
220
  {
354
221
  familiar: $familiar `Hand Turkey`,
355
- meatVal: () => 30,
222
+ drops: 30,
356
223
  probability: 1,
357
- modifier: {
358
- ["Meat Drop"]: 20,
359
- },
360
224
  },
361
225
  {
362
226
  familiar: $familiar `Hippo Ballerina`,
363
- meatVal: () => 0,
227
+ drops: 0,
364
228
  probability: 0,
365
- modifier: {
366
- ["Meat Drop"]: 20,
367
- },
368
229
  },
369
230
  {
370
231
  familiar: $familiar `Jitterbug`,
371
- meatVal: () => 0,
232
+ drops: 0,
372
233
  probability: 0,
373
- modifier: {
374
- ["Meat Drop"]: 20,
375
- },
376
234
  },
377
235
  {
378
236
  familiar: $familiar `Leprechaun`,
379
- meatVal: () => 30,
237
+ drops: 30,
380
238
  probability: 1,
381
- modifier: {
382
- ["Meat Drop"]: 20,
383
- },
384
239
  },
385
240
  {
386
241
  familiar: $familiar `Obtuse Angel`,
387
- meatVal: () => 0,
242
+ drops: 0,
388
243
  probability: 0,
389
- modifier: {
390
- ["Meat Drop"]: 20,
391
- },
392
244
  },
393
245
  {
394
246
  familiar: $familiar `Psychedelic Bear`,
395
- meatVal: () => 0,
247
+ drops: 0,
396
248
  probability: 0,
397
- modifier: {
398
- ["Meat Drop"]: 20,
399
- },
400
249
  },
401
250
  {
402
251
  familiar: $familiar `Robortender`,
403
- meatVal: () => 0,
252
+ drops: 0,
404
253
  probability: 0,
405
- modifier: {
406
- ["Meat Drop"]: 20,
407
- },
408
254
  },
409
255
  {
410
256
  familiar: $familiar `Ghost of Crimbo Commerce`,
411
- meatVal: () => 30,
257
+ drops: 30,
412
258
  probability: 1,
413
- modifier: {
414
- ["Meat Drop"]: 25,
415
- },
416
259
  },
417
260
  {
418
261
  familiar: $familiar `Hobo Monkey`,
419
- meatVal: () => 0,
262
+ drops: 0,
420
263
  probability: 0,
421
- modifier: {
422
- ["Meat Drop"]: 25,
423
- },
424
264
  },
425
265
  {
426
266
  familiar: $familiar `Rockin' Robin`,
427
- meatVal: () => 60,
267
+ drops: 60,
428
268
  probability: 1,
429
- modifier: {
430
- ["Item Drop"]: 15,
431
- },
432
269
  },
433
270
  {
434
271
  familiar: $familiar `Feral Kobold`,
435
- meatVal: () => 30,
272
+ drops: 30,
436
273
  probability: 1,
437
- modifier: {
438
- ["Item Drop"]: 15,
439
- },
440
274
  },
441
275
  {
442
276
  familiar: $familiar `Oily Woim`,
443
- meatVal: () => 30,
277
+ drops: 30,
444
278
  probability: 1,
445
- modifier: {
446
- ["Item Drop"]: 10,
447
- },
448
279
  },
449
280
  {
450
281
  familiar: $familiar `Cat Burglar`,
451
- meatVal: () => 0,
282
+ drops: 0,
452
283
  probability: 0,
453
- modifier: {
454
- ["Item Drop"]: 10,
455
- },
456
284
  },
457
285
  {
458
286
  familiar: $familiar `Misshapen Animal Skeleton`,
459
- meatVal: () => 30,
287
+ drops: 30,
460
288
  probability: 1,
461
- modifier: {
462
- ["Familiar Weight"]: 5,
463
- },
464
289
  },
465
290
  {
466
291
  familiar: $familiar `Gelatinous Cubeling`,
467
- meatVal: () => 0,
292
+ drops: 0,
468
293
  probability: 0,
469
- modifier: {
470
- ["Familiar Weight"]: 5,
471
- },
472
294
  },
473
295
  {
474
296
  familiar: $familiar `Frozen Gravy Fairy`,
475
- // drops a cold nugget every combat, 5 of which can be used to make a cold wad
476
- meatVal: () => Math.max(0.2 * getSaleValue($item `cold wad`), getSaleValue($item `cold nuggets`)),
297
+ drops: $items `cold nuggets`,
477
298
  probability: 1,
478
- modifier: { ["Cold Damage"]: 20 },
479
299
  },
480
300
  {
481
301
  familiar: $familiar `Stinky Gravy Fairy`,
482
- // drops a stench nugget every combat, 5 of which can be used to make a stench wad
483
- meatVal: () => Math.max(0.2 * getSaleValue($item `stench wad`), getSaleValue($item `stench nuggets`)),
302
+ drops: $items `stench nuggets`,
484
303
  probability: 1,
485
- modifier: { ["Stench Damage"]: 20 },
486
304
  },
487
305
  {
488
306
  familiar: $familiar `Sleazy Gravy Fairy`,
489
- // drops a sleaze nugget every combat, 5 of which can be used to make a sleaze wad
490
- meatVal: () => Math.max(0.2 * getSaleValue($item `sleaze wad`), getSaleValue($item `sleaze nuggets`)),
307
+ drops: $items `sleaze nuggets`,
491
308
  probability: 1,
492
- modifier: { ["Sleaze Damage"]: 20 },
493
309
  },
494
310
  {
495
311
  familiar: $familiar `Spooky Gravy Fairy`,
496
- // drops a spooky nugget every combat, 5 of which can be used to make a spooky wad
497
- meatVal: () => Math.max(0.2 * getSaleValue($item `spooky wad`), getSaleValue($item `spooky nuggets`)),
312
+ drops: $items `spooky nuggets`,
498
313
  probability: 1,
499
- modifier: { ["Spooky Damage"]: 20 },
500
314
  },
501
315
  {
502
316
  familiar: $familiar `Flaming Gravy Fairy`,
503
317
  // drops a hot nugget every combat, 5 of which can be used to make a hot wad
504
- meatVal: () => Math.max(0.2 * getSaleValue($item `hot wad`), getSaleValue($item `hot nuggets`)),
318
+ drops: $items `hot nuggets`,
505
319
  probability: 1,
506
- modifier: { ["Hot Damage"]: 20 },
507
320
  },
508
321
  ];
509
322
  /**
510
323
  * Value a specified familiar Crown rider
511
324
  *
512
325
  * @param rider Familiar to value
513
- * @param modifierValueFunction Value of the extra modifiers the familiar provides
326
+ * @param modifierValueFunction Value of the extra modifiers the familiar provides,
327
+ * @param dropsValueFunction Value to assign the drops of the familiar gives
514
328
  * @param ignoreLimitedDrops Whether to ignore drops that are daily or otherwise limited
515
329
  * @returns Rider value (in meat)
516
330
  */
517
- export function valueRider(rider, modifierValueFunction, ignoreLimitedDrops = false) {
331
+ export function valueRider(rider, modifierValueFunction, dropsValueFunction, ignoreLimitedDrops = false) {
518
332
  const dropValue = !rider.dropPredicate || (rider.dropPredicate() && !ignoreLimitedDrops)
519
- ? rider.probability * rider.meatVal()
333
+ ? rider.probability *
334
+ (typeof rider.drops === "number"
335
+ ? rider.drops
336
+ : dropsValueFunction(rider.drops))
520
337
  : 0;
521
- const modifierValue = modifierValueFunction(rider.modifier);
338
+ const modifierValue = modifierValueFunction(rider.familiar);
522
339
  return dropValue + modifierValue;
523
340
  }
524
341
  const riderModes = new Map();
342
+ const DEFAULTS = {
343
+ modifierValueFunction: () => 0,
344
+ dropsValueFunction: () => 0,
345
+ ignoreLimitedDrops: false,
346
+ excludeCurrentFamiliar: true,
347
+ };
525
348
  /**
526
349
  * Creates a rider mode for this session
527
350
  *
528
351
  * @param name Rider mode name
529
- * @param modifierValueFunction Function to value modifiers of a rider
530
- * @param ignoreLimitedDrops Whether to ignore daily or otherwise limited drops
531
- * @param excludeCurrentFamiliar Whether to exclude the player's current familiar
352
+ * @param details An object consisting of various settings for the RiderMode:
353
+ * @param details.modifierValueFunction Function to value a familiar itself, often using modifiers,
354
+ * @param details.dropsValueFunction Function to value the drops of a familiar, which are stored as an `Item[]` or `Map<Item, number>`
355
+ * @param details.ignoreLimitedDrops Whether to ignore daily or otherwise limited drops
356
+ * @param details.excludeCurrentFamiliar Whether to exclude the player's current familiar
532
357
  * @returns Map of all rider modes created this session, including the one that was just made
533
358
  */
534
- export function createRiderMode(name, modifierValueFunction, ignoreLimitedDrops = false, excludeCurrentFamiliar = true) {
535
- return riderModes.set(name, {
536
- modifierValueFunction: modifierValueFunction,
537
- ignoreLimitedDrops: ignoreLimitedDrops,
538
- excludeCurrentFamiliar: excludeCurrentFamiliar,
539
- });
359
+ export function createRiderMode(name, details) {
360
+ return riderModes.set(name, { ...DEFAULTS, ...details });
361
+ }
362
+ /**
363
+ * @param name The name of the `RiderMode` to check
364
+ * @returns Whether or not said `RiderMode` exists
365
+ */
366
+ export function hasRiderMode(name) {
367
+ return riderModes.has(name);
540
368
  }
541
369
  const riderLists = new Map();
542
370
  /**
@@ -549,18 +377,38 @@ export function pickRider(mode) {
549
377
  const modeData = riderModes.get(mode);
550
378
  if (!modeData)
551
379
  return null;
552
- const { modifierValueFunction, ignoreLimitedDrops, excludeCurrentFamiliar } = modeData;
380
+ const { modifierValueFunction, dropsValueFunction, ignoreLimitedDrops, excludeCurrentFamiliar, } = modeData;
553
381
  if (!riderLists.has(mode)) {
554
382
  riderLists.set(mode, ridingFamiliars
555
- .filter((rider) => have(rider.familiar))
556
- .sort((a, b) => valueRider(b, modifierValueFunction, ignoreLimitedDrops) -
557
- valueRider(a, modifierValueFunction, ignoreLimitedDrops)));
383
+ .filter(({ familiar }) => have(familiar))
384
+ .sort((a, b) => valueRider(b, modifierValueFunction, dropsValueFunction, ignoreLimitedDrops) -
385
+ valueRider(a, modifierValueFunction, dropsValueFunction, ignoreLimitedDrops)));
558
386
  }
559
387
  const list = riderLists.get(mode);
560
388
  if (list) {
561
- const riderToReturn = list.find((rider) => (!rider.dropPredicate || rider.dropPredicate()) &&
562
- (!excludeCurrentFamiliar || myFamiliar() !== rider.familiar));
389
+ const riderToReturn = list.find(({ dropPredicate, familiar }) => (dropPredicate?.() ?? true) &&
390
+ (!excludeCurrentFamiliar || myFamiliar() !== familiar));
563
391
  return riderToReturn ?? null;
564
392
  }
565
393
  return null;
566
394
  }
395
+ /**
396
+ * Find the associated NumericModifier for a given familiar when enthroned or bjornified
397
+ *
398
+ * @param modifier The NumericModifier in question
399
+ * @param familiar The Familiar in question
400
+ * @returns The value of the given numeric modifier for the Crown of Thrones (or buddy bjorn) when the given familiar is encromulated
401
+ */
402
+ export function getModifier(modifier, familiar) {
403
+ return numericModifier(`Throne:${familiar}`, modifier);
404
+ }
405
+ /**
406
+ * Create a `modifierValueFunction` for a familiar.
407
+ *
408
+ * @param modifiers An array consisting of the `NumericModifier`s relevant to your valuation
409
+ * @param functions An object keyed by `NumericModifier`s whose values are functions that map the the result of a modifier to its corresponding valuation
410
+ * @returns A function that maps a familiar to the value of its modifiers in the crown of thrones or buddy bjorn.
411
+ */
412
+ export function createModifierValueFunction(modifiers, functions) {
413
+ return (familiar) => sum(modifiers, (modifier) => functions[modifier](getModifier(modifier, familiar)));
414
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libram",
3
- "version": "0.7.18",
3
+ "version": "0.8.0",
4
4
  "description": "JavaScript helper library for KoLmafia",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",