libram 0.7.2 → 0.7.3
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.js
CHANGED
|
@@ -14,7 +14,7 @@ export function getMacroId(name = MACRO_NAME) {
|
|
|
14
14
|
if (macroMatches.length === 0) {
|
|
15
15
|
visitUrl("account_combatmacros.php?action=new");
|
|
16
16
|
const newMacroText = visitUrl(`account_combatmacros.php?macroid=0&name=${name}¯otext=abort&action=save`);
|
|
17
|
-
return parseInt(xpath(newMacroText,
|
|
17
|
+
return parseInt(xpath(newMacroText, `//input[@name=${name}]/@value`)[0], 10);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
return parseInt(macroMatches[0], 10);
|
|
@@ -167,6 +167,7 @@ export class Macro {
|
|
|
167
167
|
const id = Macro.cachedMacroIds.get(name) ?? getMacroId(name);
|
|
168
168
|
visitUrl(`account_combatmacros.php?macroid=${id}&action=edit&what=Delete&confirm=1`);
|
|
169
169
|
Macro.cachedAutoAttacks.delete(name);
|
|
170
|
+
Macro.cachedMacroIds.delete(name);
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
/**
|
package/dist/maximize.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare type MaximizeOptions = {
|
|
|
9
9
|
onlySlot: Slot[];
|
|
10
10
|
preventSlot: Slot[];
|
|
11
11
|
forceUpdate: boolean;
|
|
12
|
+
modes: Modes;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
@@ -20,6 +21,29 @@ export declare type MaximizeOptions = {
|
|
|
20
21
|
* @param options.bonusEquip Equipment to apply a bonus to ("200 bonus X").
|
|
21
22
|
*/
|
|
22
23
|
export declare function setDefaultMaximizeOptions(options: Partial<MaximizeOptions>): void;
|
|
24
|
+
declare const modeableCommands: readonly ["backupcamera", "umbrella", "snowsuit", "edpiece", "retrocape", "parka"];
|
|
25
|
+
export declare type Mode = typeof modeableCommands[number];
|
|
26
|
+
export declare type Modes = Partial<{
|
|
27
|
+
[x in Mode]: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const modeableItems: {
|
|
30
|
+
readonly backupcamera: Item;
|
|
31
|
+
readonly umbrella: Item;
|
|
32
|
+
readonly snowsuit: Item;
|
|
33
|
+
readonly edpiece: Item;
|
|
34
|
+
readonly retrocape: Item;
|
|
35
|
+
readonly parka: Item;
|
|
36
|
+
};
|
|
37
|
+
export declare const modeableState: {
|
|
38
|
+
readonly backupcamera: () => string;
|
|
39
|
+
readonly umbrella: () => string;
|
|
40
|
+
readonly snowsuit: () => string;
|
|
41
|
+
readonly edpiece: () => string;
|
|
42
|
+
readonly retrocape: () => string;
|
|
43
|
+
readonly parka: () => string;
|
|
44
|
+
};
|
|
45
|
+
export declare function getCurrentModes(): Modes;
|
|
46
|
+
export declare function applyModes(modes: Modes): void;
|
|
23
47
|
/**
|
|
24
48
|
* Run the maximizer, but only if the objective and certain pieces of game state haven't changed since it was last run.
|
|
25
49
|
* @param objectives Objectives to maximize for.
|
|
@@ -63,3 +87,4 @@ export declare class Requirement {
|
|
|
63
87
|
*/
|
|
64
88
|
static maximize(...requirements: Requirement[]): void;
|
|
65
89
|
}
|
|
90
|
+
export {};
|
package/dist/maximize.js
CHANGED
|
@@ -29,6 +29,7 @@ function mergeMaximizeOptions(defaultOptions, addendums) {
|
|
|
29
29
|
...(addendums.preventSlot ?? []),
|
|
30
30
|
],
|
|
31
31
|
forceUpdate: addendums.forceUpdate ?? defaultOptions.forceUpdate,
|
|
32
|
+
modes: { ...defaultOptions.modes, ...(addendums.modes ?? {}) },
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
const defaultMaximizeOptions = {
|
|
@@ -41,6 +42,7 @@ const defaultMaximizeOptions = {
|
|
|
41
42
|
onlySlot: [],
|
|
42
43
|
preventSlot: [],
|
|
43
44
|
forceUpdate: false,
|
|
45
|
+
modes: {},
|
|
44
46
|
};
|
|
45
47
|
/**
|
|
46
48
|
*
|
|
@@ -62,7 +64,7 @@ const modeableCommands = [
|
|
|
62
64
|
"retrocape",
|
|
63
65
|
"parka",
|
|
64
66
|
];
|
|
65
|
-
const modeableItems = {
|
|
67
|
+
export const modeableItems = {
|
|
66
68
|
backupcamera: $item `backup camera`,
|
|
67
69
|
umbrella: $item `unbreakable umbrella`,
|
|
68
70
|
snowsuit: $item `Snow Suit`,
|
|
@@ -70,7 +72,7 @@ const modeableItems = {
|
|
|
70
72
|
retrocape: $item `unwrapped knock-off retro superhero cape`,
|
|
71
73
|
parka: $item `Jurassic Parka`,
|
|
72
74
|
};
|
|
73
|
-
const modeableState = {
|
|
75
|
+
export const modeableState = {
|
|
74
76
|
backupcamera: () => getProperty("backupCameraMode"),
|
|
75
77
|
umbrella: () => getProperty("umbrellaState"),
|
|
76
78
|
snowsuit: () => getProperty("snowsuit"),
|
|
@@ -80,7 +82,7 @@ const modeableState = {
|
|
|
80
82
|
getProperty("retroCapeWashingInstructions"),
|
|
81
83
|
parka: () => getProperty("parkaMode"),
|
|
82
84
|
};
|
|
83
|
-
function getCurrentModes() {
|
|
85
|
+
export function getCurrentModes() {
|
|
84
86
|
const modes = {};
|
|
85
87
|
for (const key of modeableCommands) {
|
|
86
88
|
if (haveEquipped(modeableItems[key])) {
|
|
@@ -89,7 +91,7 @@ function getCurrentModes() {
|
|
|
89
91
|
}
|
|
90
92
|
return modes;
|
|
91
93
|
}
|
|
92
|
-
function applyModes(modes) {
|
|
94
|
+
export function applyModes(modes) {
|
|
93
95
|
for (const command of modeableCommands) {
|
|
94
96
|
if (haveEquipped(modeableItems[command])) {
|
|
95
97
|
if (modeableState[command]() !== modes[command]) {
|
|
@@ -247,7 +249,7 @@ function applyCached(entry, options) {
|
|
|
247
249
|
entry.rider.get($item `Buddy Bjorn`)) {
|
|
248
250
|
bjornifyFamiliar(entry.rider.get($item `Buddy Bjorn`) || $familiar.none);
|
|
249
251
|
}
|
|
250
|
-
applyModes(entry.modes);
|
|
252
|
+
applyModes({ ...entry.modes, ...options.modes });
|
|
251
253
|
}
|
|
252
254
|
const slotStructure = [
|
|
253
255
|
$slots `hat`,
|
|
@@ -335,7 +337,7 @@ function saveCached(cacheKey, options) {
|
|
|
335
337
|
rider.delete($item `Crown of Thrones`);
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
|
-
const entry = new CacheEntry(equipment, rider, myFamiliar(), canEquipItemCount(), getCurrentModes());
|
|
340
|
+
const entry = new CacheEntry(equipment, rider, myFamiliar(), canEquipItemCount(), { ...getCurrentModes(), ...options.modes });
|
|
339
341
|
cachedObjectives[cacheKey] = entry;
|
|
340
342
|
if (options.useOutfitCaching) {
|
|
341
343
|
const outfitName = outfitCache.insert(entry);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "core-js/modules/es.object.values";
|
|
2
|
-
import { autosellPrice, canInteract, cliExecute, getFuel, getWorkshed, haveEffect, historicalAge, historicalPrice, isNpcItem, Item, itemAmount, mallPrice, mallPrices,
|
|
2
|
+
import { autosellPrice, buy, canInteract, cliExecute, getFuel, getWorkshed, haveEffect, historicalAge, historicalPrice, isNpcItem, Item, itemAmount, mallPrice, mallPrices, toInt, visitUrl, } from "kolmafia";
|
|
3
3
|
import { getAverageAdventures, have as haveItem } from "../../lib";
|
|
4
|
-
import { PropertiesManager } from "../../property";
|
|
5
4
|
import { $effect, $item, $items } from "../../template-string";
|
|
6
5
|
import { clamp } from "../../utils";
|
|
7
6
|
var PriceAge;
|
|
@@ -119,7 +118,6 @@ export function insertFuel(it, quantity = 1) {
|
|
|
119
118
|
export function fillTo(targetUnits) {
|
|
120
119
|
if (!installed())
|
|
121
120
|
return false;
|
|
122
|
-
const manager = new PropertiesManager();
|
|
123
121
|
while (getFuel() < targetUnits) {
|
|
124
122
|
const remaining = targetUnits - getFuel();
|
|
125
123
|
// if in Hardcore/ronin, skip the price calculation and just use soda bread
|
|
@@ -127,18 +125,16 @@ export function fillTo(targetUnits) {
|
|
|
127
125
|
? getBestFuels(remaining)
|
|
128
126
|
: [$item `loaf of soda bread`, undefined];
|
|
129
127
|
const count = Math.ceil(targetUnits / getAverageAdventures(bestFuel));
|
|
128
|
+
let ceiling = undefined;
|
|
130
129
|
if (secondBest) {
|
|
131
130
|
const efficiencyOfSecondBest = mallPrice(secondBest) / getAverageAdventures(secondBest);
|
|
132
|
-
|
|
133
|
-
manager.setMaximumValue("autoBuyPriceLimit", ceiling);
|
|
131
|
+
ceiling = Math.ceil(efficiencyOfSecondBest * getAverageAdventures(bestFuel));
|
|
134
132
|
}
|
|
135
|
-
|
|
133
|
+
ceiling ? buy(count, bestFuel, ceiling) : buy(count, bestFuel);
|
|
136
134
|
if (!insertFuel(bestFuel, Math.min(itemAmount(bestFuel), count))) {
|
|
137
|
-
manager.resetAll();
|
|
138
135
|
throw new Error("Failed to fuel Asdon Martin.");
|
|
139
136
|
}
|
|
140
137
|
}
|
|
141
|
-
manager.resetAll();
|
|
142
138
|
return getFuel() >= targetUnits;
|
|
143
139
|
}
|
|
144
140
|
function fillWithBestInventoryItem(targetUnits) {
|
|
@@ -47,7 +47,7 @@ export function sendTo(target, upgrade = true) {
|
|
|
47
47
|
return null;
|
|
48
48
|
runChoice(2, `heythereprogrammer=${location.id}`);
|
|
49
49
|
if (handlingChoice())
|
|
50
|
-
|
|
50
|
+
visitUrl("main.php");
|
|
51
51
|
return location;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -59,7 +59,7 @@ export function upgrade() {
|
|
|
59
59
|
const canUpgrade = availableChoiceOptions()[1] !== undefined;
|
|
60
60
|
if (canUpgrade)
|
|
61
61
|
runChoice(1);
|
|
62
|
-
|
|
62
|
+
visitUrl("main.php");
|
|
63
63
|
return canUpgrade;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -69,7 +69,7 @@ export function availableLocations() {
|
|
|
69
69
|
if (!available())
|
|
70
70
|
return [];
|
|
71
71
|
const pageHtml = use();
|
|
72
|
-
|
|
72
|
+
visitUrl("main.php");
|
|
73
73
|
return checkLocations(pageHtml);
|
|
74
74
|
}
|
|
75
75
|
/**
|