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

Support trick coin & prank crimbo card (sniff=) #10

Merged
merged 2 commits into from
Dec 25, 2023
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
24 changes: 24 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ export const args = Args.create("crimbo23", "A script for farming elf stuff", {
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" {
Expand Down Expand Up @@ -207,6 +217,20 @@ 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
28 changes: 27 additions & 1 deletion src/macro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import {
myFamiliar,
myPrimestat,
Skill,
toMonster,
visitUrl,
} from "kolmafia";
import {
$class,
$familiar,
$item,
$items,
$monster,
$phylum,
$skill,
$slot,
$stat,
Counter,
get,
have,
maxBy,
Expand All @@ -26,7 +30,7 @@ import {
} from "libram";

import { canOpenRedPresent, timeToMeatify } from "./familiar";
import { shouldRedigitize } from "./lib";
import { getSniffTarget, shouldRedigitize } from "./lib";

const gooKillSkills = [
{ skill: $skill`Nantlers`, stat: $stat`muscle` },
Expand Down Expand Up @@ -170,9 +174,31 @@ export default class Macro extends StrictMacro {
return new Macro().gooKill();
}

trySniff(): this {
const monster = getSniffTarget();
if (monster === null) return this;
if (monster.phylum === $phylum`elf`) {
const prankCardMonster = toMonster(get('_prankCardMonster'));
if (prankCardMonster === monster && Counter.get("Prank Card Monster") !== Infinity) return this;
// eslint-disable-next-line libram/verify-constants
return this.if_(monster, Macro.tryHaveItem($item`prank Crimbo card`));
} else if (monster.phylum === $phylum`pirate`) {
const trickCoinMonster = toMonster(get('_trickCoinMonster'));
if (trickCoinMonster === monster && Counter.get("Trick Coin Monster") !== Infinity) return this;
// eslint-disable-next-line libram/verify-constants
return this.if_(monster, Macro.tryHaveItem($item`trick coin`));
}
return this;
}

static trySniff(): Macro {
return new Macro().trySniff();
}

standardCombat(): this {
return this.if_("!monstername Crimbuccaneer mudlark && !monstername Elf Guard engineer", "pickpocket")
.tryHaveSkill($skill`Curse of Weaksauce`)
.trySniff()
.familiarActions()
.externalIf(
SongBoom.song() === "Total Eclipse of Your Meat",
Expand Down
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from "libram";

import { CrimboEngine, CrimboQuest, CrimboStrategy, CrimboTask } from "./engine";
import { args, printh, validateAndSetOrbTarget } from "./lib";
import { args, printh, validateAndSetOrbTarget, validateAndSetSniffTarget } from "./lib";
import Macro from "./macro";
import { chooseQuestOutfit } from "./outfit";
import { setup } from "./setup";
Expand All @@ -46,9 +46,10 @@ export function main(command?: string) {
}

validateAndSetOrbTarget(args.orb, args.zone, args.affiliation);
validateAndSetSniffTarget(args.sniff, args.zone, args.affiliation);
setDefaultMaximizeOptions({ preventSlot: $slots`crown-of-thrones, buddy-bjorn` });

sinceKolmafiaRevision(27022);
sinceKolmafiaRevision(27753);
const turncount = myTurncount();
const completed =
args.turns > 0
Expand Down