Skip to content

Commit

Permalink
Merge pull request #101 from loathers/more-nc-force
Browse files Browse the repository at this point in the history
Rely on mafia reporting NC forcing being active, use fiesta exits
  • Loading branch information
gausie authored Dec 4, 2023
2 parents 4f3977d + ed49c02 commit 70e5eb4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 53 deletions.
5 changes: 0 additions & 5 deletions src/capsule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { $item, $location, getKramcoWandererChance } from "libram";

import { ChronerQuest, ChronerStrategy } from "./engine";
import { sober } from "./lib";
import Macro from "./macro";
import { chooseQuestOutfit, ifHave } from "./outfit";

Expand All @@ -15,17 +14,13 @@ export const capsule: ChronerQuest = {
completed: () => false,
do: $location`The Cave Before Time`,
outfit: () => {
const drunkSpec = sober()
? {}
: { offhand: $item`Drunkula's wineglass` };
const sausageSpec =
getKramcoWandererChance() >= 1
? ifHave("offhand", $item`Kramco Sausage-o-Matic™`)
: {};
return chooseQuestOutfit(
{ location, isFree: getKramcoWandererChance() >= 1 },
sausageSpec,
drunkSpec,
);
},
combat: new ChronerStrategy(() => Macro.standardCombat()),
Expand Down
21 changes: 1 addition & 20 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ export class ChronerStrategy extends CombatStrategy {
}
}

function countAvailableNcForces() {
return (get("_claraBellUsed") ? 0 : 1) + (5 - get("_spikolodonSpikeUses"));
}

