From d2a6ad2ac7a28ec30667ac1d8eaf8a8549bd47ec Mon Sep 17 00:00:00 2001 From: Ignose Date: Wed, 18 Oct 2023 16:43:40 -0400 Subject: [PATCH] Add experimental profit save check --- src/lib.ts | 9 +++++++++ src/resources.ts | 4 ++++ src/tasks/boozedrop.ts | 26 +++++++++----------------- src/tasks/leveling.ts | 7 ++++++- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/lib.ts b/src/lib.ts index 75c4291..3b597df 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -621,3 +621,12 @@ export const generalStoreXpEffect: Effect = { Mysticality: $effect`Glittering Eyelashes`, Moxie: $effect`Butt-Rock Hair`, }[mainStatStr]; + +export function checkLocketAvailable(): number { + const locketAvailable = + (get("instant_saveLocketRedSkeleton", false) ? 1 : 0) + + (get("instant_saveLocketWitchessKing", false) ? 1 : 0) + + (get("instant_saveLocketFactoryWorker", false) ? 1 : 0); + + return locketAvailable; +} diff --git a/src/resources.ts b/src/resources.ts index ebc3ae0..2faa2ef 100644 --- a/src/resources.ts +++ b/src/resources.ts @@ -219,6 +219,10 @@ const otherResources: Resource[] = [ "instant_skipBorrowedTime", "Do not use borrowed time. Level to 5 using trainset, and eat pizzas to get coil adventures. Make sure you know what you're doing before using this." ), + new Resource( + "instant_maximizeProfit", + "Check the opportunity cost of every resource spent, before spending it. If the opportunity cost is higher than turnsave * MPA, skip it." + ), ]; const allResources = [ diff --git a/src/tasks/boozedrop.ts b/src/tasks/boozedrop.ts index 09fec55..c567ba3 100644 --- a/src/tasks/boozedrop.ts +++ b/src/tasks/boozedrop.ts @@ -42,6 +42,7 @@ import { CommunityService, DaylightShavings, get, + getSaleValue, have, TrainSet, uneffect, @@ -53,26 +54,13 @@ import { setConfiguration, Station, } from "libram/dist/resources/2022/TrainSet"; -import { fuelUp, logTestSetup, tryAcquiringEffect, wishFor } from "../lib"; +import { checkLocketAvailable, fuelUp, logTestSetup, tryAcquiringEffect, wishFor } from "../lib"; import { chooseFamiliar, sugarItemsAboutToBreak } from "../engine/outfit"; import { CombatStrategy } from "grimoire-kolmafia"; import Macro from "../combat"; import { forbiddenEffects } from "../resources"; import { drive } from "libram/dist/resources/2017/AsdonMartin"; -function checkLocketAvailable(): boolean { - const locketAvailable = - (get("instant_saveLocketRedSkeleton", false) ? 1 : 0) + - (get("instant_saveLocketWitchessKing", false) ? 1 : 0) + - (get("instant_saveLocketFactoryWorker", false) ? 1 : 0); - - if (locketAvailable >= 2) { - return true; - } else { - return false; - } -} - export const BoozeDropQuest: Quest = { name: "Booze Drop", completed: () => CommunityService.BoozeDrop.isDone(), @@ -122,7 +110,9 @@ export const BoozeDropQuest: Quest = { completed: () => have($item`cyclops eyedrops`) || have($effect`One Very Clear Eye`) || - get("instant_skipCyclopsEyedrops", false), + get("instant_skipCyclopsEyedrops", false) || + (get("instant_maximizeProfit", false) && + getSaleValue($item`11-leaf clover`) > get("valueOfAdventure") * 3), do: (): void => { if (!have($effect`Lucky!`)) use($item`11-leaf clover`); if (!have($item`cyclops eyedrops`)) adv1($location`The Limerick Dungeon`, -1); @@ -152,7 +142,7 @@ export const BoozeDropQuest: Quest = { name: "Fax Ungulith", completed: () => have($item`corrupted marrow`) || have($effect`Cowrruption`), do: (): void => { - if (checkLocketAvailable()) { + if (checkLocketAvailable() >= 2) { CombatLoversLocket.reminisce($monster`ungulith`); } else { cliExecute("chat"); @@ -248,7 +238,9 @@ export const BoozeDropQuest: Quest = { completed: () => !have($item`potted power plant`) || (itemAmount($item`battery (AAA)`) < 5 && !have($item`battery (lantern)`)) || - get("instant_savePowerSeed", false), + get("instant_savePowerSeed", false) || + (get("instant_maximizeProfit", false) && + getSaleValue($item`battery (AAA)`) * 5 > get("valueOfAdventure") * 4), do: (): void => { if (itemAmount($item`battery (AAA)`) >= 5) create($item`battery (lantern)`, 1); use($item`battery (lantern)`, 1); diff --git a/src/tasks/leveling.ts b/src/tasks/leveling.ts index 48786df..ec9d6f9 100644 --- a/src/tasks/leveling.ts +++ b/src/tasks/leveling.ts @@ -82,6 +82,7 @@ import { abstractionXpEffect, abstractionXpItem, burnLibram, + checkLocketAvailable, chooseLibram, fuelUp, generalStoreXpEffect, @@ -1566,7 +1567,11 @@ export const LevelingQuest: Quest = { have($item`dented scepter`) || get("_witchessFights") >= 5 || !Witchess.have() || - get("instant_saveWitchess", false), + get("instant_saveWitchess", false) || + (get("instant_maximizeProfit", false) && + checkLocketAvailable() === 3 && + get("valueOfAdventure", 3750) * get("embezzlerMultiplier", 2.5) > + get("valueOfAdventure", 3750) * 2), do: () => Witchess.fightPiece($monster`Witchess King`), combat: new CombatStrategy().macro(Macro.default(useCinch)), outfit: baseOutfit,