Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black & White Apron project #105

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/excavator-projects/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AUTUMNATON } from "./projects/autumnaton";
import { BIRD_A_DAY } from "./projects/birdADay";
import { BLACK_AND_WHITE_APRON } from "./projects/blackAndWhiteApron";
import { COAT_OF_PAINT } from "./projects/coatOfPaint";
import { DESIGNER_SWEATPANTS } from "./projects/designerSweatpants";
import { DROP_BINDLESTOCKING } from "./projects/dropBindlestocking";
Expand All @@ -22,6 +23,7 @@ export { ExcavatorProject };
export const projects: ExcavatorProject[] = [
AUTUMNATON,
BIRD_A_DAY,
BLACK_AND_WHITE_APRON,
COAT_OF_PAINT,
GENIE,
HOOKAH,
Expand Down
55 changes: 55 additions & 0 deletions packages/excavator-projects/projects/blackAndWhiteApron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { getProperty, myClass, myDaycount, myPath } from "kolmafia";

import { ExcavatorProject } from "../type";

export const BLACK_AND_WHITE_APRON: ExcavatorProject = {
name: "Black & White Apron",
slug: "bwapron",
description: "Spade how the Black & White Apron meals are seeded",
author: "worthawholebean",
hooks: {
CHOICE_VISIT(choice: string, page: string) {
if (choice !== "1518") return null;
return spadeBw(page);
},
},
since: 28071,
};

function spadeBw(page: string) {
const main0 = page.match(
/name="meal"\s+value="0"\s+data-name="([^"]*)"/,
)?.[1];
if (!main0) return null;
const main = {
"dinner salad": "lettuce",
"chicken wings": "chicken",
"baked potatoes": "potato",
"beef stew": "beef",
"fish sandwich": "fish",
"pork butt": "pork",
}[main0];
if (!main) return null;

const ingredientMatches = Array.from(
page.matchAll(/name="ingredients([0-9])\[\]"\s+value="([0-9]+)"/g),
);
if (ingredientMatches.length !== 15) return null;
let mealsEaten = parseInt(getProperty("bwApronMealsEaten"));
if (!Number.isFinite(mealsEaten)) mealsEaten = -1;
gausie marked this conversation as resolved.
Show resolved Hide resolved

const result = {
path: myPath().id,
class: myClass().id,
day: myDaycount(),
mealsEaten,
main,
...Object.fromEntries(
ingredientMatches.map(([, meal, ingredient], index) => [
`ingredient${meal}${index % 5}`,
ingredient,
]),
),
};
return result;
}