libram 0.5.8 → 0.5.9

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.
@@ -26,6 +26,14 @@ export declare type FindActionSourceConstraints = {
26
26
  * only actions that cost nothing.
27
27
  */
28
28
  maximumCost?: () => number;
29
+ /**
30
+ * Function allowing for custom logic if an action should be allowed.
31
+ * If undefined, allow all actions to be considered by other constraints.
32
+ *
33
+ * @param action The action that is being considered.
34
+ * @returns True if the action should be allowed.
35
+ */
36
+ allowedAction?: (action: ActionSource) => boolean;
29
37
  };
30
38
  export declare type ActionConstraints = {
31
39
  /**
@@ -124,6 +124,8 @@ export class ActionSource {
124
124
  }
125
125
  function filterAction(action, constraints) {
126
126
  return (action.available() &&
127
+ (constraints.allowedAction === undefined ||
128
+ constraints.allowedAction(action)) &&
127
129
  !(constraints.requireFamiliar?.() && !action.constraints.familiar) &&
128
130
  !(constraints.requireUnlimited?.() && !action.isUnlimited()) &&
129
131
  !(constraints.noFamiliar?.() && action.constraints.familiar) &&
package/dist/ascend.js CHANGED
@@ -1,4 +1,4 @@
1
- import { containsText, eudoraItem, getCampground, getWorkshed, toInt, use, visitUrl, xpath, } from "kolmafia";
1
+ import { containsText, eudoraItem, getCampground, getWorkshed, toInt, toItem, use, visitUrl, xpath, } from "kolmafia";
2
2
  import { $item, $items, $stat } from "./template-string";
3
3
  import { ChateauMantegna } from "./resources";
4
4
  export var Lifestyle;
@@ -139,7 +139,7 @@ const eudorae = [
139
139
  * @param throwOnFail If true, this will throw an error when it fails to switch something
140
140
  */
141
141
  export function prepareAscension({ workshed, garden, eudora, chateau, } = {}) {
142
- if (workshed && workshed !== getWorkshed().name) {
142
+ if (workshed && getWorkshed() !== toItem(workshed)) {
143
143
  use(Item.get(workshed));
144
144
  }
145
145
  if (garden && !Object.getOwnPropertyNames(getCampground()).includes(garden)) {
@@ -156,8 +156,8 @@ export function prepareAscension({ workshed, garden, eudora, chateau, } = {}) {
156
156
  else {
157
157
  visitUrl(`account.php?actions[]=whichpenpal&whichpenpal=${eudoraNumber}&action=Update`, true);
158
158
  }
159
- if (eudoraItem().name !== eudora) {
160
- throw new Error(`We really thought we chaned your eudora to a ${eudora}, but Mafia is saying otherwise.`);
159
+ if (eudoraItem() !== toItem(eudora)) {
160
+ throw new Error(`We really thought we changed your eudora to a ${eudora}, but Mafia is saying otherwise.`);
161
161
  }
162
162
  }
163
163
  if (chateau && ChateauMantegna.have()) {
@@ -5,7 +5,16 @@ export declare const helmet: Item;
5
5
  */
6
6
  export declare function have(): boolean;
7
7
  export declare const buffs: Effect[];
8
+ /**
9
+ * Tells you whether you currently have a beardbuff active. Warning: because of spaghetti, this does not determine buff eligibility.
10
+ * @returns Whether you currently have a beardbuff active
11
+ */
8
12
  export declare function hasBuff(): boolean;
13
+ /**
14
+ * Checks to see if there are any beardbuffs you have more than 1 turn of, determining whether you are eligible to receive a buff post-combat.
15
+ * @returns Whether you current are able to get a buff from the Daylight Shaving Helmet.
16
+ */
17
+ export declare function buffAvailable(): boolean;
9
18
  /**
10
19
  * Calculates and returns the cycle of buffs that the hat should cycle through.
11
20
  * @param playerclass The class to generate a cycle for
@@ -11,9 +11,20 @@ export function have() {
11
11
  return haveItem(helmet);
12
12
  }
13
13
  export const buffs = $effects `Spectacle Moustache, Toiletbrush Moustache, Barbell Moustache, Grizzly Beard, Surrealist's Moustache, Musician's Musician's Moustache, Gull-Wing Moustache, Space Warlord's Beard, Pointy Wizard Beard, Cowboy Stache, Friendly Chops`;
14
+ /**
15
+ * Tells you whether you currently have a beardbuff active. Warning: because of spaghetti, this does not determine buff eligibility.
16
+ * @returns Whether you currently have a beardbuff active
17
+ */
14
18
  export function hasBuff() {
15
19
  return buffs.some((buff) => haveItem(buff));
16
20
  }
21
+ /**
22
+ * Checks to see if there are any beardbuffs you have more than 1 turn of, determining whether you are eligible to receive a buff post-combat.
23
+ * @returns Whether you current are able to get a buff from the Daylight Shaving Helmet.
24
+ */
25
+ export function buffAvailable() {
26
+ return !buffs.some((buff) => haveItem(buff, 2));
27
+ }
17
28
  /**
18
29
  * Calculates and returns the cycle of buffs that the hat should cycle through.
19
30
  * @param playerclass The class to generate a cycle for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libram",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "description": "JavaScript helper library for KoLmafia",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",