libram 0.9.23 → 0.9.25
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/combat.d.ts +1 -1
- package/dist/combat.js +4 -2
- package/dist/lib.js +18 -31
- package/dist/modifierTypes.d.ts +1 -1
- package/dist/propertyTypes.d.ts +2 -2
- package/dist/propertyTypes.js +2 -2
- package/dist/resources/2006/CommaChameleon.d.ts +19 -0
- package/dist/resources/2006/CommaChameleon.js +38 -0
- package/dist/resources/2021/CrystalBall.d.ts +4 -0
- package/dist/resources/2021/CrystalBall.js +12 -7
- package/dist/resources/2024/ChestMimic.js +3 -6
- package/dist/resources/2024/TakerSpace.d.ts +59 -0
- package/dist/resources/2024/TakerSpace.js +102 -0
- package/dist/resources/index.d.ts +4 -2
- package/dist/resources/index.js +4 -2
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +16 -0
- package/package.json +2 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { create, getWorkshed } from "kolmafia";
|
|
2
|
+
import { have as have_ } from "../../lib.js";
|
|
3
|
+
import { $item } from "../../template-string.js";
|
|
4
|
+
import { get } from "../../property.js";
|
|
5
|
+
const item = $item `TakerSpace letter of Marque`;
|
|
6
|
+
/**
|
|
7
|
+
* Determines whether the TakerSpace letter of Marque is your current workshed
|
|
8
|
+
*
|
|
9
|
+
* @returns Whether the TakerSpace letter of Marque is your current workshed
|
|
10
|
+
*/
|
|
11
|
+
export function installed() {
|
|
12
|
+
return getWorkshed() === item;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Determines whether you `have` the TakerSpace letter of Marque (or if it is installed)
|
|
16
|
+
*
|
|
17
|
+
* @returns Whether you `have` the TakerSpace letter of Marque or it's installed
|
|
18
|
+
*/
|
|
19
|
+
export function have() {
|
|
20
|
+
return installed() || have_(item);
|
|
21
|
+
}
|
|
22
|
+
const RESOURCES = ["Spice", "Rum", "Anchor", "Mast", "Silk", "Gold"];
|
|
23
|
+
const RECIPES = new Map([
|
|
24
|
+
[$item `deft pirate hook`, [0, 0, 1, 1, 0, 1]],
|
|
25
|
+
[$item `iron tricorn hat`, [0, 0, 2, 1, 0, 0]],
|
|
26
|
+
[$item `jolly roger flag`, [0, 1, 0, 1, 1, 0]],
|
|
27
|
+
[$item `sleeping profane parrot`, [15, 3, 0, 0, 2, 1]],
|
|
28
|
+
[$item `pirrrate's currrse`, [2, 2, 0, 0, 0, 0]],
|
|
29
|
+
[$item `tankard of spiced rum`, [1, 2, 0, 0, 0, 0]],
|
|
30
|
+
[$item `packaged luxury garment`, [0, 0, 0, 0, 3, 2]],
|
|
31
|
+
[$item `harpoon`, [0, 0, 0, 2, 0, 0]],
|
|
32
|
+
[$item `chili powder cutlass`, [5, 0, 1, 0, 0, 0]],
|
|
33
|
+
[$item `cursed Aztec tamale`, [2, 0, 0, 0, 0, 0]],
|
|
34
|
+
[$item `jolly roger tattoo kit`, [0, 6, 1, 1, 0, 6]],
|
|
35
|
+
[$item `golden pet rock`, [0, 0, 0, 0, 0, 7]],
|
|
36
|
+
[$item `groggles`, [0, 6, 0, 0, 0, 0]],
|
|
37
|
+
[$item `pirate dinghy`, [0, 0, 1, 1, 1, 0]],
|
|
38
|
+
[$item `anchor bomb`, [0, 1, 3, 1, 0, 1]],
|
|
39
|
+
[$item `silky pirate drawers`, [0, 0, 0, 0, 2, 0]],
|
|
40
|
+
[$item `spices`, [1, 0, 0, 0, 0, 0]],
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* @returns A copy of our map of all recipes
|
|
44
|
+
*/
|
|
45
|
+
export function allRecipes() {
|
|
46
|
+
return new Map(RECIPES.entries().map(([item, recipe]) => [item, [...recipe]]));
|
|
47
|
+
}
|
|
48
|
+
const defaultAmount = (resource) => ["Silk", "Gold"].includes(resource) ? 1 : 3;
|
|
49
|
+
/**
|
|
50
|
+
* Determine how much of a resource you will have when the TakerSpace is installed
|
|
51
|
+
* @param resource The resource in question
|
|
52
|
+
* @returns The amount of that resource that you will have when the TakerSpace is installed
|
|
53
|
+
*/
|
|
54
|
+
export function amount(resource) {
|
|
55
|
+
return (get(`takerSpace${resource}`) +
|
|
56
|
+
(!installed() && !get("_workshedItemUsed") ? defaultAmount(resource) : 0));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Determine the Recipe for a given item
|
|
60
|
+
* @param item The item in question
|
|
61
|
+
* @returns The Recipe for that item, as a length-6 array in the order Spice, Rum, Anchor, Mast, Silk, Gold
|
|
62
|
+
*/
|
|
63
|
+
export function recipeFor(item) {
|
|
64
|
+
const result = RECIPES.get(item);
|
|
65
|
+
return result ? [...result] : null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @returns Your current available resources, as a length-6 array in the order Spice, Rum, Anchor, Mast, Silk, Gold
|
|
69
|
+
*/
|
|
70
|
+
export function currentResources() {
|
|
71
|
+
return RESOURCES.map(amount);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Determine if you have enough resources to make a particular item
|
|
75
|
+
* @param item The item in question
|
|
76
|
+
* @param amount The number of the item to make; defaults to one
|
|
77
|
+
* @returns Whether we have enough resources available to make the amount of the item
|
|
78
|
+
*/
|
|
79
|
+
export function haveEnoughFor(item, amount = 1) {
|
|
80
|
+
const recipe = recipeFor(item);
|
|
81
|
+
if (!recipe)
|
|
82
|
+
return false;
|
|
83
|
+
return currentResources().every((resource, index) => resource >= amount * recipe[index]);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Determines if you're currently able to make a particular item
|
|
87
|
+
* @param item The item in question
|
|
88
|
+
* @param amount The number of the item to make; defaults to one
|
|
89
|
+
* @returns Whether we currently can make the item--that is, whether the TakerSpace is in your workshed and you have enough resources
|
|
90
|
+
*/
|
|
91
|
+
export function canMake(item, amount = 1) {
|
|
92
|
+
return installed() && haveEnoughFor(item, amount);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Attempts to make a particular item
|
|
96
|
+
* @param item The item in question
|
|
97
|
+
* @param amount The number of the item to make; defaults to one
|
|
98
|
+
* @returns Whether we succeeded in our endeavor
|
|
99
|
+
*/
|
|
100
|
+
export function make(item, amount = 1) {
|
|
101
|
+
return canMake(item, amount) && create(item, amount);
|
|
102
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as CommaChameleon from "./2006/CommaChameleon.js";
|
|
1
2
|
import * as Stickers from "./2008/Stickers.js";
|
|
2
3
|
import * as Bandersnatch from "./2009/Bandersnatch.js";
|
|
3
4
|
import * as SpookyPutty from "./2009/SpookyPutty.js";
|
|
@@ -44,6 +45,7 @@ import * as CombatLoversLocket from "./2022/CombatLoversLocket.js";
|
|
|
44
45
|
import * as GreyGoose from "./2022/GreyGoose.js";
|
|
45
46
|
import * as JuneCleaver from "./2022/JuneCleaver.js";
|
|
46
47
|
import * as TrainSet from "./2022/TrainSet.js";
|
|
48
|
+
import * as StillSuit from "./2022/Stillsuit.js";
|
|
47
49
|
import * as AugustScepter from "./2023/AugustScepter.js";
|
|
48
50
|
import * as BurningLeaves from "./2023/BurningLeaves.js";
|
|
49
51
|
import * as CinchoDeMayo from "./2023/CinchoDeMayo.js";
|
|
@@ -55,7 +57,7 @@ import * as MayamCalendar from "./2024/MayamCalendar.js";
|
|
|
55
57
|
import * as TearawayPants from "./2024/TearawayPants.js";
|
|
56
58
|
import * as BatWings from "./2024/BatWings.js";
|
|
57
59
|
import * as EverfullDarts from "./2024/EverfullDarts.js";
|
|
58
|
-
import * as
|
|
59
|
-
export { AprilingBandHelmet, AugustScepter, AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BatWings, BeachComb, BurningLeaves, CampAway, Cartography, ChateauMantegna, ChestMimic, CinchoDeMayo, ClosedCircuitPayphone, CombatLoversLocket, ConspiracyIsland, CrimboShrub, CrownOfThrones, CrystalBall, CursedMonkeyPaw, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, EverfullDarts, FloristFriar, GingerBread, GreyGoose, Guzzlr, Horsery, JuneCleaver, JungMan, Latte, LookingGlass, MayamCalendar, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, PocketProfessor, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StillSuit, StompingBoots, TearawayPants, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
|
|
60
|
+
import * as TakerSpace from "./2024/TakerSpace.js";
|
|
61
|
+
export { AprilingBandHelmet, AugustScepter, AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BatWings, BeachComb, BurningLeaves, CampAway, Cartography, ChateauMantegna, ChestMimic, CinchoDeMayo, ClosedCircuitPayphone, CombatLoversLocket, CommaChameleon, ConspiracyIsland, CrimboShrub, CrownOfThrones, CrystalBall, CursedMonkeyPaw, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, EverfullDarts, FloristFriar, GingerBread, GreyGoose, Guzzlr, Horsery, JuneCleaver, JungMan, Latte, LookingGlass, MayamCalendar, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, PocketProfessor, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StillSuit, StompingBoots, TakerSpace, TearawayPants, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
|
|
60
62
|
export * from "./putty-likes.js";
|
|
61
63
|
export * from "./LibramSummon.js";
|
package/dist/resources/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as CommaChameleon from "./2006/CommaChameleon.js";
|
|
1
2
|
import * as Stickers from "./2008/Stickers.js";
|
|
2
3
|
import * as Bandersnatch from "./2009/Bandersnatch.js";
|
|
3
4
|
import * as SpookyPutty from "./2009/SpookyPutty.js";
|
|
@@ -44,6 +45,7 @@ import * as CombatLoversLocket from "./2022/CombatLoversLocket.js";
|
|
|
44
45
|
import * as GreyGoose from "./2022/GreyGoose.js";
|
|
45
46
|
import * as JuneCleaver from "./2022/JuneCleaver.js";
|
|
46
47
|
import * as TrainSet from "./2022/TrainSet.js";
|
|
48
|
+
import * as StillSuit from "./2022/Stillsuit.js";
|
|
47
49
|
import * as AugustScepter from "./2023/AugustScepter.js";
|
|
48
50
|
import * as BurningLeaves from "./2023/BurningLeaves.js";
|
|
49
51
|
import * as CinchoDeMayo from "./2023/CinchoDeMayo.js";
|
|
@@ -55,7 +57,7 @@ import * as MayamCalendar from "./2024/MayamCalendar.js";
|
|
|
55
57
|
import * as TearawayPants from "./2024/TearawayPants.js";
|
|
56
58
|
import * as BatWings from "./2024/BatWings.js";
|
|
57
59
|
import * as EverfullDarts from "./2024/EverfullDarts.js";
|
|
58
|
-
import * as
|
|
59
|
-
export { AprilingBandHelmet, AugustScepter, AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BatWings, BeachComb, BurningLeaves, CampAway, Cartography, ChateauMantegna, ChestMimic, CinchoDeMayo, ClosedCircuitPayphone, CombatLoversLocket, ConspiracyIsland, CrimboShrub, CrownOfThrones, CrystalBall, CursedMonkeyPaw, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, EverfullDarts, FloristFriar, GingerBread, GreyGoose, Guzzlr, Horsery, JuneCleaver, JungMan, Latte, LookingGlass, MayamCalendar, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, PocketProfessor, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StillSuit, StompingBoots, TearawayPants, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
|
|
60
|
+
import * as TakerSpace from "./2024/TakerSpace.js";
|
|
61
|
+
export { AprilingBandHelmet, AugustScepter, AutumnAton, AsdonMartin, Bandersnatch, BarrelShrine, BatWings, BeachComb, BurningLeaves, CampAway, Cartography, ChateauMantegna, ChestMimic, CinchoDeMayo, ClosedCircuitPayphone, CombatLoversLocket, CommaChameleon, ConspiracyIsland, CrimboShrub, CrownOfThrones, CrystalBall, CursedMonkeyPaw, DaylightShavings, DeckOfEveryCard, Dinseylandfill, DNALab, EverfullDarts, FloristFriar, GingerBread, GreyGoose, Guzzlr, Horsery, JuneCleaver, JungMan, Latte, LookingGlass, MayamCalendar, MayoClinic, MummingTrunk, ObtuseAngel, Pantogram, PocketProfessor, RainDoh, ReagnimatedGnome, RetroCape, Robortender, Snapper, SongBoom, SourceTerminal, Spacegate, SpookyPutty, Stickers, StillSuit, StompingBoots, TakerSpace, TearawayPants, TrainSet, TunnelOfLove, WinterGarden, Witchess, };
|
|
60
62
|
export * from "./putty-likes.js";
|
|
61
63
|
export * from "./LibramSummon.js";
|
package/dist/utils.d.ts
CHANGED
|
@@ -190,4 +190,15 @@ type Enumerate<N extends number, A extends number[] = []> = A["length"] extends
|
|
|
190
190
|
* Integers on the interval [A, B).
|
|
191
191
|
*/
|
|
192
192
|
export type Range<A extends number, B extends number> = Exclude<Enumerate<B>, Enumerate<A>>;
|
|
193
|
+
/**
|
|
194
|
+
* Translate mafia's multi-dimensional array prefs into a multi-dimensional array
|
|
195
|
+
* @param prop The property (or whatever) to process; not the property NAME, the value itself
|
|
196
|
+
* @param outerDelimiter The "outer" delimiter, which separates tuples from eachother
|
|
197
|
+
* @param innerDelimiter The "inner" delimieter, which separates the elements of tuples from eachother
|
|
198
|
+
* @param mappers An array of string => whatever mapping functions that turn this into the actual objects we want
|
|
199
|
+
* @returns An array of typed tuples, based on the given inputs
|
|
200
|
+
*/
|
|
201
|
+
export declare function multiSplit<T extends any[]>(prop: string, outerDelimiter: string, innerDelimiter: string, mappers: {
|
|
202
|
+
[K in keyof T]: (str: string) => T[K];
|
|
203
|
+
}): T[];
|
|
193
204
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -274,3 +274,19 @@ export function random(array) {
|
|
|
274
274
|
* @returns Word in title case
|
|
275
275
|
*/
|
|
276
276
|
export const tc = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
277
|
+
/**
|
|
278
|
+
* Translate mafia's multi-dimensional array prefs into a multi-dimensional array
|
|
279
|
+
* @param prop The property (or whatever) to process; not the property NAME, the value itself
|
|
280
|
+
* @param outerDelimiter The "outer" delimiter, which separates tuples from eachother
|
|
281
|
+
* @param innerDelimiter The "inner" delimieter, which separates the elements of tuples from eachother
|
|
282
|
+
* @param mappers An array of string => whatever mapping functions that turn this into the actual objects we want
|
|
283
|
+
* @returns An array of typed tuples, based on the given inputs
|
|
284
|
+
*/
|
|
285
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
|
+
export function multiSplit(prop, outerDelimiter, innerDelimiter, mappers) {
|
|
287
|
+
const initialSplit = prop.split(outerDelimiter).filter(Boolean);
|
|
288
|
+
const multiDimensionalArray = outerDelimiter === innerDelimiter
|
|
289
|
+
? chunk(initialSplit, mappers.length)
|
|
290
|
+
: initialSplit.map((entry) => entry.split(innerDelimiter));
|
|
291
|
+
return multiDimensionalArray.map((tup) => mappers.map((func, index) => func(tup[index])));
|
|
292
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libram",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.25",
|
|
4
4
|
"description": "JavaScript helper library for KoLmafia",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"eslint-config-prettier": "^9.1.0",
|
|
49
49
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
50
50
|
"eslint-plugin-jsdoc": "^50.2.3",
|
|
51
|
-
"eslint-plugin-libram": "^0.4.
|
|
51
|
+
"eslint-plugin-libram": "^0.4.18",
|
|
52
52
|
"husky": "^9.1.6",
|
|
53
53
|
"java-parser": "^2.3.2",
|
|
54
54
|
"kolmafia": "^5.28047.0",
|