Skip to content

Commit

Permalink
more skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
horrible-little-slime committed Dec 18, 2024
1 parent 740c830 commit be3add7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 74 deletions.
6 changes: 4 additions & 2 deletions src/islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type HolidayIsland = {
choice: number,
}

export const Easter: HolidayIsland = {
const Easter: HolidayIsland = {
// eslint-disable-next-line libram/verify-constants
location: $location`Easter Island`,
element: $element`Stench`,
Expand All @@ -17,11 +17,13 @@ export const Easter: HolidayIsland = {
choice: 1538
};

export const StPatrick: HolidayIsland = {
const StPatrick: HolidayIsland = {
// eslint-disable-next-line libram/verify-constants
location: $location`St. Patrick's Day Island`,
element: $element`Sleaze`,
// eslint-disable-next-line libram/verify-constants
orbTarget: $monster`giant potato`,
choice: 1539
}

export default { Easter, StPatrick }
2 changes: 0 additions & 2 deletions src/islands/easter.ts

This file was deleted.

86 changes: 16 additions & 70 deletions src/lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable libram/verify-constants */
import { Args } from "grimoire-kolmafia";
import { Args, ParseError } from "grimoire-kolmafia";
import {
descToItem,
haveEquipped,
Expand All @@ -22,14 +22,15 @@ import {
$monster,
Counter,
CrystalBall,
flat,
get,
have,
SourceTerminal,
} from "libram";

import ISLANDS from './islands';
import * as OrbManager from "./orbmanager";

export type Island = keyof typeof ISLANDS;

export function shouldRedigitize(): boolean {
const digitizesLeft = SourceTerminal.getDigitizeUsesRemaining();
const monsterCount = SourceTerminal.getDigitizeMonsterCount() + 1;
Expand Down Expand Up @@ -140,68 +141,27 @@ export const args = Args.create("crimbo23", "A script for farming elf stuff", {
help: "The number of turns to run (use negative numbers for the number of turns remaining)",
default: Infinity,
}),
zone: Args.string({
options: [
["armory", "Armory"],
["bar", "The Bar"],
["cafe", "Cafe"],
["cottage", "Abuela's Cottage"],
["foundry", "Pirate Foundry"],
],
default: "cottage",
}),
affiliation: Args.string({
options: [
["none", "Do not pick a side"],
["elves", "Fight for the elves"],
["pirates", "Fight for the Crimbuccaneers"],
],
help: "The side to fight for.",
default: "elves",
}),
island: Args.custom<Island[]>({
hidden: false,
}, (str) => {
const splitStr = str.split(",");
if (![1, 2].includes(splitStr.length)) return new ParseError("Can only select 1 or 2 islands!");
if (!CrystalBall.have() && splitStr.length === 2) return new ParseError("Can only select 2 islands with orb!");
const mappedStr = splitStr.map((islandName) => Object.keys(ISLANDS).find((island) => island.toLowerCase() === islandName.toLowerCase()) ?? new ParseError(`Cannot find island for string ${islandName}`));
const error = mappedStr.find((el) => el instanceof ParseError);
if (error) return error;
return mappedStr as Island[]
}, ""),
shrub: Args.boolean({
help: "Whether to use the Crimbo Shrub when farming Crimbo zones.",
default: false,
}),
debug: Args.flag({
help: "Turn on debug printing",
default: false,
}),
orb: Args.string({
options: [
...Object.entries(
Object.assign({}, ...flat(Object.values(affiliatedZoneMonsters).map(Object.values)))
).map(([key, val]) => [key, `${val}`] as [string, string]),
["none", "Don't use it"],
],
help: "Monster to target with the orb.",
default: "none",
}),
sniff: Args.string({
options: [
...Object.entries(
Object.assign({}, ...flat(Object.values(affiliatedZoneMonsters).map(Object.values)))
).map(([key, val]) => [key, `${val}`] as [string, string]),
["none", "Don't use it"],
],
help: "Monster to sniff with a prank Crimbo card or trick coin (does not autobuy)",
default: "none",
}),
}, ),
});

export function chosenAffiliation(): "none" | "elves" | "pirates" {
switch (args.affiliation) {
case "none":
return "none";
case "elves":
return "elves";
case "pirates":
return "pirates";
default:
throw `Unknown affiliation ${args.affiliation}`;
}
}

let orbTarget: Monster | null = null;
export function validateAndSetOrbTarget(target: string, zone: string, affiliation: string) {
if (target === "none") return;
Expand All @@ -217,20 +177,6 @@ export function getOrbTarget(): Monster | null {
return orbTarget;
}

let sniffTarget: Monster | null = null;
export function validateAndSetSniffTarget(target: string, zone: string, affiliation: string) {
if (target === "none") return;
if (!(zone in affiliatedZoneMonsters)) throw new Error("Invalid zone specified");
const affiliatedMonsters = affiliatedZoneMonsters[zone as keyof typeof affiliatedZoneMonsters];
if (!(affiliation in affiliatedMonsters)) throw new Error("Invalid affiliation specified");
const monsters = affiliatedMonsters[affiliation as keyof typeof affiliatedMonsters];
if (!(target in monsters)) throw new Error("Invalid target specified");
sniffTarget = monsters[target as keyof typeof monsters];
}
export function getSniffTarget(): Monster | null {
return sniffTarget;
}

function getCMCChoices(): { [choice: string]: number } {
const options = visitUrl("campground.php?action=workshed");
let i = 0;
Expand Down

0 comments on commit be3add7

Please sign in to comment.