let ncForced = false;
export function resetNcForced() {
printd("Reset NC forcing");
ncForced = false;
}
CrownOfThrones.createRiderMode("default", {});
const chooseRider = () => CrownOfThrones.pickRider("default");
export class ChronerEngine extends Engine<never, ChronerTask> {
Expand All @@ -55,7 +46,7 @@ export class ChronerEngine extends Engine<never, ChronerTask> {
(!sober() && task.sobriety === "drunk");

if (task.forced) {
return sobriety && ncForced && super.available(task);
return sobriety && get("noncombatForcerActive") && super.available(task);
}
return sobriety && super.available(task);
}
Expand All @@ -72,16 +63,6 @@ export class ChronerEngine extends Engine<never, ChronerTask> {
return outfit;
}

execute(task: ChronerTask): void {
const ncBefore = countAvailableNcForces();
super.execute(task);
const ncAfter = countAvailableNcForces();

if (ncBefore > ncAfter) {
ncForced = true;
}
}

setChoices(task: ChronerTask, manager: PropertiesManager): void {
super.setChoices(task, manager);
if (equippedAmount($item`June cleaver`) > 0) {
Expand Down
5 changes: 0 additions & 5 deletions src/future.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { $item, $location, $monster, getKramcoWandererChance } from "libram";

import { ChronerQuest, ChronerStrategy } from "./engine";
import { sober } from "./lib";
import Macro from "./macro";
import { chooseQuestOutfit, ifHave } from "./outfit";

Expand All @@ -19,17 +18,13 @@ export const future: ChronerQuest = {
completed: () => false,
do: location,
outfit: () => {
const drunkSpec = sober()
? {}
: { offhand: $item`Drunkula's wineglass` };
const sausageSpec =
getKramcoWandererChance() >= 1
? ifHave("offhand", $item`Kramco Sausage-o-Matic™`)
: {};
return chooseQuestOutfit(
{ location, isFree: getKramcoWandererChance() >= 1 },
sausageSpec,
drunkSpec,
);
},
combat: new ChronerStrategy(() =>
Expand Down
36 changes: 19 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
adv1,
canAdventure,
cliExecute,
getLocationMonsters,
myAdventures,
myClass,
myTurncount,
totalTurnsPlayed,
use,
useSkill,
visitUrl,
} from "kolmafia";
import {
Expand All @@ -20,6 +20,7 @@ import {
$monsters,
$skill,
AsdonMartin,
CinchoDeMayo,
Counter,
get,
have,
Expand All @@ -34,9 +35,8 @@ import {
ChronerQuest,
ChronerStrategy,
ChronerTask,
resetNcForced,
} from "./engine";
import { args, printd, printh } from "./lib";
import { args, printh } from "./lib";
import Macro from "./macro";
import { chooseQuestOutfit } from "./outfit";
import { rose } from "./rose";
Expand Down Expand Up @@ -114,6 +114,20 @@ export function main(command?: string) {
},
sobriety: "either",
},
{
name: "Fiesta Exit",
ready: () => CinchoDeMayo.totalAvailableCinch() > 60,
completed: () => get("noncombatForcerActive"),
do: () => {
const turns = totalTurnsPlayed();
while (CinchoDeMayo.currentCinch() < 60) {
cliExecute("rest");
if (totalTurnsPlayed() > turns) break;
}
useSkill(1, $skill`Cincho: Fiesta Exit`);
},
sobriety: "either",
},
{
name: "Proton Ghost",
ready: () =>
Expand Down Expand Up @@ -206,20 +220,8 @@ export function main(command?: string) {
name: "Time Capsule",
do: () => {
adv1($location`The Cave Before Time`, 0, "");
if (get("lastEncounter") === "Time Cave. Period.") {
printd("Forced noncombat!");
resetNcForced();
} else {
printd("Uh oh, we didn't force the NC");
const possibleEncouters = Object.keys(
getLocationMonsters($location`The Cave Before Time`),
);
if (possibleEncouters.includes(get("lastEncounter"))) {
printd("We hit a normal monster, so reset the noncombat forcing");
resetNcForced();
} else {
printd("We hit something else, so keep trying for the noncombat");
}
if (get("lastEncounter") !== "Time Cave. Period.") {
throw "We expeted to force the NC";
}
},
forced: true,
Expand Down
6 changes: 6 additions & 0 deletions src/outfit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function chooseQuestOutfit(
p: get("_voidFreeFights") < 5 ? 1 / 13 : 0,
},
].filter(({ i }) => have(i) && canEquip(i));

const offhands = freeChance.length
? { offhand: maxBy(freeChance, "p").i }
: {};
Expand Down Expand Up @@ -105,6 +106,11 @@ export function chooseQuestOutfit(
spec[`acc${i + 1}` as OutfitSlot] = accessory;
}
const mergedSpec = mergeSpecs(...outfits, spec);

if (!sober()) {
mergedSpec.offhand = $item`Drunkula's wineglass`;
}

if (
!have($item`Crown of Thrones`) &&
have($item`Buddy Bjorn`) &&
Expand Down
5 changes: 0 additions & 5 deletions src/rose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "libram";

import { ChronerQuest, ChronerStrategy } from "./engine";
import { sober } from "./lib";
import Macro from "./macro";
import { chooseQuestOutfit, ifHave } from "./outfit";

Expand Down Expand Up @@ -38,17 +37,13 @@ export const rose: ChronerQuest = {
completed: () => false,
do: $location`Globe Theatre Main Stage`,
outfit: () => {
const drunkSpec = sober()
? {}
: { offhand: $item`Drunkula's wineglass` };
const sausageSpec =
getKramcoWandererChance() >= 1
? ifHave("offhand", $item`Kramco Sausage-o-Matic™`)
: {};
return chooseQuestOutfit(
{ location, isFree: getKramcoWandererChance() >= 1 },
sausageSpec,
drunkSpec,
);
},
combat: new ChronerStrategy(() => Macro.standardCombat()),
Expand Down
2 changes: 1 addition & 1 deletion src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const setup: Quest<ChronerTask> = {
completed: () => AutumnAton.currentlyIn() !== null,
do: (): void => {
AutumnAton.sendTo(
$locations`Moonshiners' Woods, The Cave Before Time, The Sleazy Back Alley`,
$locations`The Post-Mall, Moonshiners' Woods, The Cave Before Time, The Sleazy Back Alley`,
);
},
ready: () => AutumnAton.available(),
Expand Down

0 comments on commit 70e5eb4

Please sign in to comment.