Skip to content

Commit

Permalink
Summon Mayfly Swarm tracking (#82)
Browse files Browse the repository at this point in the history
Tracks odds of intermittent zone\location effects based on swarm size
  • Loading branch information
Rinn committed Jun 18, 2024
1 parent bdea636 commit 8be1fc6
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/excavator-projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { JUICE_BAR } from "./projects/juiceBar";
import { MONSTER_PARTS } from "./projects/monsterParts";
import { MUMMING_TRUNK } from "./projects/mummingTrunk";
import { OUT_OF_ORDER } from "./projects/outOfOrder";
import { SUMMON_MAYFLY_SWARM } from "./projects/summonMayflySwarm";
import type { ExcavatorProject } from "./type";

export { ExcavatorProject };
Expand All @@ -31,4 +32,5 @@ export const projects: ExcavatorProject[] = [
MUMMING_TRUNK,
OUT_OF_ORDER,
DESIGNER_SWEATPANTS,
SUMMON_MAYFLY_SWARM,
];
112 changes: 112 additions & 0 deletions packages/excavator-projects/projects/summonMayflySwarm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import {
currentRound,
equippedAmount,
Item,
Location,
myLocation,
} from "kolmafia";

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

const ZONE_PATTERNS = new Map<string, RegExp>([
[
"Conspiracy Island",
/The swarm of mayflies buzzes off into the spooky distance and returns a few minutes later, struggling under the weight of a mysterious coin/,
],
[
"Dinseylandfill",
/The swarm of mayflies buzzes off into the distance and returns a few moments later carrying a rolled up FunFunds/,
],
[
"Twitch",
/The swarm of mayflies buzzes off into the greasy distance and returns a few minutes later, struggling under the weight of a shiny coin/,
],
[
"Spring Break Beach",
/The swarm of mayflies buzzes off into the greasy distance and returns a few minutes later, struggling under the weight of a damp bill/,
],
[
"The Glaciest",
/The swarm of mayflies buzzes off into the frigid distance and returns a short while later carrying a rolled up Wal-Mart gift certificate/,
],
[
"Dreadsylvania",
/The swarm of mayflies buzzes off into the dreary distance and returns a few minutes later, struggling under the weight of a coin/,
],
[
"Degrassi Knoll",
/The swarm of mayflies buzzes off in the direction of one of the myriad workbenches littering the Knoll/,
],
]);

const LOCATION_PATTERNS = new Map<Location, RegExp>([
[
Location.get("Hobopolis Town Square"),
/The swarm of mayflies buzzes off into the distance and returns a few minutes later, struggling under the weight of a coin/,
],
[
Location.get("The Hole in the Sky"),
/mistakes the swarm of flies for a different (and apparently very frightening) constellation, and runs off so fast it leaves some little bits of itself behind/,
],
[
Location.get("The Sleazy Back Alley"),
/The swarm flies into a dumpster, buzzes around for a bit, and flies back out looking slightly larger/,
],
[
Location.get("The Slime Tube"),
/The swarm of mayflies plunges into the mass of Slime and emerges a few moments later, coated with goo and carrying a little glob of something/,
],
[
Location.get("South of The Border"),
/After the fight is over, one of those annoying kids runs up and tries to sell you some gum/,
],
]);

const SWARM_PATTERN = /mayflies(\d+)\.gif/;
const ITEM_PATTERN =
/The swarm of mayflies buzzes around the ground, helping you find stuff/;
const MEAT_PATTERN =
/The swarm of mayflies draws your attention to more Meat than you would've otherwise found/;

export const SUMMON_MAYFLY_SWARM: ExcavatorProject = {
name: "Summon Mayfly Swarm",
slug: "mayflyswarm",
description:
"Spade how swarm size affects result odds when casting Summon Mayfly Swarm",
author: "Rinn",
hooks: {
COMBAT_ROUND: (_: string, page: string) => {
// Must be end of battle
if (currentRound() !== 0) return null;
// Must be wearing mayfly bait necklace
if (equippedAmount(Item.get("mayfly bait necklace")) < 1) return null;
// Must be in a tracked zone or location
const specialPattern =
ZONE_PATTERNS.get(myLocation().zone) ??
LOCATION_PATTERNS.get(myLocation());
if (!specialPattern) return null;
// Ensure it was cast and get the swarm size from the image
const swarmResult = page.match(SWARM_PATTERN);
if (!swarmResult) return null;
const swarmSize = Number(swarmResult[1]);
// either zone or location, no need for multiple columns
const area =
myLocation().zone in ZONE_PATTERNS
? myLocation().zone
: `${myLocation()}`;
const patterns = {
special: specialPattern,
item: ITEM_PATTERN,
meat: MEAT_PATTERN,
};
const result =
Object.entries(patterns).find(([_, v]) => page.match(v))?.[0] ??
"nothing";
return {
area: area,
size: swarmSize,
result: result,
};
},
},
};

0 comments on commit 8be1fc6

Please sign in to comment.