libram 0.8.27 → 0.8.29
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.
- package/dist/Kmail.d.ts +29 -0
- package/dist/Kmail.js +87 -10
- package/dist/actions/ActionSource.js +2 -1
- package/dist/actions/FreeRun.js +5 -1
- package/dist/ascend.d.ts +1 -1
- package/dist/ascend.js +1 -1
- package/dist/diet/index.d.ts +11 -11
- package/dist/diet/index.js +29 -11
- package/dist/lib.d.ts +10 -0
- package/dist/lib.js +15 -3
- package/dist/maximize.d.ts +1 -0
- package/dist/maximize.js +11 -5
- package/dist/resources/2021/CrystalBall.js +2 -0
- package/dist/resources/2024/ChestMimic.d.ts +7 -0
- package/dist/resources/2024/ChestMimic.js +19 -2
- package/package.json +10 -9
package/dist/Kmail.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export default class Kmail {
|
|
|
15
15
|
readonly senderId: number;
|
|
16
16
|
readonly senderName: string;
|
|
17
17
|
readonly rawMessage: string;
|
|
18
|
+
private _parsedMessageParts;
|
|
18
19
|
/**
|
|
19
20
|
* Parses a kmail from KoL's native format
|
|
20
21
|
*
|
|
@@ -72,18 +73,46 @@ export default class Kmail {
|
|
|
72
73
|
* @returns Whether the kmail was deleted
|
|
73
74
|
*/
|
|
74
75
|
delete(): boolean;
|
|
76
|
+
private get _messageParts();
|
|
77
|
+
private _parseMessageParts;
|
|
75
78
|
/**
|
|
76
79
|
* Get message contents without any HTML from items or meat
|
|
77
80
|
*
|
|
78
81
|
* @returns Cleaned message contents
|
|
79
82
|
*/
|
|
80
83
|
get message(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Get the note on the outside of the gift. If the kmail is not a gift,
|
|
86
|
+
* this will be the entire message.
|
|
87
|
+
*
|
|
88
|
+
* @returns Note on the outside of the gift, or the entire message for non-gifts
|
|
89
|
+
*/
|
|
90
|
+
get outsideNote(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get the note on the inside of the gift
|
|
93
|
+
*
|
|
94
|
+
* @returns Note on the inside of the gift
|
|
95
|
+
*/
|
|
96
|
+
get insideNote(): string | null;
|
|
81
97
|
/**
|
|
82
98
|
* Get items attached to the kmail
|
|
83
99
|
*
|
|
84
100
|
* @returns Map of items attached to the kmail and their quantities
|
|
85
101
|
*/
|
|
86
102
|
items(): Map<Item, number>;
|
|
103
|
+
/**
|
|
104
|
+
* Get items attached to the outside of the gift, which should be
|
|
105
|
+
* just the gift wrapper for giftshop items, and all items for normal kmails
|
|
106
|
+
*
|
|
107
|
+
* @returns Map of items attached to the kmail and their quantities
|
|
108
|
+
*/
|
|
109
|
+
outsideItems(): Map<Item, number>;
|
|
110
|
+
/**
|
|
111
|
+
* Get items attached to the inside of the gift
|
|
112
|
+
*
|
|
113
|
+
* @returns Map of items attached to the kmail and their quantities
|
|
114
|
+
*/
|
|
115
|
+
insideItems(): Map<Item, number>;
|
|
87
116
|
/**
|
|
88
117
|
* Get meat attached to the kmail
|
|
89
118
|
*
|
package/dist/Kmail.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decode as decodeEntities } from "html-entities";
|
|
2
|
+
import { extractMeat, isGiftable, visitUrl } from "kolmafia";
|
|
3
|
+
import { extractItems } from "./lib";
|
|
2
4
|
import { combineQuery, EMPTY_VALUE, fetchUrl } from "./url";
|
|
3
5
|
import { arrayToCountedMap, chunk } from "./utils";
|
|
4
6
|
export default class Kmail {
|
|
@@ -8,6 +10,7 @@ export default class Kmail {
|
|
|
8
10
|
senderId;
|
|
9
11
|
senderName;
|
|
10
12
|
rawMessage;
|
|
13
|
+
_parsedMessageParts;
|
|
11
14
|
/**
|
|
12
15
|
* Parses a kmail from KoL's native format
|
|
13
16
|
*
|
|
@@ -123,12 +126,8 @@ export default class Kmail {
|
|
|
123
126
|
}), ">Package sent.</");
|
|
124
127
|
}
|
|
125
128
|
constructor(rawKmail) {
|
|
126
|
-
const date = new Date(rawKmail.localtime);
|
|
127
|
-
// Date come from KoL formatted with YY and so will be parsed 19YY, which is wrong.
|
|
128
|
-
// We can safely add 100 because if 19YY was a leap year, 20YY will be too!
|
|
129
|
-
date.setFullYear(date.getFullYear() + 100);
|
|
130
129
|
this.id = Number(rawKmail.id);
|
|
131
|
-
this.date =
|
|
130
|
+
this.date = new Date(Number(rawKmail.azunixtime) * 1000);
|
|
132
131
|
this.type = rawKmail.type;
|
|
133
132
|
this.senderId = Number(rawKmail.fromid);
|
|
134
133
|
this.senderName = rawKmail.fromname;
|
|
@@ -142,14 +141,65 @@ export default class Kmail {
|
|
|
142
141
|
delete() {
|
|
143
142
|
return Kmail.delete([this]) === 1;
|
|
144
143
|
}
|
|
144
|
+
get _messageParts() {
|
|
145
|
+
return (this._parsedMessageParts ??= this._parseMessageParts());
|
|
146
|
+
}
|
|
147
|
+
_parseMessageParts() {
|
|
148
|
+
let text = this.rawMessage;
|
|
149
|
+
let insideText;
|
|
150
|
+
if (this.type === "normal") {
|
|
151
|
+
// strip potential valentine
|
|
152
|
+
if (text.startsWith("<center>")) {
|
|
153
|
+
const endIdx = text.indexOf("</center>");
|
|
154
|
+
text = text.slice(endIdx + 9);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (this.type === "giftshop") {
|
|
158
|
+
[text, insideText] = text.split("<p>Inside Note:<p>");
|
|
159
|
+
}
|
|
160
|
+
const split = (s) => {
|
|
161
|
+
const idx = s.indexOf("<");
|
|
162
|
+
if (idx === -1)
|
|
163
|
+
return [s];
|
|
164
|
+
return [s.slice(0, idx), s.slice(idx)];
|
|
165
|
+
};
|
|
166
|
+
const [outsideNote, outsideAttachments = null] = split(text);
|
|
167
|
+
const [insideNote = null, insideAttachments = null] = insideText !== undefined ? split(insideText) : [];
|
|
168
|
+
return {
|
|
169
|
+
outsideNote: decodeEntities(outsideNote),
|
|
170
|
+
outsideAttachments,
|
|
171
|
+
insideNote: insideNote && decodeEntities(insideNote),
|
|
172
|
+
insideAttachments,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
145
175
|
/**
|
|
146
176
|
* Get message contents without any HTML from items or meat
|
|
147
177
|
*
|
|
148
178
|
* @returns Cleaned message contents
|
|
149
179
|
*/
|
|
150
180
|
get message() {
|
|
151
|
-
const
|
|
152
|
-
|
|
181
|
+
const { outsideNote, insideNote } = this._messageParts;
|
|
182
|
+
if (insideNote !== null) {
|
|
183
|
+
return `${outsideNote}\n\nInside Note:\n${insideNote}`;
|
|
184
|
+
}
|
|
185
|
+
return outsideNote;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get the note on the outside of the gift. If the kmail is not a gift,
|
|
189
|
+
* this will be the entire message.
|
|
190
|
+
*
|
|
191
|
+
* @returns Note on the outside of the gift, or the entire message for non-gifts
|
|
192
|
+
*/
|
|
193
|
+
get outsideNote() {
|
|
194
|
+
return this._messageParts.outsideNote;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the note on the inside of the gift
|
|
198
|
+
*
|
|
199
|
+
* @returns Note on the inside of the gift
|
|
200
|
+
*/
|
|
201
|
+
get insideNote() {
|
|
202
|
+
return this._messageParts.insideNote;
|
|
153
203
|
}
|
|
154
204
|
/**
|
|
155
205
|
* Get items attached to the kmail
|
|
@@ -157,7 +207,31 @@ export default class Kmail {
|
|
|
157
207
|
* @returns Map of items attached to the kmail and their quantities
|
|
158
208
|
*/
|
|
159
209
|
items() {
|
|
160
|
-
|
|
210
|
+
const { outsideAttachments, insideAttachments } = this._messageParts;
|
|
211
|
+
return extractItems(`${outsideAttachments}${insideAttachments}`);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get items attached to the outside of the gift, which should be
|
|
215
|
+
* just the gift wrapper for giftshop items, and all items for normal kmails
|
|
216
|
+
*
|
|
217
|
+
* @returns Map of items attached to the kmail and their quantities
|
|
218
|
+
*/
|
|
219
|
+
outsideItems() {
|
|
220
|
+
const { outsideAttachments } = this._messageParts;
|
|
221
|
+
if (!outsideAttachments)
|
|
222
|
+
return new Map();
|
|
223
|
+
return extractItems(outsideAttachments);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get items attached to the inside of the gift
|
|
227
|
+
*
|
|
228
|
+
* @returns Map of items attached to the kmail and their quantities
|
|
229
|
+
*/
|
|
230
|
+
insideItems() {
|
|
231
|
+
const { insideAttachments } = this._messageParts;
|
|
232
|
+
if (!insideAttachments)
|
|
233
|
+
return new Map();
|
|
234
|
+
return extractItems(insideAttachments);
|
|
161
235
|
}
|
|
162
236
|
/**
|
|
163
237
|
* Get meat attached to the kmail
|
|
@@ -165,7 +239,10 @@ export default class Kmail {
|
|
|
165
239
|
* @returns Meat attached to the kmail
|
|
166
240
|
*/
|
|
167
241
|
meat() {
|
|
168
|
-
|
|
242
|
+
const { outsideAttachments, insideAttachments } = this._messageParts;
|
|
243
|
+
if (!outsideAttachments && !insideAttachments)
|
|
244
|
+
return 0;
|
|
245
|
+
return extractMeat(`${outsideAttachments}${insideAttachments}`);
|
|
169
246
|
}
|
|
170
247
|
/**
|
|
171
248
|
* Reply to kmail
|
|
@@ -16,6 +16,7 @@ function mergeConstraints(...allConstraints) {
|
|
|
16
16
|
// Inconsistent requirements.
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
+
const familiar = familiars.find((familiar) => familiar);
|
|
19
20
|
return {
|
|
20
21
|
equipmentRequirements: () => Requirement.merge([
|
|
21
22
|
...allConstraints.map((constraints) => constraints.equipmentRequirements?.() ?? new Requirement([], {})),
|
|
@@ -28,7 +29,7 @@ function mergeConstraints(...allConstraints) {
|
|
|
28
29
|
}
|
|
29
30
|
return success;
|
|
30
31
|
},
|
|
31
|
-
familiar
|
|
32
|
+
...(familiar ? { familiar } : {}),
|
|
32
33
|
cost: () => sum(allConstraints, (constraints) => constraints.cost?.() ?? 0),
|
|
33
34
|
};
|
|
34
35
|
}
|
package/dist/actions/FreeRun.js
CHANGED
|
@@ -5,11 +5,15 @@ import { Requirement } from "../maximize";
|
|
|
5
5
|
import { get } from "../property";
|
|
6
6
|
import * as Bandersnatch from "../resources/2009/Bandersnatch";
|
|
7
7
|
import * as StompingBoots from "../resources/2011/StompingBoots";
|
|
8
|
-
import { $effect, $familiar, $item, $items } from "../template-string";
|
|
8
|
+
import { $effect, $familiar, $item, $items, $skill } from "../template-string";
|
|
9
9
|
import { ActionSource, findActionSource, } from "./ActionSource";
|
|
10
10
|
// eslint-disable-next-line libram/verify-constants
|
|
11
11
|
const EVERYTHING_LOOKS_GREEN = $effect `Everything Looks Green`;
|
|
12
12
|
const freeRunSources = [
|
|
13
|
+
// Free unlimited source
|
|
14
|
+
new ActionSource($item `spring shoes`, () => (have(EVERYTHING_LOOKS_GREEN) ? 1 : 0), Macro.skill($skill `Spring Away`), {
|
|
15
|
+
equipmentRequirements: () => new Requirement([], { forceEquip: $items `spring shoes` }),
|
|
16
|
+
}),
|
|
13
17
|
// Free limited sources
|
|
14
18
|
new ActionSource($familiar `Frumious Bandersnatch`, () => (have($effect `Ode to Booze`) || getSongCount() < getSongLimit()) &&
|
|
15
19
|
Bandersnatch.couldRunaway()
|
package/dist/ascend.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare type InputMoonSign = number | Lowercase<MoonSign> | "degrassi" | "degras
|
|
|
34
34
|
* Hops the gash, perming no skills by default
|
|
35
35
|
*
|
|
36
36
|
* @param options Configuration for the ascension
|
|
37
|
-
* @param options.path path of choice
|
|
37
|
+
* @param options.path Your path of choice for this ascension
|
|
38
38
|
* @param options.playerClass Your class of choice for this ascension
|
|
39
39
|
* @param options.lifestyle 1 for casual, 2 for softcore, 3 for hardcore. Alternately, use the Lifestyle enum
|
|
40
40
|
* @param options.kolGender An entry from the KolGender enum: 1 for male, 2 for female (sorry that it's limited to those). Defaults to 2 or the corresponding value for defaultGenderOverride pref (which should be 'male' or 'female')
|
package/dist/ascend.js
CHANGED
|
@@ -137,7 +137,7 @@ function isInValhalla() {
|
|
|
137
137
|
* Hops the gash, perming no skills by default
|
|
138
138
|
*
|
|
139
139
|
* @param options Configuration for the ascension
|
|
140
|
-
* @param options.path path of choice
|
|
140
|
+
* @param options.path Your path of choice for this ascension
|
|
141
141
|
* @param options.playerClass Your class of choice for this ascension
|
|
142
142
|
* @param options.lifestyle 1 for casual, 2 for softcore, 3 for hardcore. Alternately, use the Lifestyle enum
|
|
143
143
|
* @param options.kolGender An entry from the KolGender enum: 1 for male, 2 for female (sorry that it's limited to those). Defaults to 2 or the corresponding value for defaultGenderOverride pref (which should be 'male' or 'female')
|
package/dist/diet/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Effect, Item } from "kolmafia";
|
|
2
2
|
declare type RawDietEntry<T> = [MenuItem<T>[], number];
|
|
3
3
|
declare type RawDiet<T> = RawDietEntry<T>[];
|
|
4
|
-
declare type MenuItemOptions<T> = {
|
|
5
|
-
organ
|
|
6
|
-
size
|
|
7
|
-
maximum
|
|
8
|
-
additionalValue
|
|
9
|
-
effect
|
|
10
|
-
priceOverride
|
|
11
|
-
mayo
|
|
12
|
-
data
|
|
13
|
-
useRetrievePrice
|
|
14
|
-
}
|
|
4
|
+
declare type MenuItemOptions<T> = Partial<{
|
|
5
|
+
organ: Organ;
|
|
6
|
+
size: number;
|
|
7
|
+
maximum: number | "auto";
|
|
8
|
+
additionalValue: number;
|
|
9
|
+
effect: Effect;
|
|
10
|
+
priceOverride: number;
|
|
11
|
+
mayo: Item;
|
|
12
|
+
data: T;
|
|
13
|
+
useRetrievePrice: boolean;
|
|
14
|
+
}>;
|
|
15
15
|
export declare class MenuItem<T> {
|
|
16
16
|
item: Item;
|
|
17
17
|
organ?: Organ;
|
package/dist/diet/index.js
CHANGED
|
@@ -175,14 +175,24 @@ export class MenuItem {
|
|
|
175
175
|
...(MenuItem.defaultOptions().get(item) ?? {}),
|
|
176
176
|
};
|
|
177
177
|
this.item = item;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
const maximum_ = maximum === "auto" ? item.dailyusesleft : maximum;
|
|
179
|
+
if (maximum_)
|
|
180
|
+
this.maximum = maximum_;
|
|
181
|
+
if (additionalValue)
|
|
182
|
+
this.additionalValue = additionalValue;
|
|
183
|
+
if (effect)
|
|
184
|
+
this.effect = effect;
|
|
185
|
+
if (priceOverride)
|
|
186
|
+
this.priceOverride = priceOverride;
|
|
187
|
+
if (mayo)
|
|
188
|
+
this.mayo = mayo;
|
|
189
|
+
if (data)
|
|
190
|
+
this.data = data;
|
|
184
191
|
const typ = itemType(this.item);
|
|
185
|
-
|
|
192
|
+
if (organ)
|
|
193
|
+
this.organ = organ;
|
|
194
|
+
else if (isOrgan(typ))
|
|
195
|
+
this.organ = typ;
|
|
186
196
|
this.size =
|
|
187
197
|
size ??
|
|
188
198
|
(this.organ === "food"
|
|
@@ -225,10 +235,18 @@ class DietPlanner {
|
|
|
225
235
|
spleenValue = 0;
|
|
226
236
|
constructor(mpa, menu) {
|
|
227
237
|
this.mpa = mpa;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
238
|
+
const fork = menu.find((item) => item.item === $item `Ol' Scratch's salad fork`);
|
|
239
|
+
if (fork)
|
|
240
|
+
this.fork = fork;
|
|
241
|
+
const mug = menu.find((item) => item.item === $item `Frosty's frosty mug`);
|
|
242
|
+
if (mug)
|
|
243
|
+
this.mug = mug;
|
|
244
|
+
const seasoning = menu.find((item) => item.item === $item `Special Seasoning`);
|
|
245
|
+
if (seasoning)
|
|
246
|
+
this.seasoning = seasoning;
|
|
247
|
+
const whetStone = menu.find((item) => item.item === $item `whet stone`);
|
|
248
|
+
if (whetStone)
|
|
249
|
+
this.whetStone = whetStone;
|
|
232
250
|
this.mayoLookup = new Map();
|
|
233
251
|
if (mayoInstalled()) {
|
|
234
252
|
for (const mayo of [Mayo.flex, Mayo.zapine]) {
|
package/dist/lib.d.ts
CHANGED
|
@@ -494,4 +494,14 @@ export declare function withCombatFlags<T>(action: () => T, ...flags: {
|
|
|
494
494
|
* @returns Whether you have that effect as an intrinsic. Alternately you could just have over 2147483647 turns of that effect, but that seems unlikely.
|
|
495
495
|
*/
|
|
496
496
|
export declare function haveIntrinsic(effect: Effect): boolean;
|
|
497
|
+
/**
|
|
498
|
+
* Extracts a map of gained items from a string, for example from the result
|
|
499
|
+
* of a combat.
|
|
500
|
+
*
|
|
501
|
+
* NOTE: Make sure you trust the source of that text.
|
|
502
|
+
*
|
|
503
|
+
* @param text The text to extract items from
|
|
504
|
+
* @returns A map of items and their quantities
|
|
505
|
+
*/
|
|
506
|
+
export declare function extractItems(text: string): Map<Item, number>;
|
|
497
507
|
export {};
|
package/dist/lib.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @module GeneralLibrary */
|
|
2
|
-
import { appearanceRates, autosellPrice, availableAmount, booleanModifier, choiceFollowsFight, cliExecute, currentRound, Effect, elementalResistance, equip, equippedItem, Familiar, fullnessLimit, getCampground, getCounters, getPlayerId, getPlayerName, getRelated, handlingChoice, haveEffect, haveFamiliar, haveServant, haveSkill, holiday, inebrietyLimit, inMultiFight, Item, Location, mallPrice, Monster, myClass, myEffects, myFamiliar, myFullness, myInebriety, myPath, myPrimestat, mySpleenUse, myThrall, myTurncount, numericModifier, Path, Servant, Skill, Slot, spleenLimit, Thrall, todayToString, toItem, toSkill, totalTurnsPlayed, visitUrl, xpath, } from "kolmafia";
|
|
2
|
+
import { appearanceRates, autosellPrice, availableAmount, booleanModifier, choiceFollowsFight, cliExecute, currentRound, Effect, elementalResistance, equip, equippedItem, extractItems as kolmafiaExtractItems, Familiar, fullnessLimit, getCampground, getCounters, getPlayerId, getPlayerName, getRelated, handlingChoice, haveEffect, haveFamiliar, haveServant, haveSkill, holiday, inebrietyLimit, inMultiFight, Item, Location, mallPrice, Monster, myClass, myEffects, myFamiliar, myFullness, myInebriety, myPath, myPrimestat, mySpleenUse, myThrall, myTurncount, numericModifier, Path, Servant, Skill, Slot, spleenLimit, Thrall, todayToString, toItem, toSkill, totalTurnsPlayed, visitUrl, xpath, } from "kolmafia";
|
|
3
3
|
import logger from "./logger";
|
|
4
4
|
import { get } from "./property";
|
|
5
5
|
import { $class, $effect, $element, $familiar, $item, $items, $monsters, $skill, $stat, } from "./template-string";
|
|
@@ -743,13 +743,13 @@ const hedgeTrap3 = new Map([
|
|
|
743
743
|
* @returns An object with all information the telescope gives you about the sorceress's contests and maze
|
|
744
744
|
*/
|
|
745
745
|
export function telescope() {
|
|
746
|
-
return {
|
|
746
|
+
return Object.fromEntries(Object.entries({
|
|
747
747
|
statContest: telescopeStats.get(get("telescope1")),
|
|
748
748
|
elementContest: telescopeElements.get(get("telescope2")),
|
|
749
749
|
hedge1: hedgeTrap1.get(get("telescope3")),
|
|
750
750
|
hedge2: hedgeTrap2.get(get("telescope4")),
|
|
751
751
|
hedge3: hedgeTrap3.get(get("telescope5")),
|
|
752
|
-
};
|
|
752
|
+
}).filter(([, value]) => value));
|
|
753
753
|
}
|
|
754
754
|
/**
|
|
755
755
|
* Visit the desc_x.php page for a given thing
|
|
@@ -956,3 +956,15 @@ export function withCombatFlags(action, ...flags) {
|
|
|
956
956
|
export function haveIntrinsic(effect) {
|
|
957
957
|
return haveEffect(effect) >= 2147483647;
|
|
958
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* Extracts a map of gained items from a string, for example from the result
|
|
961
|
+
* of a combat.
|
|
962
|
+
*
|
|
963
|
+
* NOTE: Make sure you trust the source of that text.
|
|
964
|
+
*
|
|
965
|
+
* @param text The text to extract items from
|
|
966
|
+
* @returns A map of items and their quantities
|
|
967
|
+
*/
|
|
968
|
+
export function extractItems(text) {
|
|
969
|
+
return new Map(Object.entries(kolmafiaExtractItems(text)).map(([itemName, quantity]) => [Item.get(itemName), quantity]));
|
|
970
|
+
}
|
package/dist/maximize.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export declare class Requirement {
|
|
|
92
92
|
* Merges two requirements, concanating relevant arrays. Typically used in static form.
|
|
93
93
|
*
|
|
94
94
|
* @param other Requirement to merge with.
|
|
95
|
+
* @returns A new merged Requirement
|
|
95
96
|
*/
|
|
96
97
|
merge(other: Requirement): Requirement;
|
|
97
98
|
/**
|
package/dist/maximize.js
CHANGED
|
@@ -437,6 +437,14 @@ export function maximizeCached(objectives, options = {}) {
|
|
|
437
437
|
saveCached(cacheKey, fullOptions);
|
|
438
438
|
return result;
|
|
439
439
|
}
|
|
440
|
+
function mergeOptionalOptions(optionsA, optionsB, ...keys) {
|
|
441
|
+
return keys.reduce((current, key) => ({
|
|
442
|
+
...current,
|
|
443
|
+
...((optionsA[key] || optionsB[key]) === undefined
|
|
444
|
+
? {}
|
|
445
|
+
: { [key]: optionsA[key] || optionsB[key] }),
|
|
446
|
+
}), {});
|
|
447
|
+
}
|
|
440
448
|
export class Requirement {
|
|
441
449
|
#maximizeParameters;
|
|
442
450
|
#maximizeOptions;
|
|
@@ -460,15 +468,14 @@ export class Requirement {
|
|
|
460
468
|
* Merges two requirements, concanating relevant arrays. Typically used in static form.
|
|
461
469
|
*
|
|
462
470
|
* @param other Requirement to merge with.
|
|
471
|
+
* @returns A new merged Requirement
|
|
463
472
|
*/
|
|
464
473
|
merge(other) {
|
|
465
474
|
const optionsA = this.maximizeOptions;
|
|
466
475
|
const optionsB = other.maximizeOptions;
|
|
476
|
+
const optionalBooleans = mergeOptionalOptions(optionsA, optionsB, "updateOnFamiliarChange", "updateOnCanEquipChanged", "forceUpdate");
|
|
467
477
|
return new Requirement([...this.maximizeParameters, ...other.maximizeParameters], {
|
|
468
|
-
|
|
469
|
-
other.maximizeOptions.updateOnFamiliarChange,
|
|
470
|
-
updateOnCanEquipChanged: optionsA.updateOnCanEquipChanged ||
|
|
471
|
-
other.maximizeOptions.updateOnCanEquipChanged,
|
|
478
|
+
...optionalBooleans,
|
|
472
479
|
forceEquip: [
|
|
473
480
|
...(optionsA.forceEquip ?? []),
|
|
474
481
|
...(other.maximizeOptions.forceEquip ?? []),
|
|
@@ -486,7 +493,6 @@ export class Requirement {
|
|
|
486
493
|
...(optionsA.preventSlot ?? []),
|
|
487
494
|
...(optionsB.preventSlot ?? []),
|
|
488
495
|
],
|
|
489
|
-
forceUpdate: optionsA.forceUpdate || optionsB.forceUpdate,
|
|
490
496
|
});
|
|
491
497
|
}
|
|
492
498
|
/**
|
|
@@ -13,7 +13,9 @@ export function have() {
|
|
|
13
13
|
}
|
|
14
14
|
const parsedProp = () => get("crystalBallPredictions")
|
|
15
15
|
.split("|")
|
|
16
|
+
.filter(Boolean)
|
|
16
17
|
.map((element) => element.split(":"))
|
|
18
|
+
.filter((tuple) => tuple.length === 3)
|
|
17
19
|
.map(([, location, monster]) => [toLocation(location), toMonster(monster)]);
|
|
18
20
|
const getLastPondered = () => `${myTotalTurnsSpent()};${totalTurnsPlayed()};${get("lastAdventure")}`;
|
|
19
21
|
let lastPondered = "";
|
|
@@ -33,3 +33,10 @@ export declare function receive(monster: Monster): boolean;
|
|
|
33
33
|
* @returns Whether we successfully differentiated our egg
|
|
34
34
|
*/
|
|
35
35
|
export declare function differentiate(monster: Monster, ...combat: Parameters<typeof runCombat>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check how many of a monster is available to differentiate into
|
|
38
|
+
*
|
|
39
|
+
* @param monster The monster to differentiate your egg into; may behave weirdly with name collisions
|
|
40
|
+
* @returns How many of a Monster we can differentiate
|
|
41
|
+
*/
|
|
42
|
+
export declare function differentiableQuantity(monster: Monster): number;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { runChoice, runCombat, toMonster, visitUrl, xpath, } from "kolmafia";
|
|
2
|
-
import { directlyUse, have as have_ } from "../../lib";
|
|
1
|
+
import { availableAmount, runChoice, runCombat, toMonster, visitUrl, xpath, } from "kolmafia";
|
|
2
|
+
import { directlyUse, examine, have as have_ } from "../../lib";
|
|
3
3
|
import { get } from "../../property";
|
|
4
4
|
import { $familiar, $item } from "../../template-string";
|
|
5
|
+
import { clamp } from "../../utils";
|
|
5
6
|
const familiar = $familiar `Chest Mimic`;
|
|
6
7
|
/**
|
|
7
8
|
* @returns Whether you `have` the Chest Mimic familiar.
|
|
@@ -106,3 +107,19 @@ export function differentiate(monster, ...combat) {
|
|
|
106
107
|
runCombat(...combat);
|
|
107
108
|
return true;
|
|
108
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Check how many of a monster is available to differentiate into
|
|
112
|
+
*
|
|
113
|
+
* @param monster The monster to differentiate your egg into; may behave weirdly with name collisions
|
|
114
|
+
* @returns How many of a Monster we can differentiate
|
|
115
|
+
*/
|
|
116
|
+
export function differentiableQuantity(monster) {
|
|
117
|
+
if (!have_($item `mimic egg`))
|
|
118
|
+
return 0;
|
|
119
|
+
const regex = new RegExp(`${monster.name}\\s*(?:\\((\\d+)\\))?`);
|
|
120
|
+
const page = examine($item `mimic egg`);
|
|
121
|
+
const match = page.match(regex);
|
|
122
|
+
if (!match)
|
|
123
|
+
return 0;
|
|
124
|
+
return clamp(parseInt(match[1]), 0, availableAmount($item `mimic egg`)) || 1;
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libram",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.29",
|
|
4
4
|
"description": "JavaScript helper library for KoLmafia",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"repository": "https://github.com/loathers/libram",
|
|
8
8
|
"author": "Samuel Gaus <sam@gaus.co.uk>",
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"private": false,
|
|
11
10
|
"scripts": {
|
|
12
11
|
"build": "yarn run updateOverlappingItemSkillNames && yarn run build:tsc && yarn run build:bundled",
|
|
13
12
|
"build:tsc": "tsc",
|
|
@@ -16,7 +15,8 @@
|
|
|
16
15
|
"docs": "yarn run typedoc",
|
|
17
16
|
"format": "yarn run prettier --write .",
|
|
18
17
|
"lint": "yarn run eslint src tools --ext .ts && yarn run prettier --check .",
|
|
19
|
-
"
|
|
18
|
+
"test": "yarn run jest",
|
|
19
|
+
"prepack": "yarn run build",
|
|
20
20
|
"updateProps": "yarn run ts-node ./tools/parseDefaultProperties.ts",
|
|
21
21
|
"updateOverlappingItemSkillNames": "yarn run ts-node ./tools/parseItemSkillNames.ts"
|
|
22
22
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@babel/preset-env": "^7.16.11",
|
|
36
36
|
"@babel/preset-typescript": "^7.15.0",
|
|
37
37
|
"@tsconfig/node16": "^1.0.2",
|
|
38
|
-
"@types/jest": "^
|
|
38
|
+
"@types/jest": "^29.5.12",
|
|
39
39
|
"@types/lodash-es": "^4.17.4",
|
|
40
40
|
"@types/node": "^16.11.11",
|
|
41
41
|
"@types/node-fetch": "^2.5.7",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"eslint-plugin-libram": "^0.4.5",
|
|
53
53
|
"husky": "^4.3.6",
|
|
54
54
|
"java-parser": "^1.4.0",
|
|
55
|
-
"jest": "^
|
|
56
|
-
"kolmafia": "^5.
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"kolmafia": "^5.27916.0",
|
|
57
57
|
"lint-staged": ">=10",
|
|
58
58
|
"node-fetch": "^2.6.1",
|
|
59
59
|
"prettier": "^2.1.2",
|
|
60
|
-
"ts-jest": "^
|
|
60
|
+
"ts-jest": "^29.1.2",
|
|
61
61
|
"ts-node": "^10.4.0",
|
|
62
62
|
"typedoc": "^0.22.10",
|
|
63
63
|
"typescript": "^4.5.2"
|
|
@@ -73,5 +73,6 @@
|
|
|
73
73
|
"lint-staged": {
|
|
74
74
|
"src/**/*.{ts,js}": "prettier --write"
|
|
75
75
|
},
|
|
76
|
-
"sideEffects": false
|
|
77
|
-
|
|
76
|
+
"sideEffects": false,
|
|
77
|
+
"packageManager": "yarn@4.1.1"
|
|
78
|
+
}
|