libram 0.8.25 → 0.8.27

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/lib.d.ts CHANGED
@@ -488,4 +488,10 @@ export declare function withCombatFlags<T>(action: () => T, ...flags: {
488
488
  flag: AccountCombatFlag;
489
489
  value: boolean;
490
490
  }[]): T;
491
+ /**
492
+ * Determines whether you currently have an effect intrinsically
493
+ * @param effect The effect in question
494
+ * @returns Whether you have that effect as an intrinsic. Alternately you could just have over 2147483647 turns of that effect, but that seems unlikely.
495
+ */
496
+ export declare function haveIntrinsic(effect: Effect): boolean;
491
497
  export {};
package/dist/lib.js CHANGED
@@ -948,3 +948,11 @@ export function withCombatFlags(action, ...flags) {
948
948
  setCombatFlags(...initialValues);
949
949
  }
950
950
  }
951
+ /**
952
+ * Determines whether you currently have an effect intrinsically
953
+ * @param effect The effect in question
954
+ * @returns Whether you have that effect as an intrinsic. Alternately you could just have over 2147483647 turns of that effect, but that seems unlikely.
955
+ */
956
+ export function haveIntrinsic(effect) {
957
+ return haveEffect(effect) >= 2147483647;
958
+ }
@@ -3,7 +3,7 @@ import { Effect, Item } from "kolmafia";
3
3
  * @returns whether you `have` the Apriling band helmet
4
4
  */
5
5
  export declare function have(): boolean;
6
- export declare const MARCHING_SONGS: readonly ["Patrol Beat", "Battle Cadence", "Celebration Bop"];
6
+ export declare const MARCHING_SONGS: readonly ["Apriling Band Patrol Beat", "Apriling Band Battle Cadence", "Apriling Band Celebration Bop"];
7
7
  export declare type MarchingSong = typeof MARCHING_SONGS[number];
8
8
  export declare const MARCHING_SONG_EFFECTS: readonly Effect[];
9
9
  export declare const INSTRUMENTS: readonly ["Apriling band saxophone", "Apriling band quad tom", "Apriling band tuba", "Apriling band staff", "Apriling band piccolo"];
@@ -32,7 +32,7 @@ export declare function canChangeSong(): boolean;
32
32
  *
33
33
  * @returns Whether we have the effect, at the end of all things
34
34
  */
35
- export declare const changeSong: (input: Effect | "Patrol Beat" | "Battle Cadence" | "Celebration Bop") => boolean;
35
+ export declare const changeSong: (input: Effect | "Apriling Band Patrol Beat" | "Apriling Band Battle Cadence" | "Apriling Band Celebration Bop") => boolean;
36
36
  /**
37
37
  * Conduct your Apriling band helmet
38
38
  *
@@ -48,3 +48,10 @@ export declare function conduct(result: Item | Instrument | Effect | MarchingSon
48
48
  * @returns Whether we successfully played our instrument
49
49
  */
50
50
  export declare function play(instrument: Instrument | Item, acquire?: boolean): boolean;
51
+ /**
52
+ * Determine whether you can play an instrument
53
+ * @param instrument The instrument you want to play
54
+ * @param acquire Whether you're willing to obtain an instrument you don't already have
55
+ * @returns Whether you can play that instrument
56
+ */
57
+ export declare function canPlay(instrument: Instrument | Item, acquire?: boolean): boolean;
@@ -1,4 +1,4 @@
1
- import { Effect, Item, MafiaClass, myHash, runChoice, toEffect, toItem, totalTurnsPlayed, visitUrl, } from "kolmafia";
1
+ import { Effect, Item, myHash, runChoice, toEffect, toItem, totalTurnsPlayed, visitUrl, } from "kolmafia";
2
2
  import { have as have_ } from "../../lib";
3
3
  import { get } from "../../property";
4
4
  import { $item } from "../../template-string";
@@ -11,9 +11,9 @@ export function have() {
11
11
  return have_(helmet);
12
12
  }
