libram 0.6.5 → 0.6.8

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.
@@ -0,0 +1,111 @@
1
+ import { cliExecute } from "kolmafia";
2
+ import { have as haveItem } from "../../lib";
3
+ import { get } from "../../property";
4
+ import { $item, $skill } from "../../template-string";
5
+ export const item = $item `unwrapped knock-off retro superhero cape`;
6
+ /**
7
+ * Determines whether you have() the Retro Cape.
8
+ * @returns Whether you have the Retro Cape available.
9
+ */
10
+ export function have() {
11
+ return haveItem(item);
12
+ }
13
+ const Heroes = {
14
+ vampire: {
15
+ "Muscle Percent": 30,
16
+ "Maximum HP": 50,
17
+ },
18
+ heck: {
19
+ "Mysticality Percent": 30,
20
+ "Maximum MP": 50,
21
+ },
22
+ robot: {
23
+ "Moxie Percent": 30,
24
+ "Maximum HP": 25,
25
+ "Maximum MP": 25,
26
+ },
27
+ };
28
+ export const currentHero = () => get("retroCapeSuperhero");
29
+ export const currentMode = () => get("retroCapeWashingInstructions");
30
+ const modeMap = new Map([
31
+ [
32
+ ["vampire", "hold"],
33
+ {
34
+ "Hot Resistance": 3,
35
+ "Cold Resistance": 3,
36
+ "Stench Resistance": 3,
37
+ "Spooky Resistance": 3,
38
+ "Sleaze Resistance": 3,
39
+ },
40
+ ],
41
+ [
42
+ ["vampire", "thrill"],
43
+ {
44
+ "Muscle Experience": 3,
45
+ },
46
+ ],
47
+ [
48
+ ["vampire", "kiss"],
49
+ {
50
+ Skill: $skill `Smooch of the Daywalker`,
51
+ },
52
+ ],
53
+ [
54
+ ["vampire", "kill"],
55
+ {
56
+ Skill: $skill `Slay the Dead`,
57
+ },
58
+ ],
59
+ [["heck", "thrill"], { "Mysticality Experience": 3 }],
60
+ [["heck", "kiss"], { Skill: $skill `Unleash the Devil's Kiss` }],
61
+ [["robot", "hold"], { Skill: $skill `Deploy Robo-Handcuffs` }],
62
+ [["robot", "thrill"], { "Moxie Experience": 3 }],
63
+ [["robot", "kiss"], { Skill: $skill `Blow a Robo-Kiss` }],
64
+ [["robot", "kill"], { Skill: $skill `Precision Shot` }],
65
+ ]);
66
+ /**
67
+ * Tunes retro cape to a given setting
68
+ * @param hero The Superhero to set it to
69
+ * @param mode The washing instructions to set it to
70
+ * @returns Whether we successfully tuned the Retro Cape.
71
+ */
72
+ export function set(hero, mode) {
73
+ if (!have())
74
+ return false;
75
+ if (currentHero() === hero && currentMode() === mode)
76
+ return true;
77
+ cliExecute(`retrocape ${hero} ${mode}`);
78
+ return currentHero() === hero && currentMode() === mode;
79
+ }
80
+ /**
81
+ * Returns the expected Modifiers of the Retro Cape for a particular setting
82
+ * @param hero The Superhero setting
83
+ * @param mode The washing instructions setting
84
+ * @returns A Modifiers object describing the Retro Cape were it to be tuned to that setting.
85
+ */
86
+ export function getModifier(hero = currentHero(), mode = currentMode()) {
87
+ return {
88
+ ...Heroes[hero],
89
+ ...(modeMap.get([hero, mode]) ?? {}),
90
+ };
91
+ }
92
+ const skills = new Map([
93
+ [$skill `Smooch of the Daywalker`, ["vampire", "kiss"]],
94
+ [$skill `Slay the Dead`, ["vampire", "kill"]],
95
+ [$skill `Unleash the Devil's Kiss`, ["heck", "kiss"]],
96
+ [$skill `Deploy Robo-Handcuffs`, ["robot", "hold"]],
97
+ [$skill `Blow a Robo-Kiss`, ["robot", "kiss"]],
98
+ [$skill `Precision Shot`, ["robot", "kill"]],
99
+ ]);
100
+ /**
101
+ * Tunes the Retro Cape to allow it to grant a particular skill.
102
+ * @param skill The skill to tune the Retro Cape to.
103
+ * @returns Whether we successfully tuned the cape.
104
+ */
105
+ export function tuneToSkill(skill) {
106
+ const setting = skills.get(skill);
107
+ if (!setting || !have())
108
+ return false;
109
+ set(...setting);
110
+ return [currentHero(), currentMode()].every((element, index) => element === setting[index]);
111
+ }
@@ -0,0 +1,36 @@
1
+ import { Monster } from "kolmafia";
2
+ export declare const locket: import("kolmafia").Item;
3
+ export declare function have(): boolean;
4
+ /**
5
+ * Filters the set of all unlocked locket monsters to only the ones available to be locketed right now.
6
+ * @returns An array consisting of all Monsters you can fight with your locket right now.
7
+ */
8
+ export declare function availableLocketMonsters(): Monster[];
9
+ /**
10
+ * Parses getLocketMonsters and returns the collection of all Monsters as an Array.
11
+ * @returns An array consisting of all Monsters you can hypothetically fight, regardless of whether they've been fought today.
12
+ */
13
+ export declare function unlockedLocketMonsters(): Monster[];
14
+ /**
15
+ * Determines how many reminisces remain by parsing the _locketMonstersFought property.
16
+ * @returns The number of reminisces a player has available; 0 if they lack the Locket.
17
+ */
18
+ export declare function reminiscesLeft(): number;
19
+ /**
20
+ * Determines which monsters were reminisced today by parsing the _locketMonstersFought property.
21
+ * @returns An array consisting of the Monsters reminisced today.
22
+ */
23
+ export declare function monstersReminisced(): Monster[];
24
+ /**
25
+ * Fight a Monster using the Combat Lover's Locket
26
+ * @param monster The Monster to fight
27
+ * @returns false if we are unable to reminisce about this monster. Else, returns whether, at the end of all things, we have reminisced about this monster.
28
+ */
29
+ export declare function reminisce(monster: Monster): boolean;
30
+ /**
31
+ * Find a reminiscable monster that meets certain criteria and optionally maximizes a valuation function.
32
+ * @param criteria A function for delineating which monsters are "fair game" for the search.
33
+ * @param value A function for deciding which monsters are "better" than others.
34
+ * @returns A monster that fulfills the criteria function and maximizes the value function.
35
+ */
36
+ export declare function findMonster(criteria: (monster: Monster) => boolean, value?: (monster: Monster) => number): Monster | null;
@@ -0,0 +1,73 @@
1
+ import { cliExecute, getLocketMonsters, runCombat, toMonster, } from "kolmafia";
2
+ import { have as haveItem } from "../../lib";
3
+ import { get } from "../../property";
4
+ import { $item } from "../../template-string";
5
+ import { clamp } from "../../utils";
6
+ // eslint-disable-next-line libram/verify-constants
7
+ export const locket = $item `Combat Lover's Locket`;
8
+ export function have() {
9
+ return haveItem(locket);
10
+ }
11
+ /**
12
+ * Filters the set of all unlocked locket monsters to only the ones available to be locketed right now.
13
+ * @returns An array consisting of all Monsters you can fight with your locket right now.
14
+ */
15
+ export function availableLocketMonsters() {
16
+ if (reminiscesLeft() === 0)
17
+ return [];
18
+ return Object.entries(getLocketMonsters())
19
+ .filter(([, unused]) => unused)
20
+ .map(([name]) => toMonster(name));
21
+ }
22
+ /**
23
+ * Parses getLocketMonsters and returns the collection of all Monsters as an Array.
24
+ * @returns An array consisting of all Monsters you can hypothetically fight, regardless of whether they've been fought today.
25
+ */
26
+ export function unlockedLocketMonsters() {
27
+ return Object.entries(getLocketMonsters()).map(([name]) => toMonster(name));
28
+ }
29
+ function parseLocketProperty() {
30
+ return get("_locketMonstersFought")
31
+ .split(",")
32
+ .filter((id) => id.trim().length > 0);
33
+ }
34
+ /**
35
+ * Determines how many reminisces remain by parsing the _locketMonstersFought property.
36
+ * @returns The number of reminisces a player has available; 0 if they lack the Locket.
37
+ */
38
+ export function reminiscesLeft() {
39
+ return have() ? clamp(3 - parseLocketProperty().length, 0, 3) : 0;
40
+ }
41
+ /**
42
+ * Determines which monsters were reminisced today by parsing the _locketMonstersFought property.
43
+ * @returns An array consisting of the Monsters reminisced today.
44
+ */
45
+ export function monstersReminisced() {
46
+ return parseLocketProperty().map((id) => toMonster(id));
47
+ }
48
+ /**
49
+ * Fight a Monster using the Combat Lover's Locket
50
+ * @param monster The Monster to fight
51
+ * @returns false if we are unable to reminisce about this monster. Else, returns whether, at the end of all things, we have reminisced about this monster.
52
+ */
53
+ export function reminisce(monster) {
54
+ if (!have() || reminiscesLeft() === 0 || !getLocketMonsters()[monster.name]) {
55
+ return false;
56
+ }
57
+ cliExecute(`reminisce ${monster}`);
58
+ runCombat();
59
+ return monstersReminisced().includes(monster);
60
+ }
61
+ /**
62
+ * Find a reminiscable monster that meets certain criteria and optionally maximizes a valuation function.
63
+ * @param criteria A function for delineating which monsters are "fair game" for the search.
64
+ * @param value A function for deciding which monsters are "better" than others.
65
+ * @returns A monster that fulfills the criteria function and maximizes the value function.
66
+ */
67
+ export function findMonster(criteria, value = () => 1) {
68
+ if (!have() || reminiscesLeft() === 0)
69
+ return null;
70
+ return (availableLocketMonsters()
71
+ .filter(criteria)
72
+ .sort((a, b) => value(b) - value(a))[0] ?? null);
73
+ }
@@ -12,6 +12,7 @@ import * as MayoClinic from "./2015/MayoClinic";
12
12
  import * as SourceTerminal from "./2016/SourceTerminal";
