libram 0.7.9 → 0.7.11

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.js CHANGED
@@ -2,7 +2,7 @@ import { Skill, Class, eudoraItem, getCampground, Item, Path, toInt, use, visitU
2
2
  import { get } from "./property";
3
3
  import { ChateauMantegna } from "./resources";
4
4
  import { $item, $items, $stat } from "./template-string";
5
- import { createStringUnionTypeGuardFunction } from "./utils";
5
+ import { arrayContains } from "./utils";
6
6
  export var Lifestyle;
7
7
  (function (Lifestyle) {
8
8
  Lifestyle[Lifestyle["casual"] = 1] = "casual";
@@ -61,11 +61,11 @@ const eudorae = [
61
61
  "New-You Club Membership Form",
62
62
  "Our Daily Candles™ order form",
63
63
  ];
64
- const isGarden = createStringUnionTypeGuardFunction(gardens);
65
- const isEudora = createStringUnionTypeGuardFunction(eudorae);
66
- const isDesk = createStringUnionTypeGuardFunction(ChateauMantegna.desks);
67
- const isNightstand = createStringUnionTypeGuardFunction(ChateauMantegna.nightstands);
68
- const isCeiling = createStringUnionTypeGuardFunction(ChateauMantegna.ceilings);
64
+ const isGarden = (x) => arrayContains(x, gardens);
65
+ const isEudora = (x) => arrayContains(x, eudorae);
66
+ const isDesk = (x) => arrayContains(x, ChateauMantegna.desks);
67
+ const isNightstand = (x) => arrayContains(x, ChateauMantegna.nightstands);
68
+ const isCeiling = (x) => arrayContains(x, ChateauMantegna.ceilings);
69
69
  export class AscensionPrepError extends Error {
70
70
  cause;
71
71
  constructor(cause, original) {
@@ -19,6 +19,7 @@ const statCommunityServicePredictor = (stat) => {
19
19
  : stat)));
20
20
  };
21
21
  const visitCouncil = () => visitUrl("council.php");
22
+ const baseWeight = () => have($effect `Fidoxene`) ? 20 : familiarWeight(myFamiliar());
22
23
  export default class CommunityService {
23
24
  choice;
24
25
  stat;
@@ -121,7 +122,8 @@ export default class CommunityService {
121
122
  try {
122
123
  additionalTurns = prepare() ?? 0;
123
124
  }
124
- catch {
125
+ catch (e) {
126
+ print(`${e}`, "red");
125
127
  return "failed";
126
128
  }
127
129
  const prediction = this.predictor();
@@ -194,7 +196,7 @@ export default class CommunityService {
194
196
  static Muscle = new CommunityService(2, "Muscle", "Feed The Children", statCommunityServicePredictor($stat `Muscle`), new Requirement(["Muscle"], {}));
195
197
  static Mysticality = new CommunityService(3, "Mysticality", "Build Playground Mazes", statCommunityServicePredictor($stat `Mysticality`), new Requirement(["Mysticality"], {}));
196
198
  static Moxie = new CommunityService(4, "Moxie", "Feed Conspirators", statCommunityServicePredictor($stat `Moxie`), new Requirement(["Moxie"], {}));
197
- static FamiliarWeight = new CommunityService(5, "Familiar Weight", "Breed More Collies", () => 60 - Math.floor((familiarWeight(myFamiliar()) + weightAdjustment()) / 5), new Requirement(["Familiar Weight"], {}));
199
+ static FamiliarWeight = new CommunityService(5, "Familiar Weight", "Breed More Collies", () => 60 - Math.floor((baseWeight() + weightAdjustment()) / 5), new Requirement(["Familiar Weight"], {}));
198
200
  static WeaponDamage = new CommunityService(6, "Weapon Damage", "Reduce Gazelle Population", () => {
199
201
  const weaponPower = getPower(equippedItem($slot `weapon`));
200
202
  const offhandPower = toSlot(equippedItem($slot `off-hand`)) === $slot `weapon`
@@ -216,7 +218,7 @@ export default class CommunityService {
216
218
  }, new Requirement(["Weapon Damage", "Weapon Damage Percent"], {}));
217
219
  static SpellDamage = new CommunityService(7, "Spell Damage", "Make Sausage", () => {
218
220
  const dragonfishDamage = myFamiliar() === $familiar `Magic Dragonfish`
219
- ? numericModifier($familiar `Magic Dragonfish`, "Spell Damage Percent", familiarWeight($familiar `Magic Dragonfish`) + weightAdjustment(), $item.none)
221
+ ? numericModifier($familiar `Magic Dragonfish`, "Spell Damage Percent", baseWeight() + weightAdjustment(), $item.none)
220
222
  : 0;
221
223
  // We add 0.001 because the floor function sometimes introduces weird rounding errors
222
224
  return (60 -
@@ -233,10 +235,10 @@ export default class CommunityService {
233
235
  const mummingBuff = mummingCostume && mummingCostume[0] === "Item Drop"
234
236
  ? mummingCostume[1]
235
237
  : 0;
236
- const familiarItemDrop = numericModifier(myFamiliar(), "Item Drop", familiarWeight(myFamiliar()) + weightAdjustment(), equippedItem($slot `familiar`)) +
238
+ const familiarItemDrop = numericModifier(myFamiliar(), "Item Drop", baseWeight() + weightAdjustment(), equippedItem($slot `familiar`)) +
237
239
  mummingBuff -
238
240
  numericModifier(equippedItem($slot `familiar`), "Item Drop");
239
- const familiarBoozeDrop = numericModifier(myFamiliar(), "Booze Drop", familiarWeight(myFamiliar()) + weightAdjustment(), equippedItem($slot `familiar`)) - numericModifier(equippedItem($slot `familiar`), "Booze Drop");
241
+ const familiarBoozeDrop = numericModifier(myFamiliar(), "Booze Drop", baseWeight() + weightAdjustment(), equippedItem($slot `familiar`)) - numericModifier(equippedItem($slot `familiar`), "Booze Drop");
240
242
  // Champagne doubling does NOT count for CS, so we undouble
241
243
  const multiplier = haveEquipped($item `broken champagne bottle`) &&
242
244
  get("garbageChampagneCharge") > 0
package/dist/combat.d.ts CHANGED
@@ -34,9 +34,15 @@ export declare class Macro {
34
34
  /**
35
35
  * Gives your macro a new name to be used when saving an autoattack.
36
36
  * @param name The name to be used when saving as an autoattack.
37
- * @returns The previous name assigned to this macro.
37
+ * @returns The macro in question
38
38
  */
39
- rename(name: string): string;
39
+ rename(name: string): this;
40
+ /**
41
+ * Creates a new Macro with a name other than the default name.
42
+ * @param name The name to assign this macro.
43
+ * @returns A new Macro with the assigned name.
44
+ */
45
+ static rename<T extends Macro>(this: Constructor<T>, name: string): T;
40
46
  /**
41
47
  * Save a macro to a Mafia property for use in a consult script.
42
48
  */
package/dist/combat.js CHANGED
@@ -23,8 +23,10 @@ export function getMacroId(name = MACRO_NAME) {
23
23
  function itemOrNameToItem(itemOrName) {
24
24
  return typeof itemOrName === "string" ? Item.get(itemOrName) : itemOrName;
25
25
  }
26
- const substringCombatItems = $items `spider web, really sticky spider web, dictionary, NG, Cloaca-Cola, yo-yo, top, ball, kite, yo, red potion, blue potion, adder, red button, pile of sand, mushroom, deluxe mushroom`;
27
- const substringCombatSkills = $skills `Shoot, Thrust-Smack, Headbutt, Toss, Sing, Disarm, LIGHT, BURN, Extract, Meteor Shower, Cleave, Boil, Slice, Rainbow`;
26
+ // The list of all combat items whose name is a strict substring of another combat item
27
+ const substringCombatItems = $items `spider web, really sticky spider web, dictionary, NG, Cloaca-Cola, yo-yo, top, ball, kite, yo, red potion, blue potion, bowling ball, adder, red button, pile of sand, mushroom, deluxe mushroom`;
28
+ // The list of all combat skills whose name is a strict substring of another combat skill
29
+ const substringCombatSkills = $skills `Shoot, Thrust-Smack, Headbutt, Toss, Sing, Disarm, LIGHT, BURN, Extract, Meteor Shower, Snipe, Cleave, Boil, Slice, Rainbow`;
28
30
  function itemOrItemsBallsMacroName(itemOrItems) {
29
31
  if (Array.isArray(itemOrItems)) {
30
32
  return itemOrItems.map(itemOrItemsBallsMacroName).join(", ");
@@ -83,12 +85,19 @@ export class Macro {
83
85
  /**
84
86
  * Gives your macro a new name to be used when saving an autoattack.
85
87
  * @param name The name to be used when saving as an autoattack.
86
- * @returns The previous name assigned to this macro.
88
+ * @returns The macro in question
87
89
  */
88
90
  rename(name) {
89
- const returnValue = this.name;
90
91
  this.name = name;
91
- return returnValue;
92
+ return this;
93
+ }
94
+ /**
95
+ * Creates a new Macro with a name other than the default name.
96
+ * @param name The name to assign this macro.
97
+ * @returns A new Macro with the assigned name.
98
+ */
99
+ static rename(name) {
100
+ return new this().rename(name);
92
101
  }
93
102
  /**
94
103
  * Save a macro to a Mafia property for use in a consult script.
package/dist/logger.js CHANGED
@@ -1,8 +1,17 @@
1
- import { printHtml } from "kolmafia";
1
+ import { logprint, printHtml } from "kolmafia";
2
2
  const defaultHandlers = {
3
- info: (message) => printHtml(`<b>[Libram]</b> ${message}`),
4
- warning: (message) => printHtml(`<span style="background: orange; color: white;"><b>[Libram]</b> ${message}</span>`),
5
- error: (error) => printHtml(`<span style="background: red; color: white;"><b>[Libram]</b> ${error.toString()}</span>`),
3
+ info: (message) => {
4
+ printHtml(`<b>[Libram]</b> ${message}`);
5
+ logprint(`[Libram] ${message}`);
6
+ },
7
+ warning: (message) => {
8
+ printHtml(`<span style="background: orange; color: white;"><b>[Libram]</b> ${message}</span>`);
9
+ logprint(`[Libram] ${message}`);
10
+ },
11
+ error: (error) => {
12
+ printHtml(`<span style="background: red; color: white;"><b>[Libram]</b> ${error.toString()}</span>`);
13
+ logprint(`[Libram] ${error.toString()}`);
14
+ },
6
15
  };
7
16
  class Logger {
8
17
  handlers = defaultHandlers;
@@ -11,6 +11,12 @@ export declare type MaximizeOptions = {
11
11
  forceUpdate: boolean;
12
12
  modes: Modes;
13
13
  };
14
+ /**
15
+ * Merges a Partial<MaximizeOptions> onto a MaximizeOptions. We merge via overriding for all boolean properties and for onlySlot, and concat all other array properties.
16
+ * @param defaultOptions MaximizeOptions to use as a "base."
17
+ * @param addendums Options to attempt to merge onto defaultOptions.
18
+ */
19
+ export declare function mergeMaximizeOptions(defaultOptions: MaximizeOptions, addendums: Partial<MaximizeOptions>): MaximizeOptions;
14
20
  /**
15
21
  *
16
22
  * @param options Default options for each maximizer run.
package/dist/maximize.js CHANGED
@@ -7,7 +7,7 @@ import { setEqual } from "./utils";
7
7
  * @param defaultOptions MaximizeOptions to use as a "base."
8
8
  * @param addendums Options to attempt to merge onto defaultOptions.
9
9
  */
10
- function mergeMaximizeOptions(defaultOptions, addendums) {
10
+ export function mergeMaximizeOptions(defaultOptions, addendums) {
11
11
  return {
12
12
  updateOnFamiliarChange: addendums.updateOnFamiliarChange ?? defaultOptions.updateOnFamiliarChange,
13
13
  updateOnCanEquipChanged: addendums.updateOnCanEquipChanged ??
@@ -269,7 +269,7 @@ const slotStructure = [
269
269
  * @param entry The CacheEntry to verify
270
270
  * @returns If all desired equipment was appliedn in the correct slots.
271
271
  */
272
- function verifyCached(entry) {
272
+ function verifyCached(entry, warn = true) {
273
273
  let success = true;
274
274
  for (const slotGroup of slotStructure) {
275
275
  const desiredSlots = slotGroup
@@ -278,21 +278,27 @@ function verifyCached(entry) {
278
278
  const desiredSet = desiredSlots.map(([, item]) => item);
279
279
  const equippedSet = desiredSlots.map(([slot]) => equippedItem(slot));
280
280
  if (!setEqual(desiredSet, equippedSet)) {
281
- logger.warning(`Failed to apply cached ${desiredSet.join(", ")} in ${slotGroup.join(", ")}.`);
281
+ if (warn) {
282
+ logger.warning(`Failed to apply cached ${desiredSet.join(", ")} in ${slotGroup.join(", ")}.`);
283
+ }
282
284
  success = false;
283
285
  }
284
286
  }
285
287
  if (equippedAmount($item `Crown of Thrones`) > 0 &&
286
288
  entry.rider.get($item `Crown of Thrones`)) {
287
289
  if (entry.rider.get($item `Crown of Thrones`) !== myEnthronedFamiliar()) {
288
- logger.warning(`Failed to apply ${entry.rider.get($item `Crown of Thrones`)} in ${$item `Crown of Thrones`}.`);
290
+ if (warn) {
291
+ logger.warning(`Failed to apply ${entry.rider.get($item `Crown of Thrones`)} in ${$item `Crown of Thrones`}.`);
292
+ }
289
293
  success = false;
290
294
  }
291
295
  }
292
296
  if (equippedAmount($item `Buddy Bjorn`) > 0 &&
293
297
  entry.rider.get($item `Buddy Bjorn`)) {
294
298
  if (entry.rider.get($item `Buddy Bjorn`) !== myBjornedFamiliar()) {
295
- logger.warning(`Failed to apply${entry.rider.get($item `Buddy Bjorn`)} in ${$item `Buddy Bjorn`}.`);
299
+ if (warn) {
300
+ logger.warning(`Failed to apply${entry.rider.get($item `Buddy Bjorn`)} in ${$item `Buddy Bjorn`}.`);
301
+ }
296
302
  success = false;
297
303
  }
298
304
  }
@@ -388,7 +394,7 @@ export function maximizeCached(objectives, options = {}) {
388
394
  ].join("; ");
389
395
  const cacheEntry = checkCache(cacheKey, fullOptions);
390
396
  if (cacheEntry && !forceUpdate) {
391
- if (verifyCached(cacheEntry))
397
+ if (verifyCached(cacheEntry, false))
392
398
  return true;
393
399
  logger.info("Equipment found in maximize cache, equipping...");
394
400
  applyCached(cacheEntry, fullOptions);