13
13
  export const MARCHING_SONGS = Object.freeze([
14
- "Patrol Beat",
15
- "Battle Cadence",
16
- "Celebration Bop",
14
+ "Apriling Band Patrol Beat",
15
+ "Apriling Band Battle Cadence",
16
+ "Apriling Band Celebration Bop",
17
17
  ]);
18
18
  export const MARCHING_SONG_EFFECTS = Object.freeze(MARCHING_SONGS.map((song) => toEffect(song)));
19
19
  export const INSTRUMENTS = Object.freeze([
@@ -35,9 +35,9 @@ function makeConductFunction(mafiaClass, canDo, set, offset) {
35
35
  return (input) => {
36
36
  if (!canDo())
37
37
  return false;
38
- const [name, instance] = input instanceof MafiaClass
39
- ? [input.toString(), input]
40
- : [input, mafiaClass.get(input)];
38
+ const [name, instance] = typeof input === "string"
39
+ ? [input, mafiaClass.get(input)]
40
+ : [input.name, input];
41
41
  if (have_(instance))
42
42
  return true;
43
43
  const key = set.indexOf(name);
@@ -56,7 +56,7 @@ function makeConductFunction(mafiaClass, canDo, set, offset) {
56
56
  *
57
57
  * @returns Whether we have the item, at the end of all things
58
58
  */
59
- export const joinSection = makeConductFunction(Item, canJoinSection, INSTRUMENTS, 1);
59
+ export const joinSection = makeConductFunction(Item, canJoinSection, INSTRUMENTS, 4);
60
60
  /**
61
61
  * @returns Whether we can currently change the marching song of our Apriling Band
62
62
  */
@@ -70,7 +70,7 @@ export function canChangeSong() {
70
70
  *
71
71
  * @returns Whether we have the effect, at the end of all things
72
72
  */
73
- export const changeSong = makeConductFunction(Effect, canChangeSong, MARCHING_SONGS, 4);
73
+ export const changeSong = makeConductFunction(Effect, canChangeSong, MARCHING_SONGS, 1);
74
74
  /**
75
75
  * Conduct your Apriling band helmet
76
76
  *
@@ -92,11 +92,27 @@ export function conduct(result) {
92
92
  */
93
93
  export function play(instrument, acquire = false) {
94
94
  const item = instrument instanceof Item ? instrument : Item.get(instrument);
95
- if (!(acquire ? joinSection : have_)(item))
95
+ if (!canPlay(instrument, acquire))
96
96
  return false;
97
+ if (acquire && !have_(item))
98
+ joinSection(item);
97
99
  const currentUsesRemaining = item.dailyusesleft;
98
- if (currentUsesRemaining <= 0)
99
- return false;
100
100
  visitUrl(`inventory.php?pwd=${myHash()}&iid=${item.id}&action=aprilplay`, false);
101
101
  return item.dailyusesleft !== currentUsesRemaining;
102
102
  }
103
+ /**
104
+ * Determine whether you can play an instrument
105
+ * @param instrument The instrument you want to play
106
+ * @param acquire Whether you're willing to obtain an instrument you don't already have
107
+ * @returns Whether you can play that instrument
108
+ */
109
+ export function canPlay(instrument, acquire = false) {
110
+ if (!have())
111
+ return false;
112
+ const item = instrument instanceof Item ? instrument : Item.get(instrument);
113
+ if (!have_(item) && (!acquire || !canJoinSection()))
114
+ return false;
115
+ if (item.dailyusesleft <= 0)
116
+ return false;
117
+ return true;
118
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libram",
3
- "version": "0.8.25",
3
+ "version": "0.8.27",
4
4
  "description": "JavaScript helper library for KoLmafia",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -53,7 +53,7 @@
53
53
  "husky": "^4.3.6",
54
54
  "java-parser": "^1.4.0",
55
55
  "jest": "^27.1.0",
56
- "kolmafia": "^5.27668.0",
56
+ "kolmafia": "^5.27901.0",
57
57
  "lint-staged": ">=10",
58
58
  "node-fetch": "^2.6.1",
59
59
  "prettier": "^2.1.2",