libram 0.8.12 → 0.8.14

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/ascend.d.ts CHANGED
@@ -6,6 +6,10 @@ export declare enum Lifestyle {
6
6
  normal = 2,
7
7
  hardcore = 3
8
8
  }
9
+ export declare enum KolGender {
10
+ male = 1,
11
+ female = 2
12
+ }
9
13
  /**
10
14
  * Get a mapping of permed skills to the extent to which they're permed.
11
15
  *
@@ -40,21 +44,32 @@ export declare function signNameToId(moon: MoonSign): number;
40
44
  */
41
45
  export declare function signIdToName(id: number): MoonSign | "None";
42
46
  /**
43
- * Hops the gash, perming no skills
47
+ * Hops the gash, perming no skills by default
44
48
  *
45
- * @param path path of choice, as a Path object--these exist as properties of Paths
46
- * @param playerClass Your class of choice for this ascension
47
- * @param lifestyle 1 for casual, 2 for softcore, 3 for hardcore. Alternately, use the Lifestyle enum
48
- * @param moon Your moon sign as a string, or the zone you're looking for as a string
49
- * @param consumable From the astral deli. Pick the container item, not the product.
50
- * @param pet From the astral pet store.
51
- * @param permOptions Options for perming during a player's stay in Valhalla
52
- * @param permOptions.permSkills A Map<Skill, Lifestyle> of skills you'd like to perm, ordered by priority.
53
- * @param permOptions.neverAbort Whether the ascension shouold abort on failure
49
+ * @param options Configuration for the ascension
50
+ * @param options.path path of choice, as a Path object--these exist as properties of Paths
51
+ * @param options.playerClass Your class of choice for this ascension
52
+ * @param options.lifestyle 1 for casual, 2 for softcore, 3 for hardcore. Alternately, use the Lifestyle enum
53
+ * @param options.kolGender An entry from the KolGender enum: 1 for male, 2 for female (sorry that it's limited to those). Defaults to 2 or the corresponding value for defaultGenderOverride pref (which should be 'male' or 'female')
54
+ * @param options.moon Your moon sign as a string, or the zone you're looking for as a string
55
+ * @param options.consumable From the astral deli. Pick the container item, not the product. Defaults to astral six-pack, provide $item`none` for nothing.
56
+ * @param options.pet From the astral pet store.
57
+ * @param options.permOptions Options for perming during a player's stay in Valhalla
58
+ * @param options.permOptions.permSkills A Map<Skill, Lifestyle> of skills you'd like to perm, ordered by priority.
59
+ * @param options.permOptions.neverAbort Whether the ascension should abort on failure
54
60
  */
