libram 0.4.2 → 0.4.6
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/Clan.js +7 -4
- package/dist/Copier.js +5 -1
- package/dist/Kmail.js +18 -12
- package/dist/Path.js +9 -0
- package/dist/combat.d.ts +22 -11
- package/dist/combat.js +74 -19
- package/dist/diet/index.d.ts +9 -0
- package/dist/diet/index.js +191 -88
- package/dist/diet/knapsack.js +16 -2
- package/dist/freerun.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/lib.d.ts +2 -0
- package/dist/lib.js +22 -2
- package/dist/logger.js +1 -3
- package/dist/maximize.js +12 -12
- package/dist/mood.d.ts +5 -0
- package/dist/mood.js +43 -15
- package/dist/property.js +5 -1
- package/dist/propertyTypes.d.ts +5 -4
- package/dist/propertyTyping.d.ts +4 -3
- package/dist/propertyTyping.js +4 -0
- package/dist/resources/2010/CrownOfThrones.d.ts +3 -3
- package/dist/resources/2010/CrownOfThrones.js +7 -7
- package/dist/resources/2013/Florist.js +5 -0
- package/dist/resources/2014/DNALab.d.ts +47 -0
- package/dist/resources/2014/DNALab.js +154 -0
- package/dist/resources/2015/MayoClinic.d.ts +2 -0
- package/dist/resources/2015/MayoClinic.js +8 -2
- package/dist/resources/2017/AsdonMartin.d.ts +27 -0
- package/dist/resources/2017/AsdonMartin.js +80 -0
- package/dist/resources/2019/Snapper.js +2 -3
- package/dist/resources/2020/Guzzlr.d.ts +3 -0
- package/dist/resources/2020/Guzzlr.js +14 -1
- package/dist/resources/LibramSummon.js +2 -2
- package/dist/resources/index.d.ts +3 -1
- package/dist/resources/index.js +3 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +12 -1
- package/package.json +14 -8
package/dist/Clan.js
CHANGED
|
@@ -9,6 +9,7 @@ import { getFoldGroup } from "./lib";
|
|
|
9
9
|
import logger from "./logger";
|
|
10
10
|
import { arrayToCountedMap, countedMapToArray, countedMapToString, notNull, parseNumber, } from "./utils";
|
|
11
11
|
export class ClanError extends Error {
|
|
12
|
+
reason;
|
|
12
13
|
constructor(message, reason) {
|
|
13
14
|
super(message);
|
|
14
15
|
this.reason = reason;
|
|
@@ -38,10 +39,8 @@ const toPlayerId = (player) => typeof player === "string" ? getPlayerId(player)
|
|
|
38
39
|
const LOG_FAX_PATTERN = /(\d{2}\/\d{2}\/\d{2}, \d{2}:\d{2}(?:AM|PM): )<a [^>]+>([^<]+)<\/a>(?: faxed in a (?<monster>.*?))<br>/;
|
|
39
40
|
const WHITELIST_DEGREE_PATTERN = /(?<name>.*?) \(°(?<degree>\d+)\)/;
|
|
40
41
|
export class Clan {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.name = name;
|
|
44
|
-
}
|
|
42
|
+
id;
|
|
43
|
+
name;
|
|
45
44
|
static _join(id) {
|
|
46
45
|
const result = visitUrl(`showclan.php?recruiter=1&whichclan=${id}&pwd&whichclan=${id}&action=joinclan&apply=Apply+to+this+Clan&confirm=on`);
|
|
47
46
|
if (!result.includes("clanhalltop.gif")) {
|
|
@@ -143,6 +142,10 @@ export class Clan {
|
|
|
143
142
|
return new Clan(id, name);
|
|
144
143
|
});
|
|
145
144
|
}
|
|
145
|
+
constructor(id, name) {
|
|
146
|
+
this.id = id;
|
|
147
|
+
this.name = name;
|
|
148
|
+
}
|
|
146
149
|
/**
|
|
147
150
|
* Join clan
|
|
148
151
|
*/
|
package/dist/Copier.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export class Copier {
|
|
2
|
+
couldCopy;
|
|
3
|
+
prepare;
|
|
4
|
+
canCopy;
|
|
5
|
+
copiedMonster;
|
|
6
|
+
fightCopy = null;
|
|
2
7
|
constructor(couldCopy, prepare, canCopy, copiedMonster, fightCopy) {
|
|
3
|
-
this.fightCopy = null;
|
|
4
8
|
this.couldCopy = couldCopy;
|
|
5
9
|
this.prepare = prepare;
|
|
6
10
|
this.canCopy = canCopy;
|
package/dist/Kmail.js
CHANGED
|
@@ -2,18 +2,12 @@ import "core-js/modules/es.object.entries";
|
|
|
2
2
|
import { extractItems, extractMeat, isGiftable, toInt, visitUrl, } from "kolmafia";
|
|
3
3
|
import { arrayToCountedMap, chunk } from "./utils";
|
|
4
4
|
export default class Kmail {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.date = date;
|
|
12
|
-
this.type = rawKmail.type;
|
|
13
|
-
this.senderId = Number(rawKmail.fromid);
|
|
14
|
-
this.senderName = rawKmail.fromname;
|
|
15
|
-
this.rawMessage = rawKmail.message;
|
|
16
|
-
}
|
|
5
|
+
id;
|
|
6
|
+
date;
|
|
7
|
+
type;
|
|
8
|
+
senderId;
|
|
9
|
+
senderName;
|
|
10
|
+
rawMessage;
|
|
17
11
|
/**
|
|
18
12
|
* Parses a kmail from KoL's native format
|
|
19
13
|
*
|
|
@@ -99,6 +93,18 @@ export default class Kmail {
|
|
|
99
93
|
const baseUrl = `town_sendgift.php?action=Yep.&pwd&fromwhere=0¬e=${message}&insidenote=${insideNote}&towho=${to}`;
|
|
100
94
|
return Kmail._genericSend(to, message, items, meat, 3, (m, itemsQuery, chunkSize) => `${baseUrl}&whichpackage=${chunkSize}${itemsQuery ? `&${itemsQuery}` : ""}&sendmeat=${m}`, ">Package sent.</");
|
|
101
95
|
}
|
|
96
|
+
constructor(rawKmail) {
|
|
97
|
+
const date = new Date(rawKmail.localtime);
|
|
98
|
+
// Date come from KoL formatted with YY and so will be parsed 19YY, which is wrong.
|
|
99
|
+
// We can safely add 100 because if 19YY was a leap year, 20YY will be too!
|
|
100
|
+
date.setFullYear(date.getFullYear() + 100);
|
|
101
|
+
this.id = Number(rawKmail.id);
|
|
102
|
+
this.date = date;
|
|
103
|
+
this.type = rawKmail.type;
|
|
104
|
+
this.senderId = Number(rawKmail.fromid);
|
|
105
|
+
this.senderName = rawKmail.fromname;
|
|
106
|
+
this.rawMessage = rawKmail.message;
|
|
107
|
+
}
|
|
102
108
|
/**
|
|
103
109
|
* Delete the kmail
|
|
104
110
|
*
|
package/dist/Path.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { $classes } from "./template-string";
|
|
2
2
|
export class Path {
|
|
3
|
+
name;
|
|
4
|
+
id;
|
|
5
|
+
hasAllPerms; //here, we define avatar-ness around being its own class
|
|
6
|
+
hasCampground;
|
|
7
|
+
hasTerrarium;
|
|
8
|
+
stomachSize;
|
|
9
|
+
liverSize; //Defined as the lowest inebriety that makes you unable to drink more, just to make it fifteens across the board
|
|
10
|
+
spleenSize;
|
|
11
|
+
classes;
|
|
3
12
|
/**
|
|
4
13
|
*
|
|
5
14
|
* @param name Name of path
|
package/dist/combat.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ declare type SkillOrName = Skill | string;
|
|
|
10
10
|
declare type Constructor<T> = {
|
|
11
11
|
new (): T;
|
|
12
12
|
};
|
|
13
|
+
export declare class InvalidMacroError extends Error {
|
|
14
|
+
}
|
|
13
15
|
/**
|
|
14
16
|
* BALLS macro builder for direct submission to KoL.
|
|
15
17
|
* Create a new macro with `new Macro()` and add steps using the instance methods.
|
|
@@ -84,14 +86,14 @@ export declare class Macro {
|
|
|
84
86
|
* @param ifTrue Continuation if the condition is true.
|
|
85
87
|
* @returns {Macro} This object itself.
|
|
86
88
|
*/
|
|
87
|
-
if_(condition: string, ifTrue: string | Macro): this;
|
|
89
|
+
if_(condition: string | Monster | Effect | Skill | Item | Location | Class | Stat, ifTrue: string | Macro): this;
|
|
88
90
|
/**
|
|
89
91
|
* Create a new macro with an "if" statement.
|
|
90
92
|
* @param condition The BALLS condition for the if statement.
|
|
91
93
|
* @param ifTrue Continuation if the condition is true.
|
|
92
94
|
* @returns {Macro} This object itself.
|
|
93
95
|
*/
|
|
94
|
-
static if_<T extends Macro>(this: Constructor<T>, condition:
|
|
96
|
+
static if_<T extends Macro>(this: Constructor<T>, condition: Parameters<T["if_"]>[0], ifTrue: string | Macro): T;
|
|
95
97
|
/**
|
|
96
98
|
* Add a "while" statement to this macro.
|
|
97
99
|
* @param condition The BALLS condition for the if statement.
|
|
@@ -118,9 +120,10 @@ export declare class Macro {
|
|
|
118
120
|
* Create a new macro with a condition evaluated at the time of building the macro.
|
|
119
121
|
* @param condition The JS condition.
|
|
120
122
|
* @param ifTrue Continuation to add if the condition is true.
|
|
123
|
+
* @param ifFalse Optional input to turn this into an if...else statement.
|
|
121
124
|
* @returns {Macro} This object itself.
|
|
122
125
|
*/
|
|
123
|
-
static externalIf<T extends Macro>(this: Constructor<T>, condition: boolean, ifTrue: string | Macro): T;
|
|
126
|
+
static externalIf<T extends Macro>(this: Constructor<T>, condition: boolean, ifTrue: string | Macro, ifFalse?: string | Macro): T;
|
|
124
127
|
/**
|
|
125
128
|
* Add a repeat step to the macro.
|
|
126
129
|
* @returns {Macro} This object itself.
|
|
@@ -197,17 +200,25 @@ export declare class Macro {
|
|
|
197
200
|
*/
|
|
198
201
|
static attack<T extends Macro>(this: Constructor<T>): T;
|
|
199
202
|
/**
|
|
200
|
-
* Create an if_ statement
|
|
201
|
-
* @param
|
|
202
|
-
|
|
203
|
+
* Create an if_ statement based on what holiday of loathing it currently is. On non-holidays, returns the original macro, unmutated.
|
|
204
|
+
* @param macro The macro to place in the if_ statement
|
|
205
|
+
*/
|
|
206
|
+
ifHolidayWanderer(macro: Macro): this;
|
|
207
|
+
/**
|
|
208
|
+
* Create a new macro starting with an ifHolidayWanderer step.
|
|
209
|
+
* @param macro The macro to place inside the if_ statement
|
|
210
|
+
*/
|
|
211
|
+
static ifHolidayWanderer<T extends Macro>(this: Constructor<T>, macro: Macro): T;
|
|
212
|
+
/**
|
|
213
|
+
* Create an if_ statement based on what holiday of loathing it currently is. On non-holidays, returns the original macro, with the input macro appended.
|
|
214
|
+
* @param macro The macro to place in the if_ statement.
|
|
203
215
|
*/
|
|
204
|
-
|
|
216
|
+
ifNotHolidayWanderer(macro: Macro): this;
|
|
205
217
|
/**
|
|
206
|
-
* Create a new macro with an
|
|
207
|
-
* @param
|
|
208
|
-
* @param macro The macro to trigger when the monster is found
|
|
218
|
+
* Create a new macro starting with an ifNotHolidayWanderer step.
|
|
219
|
+
* @param macro The macro to place inside the if_ statement
|
|
209
220
|
*/
|
|
210
|
-
static
|
|
221
|
+
static ifNotHolidayWanderer<T extends Macro>(this: Constructor<T>, macro: Macro): T;
|
|
211
222
|
}
|
|
212
223
|
/**
|
|
213
224
|
* Adventure in a location and handle all combats with a given macro.
|
package/dist/combat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { adv1, choiceFollowsFight, getAutoAttack, inMultiFight, removeProperty, runCombat, setAutoAttack, toInt, urlEncode, visitUrl, xpath, } from "kolmafia";
|
|
2
2
|
import { $items, $skills } from "./template-string";
|
|
3
3
|
import { get, set } from "./property";
|
|
4
|
+
import { getTodaysHolidayWanderers } from "./lib";
|
|
4
5
|
const MACRO_NAME = "Script Autoattack Macro";
|
|
5
6
|
/**
|
|
6
7
|
* Get the KoL native ID of the macro with name Script Autoattack Macro.
|
|
@@ -58,6 +59,8 @@ function skillBallsMacroName(skillOrName) {
|
|
|
58
59
|
? skill.name
|
|
59
60
|
: toInt(skill);
|
|
60
61
|
}
|
|
62
|
+
export class InvalidMacroError extends Error {
|
|
63
|
+
}
|
|
61
64
|
/**
|
|
62
65
|
* BALLS macro builder for direct submission to KoL.
|
|
63
66
|
* Create a new macro with `new Macro()` and add steps using the instance methods.
|
|
@@ -66,9 +69,10 @@ function skillBallsMacroName(skillOrName) {
|
|
|
66
69
|
* For example, you can do `Macro.skill('Saucestorm').attack()`.
|
|
67
70
|
*/
|
|
68
71
|
export class Macro {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
static SAVED_MACRO_PROPERTY = "libram_savedMacro";
|
|
73
|
+
static cachedMacroId = null;
|
|
74
|
+
static cachedAutoAttack = null;
|
|
75
|
+
components = [];
|
|
72
76
|
/**
|
|
73
77
|
* Convert macro to string.
|
|
74
78
|
*/
|
|
@@ -171,7 +175,42 @@ export class Macro {
|
|
|
171
175
|
* @returns {Macro} This object itself.
|
|
172
176
|
*/
|
|
173
177
|
if_(condition, ifTrue) {
|
|
174
|
-
|
|
178
|
+
let ballsCondition = "";
|
|
179
|
+
if (condition instanceof Monster) {
|
|
180
|
+
ballsCondition = `monsterid ${condition.id}`;
|
|
181
|
+
}
|
|
182
|
+
else if (condition instanceof Effect) {
|
|
183
|
+
ballsCondition = `haseffect ${toInt(condition)}`;
|
|
184
|
+
}
|
|
185
|
+
else if (condition instanceof Skill) {
|
|
186
|
+
ballsCondition = `hasskill ${skillBallsMacroName(condition)}`;
|
|
187
|
+
}
|
|
188
|
+
else if (condition instanceof Item) {
|
|
189
|
+
if (!condition.combat) {
|
|
190
|
+
throw new InvalidMacroError(`Item ${condition} cannot be made a valid BALLS predicate (it is not combat-usable)`);
|
|
191
|
+
}
|
|
192
|
+
ballsCondition = `hascombatitem ${itemOrItemsBallsMacroName(condition)}`;
|
|
193
|
+
}
|
|
194
|
+
else if (condition instanceof Location) {
|
|
195
|
+
const snarfblat = condition.id;
|
|
196
|
+
if (snarfblat < 1) {
|
|
197
|
+
throw new InvalidMacroError(`Location ${condition} cannot be made a valid BALLS predicate (it has no location id)`);
|
|
198
|
+
}
|
|
199
|
+
ballsCondition = `snarfblat ${snarfblat}`;
|
|
200
|
+
}
|
|
201
|
+
else if (condition instanceof Class) {
|
|
202
|
+
if (toInt(condition) > 6) {
|
|
203
|
+
throw new InvalidMacroError(`Class ${condition} cannot be made a valid BALLS predicate (it is not a standard class)`);
|
|
204
|
+
}
|
|
205
|
+
ballsCondition = condition.toString().replaceAll(" ", "").toLowerCase();
|
|
206
|
+
}
|
|
207
|
+
else if (condition instanceof Stat) {
|
|
208
|
+
ballsCondition = `${condition.toString().toLowerCase()}class`;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
ballsCondition = condition;
|
|
212
|
+
}
|
|
213
|
+
return this.step(`if ${ballsCondition}`).step(ifTrue).step("endif");
|
|
175
214
|
}
|
|
176
215
|
/**
|
|
177
216
|
* Create a new macro with an "if" statement.
|
|
@@ -219,10 +258,11 @@ export class Macro {
|
|
|
219
258
|
* Create a new macro with a condition evaluated at the time of building the macro.
|
|
220
259
|
* @param condition The JS condition.
|
|
221
260
|
* @param ifTrue Continuation to add if the condition is true.
|
|
261
|
+
* @param ifFalse Optional input to turn this into an if...else statement.
|
|
222
262
|
* @returns {Macro} This object itself.
|
|
223
263
|
*/
|
|
224
|
-
static externalIf(condition, ifTrue) {
|
|
225
|
-
return new this().externalIf(condition, ifTrue);
|
|
264
|
+
static externalIf(condition, ifTrue, ifFalse) {
|
|
265
|
+
return new this().externalIf(condition, ifTrue, ifFalse);
|
|
226
266
|
}
|
|
227
267
|
/**
|
|
228
268
|
* Add a repeat step to the macro.
|
|
@@ -336,25 +376,40 @@ export class Macro {
|
|
|
336
376
|
return new this().attack();
|
|
337
377
|
}
|
|
338
378
|
/**
|
|
339
|
-
* Create an if_ statement
|
|
340
|
-
* @param
|
|
341
|
-
|
|
379
|
+
* Create an if_ statement based on what holiday of loathing it currently is. On non-holidays, returns the original macro, unmutated.
|
|
380
|
+
* @param macro The macro to place in the if_ statement
|
|
381
|
+
*/
|
|
382
|
+
ifHolidayWanderer(macro) {
|
|
383
|
+
const todaysWanderers = getTodaysHolidayWanderers();
|
|
384
|
+
if (todaysWanderers.length === 0)
|
|
385
|
+
return this;
|
|
386
|
+
return this.if_(todaysWanderers.map((monster) => `monsterid ${monster.id}`).join(" || "), macro);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Create a new macro starting with an ifHolidayWanderer step.
|
|
390
|
+
* @param macro The macro to place inside the if_ statement
|
|
391
|
+
*/
|
|
392
|
+
static ifHolidayWanderer(macro) {
|
|
393
|
+
return new this().ifHolidayWanderer(macro);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Create an if_ statement based on what holiday of loathing it currently is. On non-holidays, returns the original macro, with the input macro appended.
|
|
397
|
+
* @param macro The macro to place in the if_ statement.
|
|
342
398
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
399
|
+
ifNotHolidayWanderer(macro) {
|
|
400
|
+
const todaysWanderers = getTodaysHolidayWanderers();
|
|
401
|
+
if (todaysWanderers.length === 0)
|
|
402
|
+
return this.step(macro);
|
|
403
|
+
return this.if_(todaysWanderers.map((monster) => `!monsterid ${monster.id}`).join(" && "), macro);
|
|
345
404
|
}
|
|
346
405
|
/**
|
|
347
|
-
* Create a new macro with an
|
|
348
|
-
* @param
|
|
349
|
-
* @param macro The macro to trigger when the monster is found
|
|
406
|
+
* Create a new macro starting with an ifNotHolidayWanderer step.
|
|
407
|
+
* @param macro The macro to place inside the if_ statement
|
|
350
408
|
*/
|
|
351
|
-
static
|
|
352
|
-
return new
|
|
409
|
+
static ifNotHolidayWanderer(macro) {
|
|
410
|
+
return new this().ifNotHolidayWanderer(macro);
|
|
353
411
|
}
|
|
354
412
|
}
|
|
355
|
-
Macro.SAVED_MACRO_PROPERTY = "libram_savedMacro";
|
|
356
|
-
Macro.cachedMacroId = null;
|
|
357
|
-
Macro.cachedAutoAttack = null;
|
|
358
413
|
/**
|
|
359
414
|
* Adventure in a location and handle all combats with a given macro.
|
|
360
415
|
* To use this function you will need to create a consult script that runs Macro.load().submit() and a CCS that calls that consult script.
|
package/dist/diet/index.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ export declare class MenuItem {
|
|
|
13
13
|
additionalValue?: number;
|
|
14
14
|
wishEffect?: Effect;
|
|
15
15
|
static defaultOptions: Map<Item, MenuItemOptions>;
|
|
16
|
+
/**
|
|
17
|
+
* Construct a new menu item, possibly with extra properties. Items in MenuItem.defaultOptions have intelligent defaults.
|
|
18
|
+
* @param item Item to add to menu.
|
|
19
|
+
* @param options.organ Designate item as belonging to a specific organ.
|
|
20
|
+
* @param options.size Override item organ size. Necessary for any non-food/booze/spleen item.
|
|
21
|
+
* @param options.maximum Maximum uses remaining today, or "auto" to check dailyusesleft Mafia property.
|
|
22
|
+
* @param options.additionalValue Additional value (positive) or cost (negative) to consider with item, e.g. from buffs.
|
|
23
|
+
* @param options.wishEffect If item is a pocket wish, effect to wish for.
|
|
24
|
+
*/
|
|
16
25
|
constructor(item: Item, options?: MenuItemOptions);
|
|
17
26
|
equals(other: MenuItem): boolean;
|
|
18
27
|
toString(): string;
|