libram 0.8.0 → 0.8.2

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.
Files changed (37) hide show
  1. package/dist/Kmail.js +2 -2
  2. package/dist/ascend.d.ts +14 -2
  3. package/dist/ascend.js +36 -26
  4. package/dist/combat.js +5 -5
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +1 -0
  7. package/dist/lib.js +4 -4
  8. package/dist/maximize.js +6 -3
  9. package/dist/propertyTypes.d.ts +3 -3
  10. package/dist/propertyTypes.js +3 -3
  11. package/dist/resources/2008/Stickers.js +3 -4
  12. package/dist/resources/2010/CrownOfThrones.js +2 -2
  13. package/dist/resources/2010/LookingGlass.js +4 -5
  14. package/dist/resources/2015/DeckOfEveryCard.d.ts +2 -3
  15. package/dist/resources/2015/DeckOfEveryCard.js +2 -2
  16. package/dist/resources/2015/MayoClinic.js +2 -2
  17. package/dist/resources/2016/Witchess.js +2 -2
  18. package/dist/resources/2017/AsdonMartin.js +2 -2
  19. package/dist/resources/2017/Pantogram.js +2 -2
  20. package/dist/resources/2017/Robortender.js +2 -2
  21. package/dist/resources/2017/Spacegate.js +2 -2
  22. package/dist/resources/2019/BeachComb.d.ts +6 -0
  23. package/dist/resources/2019/BeachComb.js +10 -2
  24. package/dist/resources/2019/CampAway.d.ts +39 -0
  25. package/dist/resources/2019/CampAway.js +72 -0
  26. package/dist/resources/2021/DaylightShavings.js +3 -3
  27. package/dist/resources/2022/GreyGoose.js +2 -2
  28. package/dist/resources/2023/CinchoDeMayo.d.ts +25 -0
  29. package/dist/resources/2023/CinchoDeMayo.js +45 -0
  30. package/dist/resources/index.d.ts +3 -1
  31. package/dist/resources/index.js +3 -1
  32. package/dist/session.js +18 -3
  33. package/dist/template-string.d.ts +64 -16
  34. package/dist/template-string.js +34 -8
  35. package/dist/utils.d.ts +12 -0
  36. package/dist/utils.js +14 -0
  37. package/package.json +3 -3
package/dist/Kmail.js CHANGED
@@ -1,4 +1,4 @@
1
- import { extractItems, extractMeat, isGiftable, Item, toInt, visitUrl, } from "kolmafia";
1
+ import { extractItems, extractMeat, isGiftable, Item, visitUrl, } from "kolmafia";
2
2
  import { arrayToCountedMap, chunk } from "./utils";
