libram 0.4.7 → 0.5.1
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/combat.d.ts +19 -3
- package/dist/combat.js +43 -12
- package/dist/counter.d.ts +13 -0
- package/dist/counter.js +26 -0
- package/dist/diet/index.d.ts +49 -14
- package/dist/diet/index.js +222 -76
- package/dist/freerun.d.ts +2 -1
- package/dist/freerun.js +6 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib.d.ts +1 -0
- package/dist/lib.js +9 -2
- package/dist/maximize.d.ts +4 -2
- package/dist/maximize.js +41 -7
- package/dist/modifier.d.ts +6 -0
- package/dist/modifier.js +30 -0
- package/dist/property.d.ts +42 -2
- package/dist/property.js +69 -3
- package/dist/propertyTypes.d.ts +6 -6
- package/dist/resources/2013/Florist.d.ts +7 -4
- package/dist/resources/2013/Florist.js +108 -46
- package/dist/resources/2018/LatteLoversMembersMug.d.ts +3 -0
- package/dist/resources/2018/LatteLoversMembersMug.js +13 -0
- package/dist/resources/2020/Guzzlr.d.ts +3 -1
- package/dist/resources/2020/Guzzlr.js +29 -2
- package/dist/resources/2021/CrystalBall.d.ts +1 -0
- package/dist/resources/2021/CrystalBall.js +15 -0
- package/dist/resources/index.d.ts +3 -1
- package/dist/resources/index.js +3 -1
- package/package.json +1 -1
package/dist/freerun.js
CHANGED
|
@@ -87,10 +87,13 @@ function cheapestRunSource() {
|
|
|
87
87
|
}
|
|
88
88
|
function cheapestItemRun() {
|
|
89
89
|
const cheapestRun = cheapestRunSource();
|
|
90
|
-
return new FreeRun("Cheap Combat Item", () => retrieveItem(cheapestRun), Macro.trySkill($skill `Asdon Martin: Spring-Loaded Front Bumper`).item(
|
|
90
|
+
return new FreeRun("Cheap Combat Item", () => retrieveItem(cheapestRun), Macro.trySkill($skill `Asdon Martin: Spring-Loaded Front Bumper`).item(cheapestRun), {
|
|
91
91
|
preparation: () => retrieveItem(cheapestRun),
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
export function
|
|
95
|
-
return (freeRuns.find((run) => run.available() && (useFamiliar || run?.options?.familiar)) ??
|
|
94
|
+
export function tryFindFreeRun(useFamiliar = true) {
|
|
95
|
+
return (freeRuns.find((run) => run.available() && (useFamiliar || run?.options?.familiar)) ?? null);
|
|
96
|
+
}
|
|
97
|
+
export function ensureFreeRun(useFamiliar = true) {
|
|
98
|
+
return tryFindFreeRun(useFamiliar) ?? cheapestItemRun();
|
|
96
99
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/lib.d.ts
CHANGED
package/dist/lib.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @module GeneralLibrary */
|
|
2
2
|
import "core-js/modules/es.object.entries";
|
|
3
|
+
import "core-js/features/array/flat";
|
|
3
4
|
import { appearanceRates, autosellPrice, availableAmount, booleanModifier, cliExecute, fullnessLimit, getCampground, getCounters, getPlayerId, getPlayerName, getRelated, haveEffect, haveFamiliar, haveServant, haveSkill, holiday, inebrietyLimit, mallPrice, myEffects, myFamiliar, myFullness, myInebriety, myPath, mySpleenUse, myThrall, myTurncount, numericModifier, spleenLimit, toItem, toSkill, totalTurnsPlayed, } from "kolmafia";
|
|
4
5
|
import { $class, $familiar, $item, $items, $monsters } from "./template-string";
|
|
5
6
|
import { get } from "./property";
|
|
@@ -21,8 +22,14 @@ export function getSongLimit() {
|
|
|
21
22
|
* @param skillOrEffect The Skill or Effect
|
|
22
23
|
*/
|
|
23
24
|
export function isSong(skillOrEffect) {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
if (skillOrEffect instanceof Effect &&
|
|
26
|
+
skillOrEffect.attributes.includes("song")) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const skill = skillOrEffect instanceof Effect ? toSkill(skillOrEffect) : skillOrEffect;
|
|
31
|
+
return skill.class === $class `Accordion Thief` && skill.buff;
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
34
|
/**
|
|
28
35
|
* List all active Effects
|
package/dist/maximize.d.ts
CHANGED
|
@@ -27,8 +27,9 @@ export declare function setDefaultMaximizeOptions(options: Partial<MaximizeOptio
|
|
|
27
27
|
* @param options.forceEquip Equipment to force-equip ("equip X").
|
|
28
28
|
* @param options.preventEquip Equipment to prevent equipping ("-equip X").
|
|
29
29
|
* @param options.bonusEquip Equipment to apply a bonus to ("200 bonus X").
|
|
30
|
+
* @returns Whether the maximize call succeeded.
|
|
30
31
|
*/
|
|
31
|
-
export declare function maximizeCached(objectives: string[], options?: Partial<MaximizeOptions>):
|
|
32
|
+
export declare function maximizeCached(objectives: string[], options?: Partial<MaximizeOptions>): boolean;
|
|
32
33
|
export declare class Requirement {
|
|
33
34
|
#private;
|
|
34
35
|
/**
|
|
@@ -51,8 +52,9 @@ export declare class Requirement {
|
|
|
51
52
|
static merge(allRequirements: Requirement[]): Requirement;
|
|
52
53
|
/**
|
|
53
54
|
* Runs maximizeCached, using the maximizeParameters and maximizeOptions contained by this requirement.
|
|
55
|
+
* @returns Whether the maximize call succeeded.
|
|
54
56
|
*/
|
|
55
|
-
maximize():
|
|
57
|
+
maximize(): boolean;
|
|
56
58
|
/**
|
|
57
59
|
* Merges requirements, and then runs maximizeCached on the combined requirement.
|
|
58
60
|
* @param requirements Requirements to maximize on
|
package/dist/maximize.js
CHANGED
|
@@ -2,6 +2,34 @@ import { availableAmount, bjornifyFamiliar, canEquip, cliExecute, enthroneFamili
|
|
|
2
2
|
import { $familiar, $item, $slot, $slots, $stats } from "./template-string";
|
|
3
3
|
import logger from "./logger";
|
|
4
4
|
import { setEqual } from "./utils";
|
|
5
|
+
/**
|
|
6
|
+
* Merges a Partial<MaximizeOptions> onto a MaximizeOptions. We merge via overriding for all boolean properties and for onlySlot, and concat all other array properties.
|
|
7
|
+
* @param defaultOptions MaximizeOptions to use as a "base."
|
|
8
|
+
* @param addendums Options to attempt to merge onto defaultOptions.
|
|
9
|
+
*/
|
|
10
|
+
function mergeMaximizeOptions(defaultOptions, addendums) {
|
|
11
|
+
return {
|
|
12
|
+
updateOnFamiliarChange: addendums.updateOnFamiliarChange ?? defaultOptions.updateOnFamiliarChange,
|
|
13
|
+
updateOnCanEquipChanged: addendums.updateOnCanEquipChanged ??
|
|
14
|
+
defaultOptions.updateOnCanEquipChanged,
|
|
15
|
+
useOutfitCaching: addendums.useOutfitCaching ?? defaultOptions.useOutfitCaching,
|
|
16
|
+
forceEquip: [...defaultOptions.forceEquip, ...(addendums.forceEquip ?? [])],
|
|
17
|
+
preventEquip: [
|
|
18
|
+
...defaultOptions.preventEquip,
|
|
19
|
+
...(addendums.preventEquip ?? []),
|
|
20
|
+
].filter((item) => !defaultOptions.forceEquip.includes(item) &&
|
|
21
|
+
!addendums.forceEquip?.includes(item)),
|
|
22
|
+
bonusEquip: new Map([
|
|
23
|
+
...defaultOptions.bonusEquip,
|
|
24
|
+
...(addendums.bonusEquip ?? []),
|
|
25
|
+
]),
|
|
26
|
+
onlySlot: addendums.onlySlot ?? defaultOptions.onlySlot,
|
|
27
|
+
preventSlot: [
|
|
28
|
+
...defaultOptions.preventSlot,
|
|
29
|
+
...(addendums.preventSlot ?? []),
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
5
33
|
const defaultMaximizeOptions = {
|
|
6
34
|
updateOnFamiliarChange: true,
|
|
7
35
|
updateOnCanEquipChanged: true,
|
|
@@ -149,7 +177,7 @@ function applyCached(entry, options) {
|
|
|
149
177
|
}
|
|
150
178
|
const familiarEquip = entry.equipment.get($slot `familiar`);
|
|
151
179
|
if (familiarEquip)
|
|
152
|
-
equip(familiarEquip);
|
|
180
|
+
equip($slot `familiar`, familiarEquip);
|
|
153
181
|
}
|
|
154
182
|
else {
|
|
155
183
|
for (const [slot, item] of entry.equipment) {
|
|
@@ -189,8 +217,11 @@ const slotStructure = [
|
|
|
189
217
|
function verifyCached(entry) {
|
|
190
218
|
let success = true;
|
|
191
219
|
for (const slotGroup of slotStructure) {
|
|
192
|
-
const
|
|
193
|
-
|
|
220
|
+
const desiredSlots = slotGroup
|
|
221
|
+
.map((slot) => [slot, entry.equipment.get(slot) ?? null])
|
|
222
|
+
.filter(([, item]) => item !== null);
|
|
223
|
+
const desiredSet = desiredSlots.map(([, item]) => item);
|
|
224
|
+
const equippedSet = desiredSlots.map(([slot]) => equippedItem(slot));
|
|
194
225
|
if (!setEqual(desiredSet, equippedSet)) {
|
|
195
226
|
logger.warning(`Failed to apply cached ${desiredSet.join(", ")} in ${slotGroup.join(", ")}.`);
|
|
196
227
|
success = false;
|
|
@@ -272,9 +303,10 @@ function saveCached(cacheKey, options) {
|
|
|
272
303
|
* @param options.forceEquip Equipment to force-equip ("equip X").
|
|
273
304
|
* @param options.preventEquip Equipment to prevent equipping ("-equip X").
|
|
274
305
|
* @param options.bonusEquip Equipment to apply a bonus to ("200 bonus X").
|
|
306
|
+
* @returns Whether the maximize call succeeded.
|
|
275
307
|
*/
|
|
276
308
|
export function maximizeCached(objectives, options = {}) {
|
|
277
|
-
const fullOptions =
|
|
309
|
+
const fullOptions = mergeMaximizeOptions(defaultMaximizeOptions, options);
|
|
278
310
|
const { forceEquip, preventEquip, bonusEquip, onlySlot, preventSlot, } = fullOptions;
|
|
279
311
|
// Sort each group in objective to ensure consistent ordering in string
|
|
280
312
|
const objective = [
|
|
@@ -294,12 +326,13 @@ export function maximizeCached(objectives, options = {}) {
|
|
|
294
326
|
applyCached(cacheEntry, fullOptions);
|
|
295
327
|
if (verifyCached(cacheEntry)) {
|
|
296
328
|
logger.info(`Equipped cached ${objective}`);
|
|
297
|
-
return;
|
|
329
|
+
return true;
|
|
298
330
|
}
|
|
299
331
|
logger.warning("Maximize cache application failed, maximizing...");
|
|
300
332
|
}
|
|
301
|
-
maximize(objective, false);
|
|
333
|
+
const result = maximize(objective, false);
|
|
302
334
|
saveCached(objective, fullOptions);
|
|
335
|
+
return result;
|
|
303
336
|
}
|
|
304
337
|
export class Requirement {
|
|
305
338
|
#maximizeParameters;
|
|
@@ -359,9 +392,10 @@ export class Requirement {
|
|
|
359
392
|
}
|
|
360
393
|
/**
|
|
361
394
|
* Runs maximizeCached, using the maximizeParameters and maximizeOptions contained by this requirement.
|
|
395
|
+
* @returns Whether the maximize call succeeded.
|
|
362
396
|
*/
|
|
363
397
|
maximize() {
|
|
364
|
-
maximizeCached(this.maximizeParameters, this.maximizeOptions);
|
|
398
|
+
return maximizeCached(this.maximizeParameters, this.maximizeOptions);
|
|
365
399
|
}
|
|
366
400
|
/**
|
|
367
401
|
* Merges requirements, and then runs maximizeCached on the combined requirement.
|
package/dist/modifier.d.ts
CHANGED
|
@@ -11,3 +11,9 @@ export declare type ModifierValue<T> = T extends BooleanModifier ? boolean : T e
|
|
|
11
11
|
export declare type Modifiers = Partial<{
|
|
12
12
|
[T in BooleanModifier | ClassModifier | EffectModifier | MonsterModifier | NumericModifier | SkillModifier | StatModifier | StringModifier]: ModifierValue<T>;
|
|
13
13
|
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Merge arbitrarily many Modifiers objects into one, summing all numeric modifiers, and ||ing all boolean modifiers.
|
|
16
|
+
* @param modifierss Modifiers objects to be merged together.
|
|
17
|
+
* @returns A single Modifiers object obtained by merging.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeModifiers(...modifierss: Modifiers[]): Modifiers;
|
package/dist/modifier.js
CHANGED
|
@@ -33,3 +33,33 @@ export function get(name, subject) {
|
|
|
33
33
|
return statModifier(subject, name);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Merge two Modifiers objects into one, summing all numeric modifiers, ||ing all boolean modifiers, and otherwise letting the second object overwrite the first.
|
|
38
|
+
* @param modifiers1 Modifiers objects to be merged onto.
|
|
39
|
+
* @param modifiers2 Modifiers object to merge.
|
|
40
|
+
* @returns A single Modifiers object obtained by merging.
|
|
41
|
+
*/
|
|
42
|
+
function pairwiseMerge(modifiers1, modifiers2) {
|
|
43
|
+
const returnValue = { ...modifiers1, ...modifiers2 };
|
|
44
|
+
for (const modifier in modifiers1) {
|
|
45
|
+
if (Array.from(Object.values(modifiers2)).includes(modifier)) {
|
|
46
|
+
if (arrayContains(modifier, numericModifiers)) {
|
|
47
|
+
returnValue[modifier] =
|
|
48
|
+
(modifiers1[modifier] ?? 0) + (modifiers2[modifier] ?? 0);
|
|
49
|
+
}
|
|
50
|
+
if (arrayContains(modifier, booleanModifiers)) {
|
|
51
|
+
returnValue[modifier] =
|
|
52
|
+
(modifiers1[modifier] ?? false) || (modifiers2[modifier] ?? false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return returnValue;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Merge arbitrarily many Modifiers objects into one, summing all numeric modifiers, and ||ing all boolean modifiers.
|
|
60
|
+
* @param modifierss Modifiers objects to be merged together.
|
|
61
|
+
* @returns A single Modifiers object obtained by merging.
|
|
62
|
+
*/
|
|
63
|
+
export function mergeModifiers(...modifierss) {
|
|
64
|
+
return modifierss.reduce((a, b) => pairwiseMerge(a, b), {});
|
|
65
|
+
}
|
package/dist/property.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "core-js/modules/es.object.entries";
|
|
2
2
|
import "core-js/modules/es.object.from-entries";
|
|
3
3
|
import { KnownProperty, PropertyValue } from "./propertyTyping";
|
|
4
|
+
import { NumericProperty } from "./propertyTypes";
|
|
4
5
|
export declare const getString: (property: string, default_?: string | undefined) => string;
|
|
5
6
|
export declare const getCommaSeparated: (property: string, default_?: string[] | undefined) => string[];
|
|
6
7
|
export declare const getBoolean: (property: string, default_?: boolean | undefined) => boolean;
|
|
@@ -45,12 +46,51 @@ export declare function withChoices(choices: {
|
|
|
45
46
|
}, callback: () => void): void;
|
|
46
47
|
export declare function withChoice(choice: number, value: number | string, callback: () => void): void;
|
|
47
48
|
export declare class PropertiesManager {
|
|
48
|
-
properties
|
|
49
|
-
|
|
49
|
+
private properties;
|
|
50
|
+
get storedValues(): Properties;
|
|
51
|
+
/**
|
|
52
|
+
* Sets a collection of properties to the given values, storing the old values.
|
|
53
|
+
* @param propertiesToSet A Properties object, keyed by property name.
|
|
54
|
+
*/
|
|
50
55
|
set(propertiesToSet: Properties): void;
|
|
56
|
+
/**
|
|
57
|
+
* Sets a collection of choice adventure properties to the given values, storing the old values.
|
|
58
|
+
* @param choicesToSet An object keyed by choice adventure number.
|
|
59
|
+
*/
|
|
51
60
|
setChoices(choicesToSet: {
|
|
52
61
|
[choice: number]: number | string;
|
|
53
62
|
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Resets the given properties to their original stored value. Does not delete entries from the manager.
|
|
65
|
+
* @param properties Collection of properties to reset.
|
|
66
|
+
*/
|
|
67
|
+
reset(...properties: KnownProperty[]): void;
|
|
68
|
+
/**
|
|
69
|
+
* Iterates over all stored values, setting each property back to its original stored value. Does not delete entries from the manager.
|
|
70
|
+
*/
|
|
54
71
|
resetAll(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Stops storing the original values of inputted properties.
|
|
74
|
+
* @param properties Properties for the manager to forget.
|
|
75
|
+
*/
|
|
76
|
+
clear(...properties: KnownProperty[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Clears all properties.
|
|
79
|
+
*/
|
|
80
|
+
clearAll(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Increases a numeric property to the given value if necessary.
|
|
83
|
+
* @param property The numeric property we want to potentially raise.
|
|
84
|
+
* @param value The minimum value we want that property to have.
|
|
85
|
+
* @returns Whether we needed to change the property.
|
|
86
|
+
*/
|
|
87
|
+
setMinimumValue(property: NumericProperty, value: number): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Decrease a numeric property to the given value if necessary.
|
|
90
|
+
* @param property The numeric property we want to potentially lower.
|
|
91
|
+
* @param value The maximum value we want that property to have.
|
|
92
|
+
* @returns Whether we needed to change the property.
|
|
93
|
+
*/
|
|
94
|
+
setMaximumValue(property: NumericProperty, value: number): boolean;
|
|
55
95
|
}
|
|
56
96
|
export {};
|
package/dist/property.js
CHANGED
|
@@ -89,10 +89,14 @@ export function withChoice(choice, value, callback) {
|
|
|
89
89
|
withChoices({ [choice]: value }, callback);
|
|
90
90
|
}
|
|
91
91
|
export class PropertiesManager {
|
|
92
|
-
properties;
|
|
93
|
-
|
|
94
|
-
this.properties
|
|
92
|
+
properties = {};
|
|
93
|
+
get storedValues() {
|
|
94
|
+
return this.properties;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Sets a collection of properties to the given values, storing the old values.
|
|
98
|
+
* @param propertiesToSet A Properties object, keyed by property name.
|
|
99
|
+
*/
|
|
96
100
|
set(propertiesToSet) {
|
|
97
101
|
for (const [propertyName, propertyValue] of Object.entries(propertiesToSet)) {
|
|
98
102
|
if (this.properties[propertyName] === undefined) {
|
|
@@ -101,13 +105,75 @@ export class PropertiesManager {
|
|
|
101
105
|
set(propertyName, propertyValue);
|
|
102
106
|
}
|
|
103
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Sets a collection of choice adventure properties to the given values, storing the old values.
|
|
110
|
+
* @param choicesToSet An object keyed by choice adventure number.
|
|
111
|
+
*/
|
|
104
112
|
setChoices(choicesToSet) {
|
|
105
113
|
this.set(Object.fromEntries(Object.entries(choicesToSet).map(([choiceNumber, choiceValue]) => [
|
|
106
114
|
`choiceAdventure${choiceNumber}`,
|
|
107
115
|
choiceValue,
|
|
108
116
|
])));
|
|
109
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Resets the given properties to their original stored value. Does not delete entries from the manager.
|
|
120
|
+
* @param properties Collection of properties to reset.
|
|
121
|
+
*/
|
|
122
|
+
reset(...properties) {
|
|
123
|
+
for (const property of properties) {
|
|
124
|
+
const value = this.properties[property];
|
|
125
|
+
if (value) {
|
|
126
|
+
set(property, value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Iterates over all stored values, setting each property back to its original stored value. Does not delete entries from the manager.
|
|
132
|
+
*/
|
|
110
133
|
resetAll() {
|
|
111
134
|
Object.entries(this.properties).forEach(([propertyName, propertyValue]) => set(propertyName, propertyValue));
|
|
112
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Stops storing the original values of inputted properties.
|
|
138
|
+
* @param properties Properties for the manager to forget.
|
|
139
|
+
*/
|
|
140
|
+
clear(...properties) {
|
|
141
|
+
for (const property of properties) {
|
|
142
|
+
if (this.properties[property]) {
|
|
143
|
+
delete this.properties[property];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Clears all properties.
|
|
149
|
+
*/
|
|
150
|
+
clearAll() {
|
|
151
|
+
this.properties = {};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Increases a numeric property to the given value if necessary.
|
|
155
|
+
* @param property The numeric property we want to potentially raise.
|
|
156
|
+
* @param value The minimum value we want that property to have.
|
|
157
|
+
* @returns Whether we needed to change the property.
|
|
158
|
+
*/
|
|
159
|
+
setMinimumValue(property, value) {
|
|
160
|
+
if (get(property) < value) {
|
|
161
|
+
this.set({ [property]: value });
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Decrease a numeric property to the given value if necessary.
|
|
168
|
+
* @param property The numeric property we want to potentially lower.
|
|
169
|
+
* @param value The maximum value we want that property to have.
|
|
170
|
+
* @returns Whether we needed to change the property.
|
|
171
|
+
*/
|
|
172
|
+
setMaximumValue(property, value) {
|
|
173
|
+
if (get(property) > value) {
|
|
174
|
+
this.set({ [property]: value });
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
113
179
|
}
|