13
13
  import * as Witchess from "./2016/Witchess";
14
14
  import * as AsdonMartin from "./2017/AsdonMartin";
15
+ import * as MummingTrunk from "./2017/MummingTrunk";
15
16
  import * as Pantogram from "./2017/Pantogram";
16
17
  import * as TunnelOfLove from "./2017/TunnelOfLove";
17
18
  import * as Latte from "./2018/LatteLoversMembersMug";
@@ -19,8 +20,10 @@ import * as SongBoom from "./2018/SongBoom";
19
20
  import * as BeachComb from "./2019/BeachComb";
20
21
  import * as Snapper from "./2019/Snapper";
21
22
  import * as Guzzlr from "./2020/Guzzlr";
23
+ import * as RetroCape from "./2020/RetroCape";
22
24
  import * as CrystalBall from "./2021/CrystalBall";
23
25
  import * as DaylightShavings from "./2021/DaylightShavings";
24
- export { AsdonMartin, Bandersnatch, BeachComb, ChateauMantegna, CrownOfThrones, CrystalBall, DaylightShavings, DNALab, FloristFriar, Guzzlr, Latte, MayoClinic, ObtuseAngel, Pantogram, RainDoh, Snapper, SongBoom, SourceTerminal, SpookyPutty, StompingBoots, TunnelOfLove, WinterGarden, Witchess, };
26
+ import * as CombatLoversLocket from "./2022/CombatLoversLocket";
27
+ export { AsdonMartin, Bandersnatch, BeachComb, ChateauMantegna, CombatLoversLocket, CrownOfThrones, CrystalBall, DaylightShavings, DNALab, FloristFriar, Guzzlr, Latte, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, RainDoh, RetroCape, Snapper, SongBoom, SourceTerminal, SpookyPutty, StompingBoots, TunnelOfLove, WinterGarden, Witchess, };
25
28
  export * from "./putty-likes";
