Skip to content

Commit 645fa46

Browse files
Merge branch 'main' into bcz-cast
2 parents 41c9e36 + 0ff05b8 commit 645fa46

File tree

6 files changed

+82
-6
lines changed

6 files changed

+82
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "libram",
3-
"version": "0.11.16",
3+
"version": "0.11.17",
44
"description": "JavaScript helper library for KoLmafia",
55
"type": "module",
66
"main": "dist/index.js",

src/modifier.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,17 @@ export type ModifierParser = {
325325
multiString: (value: string) => string[];
326326
};
327327

328-
function parseModifierString(
328+
/**
329+
* Parse a modifier string into a Modifiers object
330+
* @param modifiers The modifier string to parse
331+
* @param parser An optional partial object for transforming string values into modifier values
332+
* @param parser.numeric How to translate values into numeric modifiers; defaults to the Number function
333+
* @param parser.str How to translate values into string modifiers; defaults to the String function
334+
* @param parser.bool How to translate values into boolean modifiers; defaults to checking equality with `"true"`
335+
* @param parser.multiString How to parse multistring modifiers; defaults to splitting on `,`
336+
* @returns A `Modifiers` object
337+
*/
338+
export function parseModifierString(
329339
modifiers: string,
330340
{
331341
numeric = Number,

src/propertyTypes.ts

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

src/resources/2015/ChateauMantegna.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,26 @@ export function changeNightstand(nightstand: Nightstand): boolean {
114114
buy(Item.get(nightstand));
115115
return getNightstand() === nightstand;
116116
}
117+
118+
/**
119+
* @returns Whether we successfully harvested
120+
*/
121+
export function harvestDesk(): boolean {
122+
if (get("_chateauDeskHarvested")) return false;
123+
const currentDesk = getDesk();
124+
const deskMap = new Map([
125+
["Swiss piggy bank", 1],
126+
["continental juice bar", 2],
127+
["fancy stationery set", 3],
128+
]);
129+
if (currentDesk) {
130+
visitUrl(
131+
`place.php?whichplace=chateau&action=chateau_desk${deskMap.get(currentDesk)}`,
132+
false,
133+
);
134+
} else {
135+
return false;
136+
}
137+
138+
return get("_chateauDeskHarvested");
139+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Item, equippedItem, stringModifier } from "kolmafia";
2+
import { have as have_ } from "../../lib.js";
3+
import { $item, $slots } from "../../template-string.js";
4+
import { Modifiers, parseModifierString } from "../../modifier";
5+
6+
/**
7+
* @returns Whether or not you `have` The Eternity Codpiece
8+
*/
9+
export function have(): boolean {
10+
return have_($item`The Eternity Codpiece`);
11+
}
12+
13+
export const SLOTS = Object.freeze(
14+
$slots`codpiece1, codpiece2, codpiece3, codpiece4, codpiece5`,
15+
);
16+
17+
/**
18+
* @returns An array of the current gems you have equipped in your codpiece, regardless of whether the codpiece is active
19+
*/
20+
export function currentGems(): Item[] {
21+
return SLOTS.map((slot) => equippedItem(slot));
22+
}
23+
24+
/**
25+
* Determines if a given item is a codpieceable gem
26+
* @param item The gem in question
27+
* @returns Whether or not it can be placed into your codpiece
28+
*/
29+
export function equippable(item: Item): boolean {
30+
return stringModifier(`EternityCodpiece:${item}`, "Modifiers").length > 0;
31+
}
32+
33+
/**
34+
* Parse the expected modifiers of a gem item into a `Modifiers` object
35+
* @param item The gem in question
36+
* @returns A `Modifiers` object representing the gem's enchantment in the codpiece
37+
*/
38+
export function modifiers(item: Item): Modifiers {
39+
return parseModifierString(
40+
stringModifier(`EternityCodpiece:${item}, "Modifiers`),
41+
);
42+
}

src/resources/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import * as PrismaticBeret from "./2025/PrismaticBeret.js";
7070
import * as BloodCubicZirconia from "./2025/BloodCubicZirconia.js";
7171
import * as SkeletonOfCrimboPast from "./2025/SkeletonOfCrimboPast.js";
7272
import * as LegendarySealClubbingClub from "./2026/LegendarySealClubbingClub.js";
73-
73+
import * as EternityCodpiece from "./2026/EternityCodpiece.js";
7474
export {
7575
AprilingBandHelmet,
7676
AsdonMartin,
@@ -103,6 +103,7 @@ export {
103103
DesignerSweatpants,
104104
Dinseylandfill,
105105
DNALab,
106+
EternityCodpiece,
106107
EverfullDarts,
107108
FloristFriar,
108109
GingerBread,

0 commit comments

Comments
 (0)