3
3
  export default class Kmail {
4
4
  id;
@@ -46,7 +46,7 @@ export default class Kmail {
46
46
  for (const c of chunks.length > 0 ? chunks : [null]) {
47
47
  const itemsQuery = c === null
48
48
  ? []
49
- : c.map(([item, quantity], index) => `whichitem${index + 1}=${toInt(item)}&howmany${index + 1}=${quantity}`);
49
+ : c.map(([item, quantity], index) => `whichitem${index + 1}=${item.id}&howmany${index + 1}=${quantity}`);
50
50
  const r = visitUrl(constructUrl(m, itemsQuery.join("&"), itemsQuery.length));
51
51
  if (r.includes("That player cannot receive Meat or items")) {
52
52
  return Kmail.gift(to, message, items, meat);
package/dist/ascend.d.ts CHANGED
@@ -26,7 +26,19 @@ export declare class AscensionPrepError extends Error {
26
26
  cause: string;
27
27
  constructor(cause: string, original?: MafiaClass | string);
28
28
  }
29
- declare type MoonSign = number | "mongoose" | "wallaby" | "vole" | "platypus" | "opossum" | "marmot" | "wombat" | "blender" | "packrat" | "degrassi" | "degrassi knoll" | "friendly degrassi knoll" | "knoll" | "canada" | "canadia" | "little canadia" | "gnomads" | "gnomish" | "gnomish gnomads camp";
29
+ declare const MoonSigns: readonly ["Mongoose", "Wallaby", "Vole", "Platypus", "Opossum", "Marmot", "Wombat", "Blender", "Packrat"];
30
+ declare type MoonSign = typeof MoonSigns[number];
31
+ declare type InputMoonSign = number | Lowercase<MoonSign> | "degrassi" | "degrassi knoll" | "friendly degrassi knoll" | "knoll" | "canada" | "canadia" | "little canadia" | "gnomads" | "gnomish" | "gnomish gnomads camp";
32
+ /**
33
+ * @param moon Moon sign name
34
+ * @returns Moon sign id else 0
35
+ */
36
+ export declare function signNameToId(moon: MoonSign): number;
37
+ /**
38
+ * @param id Moon sign id
39
+ * @returns Name of moon sign else "None"
40
+ */
41
+ export declare function signIdToName(id: number): MoonSign | "None";
30
42
  /**
31
43
  * Hops the gash, perming no skills
32
44
  *
@@ -40,7 +52,7 @@ declare type MoonSign = number | "mongoose" | "wallaby" | "vole" | "platypus" |
40
52
  * @param permOptions.permSkills A Map<Skill, Lifestyle> of skills you'd like to perm, ordered by priority.
41
53
  * @param permOptions.neverAbort Whether the ascension shouold abort on failure
42
54
  */
43
- export declare function ascend(path: Path, playerClass: Class, lifestyle: Lifestyle, moon: MoonSign, consumable?: Item | undefined, pet?: Item | undefined, permOptions?: {
55
+ export declare function ascend(path: Path, playerClass: Class, lifestyle: Lifestyle, moon: InputMoonSign, consumable?: Item | undefined, pet?: Item | undefined, permOptions?: {
44
56
  permSkills: Map<Skill, Lifestyle>;
45
57
  neverAbort: boolean;
46
58
  }): void;
package/dist/ascend.js CHANGED
@@ -1,8 +1,8 @@
1
- import { Skill, Class, eudoraItem, getCampground, Item, Path, toInt, use, visitUrl, xpath, haveSkill, getPermedSkills, toSkill, } from "kolmafia";
1
+ import { Skill, Class, eudoraItem, getCampground, Item, Path, use, visitUrl, xpath, haveSkill, getPermedSkills, toSkill, } from "kolmafia";
2
2
  import { get } from "./property";
3
3
  import { ChateauMantegna } from "./resources";
4
4
  import { $item, $items, $stat } from "./template-string";
5
- import { arrayContains } from "./utils";
5
+ import { arrayContains, tc } from "./utils";
6
6
  export var Lifestyle;
7
7
  (function (Lifestyle) {
8
8
  Lifestyle[Lifestyle["casual"] = 1] = "casual";
@@ -97,6 +97,31 @@ export class AscensionPrepError extends Error {
97
97
  this.cause = cause;
98
98
  }
99
99
  }
100
+ const MoonSigns = [
101
+ "Mongoose",
102
+ "Wallaby",
103
+ "Vole",
104
+ "Platypus",
105
+ "Opossum",
106
+ "Marmot",
107
+ "Wombat",
108
+ "Blender",
109
+ "Packrat",
110
+ ];
111
+ /**
112
+ * @param moon Moon sign name
113
+ * @returns Moon sign id else 0
114
+ */
115
+ export function signNameToId(moon) {
116
+ return MoonSigns.indexOf(moon) + 1;
117
+ }
118
+ /**
119
+ * @param id Moon sign id
120
+ * @returns Name of moon sign else "None"
121
+ */
122
+ export function signIdToName(id) {
123
+ return MoonSigns[id - 1] || "None";
124
+ }
100
125
  /**
101
126
  * Determine the id of the appropriate moon sign.
102
127
  *
@@ -104,7 +129,7 @@ export class AscensionPrepError extends Error {
104
129
  * @param playerClass Class, required for working out a moon sign based on the desired zone
105
130
  * @returns Moon sign id
106
131
  */
107
- function toMoonId(moon, playerClass) {
132
+ function inputToMoonId(moon, playerClass) {
108
133
  if (typeof moon === "number")
109
134
  return moon;
110
135
  const offset = () => {
@@ -119,25 +144,10 @@ function toMoonId(moon, playerClass) {
119
144
  throw new AscendError(`unknown prime stat for ${playerClass}`);
120
145
  }
121
146
  };
147
+ const fromNormalInput = signNameToId(tc(moon));
148
+ if (fromNormalInput >= 0)
149
+ return fromNormalInput;
122
150
  switch (moon.toLowerCase()) {
123
- case "mongoose":
124
- return 1;
125
- case "wallaby":
126
- return 2;
127
- case "vole":
128
- return 3;
129
- case "platypus":
130
- return 4;
131
- case "opossum":
132
- return 5;
133
- case "marmot":
134
- return 6;
135
- case "wombat":
136
- return 7;
137
- case "blender":
138
- return 8;
139
- case "packrat":
140
- return 9;
141
151
  case "degrassi":
142
152
  case "degrassi knoll":
143
153
  case "friendly degrassi knoll":
@@ -187,7 +197,7 @@ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `a
187
197
  }
188
198
  if (path.id < 0)
189
199
  throw new AscendError(path);
190
- const moonId = toMoonId(moon, playerClass);
200
+ const moonId = inputToMoonId(moon, playerClass);
191
201
  if (moonId < 1 || moonId > 9)
192
202
  throw new Error(`Invalid moon ${moon}`);
193
203
  if (consumable &&
@@ -212,10 +222,10 @@ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `a
212
222
  }
213
223
  visitUrl("afterlife.php?action=pearlygates");
214
224
  if (consumable) {
215
- visitUrl(`afterlife.php?action=buydeli&whichitem=${toInt(consumable)}`);
225
+ visitUrl(`afterlife.php?action=buydeli&whichitem=${consumable.id}`);
216
226
  }
217
227
  if (pet)
218
- visitUrl(`afterlife.php?action=buyarmory&whichitem=${toInt(pet)}`);
228
+ visitUrl(`afterlife.php?action=buyarmory&whichitem=${pet.id}`);
219
229
  if (permOptions) {
220
230
  const currentPerms = permedSkills();
221
231
  let karma = get("bankedKarma");
@@ -230,11 +240,11 @@ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `a
230
240
  }
231
241
  karma -= expectedKarma;
232
242
  const permText = prospectivePermLevel === Lifestyle.hardcore ? "hcperm" : "scperm";
233
- visitUrl(`afterlife.php?action=${permText}&whichskill=${toInt(skill)}`);
243
+ visitUrl(`afterlife.php?action=${permText}&whichskill=${skill.id}`);
234
244
  }
235
245
  }
236
246
  }
237
- visitUrl(`afterlife.php?action=ascend&confirmascend=1&whichsign=${moonId}&gender=2&whichclass=${toInt(playerClass)}&whichpath=${path.id}&asctype=${lifestyle}&nopetok=1&noskillsok=1&lamepathok=1&lamesignok=1&pwd`, true);
247
+ visitUrl(`afterlife.php?action=ascend&confirmascend=1&whichsign=${moonId}&gender=2&whichclass=${playerClass.id}&whichpath=${path.id}&asctype=${lifestyle}&nopetok=1&noskillsok=1&lamepathok=1&lamesignok=1&pwd`, true);
238
248
  }
239
249
  /**
240
250
  * Sets up various iotms you may want to use in the coming ascension
package/dist/combat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { adv1, choiceFollowsFight, Class, Effect, getAutoAttack, inMultiFight, Item, Location, Monster, removeProperty, runCombat, setAutoAttack, Skill, Stat, toInt, urlEncode, visitUrl, xpath, } from "kolmafia";
1
+ import { adv1, choiceFollowsFight, Class, Effect, getAutoAttack, inMultiFight, Item, Location, Monster, removeProperty, runCombat, setAutoAttack, Skill, Stat, urlEncode, visitUrl, xpath, } from "kolmafia";
2
2
  import { getTodaysHolidayWanderers } from "./lib";
3
3
  import { overlappingItemNames, overlappingSkillNames, } from "./overlappingNames";
4
4
  import { get, set } from "./property";
@@ -44,7 +44,7 @@ function itemOrItemsBallsMacroName(itemOrItems) {
44
44
  const item = itemOrNameToItem(itemOrItems);
45
45
  return !overlappingItemNames.includes(item.name)
46
46
  ? item.name
47
- : toInt(item).toString();
47
+ : item.id.toFixed(0);
48
48
  }
49
49
  }
50
50
  /**
@@ -86,7 +86,7 @@ function skillBallsMacroName(skillOrName) {
86
86
  return skill.name.match(/^[A-Za-z ]+$/) &&
87
87
  !overlappingSkillNames.includes(skill.name)
88
88
  ? skill.name
89
- : toInt(skill);
89
+ : skill.id;
90
90
  }
91
91
  export class InvalidMacroError extends Error {
92
92
  }
@@ -279,7 +279,7 @@ export class Macro {
279
279
  ballsCondition = `(${ballsCondition})`;
280
280
  }
281
281
  else if (condition instanceof Effect) {
282
- ballsCondition = `haseffect ${toInt(condition)}`;
282
+ ballsCondition = `haseffect ${condition.id}`;
283
283
  }
284
284
  else if (condition instanceof Skill) {
285
285
  ballsCondition = `hasskill ${skillBallsMacroName(condition)}`;
@@ -298,7 +298,7 @@ export class Macro {
298
298
  ballsCondition = `snarfblat ${snarfblat}`;
299
299
  }
300
300
  else if (condition instanceof Class) {
301
- if (toInt(condition) > 6) {
301
+ if (condition.id > 6) {
302
302
  throw new InvalidMacroError(`Class ${condition} cannot be made a valid BALLS predicate (it is not a standard class)`);
303
303
  }
304
304
  ballsCondition = condition.toString().replaceAll(" ", "").toLowerCase();
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./diet";
8
8
  export * from "./Dungeon";
9
9
  export * from "./lib";
10
10
  export * from "./maximize";
11
+ export { numericModifiers, statModifiers, booleanModifiers, classModifiers, monsterModifiers, effectModifiers, skillModifiers, } from "./modifierTypes";
11
12
  export * from "./mood";
12
13
  export * from "./propertyTyping";
13
14
  export * from "./resources";
@@ -25,3 +26,4 @@ export { get as getModifier, getTotalModifier } from "./modifier";
25
26
  export { Session } from "./session";
26
27
  export type { LogLevels } from "./logger";
27
28
  export type { Modifiers } from "./modifier";
29
+ export type { NumericModifier, StringModifier, ClassModifier, StatModifier, BooleanModifier, EffectModifier, SkillModifier, } from "./modifierTypes";
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export * from "./diet";
8
8
  export * from "./Dungeon";
9
9
  export * from "./lib";
10
10
  export * from "./maximize";
11
+ export { numericModifiers, statModifiers, booleanModifiers, classModifiers, monsterModifiers, effectModifiers, skillModifiers, } from "./modifierTypes";
11
12
  export * from "./mood";
12
13
  export * from "./propertyTyping";
13
14
  export * from "./resources";
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, toInt, toItem, toSkill, totalTurnsPlayed, visitUrl, } from "kolmafia";
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, toItem, toSkill, totalTurnsPlayed, visitUrl, } from "kolmafia";
3
3
  import logger from "./logger";
4
4
  import { get } from "./property";
5
5
  import { $class, $element, $familiar, $item, $items, $monsters, $skill, $stat, } from "./template-string";
@@ -717,10 +717,10 @@ export function examine(thing) {
717
717
  const url = thing instanceof Item
718
718
  ? `desc_item.php?whichitem=${thing.descid}`
719
719
  : thing instanceof Familiar
720
- ? `desc_familiar.php?which=${toInt(thing)}`
720
+ ? `desc_familiar.php?which=${thing.id}`
721
721
  : thing instanceof Effect
722
722
  ? `desc_effect.php?whicheffect=${thing.descid}`
723
- : `desc_skill.php?whichskill=${toInt(thing)}`;
723
+ : `desc_skill.php?whichskill=${thing.id}`;
724
724
  return visitUrl(url);
725
725
  }
726
726
  /**
@@ -744,7 +744,7 @@ export const byClass = makeByXFunction(() => myClass().toString());
744
744
  * @returns The html of the resulting page
745
745
  */
746
746
  export function directlyUse(item) {
747
- return visitUrl(`inv_use.php?which=3&whichitem=${toInt(item)}&pwd`);
747
+ return visitUrl(`inv_use.php?which=3&whichitem=${item.id}&pwd`);
748
748
  }
749
749
  /**
750
750
  * Empty a slot, or unequip all instances of a given equipped item
package/dist/maximize.js CHANGED
@@ -2,6 +2,9 @@ import { availableAmount, bjornifyFamiliar, canEquip, cliExecute, enthroneFamili
2
2
  import logger from "./logger";
3
3
  import { $familiar, $item, $slot, $slots, $stats } from "./template-string";
4
4
  import { setEqual } from "./utils";
5
+ function toMaximizerName({ name, id }) {
6
+ return name.includes(";") ? `¶${id}` : name;
7
+ }
5
8
  /**
6
9
  * Merges a partial set of maximizer options onto a full set maximizer options. We merge via overriding for all boolean properties and for onlySlot, and concat all other array properties.
7
10
  *
@@ -394,13 +397,13 @@ export function maximizeCached(objectives, options = {}) {
394
397
  const objective = [
395
398
  ...new Set([
396
399
  ...objectives.sort(),
397
- ...forceEquip.map((item) => `equip ${item}`).sort(),
398
- ...preventEquip.map((item) => `-equip ${item}`).sort(),
400
+ ...forceEquip.map((item) => `"equip ${toMaximizerName(item)}"`).sort(),
401
+ ...preventEquip.map((item) => `-"equip ${toMaximizerName(item)}"`).sort(),
399
402
  ...onlySlot.map((slot) => `${slot}`).sort(),
400
403
  ...preventSlot.map((slot) => `-${slot}`).sort(),
401
404
  ...Array.from(bonusEquip.entries())
402
405
  .filter(([, bonus]) => bonus !== 0)
403
- .map(([item, bonus]) => `${Math.round(bonus * 100) / 100} bonus ${item}`)
406
+ .map(([item, bonus]) => `${Math.round(bonus * 100) / 100} "bonus ${toMaximizerName(item)}"`)
404
407
  .sort(),
405
408
  ]),
406
409
  ].join(", ");