libram 0.8.16 → 0.8.18
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.js +42 -10
- package/dist/ascend.d.ts +1 -12
- package/dist/ascend.js +1 -25
- package/dist/challengePaths/2015/CommunityService.js +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/maximize.d.ts +3 -1
- package/dist/maximize.js +3 -0
- package/dist/moonSign.d.ts +13 -0
- package/dist/moonSign.js +25 -0
- package/dist/property.d.ts +5 -2
- package/dist/property.js +15 -4
- package/dist/propertyTypes.d.ts +3 -3
- package/dist/propertyTypes.js +3 -3
- package/dist/resources/2013/Florist.js +9 -8
- package/dist/resources/2019/CampAway.js +1 -1
- package/dist/resources/2021/CrystalBall.js +1 -1
- package/dist/resources/2023/BurningLeaves.d.ts +3 -2
- package/dist/resources/2023/BurningLeaves.js +16 -10
- package/dist/url.d.ts +35 -0
- package/dist/url.js +67 -0
- package/package.json +1 -1
- package/dist/Path.d.ts +0 -72
- package/dist/Path.js +0 -84
package/dist/Kmail.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractItems, extractMeat, isGiftable, Item, visitUrl, } from "kolmafia";
|
|
2
|
+
import { combineQuery, EMPTY_VALUE, fetchUrl } from "./url";
|
|
2
3
|
import { arrayToCountedMap, chunk } from "./utils";
|
|
3
4
|
export default class Kmail {
|
|
4
5
|
id;
|
|
@@ -32,9 +33,12 @@ export default class Kmail {
|
|
|
32
33
|
* @returns Number of kmails deleted
|
|
33
34
|
*/
|
|
34
35
|
static delete(kmails) {
|
|
35
|
-
const results =
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const results = fetchUrl("messages.php", [
|
|
37
|
+
["the_action", "delete"],
|
|
38
|
+
["box", "Inbox"],
|
|
39
|
+
["pwd", EMPTY_VALUE],
|
|
40
|
+
...kmails.map((k) => [`sel${k.id}`, "on"]),
|
|
41
|
+
]);
|
|
38
42
|
return Number(results.match(/<td>(\d) messages? deleted.<\/td>/)?.[1] ?? 0);
|
|
39
43
|
}
|
|
40
44
|
static _genericSend(to, message, items, meat, chunkSize, constructUrl, successString) {
|
|
@@ -44,10 +48,18 @@ export default class Kmail {
|
|
|
44
48
|
const chunks = chunk(sendableItems, chunkSize);
|
|
45
49
|
// Split the items to be sent into chunks of max 11 item types
|
|
46
50
|
for (const c of chunks.length > 0 ? chunks : [null]) {
|
|
47
|
-
const itemsQuery =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const itemsQuery = {};
|
|
52
|
+
if (c !== null) {
|
|
53
|
+
c.forEach(([item, quantity], i) => {
|
|
54
|
+
itemsQuery[`whichitem${i + 1}`] = item.id;
|
|
55
|
+
itemsQuery[`howmany${i + 1}`] = quantity;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const { path, query } = constructUrl({
|
|
59
|
+
meat: m,
|
|
60
|
+
chunkSize: c?.length ?? 0,
|
|
61
|
+
});
|
|
62
|
+
const r = fetchUrl(path, combineQuery(query, itemsQuery));
|
|
51
63
|
if (r.includes("That player cannot receive Meat or items")) {
|
|
52
64
|
return Kmail.gift(to, message, items, meat);
|
|
53
65
|
}
|
|
@@ -71,7 +83,16 @@ export default class Kmail {
|
|
|
71
83
|
* @returns True if the kmail was successfully sent
|
|
72
84
|
*/
|
|
73
85
|
static send(to, message = "", items = [], meat = 0) {
|
|
74
|
-
return Kmail._genericSend(to, message, items, meat, 11, (meat
|
|
86
|
+
return Kmail._genericSend(to, message, items, meat, 11, ({ meat }) => ({
|
|
87
|
+
path: "sendmessage.php",
|
|
88
|
+
query: {
|
|
89
|
+
action: "send",
|
|
90
|
+
pwd: EMPTY_VALUE,
|
|
91
|
+
towho: to,
|
|
92
|
+
message,
|
|
93
|
+
sendmeat: meat,
|
|
94
|
+
},
|
|
95
|
+
}), ">Message sent.</");
|
|
75
96
|
}
|
|
76
97
|
/**
|
|
77
98
|
* Sends a gift to a player
|
|
@@ -87,8 +108,19 @@ export default class Kmail {
|
|
|
87
108
|
* @returns True if the gift was successfully sent
|
|
88
109
|
*/
|
|
89
110
|
static gift(to, message = "", items = [], meat = 0, insideNote = "") {
|
|
90
|
-
|
|
91
|
-
|
|
111
|
+
return Kmail._genericSend(to, message, items, meat, 3, ({ meat, chunkSize }) => ({
|
|
112
|
+
path: `town_sendgift.php`,
|
|
113
|
+
query: {
|
|
114
|
+
action: "Yep.",
|
|
115
|
+
pwd: EMPTY_VALUE,
|
|
116
|
+
fromwhere: 0,
|
|
117
|
+
note: message,
|
|
118
|
+
insidenote: insideNote,
|
|
119
|
+
towho: to,
|
|
120
|
+
whichpackage: chunkSize,
|
|
121
|
+
sendmeat: meat,
|
|
122
|
+
},
|
|
123
|
+
}), ">Package sent.</");
|
|
92
124
|
}
|
|
93
125
|
constructor(rawKmail) {
|
|
94
126
|
const date = new Date(rawKmail.localtime);
|
package/dist/ascend.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Skill, Class, Item, Path, MafiaClass } from "kolmafia";
|
|
2
|
+
import { MoonSign } from "./moonSign";
|
|
2
3
|
import { ChateauMantegna } from "./resources";
|
|
3
4
|
export declare enum Lifestyle {
|
|
4
5
|
casual = 1,
|
|
@@ -30,19 +31,7 @@ export declare class AscensionPrepError extends Error {
|
|
|
30
31
|
cause: string;
|
|
31
32
|
constructor(cause: string, original?: MafiaClass | string);
|
|
32
33
|
}
|
|
33
|
-
declare const MoonSigns: readonly ["Mongoose", "Wallaby", "Vole", "Platypus", "Opossum", "Marmot", "Wombat", "Blender", "Packrat"];
|
|
34
|
-
declare type MoonSign = typeof MoonSigns[number];
|
|
35
34
|
declare type InputMoonSign = number | Lowercase<MoonSign> | "degrassi" | "degrassi knoll" | "friendly degrassi knoll" | "knoll" | "canada" | "canadia" | "little canadia" | "gnomads" | "gnomish" | "gnomish gnomads camp";
|
|
36
|
-
/**
|
|
37
|
-
* @param moon Moon sign name
|
|
38
|
-
* @returns Moon sign id else 0
|
|
39
|
-
*/
|
|
40
|
-
export declare function signNameToId(moon: MoonSign): number;
|
|
41
|
-
/**
|
|
42
|
-
* @param id Moon sign id
|
|
43
|
-
* @returns Name of moon sign else "None"
|
|
44
|
-
*/
|
|
45
|
-
export declare function signIdToName(id: number): MoonSign | "None";
|
|
46
35
|
/**
|
|
47
36
|
* Hops the gash, perming no skills by default
|
|
48
37
|
*
|
package/dist/ascend.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Skill, Class, eudoraItem, getCampground, Item, Path, use, visitUrl, xpath, haveSkill, getPermedSkills, toSkill, } from "kolmafia";
|
|
2
|
+
import { signNameToId } from "./moonSign";
|
|
2
3
|
import { get } from "./property";
|
|
3
4
|
import { ChateauMantegna } from "./resources";
|
|
4
5
|
import { $item, $items, $stat } from "./template-string";
|
|
@@ -102,31 +103,6 @@ export class AscensionPrepError extends Error {
|
|
|
102
103
|
this.cause = cause;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
const MoonSigns = [
|
|
106
|
-
"Mongoose",
|
|
107
|
-
"Wallaby",
|
|
108
|
-
"Vole",
|
|
109
|
-
"Platypus",
|
|
110
|
-
"Opossum",
|
|
111
|
-
"Marmot",
|
|
112
|
-
"Wombat",
|
|
113
|
-
"Blender",
|
|
114
|
-
"Packrat",
|
|
115
|
-
];
|
|
116
|
-
/**
|
|
117
|
-
* @param moon Moon sign name
|
|
118
|
-
* @returns Moon sign id else 0
|
|
119
|
-
*/
|
|
120
|
-
export function signNameToId(moon) {
|
|
121
|
-
return MoonSigns.indexOf(moon) + 1;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* @param id Moon sign id
|
|
125
|
-
* @returns Name of moon sign else "None"
|
|
126
|
-
*/
|
|
127
|
-
export function signIdToName(id) {
|
|
128
|
-
return MoonSigns[id - 1] || "None";
|
|
129
|
-
}
|
|
130
106
|
/**
|
|
131
107
|
* Determine the id of the appropriate moon sign.
|
|
132
108
|
*
|
|
@@ -277,13 +277,15 @@ export default class CommunityService {
|
|
|
277
277
|
}, new Requirement(["Spell Damage", "Spell Damage Percent"], {}));
|
|
278
278
|
static Noncombat = new CommunityService(8, "Non-Combat", "Be a Living Statue", (...effects) => {
|
|
279
279
|
const noncombatRate = -1 * hypotheticalModifier("Combat Rate", ...effects);
|
|
280
|
-
const unsoftcappedRate =
|
|
280
|
+
const unsoftcappedRate = (rate) => rate > 25 ? 25 + (rate - 25) * 5 : rate;
|
|
281
281
|
const currentFamiliarModifier = -1 *
|
|
282
282
|
numericModifier(myFamiliar(), "Combat Rate", familiarWeight(myFamiliar()) + numericModifier("Familiar Weight"), equippedItem($slot `familiar`));
|
|
283
283
|
const newFamiliarModifier = -1 *
|
|
284
284
|
numericModifier(myFamiliar(), "Combat Rate", familiarWeight(myFamiliar()) +
|
|
285
|
-
hypotheticalModifier("
|
|
286
|
-
const adjustedRate = unsoftcappedRate -
|
|
285
|
+
hypotheticalModifier("Familiar Weight", ...effects), equippedItem($slot `familiar`));
|
|
286
|
+
const adjustedRate = unsoftcappedRate(noncombatRate) -
|
|
287
|
+
unsoftcappedRate(currentFamiliarModifier) +
|
|
288
|
+
unsoftcappedRate(newFamiliarModifier);
|
|
287
289
|
return 60 - 3 * Math.floor(adjustedRate / 5);
|
|
288
290
|
}, new Requirement(["-combat"], {}));
|
|
289
291
|
static BoozeDrop = new CommunityService(9, "Item Drop", "Make Margaritas", (...effects) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -10,12 +10,12 @@ export * from "./lib";
|
|
|
10
10
|
export * from "./maximize";
|
|
11
11
|
export { numericModifiers, statModifiers, booleanModifiers, classModifiers, monsterModifiers, effectModifiers, skillModifiers, } from "./modifierTypes";
|
|
12
12
|
export * from "./mood";
|
|
13
|
+
export * from "./moonSign";
|
|
13
14
|
export * from "./propertyTyping";
|
|
14
15
|
export * from "./resources";
|
|
15
16
|
export * from "./since";
|
|
16
17
|
export * from "./template-string";
|
|
17
18
|
export { default as Kmail } from "./Kmail";
|
|
18
|
-
export * from "./Path";
|
|
19
19
|
export { default as logger } from "./logger";
|
|
20
20
|
export * as console from "./console";
|
|
21
21
|
export * as property from "./property";
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,12 @@ export * from "./lib";
|
|
|
10
10
|
export * from "./maximize";
|
|
11
11
|
export { numericModifiers, statModifiers, booleanModifiers, classModifiers, monsterModifiers, effectModifiers, skillModifiers, } from "./modifierTypes";
|
|
12
12
|
export * from "./mood";
|
|
13
|
+
export * from "./moonSign";
|
|
13
14
|
export * from "./propertyTyping";
|
|
14
15
|
export * from "./resources";
|
|
15
16
|
export * from "./since";
|
|
16
17
|
export * from "./template-string";
|
|
17
18
|
export { default as Kmail } from "./Kmail";
|
|
18
|
-
export * from "./Path";
|
|
19
19
|
export { default as logger } from "./logger";
|
|
20
20
|
export * as console from "./console";
|
|
21
21
|
export * as property from "./property";
|
package/dist/maximize.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function mergeMaximizeOptions(defaultOptions: MaximizeOptions, ad
|
|
|
29
29
|
* @param options.bonusEquip Equipment to apply a bonus to ("200 bonus X").
|
|
30
30
|
*/
|
|
31
31
|
export declare function setDefaultMaximizeOptions(options: Partial<MaximizeOptions>): void;
|
|
32
|
-
declare const modeableCommands: readonly ["backupcamera", "umbrella", "snowsuit", "edpiece", "retrocape", "parka"];
|
|
32
|
+
declare const modeableCommands: readonly ["backupcamera", "umbrella", "snowsuit", "edpiece", "retrocape", "parka", "jillcandle"];
|
|
33
33
|
export declare type Mode = typeof modeableCommands[number];
|
|
34
34
|
export declare type Modes = Partial<{
|
|
35
35
|
[x in Mode]: string;
|
|
@@ -41,6 +41,7 @@ export declare const modeableItems: {
|
|
|
41
41
|
readonly edpiece: Item;
|
|
42
42
|
readonly retrocape: Item;
|
|
43
43
|
readonly parka: Item;
|
|
44
|
+
readonly jillcandle: Item;
|
|
44
45
|
};
|
|
45
46
|
export declare const modeableState: {
|
|
46
47
|
readonly backupcamera: () => string;
|
|
@@ -49,6 +50,7 @@ export declare const modeableState: {
|
|
|
49
50
|
readonly edpiece: () => string;
|
|
50
51
|
readonly retrocape: () => string;
|
|
51
52
|
readonly parka: () => string;
|
|
53
|
+
readonly jillcandle: () => string;
|
|
52
54
|
};
|
|
53
55
|
/**
|
|
54
56
|
* Get set of current modes for modeables
|
package/dist/maximize.js
CHANGED
|
@@ -69,6 +69,7 @@ const modeableCommands = [
|
|
|
69
69
|
"edpiece",
|
|
70
70
|
"retrocape",
|
|
71
71
|
"parka",
|
|
72
|
+
"jillcandle",
|
|
72
73
|
];
|
|
73
74
|
export const modeableItems = {
|
|
74
75
|
backupcamera: $item `backup camera`,
|
|
@@ -77,6 +78,7 @@ export const modeableItems = {
|
|
|
77
78
|
edpiece: $item `The Crown of Ed the Undying`,
|
|
78
79
|
retrocape: $item `unwrapped knock-off retro superhero cape`,
|
|
79
80
|
parka: $item `Jurassic Parka`,
|
|
81
|
+
jillcandle: $item `LED candle`,
|
|
80
82
|
};
|
|
81
83
|
export const modeableState = {
|
|
82
84
|
backupcamera: () => getProperty("backupCameraMode"),
|
|
@@ -87,6 +89,7 @@ export const modeableState = {
|
|
|
87
89
|
" " +
|
|
88
90
|
getProperty("retroCapeWashingInstructions"),
|
|
89
91
|
parka: () => getProperty("parkaMode"),
|
|
92
|
+
jillcandle: () => getProperty("ledCandleMode"),
|
|
90
93
|
};
|
|
91
94
|
/**
|
|
92
95
|
* Get set of current modes for modeables
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const MoonSigns: readonly ["Mongoose", "Wallaby", "Vole", "Platypus", "Opossum", "Marmot", "Wombat", "Blender", "Packrat"];
|
|
2
|
+
export declare type MoonSign = typeof MoonSigns[number];
|
|
3
|
+
/**
|
|
4
|
+
* @param moon Moon sign name
|
|
5
|
+
* @returns Moon sign id else 0
|
|
6
|
+
*/
|
|
7
|
+
export declare function signNameToId(moon: MoonSign): number;
|
|
8
|
+
/**
|
|
9
|
+
* @param id Moon sign id
|
|
10
|
+
* @returns Name of moon sign else "None"
|
|
11
|
+
*/
|
|
12
|
+
export declare function signIdToName(id: number): MoonSign | "None";
|
|
13
|
+
export {};
|
package/dist/moonSign.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const MoonSigns = [
|
|
2
|
+
"Mongoose",
|
|
3
|
+
"Wallaby",
|
|
4
|
+
"Vole",
|
|
5
|
+
"Platypus",
|
|
6
|
+
"Opossum",
|
|
7
|
+
"Marmot",
|
|
8
|
+
"Wombat",
|
|
9
|
+
"Blender",
|
|
10
|
+
"Packrat",
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* @param moon Moon sign name
|
|
14
|
+
* @returns Moon sign id else 0
|
|
15
|
+
*/
|
|
16
|
+
export function signNameToId(moon) {
|
|
17
|
+
return MoonSigns.indexOf(moon) + 1;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param id Moon sign id
|
|
21
|
+
* @returns Name of moon sign else "None"
|
|
22
|
+
*/
|
|
23
|
+
export function signIdToName(id) {
|
|
24
|
+
return MoonSigns[id - 1] || "None";
|
|
25
|
+
}
|
package/dist/property.d.ts
CHANGED
|
@@ -76,7 +76,9 @@ export declare function increment(property: NumericProperty, delta?: number, max
|
|
|
76
76
|
export declare function decrement(property: NumericProperty, delta?: number, min?: number): number;
|
|
77
77
|
declare type Properties = Partial<{
|
|
78
78
|
[P in KnownProperty]: unknown;
|
|
79
|
-
}
|
|
79
|
+
}> & {
|
|
80
|
+
[x in string]: unknown;
|
|
81
|
+
};
|
|
80
82
|
/**
|
|
81
83
|
* Sets the value of a set of mafia properties
|
|
82
84
|
*
|
|
@@ -120,6 +122,7 @@ export declare function withChoices<T>(choices: {
|
|
|
120
122
|
*/
|
|
121
123
|
export declare function withChoice<T>(choice: number, value: number | string, callback: () => T): T;
|
|
122
124
|
export declare class PropertiesManager {
|
|
125
|
+
private static EMPTY_PREFERENCE;
|
|
123
126
|
private properties;
|
|
124
127
|
get storedValues(): Properties;
|
|
125
128
|
/**
|
|
@@ -158,7 +161,7 @@ export declare class PropertiesManager {
|
|
|
158
161
|
*
|
|
159
162
|
* @param properties Properties for the manager to forget.
|
|
160
163
|
*/
|
|
161
|
-
clear(...properties: KnownProperty[]): void;
|
|
164
|
+
clear(...properties: (KnownProperty | string)[]): void;
|
|
162
165
|
/**
|
|
163
166
|
* Clears all properties.
|
|
164
167
|
*/
|
package/dist/property.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bounty, Class, Coinmaster, Effect, Element, Familiar, getProperty, Item, Location, Monster, Phylum, Servant, setProperty, Skill, Slot, Stat, Thrall, toBounty, toClass, toCoinmaster, toEffect, toElement, toFamiliar, toItem, toLocation, toMonster, toPhylum, toServant, toSkill, toSlot, toStat, toThrall, } from "kolmafia";
|
|
1
|
+
import { Bounty, Class, Coinmaster, Effect, Element, Familiar, getProperty, Item, Location, Monster, Phylum, propertyExists, removeProperty, Servant, setProperty, Skill, Slot, Stat, Thrall, toBounty, toClass, toCoinmaster, toEffect, toElement, toFamiliar, toItem, toLocation, toMonster, toPhylum, toServant, toSkill, toSlot, toStat, toThrall, } from "kolmafia";
|
|
2
2
|
import { isBooleanProperty, isFamiliarProperty, isLocationProperty, isMonsterProperty, isNumericOrStringProperty, isNumericProperty, isPhylumProperty, isStatProperty, isStringProperty, } from "./propertyTyping";
|
|
3
3
|
const createPropertyGetter = (transform) => (property, default_) => {
|
|
4
4
|
const value = getProperty(property);
|
|
@@ -204,6 +204,7 @@ export function withChoice(choice, value, callback) {
|
|
|
204
204
|
return withChoices({ [choice]: value }, callback);
|
|
205
205
|
}
|
|
206
206
|
export class PropertiesManager {
|
|
207
|
+
static EMPTY_PREFERENCE = Symbol("empty preference");
|
|
207
208
|
properties = {};
|
|
208
209
|
get storedValues() {
|
|
209
210
|
return this.properties;
|
|
@@ -215,8 +216,10 @@ export class PropertiesManager {
|
|
|
215
216
|
*/
|
|
216
217
|
set(propertiesToSet) {
|
|
217
218
|
for (const [propertyName, propertyValue] of Object.entries(propertiesToSet)) {
|
|
218
|
-
if (this.properties
|
|
219
|
-
this.properties[propertyName] =
|
|
219
|
+
if (!(propertyName in this.properties)) {
|
|
220
|
+
this.properties[propertyName] = propertyExists(propertyName)
|
|
221
|
+
? get(propertyName)
|
|
222
|
+
: PropertiesManager.EMPTY_PREFERENCE;
|
|
220
223
|
}
|
|
221
224
|
set(propertyName, propertyValue);
|
|
222
225
|
}
|
|
@@ -248,10 +251,18 @@ export class PropertiesManager {
|
|
|
248
251
|
*/
|
|
249
252
|
reset(...properties) {
|
|
250
253
|
for (const property of properties) {
|
|
254
|
+
if (!(property in this.properties))
|
|
255
|
+
continue;
|
|
251
256
|
const value = this.properties[property];
|
|
252
|
-
if (value) {
|
|
257
|
+
if (value === PropertiesManager.EMPTY_PREFERENCE) {
|
|
258
|
+
removeProperty(property);
|
|
259
|
+
}
|
|
260
|
+
else if (value) {
|
|
253
261
|
set(property, value);
|
|
254
262
|
}
|
|
263
|
+
else {
|
|
264
|
+
set(property, "");
|
|
265
|
+
}
|
|
255
266
|
}
|
|
256
267
|
}
|
|
257
268
|
/**
|