26
29
  export * from "./LibramSummon";
@@ -12,6 +12,7 @@ import * as MayoClinic from "./2015/MayoClinic";
12
12
  import * as SourceTerminal from "./2016/SourceTerminal";
13
13
  import * as Witchess from "./2016/Witchess";
14
14
  import * as AsdonMartin from "./2017/AsdonMartin";
15
+ import * as MummingTrunk from "./2017/MummingTrunk";
15
16
  import * as Pantogram from "./2017/Pantogram";
16
17
  import * as TunnelOfLove from "./2017/TunnelOfLove";
17
18
  import * as Latte from "./2018/LatteLoversMembersMug";
@@ -19,8 +20,10 @@ import * as SongBoom from "./2018/SongBoom";
19
20
  import * as BeachComb from "./2019/BeachComb";
20
21
  import * as Snapper from "./2019/Snapper";
21
22
  import * as Guzzlr from "./2020/Guzzlr";
23
+ import * as RetroCape from "./2020/RetroCape";
22
24
  import * as CrystalBall from "./2021/CrystalBall";
23
25
  import * as DaylightShavings from "./2021/DaylightShavings";
24
- export { AsdonMartin, Bandersnatch, BeachComb, ChateauMantegna, CrownOfThrones, CrystalBall, DaylightShavings, DNALab, FloristFriar, Guzzlr, Latte, MayoClinic, ObtuseAngel, Pantogram, RainDoh, Snapper, SongBoom, SourceTerminal, SpookyPutty, StompingBoots, TunnelOfLove, WinterGarden, Witchess, };
26
+ import * as CombatLoversLocket from "./2022/CombatLoversLocket";
27
+ export { AsdonMartin, Bandersnatch, BeachComb, ChateauMantegna, CombatLoversLocket, CrownOfThrones, CrystalBall, DaylightShavings, DNALab, FloristFriar, Guzzlr, Latte, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, RainDoh, RetroCape, Snapper, SongBoom, SourceTerminal, SpookyPutty, StompingBoots, TunnelOfLove, WinterGarden, Witchess, };
25
28
  export * from "./putty-likes";