55
- export declare function ascend(path: Path, playerClass: Class, lifestyle: Lifestyle, moon: InputMoonSign, consumable?: Item | undefined, pet?: Item | undefined, permOptions?: {
56
- permSkills: Map<Skill, Lifestyle>;
57
- neverAbort: boolean;
61
+ export declare function ascend(options: {
62
+ path: Path;
63
+ playerClass: Class;
64
+ lifestyle: Lifestyle;
65
+ kolGender?: KolGender;
66
+ moon: InputMoonSign;
67
+ consumable?: Item;
68
+ pet?: Item;
69
+ permOptions?: {
70
+ permSkills: Map<Skill, Lifestyle>;
71
+ neverAbort: boolean;
72
+ };
58
73
  }): void;
59
74
  /**
60
75
  * Sets up various iotms you may want to use in the coming ascension
package/dist/ascend.js CHANGED
@@ -10,6 +10,11 @@ export var Lifestyle;
10
10
  Lifestyle[Lifestyle["normal"] = 2] = "normal";
11
11
  Lifestyle[Lifestyle["hardcore"] = 3] = "hardcore";
12
12
  })(Lifestyle || (Lifestyle = {}));
13
+ export var KolGender;
14
+ (function (KolGender) {
15
+ KolGender[KolGender["male"] = 1] = "male";
16
+ KolGender[KolGender["female"] = 2] = "female";
17
+ })(KolGender || (KolGender = {}));
13
18
  /**
14
19
  * Get a mapping of permed skills to the extent to which they're permed.
15
20
  *
@@ -179,19 +184,29 @@ function isInValhalla() {
179
184
  return matches !== null;
180
185
  }
181
186
  /**
182
- * Hops the gash, perming no skills
187
+ * Hops the gash, perming no skills by default
183
188
  *
184
- * @param path path of choice, as a Path object--these exist as properties of Paths
185
- * @param playerClass Your class of choice for this ascension
186
- * @param lifestyle 1 for casual, 2 for softcore, 3 for hardcore. Alternately, use the Lifestyle enum
187
- * @param moon Your moon sign as a string, or the zone you're looking for as a string
188
- * @param consumable From the astral deli. Pick the container item, not the product.
189
- * @param pet From the astral pet store.
190
- * @param permOptions Options for perming during a player's stay in Valhalla
191
- * @param permOptions.permSkills A Map<Skill, Lifestyle> of skills you'd like to perm, ordered by priority.
192
- * @param permOptions.neverAbort Whether the ascension shouold abort on failure
189
+ * @param options Configuration for the ascension
190
+ * @param options.path path of choice, as a Path object--these exist as properties of Paths
191
+ * @param options.playerClass Your class of choice for this ascension
192
+ * @param options.lifestyle 1 for casual, 2 for softcore, 3 for hardcore. Alternately, use the Lifestyle enum
193
+ * @param options.kolGender An entry from the KolGender enum: 1 for male, 2 for female (sorry that it's limited to those). Defaults to 2 or the corresponding value for defaultGenderOverride pref (which should be 'male' or 'female')
194
+ * @param options.moon Your moon sign as a string, or the zone you're looking for as a string
195
+ * @param options.consumable From the astral deli. Pick the container item, not the product. Defaults to astral six-pack, provide $item`none` for nothing.
196
+ * @param options.pet From the astral pet store.
197
+ * @param options.permOptions Options for perming during a player's stay in Valhalla
198
+ * @param options.permOptions.permSkills A Map<Skill, Lifestyle> of skills you'd like to perm, ordered by priority.
199
+ * @param options.permOptions.neverAbort Whether the ascension should abort on failure
193
200
  */
194
- export function ascend(path, playerClass, lifestyle, moon, consumable = $item `astral six-pack`, pet = undefined, permOptions) {
201
+ export function ascend(options) {
202
+ const DEFAULT_OPTIONS = {
203
+ kolGender: get("defaultGenderOverride", "female") === "male"
204
+ ? KolGender.male
205
+ : KolGender.female,
206
+ consumable: $item `astral six-pack`,
207
+ pet: $item `none`,
208
+ };
209
+ const { path, playerClass, lifestyle, kolGender, moon, consumable, pet, permOptions, } = { ...DEFAULT_OPTIONS, ...options };
195
210
  if (playerClass.path !== (path.avatar ? path : Path.none)) {
196
211
  throw new AscendError(playerClass);
197
212
  }
@@ -200,12 +215,10 @@ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `a
200
215
  const moonId = inputToMoonId(moon, playerClass);
201
216
  if (moonId < 1 || moonId > 9)
202
217
  throw new Error(`Invalid moon ${moon}`);
203
- if (consumable &&
204
- !$items `astral six-pack, astral hot dog dinner, [10882]carton of astral energy drinks`.includes(consumable)) {
218
+ if (!$items `none, astral six-pack, astral hot dog dinner, [10882]carton of astral energy drinks`.includes(consumable)) {
205
219
  throw new AscendError(consumable);
206
220
  }
207
- if (pet &&
208
- !$items `astral bludgeon, astral shield, astral chapeau, astral bracer, astral longbow, astral shorts, astral mace, astral trousers, astral ring, astral statuette, astral pistol, astral mask, astral pet sweater, astral shirt, astral belt`.includes(pet)) {
221
+ if (!$items `none, astral bludgeon, astral shield, astral chapeau, astral bracer, astral longbow, astral shorts, astral mace, astral trousers, astral ring, astral statuette, astral pistol, astral mask, astral pet sweater, astral shirt, astral belt`.includes(pet)) {
209
222
  throw new AscendError(pet);
210
223
  }
211
224
  const illegalSkill = permOptions
@@ -221,11 +234,12 @@ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `a
221
234
  throw new AscendError();
222
235
  }
223
236
  visitUrl("afterlife.php?action=pearlygates");
224
- if (consumable) {
237
+ if (consumable !== $item `none`) {
225
238
  visitUrl(`afterlife.php?action=buydeli&whichitem=${consumable.id}`);
226
239
  }
227
- if (pet)
240
+ if (pet !== $item `none`) {
228
241
  visitUrl(`afterlife.php?action=buyarmory&whichitem=${pet.id}`);
242
+ }
229
243
  if (permOptions) {
230
244
  const currentPerms = permedSkills();
231
245
  let karma = get("bankedKarma");
@@ -244,7 +258,7 @@ export function ascend(path, playerClass, lifestyle, moon, consumable = $item `a
244
258
  }
245
259
  }
246
260
  }
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);
261
+ visitUrl(`afterlife.php?action=ascend&confirmascend=1&whichsign=${moonId}&gender=${kolGender}&whichclass=${playerClass.id}&whichpath=${path.id}&asctype=${lifestyle}&nopetok=1&noskillsok=1&lamepathok=1&lamesignok=1&pwd`, true);
248
262
  }
249
263
  /**
250
264
  * Sets up various iotms you may want to use in the coming ascension
@@ -121,6 +121,15 @@ export class MenuItem {
121
121
  { maximum: get("_docClocksThymeCocktailDrunk") ? 0 : 1 },
122
122
  ],
123
123
  [$item `Mr. Burnsger`, { maximum: get("_mrBurnsgerEaten") ? 0 : 1 }],
124
+ [
125
+ $item `Calzone of Legend`,
126
+ { maximum: get("calzoneOfLegendEaten") ? 0 : 1 },
127
+ ],
128
+ [
129
+ $item `Deep Dish of Legend`,
130
+ { maximum: get("deepDishOfLegendEaten") ? 0 : 1 },
131
+ ],
132
+ [$item `Pizza of Legend`, { maximum: get("pizzaOfLegendEaten") ? 0 : 1 }],
124
133
  ]);
125
134
  }
126
135
  /**
package/dist/lib.d.ts CHANGED
@@ -385,3 +385,26 @@ export declare function unequip(slot: Slot): boolean;
385
385
  * @returns a Date object corresponding to the current in-game day, at midnight
386
386
  */
387
387
  export declare function gameDay(): Date;
388
+ /**
389
+ * @param [type="all"] the type of crafting to check for free crafts
390
+ * @returns the number of free crafts available of that type
391
+ */
392
+ export declare function freeCrafts(type?: "food" | "smith" | "booze" | "all"): number;
393
+ export declare const realmTypes: readonly ["spooky", "stench", "hot", "cold", "sleaze", "fantasy", "pirate"];
394
+ export declare type RealmType = typeof realmTypes[number];
395
+ /**
396
+ * @param identifier which realm to check for
397
+ * @returns if that realm is available
398
+ */
399
+ export declare function realmAvailable(identifier: RealmType): boolean;
400
+ /**
401
+ * Compute the currently available Lucky Gold Ring Currencies
402
+ * @param realm the realm type to consider
403
+ * @returns The currency for the given zone
404
+ */
405
+ export declare function realmCurrency(realm: RealmType): Item | undefined;
406
+ /**
407
+ * Compute which Lucky Gold Ring currencies are currently available
408
+ * @returns a list of currently available currencies
409
+ */
410
+ export declare function lgrCurrencies(): Item[];
package/dist/lib.js CHANGED
@@ -2,7 +2,7 @@
2
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, todayToString, toItem, toSkill, totalTurnsPlayed, visitUrl, } from "kolmafia";
3
3
  import logger from "./logger";
4
4
  import { get } from "./property";
5
- import { $class, $element, $familiar, $item, $items, $monsters, $skill, $stat, } from "./template-string";
5
+ import { $class, $effect, $element, $familiar, $item, $items, $monsters, $skill, $stat, } from "./template-string";
6
6
  import { makeByXFunction, chunk, flat } from "./utils";
7
7
  /**
8
8
  * Determines the current maximum Accordion Thief songs the player can have in their head
@@ -774,3 +774,76 @@ export function gameDay() {
774
774
  const [, year, month, day] = (todayToString().match(/(\d{4})(\d{2})(\d{2})/) ?? []).map(Number);
775
775
  return new Date(year, month - 1, day, 0, 0, 0);
776
776
  }
777
+ /**
778
+ * @param [type="all"] the type of crafting to check for free crafts
779
+ * @returns the number of free crafts available of that type
780
+ */
781
+ export function freeCrafts(type = "all") {
782
+ const effectCrafts = (effect) => Math.floor(haveEffect(effect) / 5);
783
+ const all = (have($skill `Rapid Prototyping`) ? 5 - get("_rapidPrototypingUsed") : 0) +
784
+ (have($skill `Expert Corner-Cutter`)
785
+ ? 5 - get("_expertCornerCutterUsed")
786
+ : 0) +
787
+ effectCrafts($effect `Inigo's Incantation of Inspiration`) +
788
+ effectCrafts($effect `Craft Tea`) +
789
+ // eslint-disable-next-line libram/verify-constants
790
+ effectCrafts($effect `Cooking Concentrate`);
791
+ const food = type === "food" ? 5 - get("_cookbookbatCrafting") : 0;
792
+ const smith = type === "smith" ? 5 - get("_thorsPliersCrafting") : 0;
793
+ const booze = 0; // currently there is no booze specific free crafting skill
794
+ return all + food + smith + booze;
795
+ }
796
+ export const realmTypes = [
797
+ "spooky",
798
+ "stench",
799
+ "hot",
800
+ "cold",
801
+ "sleaze",
802
+ "fantasy",
803
+ "pirate",
804
+ ];
805
+ /**
806
+ * @param identifier which realm to check for
807
+ * @returns if that realm is available
808
+ */
809
+ export function realmAvailable(identifier) {
810
+ if (identifier === "fantasy") {
811
+ return get(`_frToday`) || get(`frAlways`);
812
+ }
813
+ else if (identifier === "pirate") {
814
+ return get(`_prToday`) || get(`prAlways`);
815
+ }
816
+ return get(`_${identifier}AirportToday`) || get(`${identifier}AirportAlways`);
817
+ }
818
+ /**
819
+ * Compute the currently available Lucky Gold Ring Currencies
820
+ * @param realm the realm type to consider
821
+ * @returns The currency for the given zone
822
+ */
823
+ export function realmCurrency(realm) {
824
+ switch (realm) {
825
+ case "sleaze":
826
+ return $item `Beach Buck`;
827
+ case "spooky":
828
+ return $item `Coinspiracy`;
829
+ case "stench":
830
+ return $item `FunFunds™`;
831
+ case "cold":
832
+ return $item `Wal-Mart gift certificate`;
833
+ case "hot":
834
+ return $item `Volcoino`;
835
+ case "fantasy":
836
+ return $item `Rubee™`;
837
+ }
838
+ }
839
+ /**
840
+ * Compute which Lucky Gold Ring currencies are currently available
841
+ * @returns a list of currently available currencies
842
+ */
843
+ export function lgrCurrencies() {
844
+ return realmTypes
845
+ .filter((realm) => realmAvailable(realm) &&
846
+ !(realm === "hot" && get("_luckyGoldRingVolcoino")))
847
+ .map(realmCurrency)
848
+ .filter((i) => !!i);
849
+ }
package/dist/mood.js CHANGED
@@ -150,9 +150,9 @@ class PotionMoodElement extends MoodElement {
150
150
  // fractional part
151
151
  const remainingDifference = ensureTurns - haveEffect(effect);
152
152
  if (remainingDifference > 0) {
153
- const price = Math.floor(this.maxPricePerTurn * remainingDifference);
154
- if (price <= mallPrice(this.potion)) {
155
- if (availableAmount(this.potion) || buy(1, this.potion, price)) {
153
+ const maxPrice = Math.floor(this.maxPricePerTurn * remainingDifference);
154
+ if (mallPrice(this.potion) <= maxPrice) {
155
+ if (availableAmount(this.potion) || buy(1, this.potion, maxPrice)) {
156
156
  use(1, this.potion);
157
157
  }
158
158
  }