Skip to content

Commit

Permalink
KoL Con 13 snowglobe tracking (#63)
Browse files Browse the repository at this point in the history
* KoL Con 13 snowglobe tracking

* Update dropConSnowglobe.ts
  • Loading branch information
Rinn authored Apr 7, 2024
1 parent d4c5949 commit 7312f3a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
99 changes: 99 additions & 0 deletions packages/excavator-script/src/projects/dropConSnowglobe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* @author rinn
* Track drops from the KoL Con 13 snowglobe
*/
import { currentRound, equippedAmount, Item } from "kolmafia";
import { $item } from "libram";

import { ExcavatorProject } from "../type";
import { toNormalisedString } from "../utils/game";

type Indicator = { type: "substat" | "item"; pattern: RegExp };

const INDICATORS: Indicator[] = [
{
type: "substat",
pattern: /when you helped carry the kegs to an afterparty/g,
},
{
type: "substat",
pattern: /when you armwrestled/g,
},
{ type: "substat", pattern: /took turns doing benchpresses with/g },
{
type: "substat",
pattern:
/trivia contest with your vast stores of useless esoteric knowledge/g,
},
{
type: "substat",
pattern: /taught you to play that really complicated board game/g,
},
{
type: "substat",
pattern:
/when you managed to successfully coordinate a dinner for a group/g,
},
{ type: "substat", pattern: /totally stole the show at karaoke/g },
{
type: "substat",
pattern: /when everybody got really excited about your/g,
},
{ type: "substat", pattern: /complimented you on your dancing/g },
{
type: "item",
pattern:
/and find a weird thing you don't remember packing in the first place.*?You acquire an item: <b>(.*?)<\/b>/g,
},
{
type: "item",
pattern:
/go into your kitchen and try to recreate it.*?You acquire an item: <b>(.*?)<\/b>/g,
},
{
type: "item",
pattern:
/that dinner is still in your refrigerator.*?You acquire an item: <b>(.*?)<\/b>/g,
},
];

type SnowglobeData = {
type: string;
item: string;
};

function spadeSnowglobe(
encounter: string,
page: string,
): SnowglobeData[] | null {
// Must be end of battle
if (currentRound() !== 0) return null;
// Must be wearing KoL Con 13 snowglobe
if (equippedAmount($item`KoL Con 13 snowglobe`) < 1) return null;

const data = [];

for (const indicator of INDICATORS) {
// Multiple results are possible if the time-twitching toolbelt is equipped
for (const match of page.matchAll(indicator.pattern)) {
let str = "";
if (indicator.type === "item") {
const item = Item.get(match[1]);
str = item !== $item`none` ? toNormalisedString(item) : match[1];
}
data.push({
type: indicator.type,
item: str,
});
}
}

return data;
}

export const DROP_CON_SNOWGLOBE: ExcavatorProject = {
name: "KoL Con 13 Snowglobe",
hooks: {
COMBAT_ROUND: spadeSnowglobe,
},
};
2 changes: 1 addition & 1 deletion packages/excavator-script/src/projects/dropMrCheengs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @author rinn
* Track drops from the can of mixed everything
* Track drops from the Mr. Cheeng's Spectacles
*/
import { currentRound, equippedAmount, Item } from "kolmafia";
import { $item } from "libram";
Expand Down
2 changes: 1 addition & 1 deletion packages/excavator-script/src/projects/dropMrScreeges.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @author rinn
* Track drops from the can of mixed everything
* Track drops from the Mr. Screege's Spectacles
*/
import { currentRound, equippedAmount, Item } from "kolmafia";
import { $item } from "libram";
Expand Down
2 changes: 2 additions & 0 deletions packages/excavator-script/src/projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ExcavatorProject } from "../type";
import { AUTUMNATON } from "./autumnaton";
import { BIRD_A_DAY } from "./birdADay";
import { COAT_OF_PAINT } from "./coatOfPaint";
import { DROP_CON_SNOWGLOBE } from "./dropConSnowglobe";
import { DROP_MIXED_EVERYTHING } from "./dropMixedEverything";
import { DROP_MR_CHEENGS } from "./dropMrCheengs";
import { DROP_MR_SCREEGES } from "./dropMrScreeges";
Expand All @@ -20,6 +21,7 @@ export const projects: ExcavatorProject[] = [
GENIE,
HOOKAH,
JUICE_BAR,
DROP_CON_SNOWGLOBE,
DROP_MIXED_EVERYTHING,
DROP_MR_CHEENGS,
DROP_MR_SCREEGES,
Expand Down

0 comments on commit 7312f3a

Please sign in to comment.