26
29
  export * from "./LibramSummon";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libram",
3
- "version": "0.6.5",
3
+ "version": "0.6.8",
4
4
  "description": "JavaScript helper library for KoLmafia",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,10 @@
9
9
  "license": "MIT",
10
10
  "private": false,
11
11
  "scripts": {
12
- "build": "yarn run tsc",
12
+ "build": "yarn run build:tsc && yarn run build:bundled",
13
+ "build:tsc": "tsc",
14
+ "build:bundled": "webpack",
15
+ "build:watch": "tsc --watch",
13
16
  "clean": "rm -rf dist",
14
17
  "docs": "yarn run typedoc",
15
18
  "format": "yarn run prettier --write .",
@@ -22,13 +25,12 @@
22
25
  "dist/**/*.d.ts"
23
26
  ],
24
27
  "devDependencies": {
25
- "@babel/cli": "^7.14.8",
26
- "@babel/compat-data": "^7.15.0",
27
- "@babel/core": "^7.15.0",
28
+ "@babel/compat-data": "^7.17.0",
29
+ "@babel/core": "^7.17.2",
28
30
  "@babel/plugin-proposal-class-properties": "^7.14.5",
29
- "@babel/plugin-proposal-decorators": "^7.14.5",
31
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.7",
30
32
  "@babel/plugin-transform-runtime": "^7.15.0",
31
- "@babel/preset-env": "^7.15.0",
33
+ "@babel/preset-env": "^7.16.11",
32
34
  "@babel/preset-typescript": "^7.15.0",
33
35
  "@tsconfig/node16": "^1.0.2",
34
36
  "@types/jest": "^27.0.1",
@@ -37,7 +39,7 @@
37
39
  "@types/node-fetch": "^2.5.7",
38
40
  "@typescript-eslint/eslint-plugin": "^5.5.0",
39
41
  "@typescript-eslint/parser": "^5.5.0",
40
- "babel-loader": "^8.2.2",
42
+ "babel-loader": "^8.2.3",
41
43
  "eslint": "^7.16.0",
42
44
  "eslint-config-prettier": "^8.3.0",
43
45
  "eslint-import-resolver-typescript": "^2.5.0",
@@ -54,13 +56,13 @@
54
56
  "ts-node": "^10.4.0",
55
57
  "typedoc": "^0.22.10",
56
58
  "typescript": "^4.5.2",
57
- "webpack": "^5.10.0",
58
- "webpack-cli": "^4.2.0"
59
+ "webpack": "^5.67.0",
60
+ "webpack-cli": "^4.9.2"
59
61
  },
60
62
  "dependencies": {
61
- "@babel/runtime-corejs3": "^7.14.9",
62
- "core-js": "3.15.2",
63
- "kolmafia": "^2.0.0",
63
+ "@babel/runtime-corejs3": "^7.17.2",
64
+ "core-js": "^3.21.0",
65
+ "kolmafia": "^2.1.1",
64
66
  "lodash": "^4.17.21"
65
67
  },
66
68
  "husky": {