Skip to content

Commit

Permalink
Pull automation and other enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignose committed May 8, 2024
1 parent d361252 commit 3924a1f
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/engine/outfit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function optimisticCandle(): Familiar {
}

function melodramedary(): Familiar {
if (have($effect`Spit Upon`)) return $familiar.none;
return (have($familiar`Melodramedary`) &&
camelFightsLeft() >= Math.ceil((100 - get("camelSpit")) / 3.0) &&
get("camelSpit") < 100) ||
Expand Down
38 changes: 33 additions & 5 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
autosell,
availableAmount,
buy,
buyUsingStorage,
cliExecute,
create,
Effect,
Expand Down Expand Up @@ -529,9 +530,14 @@ type valuePull = {
value: number;
};

export const jacks =
mallPrice($item`box of Familiar Jacks`) < mallPrice($item`yule battery`)
? $item`box of Familiar Jacks`
: $item`yule battery`;

export const pullValue: valuePull[] = [
{
item: $item`box of Familiar Jacks`,
item: jacks,
value: famJacksValue(),
},
{
Expand Down Expand Up @@ -572,6 +578,17 @@ export const pullValue: valuePull[] = [
},
];

export function acquirePulls(item: Item): boolean {
if (storageAmount(item) >= 1) return true;
const pull = pullValue.find((pull) => pull.item === item);
if (pull === undefined) return false;
if (pull.value * get("valueOfAdventure") > mallPrice(item)) {
buyUsingStorage(item);
return true;
}
return false;
}

export function checkPull(item: Item): boolean {
if (
get("_roninStoragePulls").split(",").length >= 5 ||
Expand All @@ -585,10 +602,21 @@ export function checkPull(item: Item): boolean {
}

export function findMaxPull(): Item | null {
return maxBy(
pullValue.filter(({ item }) => storageAmount(item) >= 1),
`value`
).item;
const availablePulls = pullValue
.filter(({ item }) => storageAmount(item) >= 1)
.filter(({ item }) => !have(item))
.filter(({ value }) => value >= 1)
.sort((a, b) => b.value - a.value);
return maxBy(availablePulls, `value`).item;
}

export function simMaxPull(): valuePull[] | null | Item {
const pullList = pullValue
.filter(({ item }) => have(item) || storageAmount(item) >= 1)
.filter(({ value }) => value >= 1)
.sort((a, b) => b.value - a.value);

return pullList;
}

export const forbiddenEffects: Effect[] = [];
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { HotResQuest } from "./tasks/hotres";
import { WeaponDamageQuest } from "./tasks/weapondamage";
import { DonateQuest, logResourceUsage } from "./tasks/donate";
import { SpellDamageQuest } from "./tasks/spelldamage";
import { checkRequirements, checkTests } from "./sim";
import { checkRequirements, checkTests, simPulls } from "./sim";
import { args } from "./args";

const timeProperty = "fullday_elapsedTime";
Expand All @@ -49,6 +49,7 @@ export function main(command?: string): void {
if (args.sim) {
checkRequirements();
checkTests();
simPulls();
return;
}

Expand Down
17 changes: 17 additions & 0 deletions src/sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
computeHotRes,
computeSpellDamage,
computeWeaponDamage,
simMaxPull,
} from "./lib";

class Hardcoded {
Expand Down Expand Up @@ -648,4 +649,20 @@ export function checkTests(): void {

const boozeTestTurns = computeBoozeDrop();
print(`Booze Drop Test expected to take ${boozeTestTurns} turns.`);

print("");
}

export function simPulls(): void {
const pulls = simMaxPull();
if (pulls instanceof Item) print(`Best Item to Pull: ${pulls}`);
else if (pulls) {
print("Expected pulls:");
pulls.forEach((pull) => {
print(`Item: ${pull.item}`);
print(`- Turns Saved: ${pull.value}`);
});
} else {
print("No pulls available.");
}
}
39 changes: 38 additions & 1 deletion src/tasks/leveling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import {
} from "libram";
import { CombatStrategy, OutfitSpec } from "grimoire-kolmafia";
import {
acquirePulls,
boomBoxProfit,
burnLibram,
//burnLibram,
Expand All @@ -90,11 +91,14 @@ import {
checkValue,
chooseLibram,
computeCombatFrequency,
computeHotRes,
computeWeaponDamage,
findMaxPull,
forbiddenEffects,
generalStoreXpEffect,
getSynthExpBuff,
getValidComplexCandyPairs,
jacks,
overlevelled,
reagentBalancerEffect,
reagentBalancerIngredient,
Expand Down Expand Up @@ -493,9 +497,14 @@ export const LevelingQuest: Quest = {
{
name: "Pull Some Everything",
ready: () => args.dopullstest,
prepare: () =>
$items`tobiko marble soda, ${jacks.name}`.forEach((item) => acquirePulls(item)),
completed: () => 5 - get("_roninStoragePulls").split(",").length <= args.savepulls,
do: (): void => {
while (5 - get("_roninStoragePulls").split(",").length <= args.savepulls) {
while (
5 - get("_roninStoragePulls").split(",").length >= args.savepulls ||
get("_roninStoragePulls").split(",").length === 5
) {
const maxPullItem = findMaxPull();
if (maxPullItem) takeStorage(maxPullItem, 1);
else print("Hmmm, seems like we don't have anything to pull.");
Expand Down Expand Up @@ -1608,6 +1617,34 @@ export const LevelingQuest: Quest = {
boomBoxProfit();
},
},
{
name: "Early Camel Spit",
ready: () =>
get("camelSpit") >= 100 &&
have($familiar`Comma Chameleon`) &&
get("_neverendingPartyFreeTurns") < 10 &&
computeHotRes(false) + computeWeaponDamage(false) + 4 < 10,
prepare: (): void => {
restoreHp(clamp(1000, myMaxhp() / 2, myMaxhp()));
unbreakableUmbrella();
[...usefulEffects, ...statEffects].forEach((ef) => tryAcquiringEffect(ef));
restoreMp(50);
garbageShirt();
},
completed: () => have($effect`Spit Upon`),
do: $location`The Neverending Party`,
combat: new CombatStrategy().macro(Macro.trySkill($skill`%fn, spit on me!`).kill()),
outfit: () => ({
...baseOutfit(),
familiar: $familiar`Melodramedary`,
}),
limit: { tries: 1 },
post: (): void => {
sendAutumnaton();
sellMiscellaneousItems();
boomBoxProfit();
},
},
{
name: "Powerlevel",
completed: () =>
Expand Down

0 comments on commit 3924a1f

Please sign in to comment.