Skip to content

Commit

Permalink
Jill-finally (#1765)
Browse files Browse the repository at this point in the history
* hardcode Jill into meatFamiliar()

* barfFamiliar jill handling (needs new grimoire)

* upgrade grimoire

* add jill to embezzler too lol

* fix caching; pass jill equipment into NumericModifier

* generalize
  • Loading branch information
horrible-little-slime authored Dec 9, 2023
1 parent 8b103bb commit ed5eb53
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 28 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/garbo-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"eslint": "^8.50.0",
"eslint-config-garbo": "^0.0.1",
"kolmafia": "^5.27668.0",
"libram": "^0.8.17",
"libram": "latest",
"lint-staged": "^14.0.1",
"madge": "^6.1.0",
"prettier": "^3.0.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/garbo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"dependencies": {
"core-js": "^3.32.2",
"garbo-lib": "*",
"grimoire-kolmafia": "^0.3.25",
"grimoire-kolmafia": "latest",
"kolmafia": "^5.27668.0",
"libram": "^0.8.17"
"libram": "latest"
},
"devDependencies": {
"@babel/cli": "^7.22.15",
Expand Down
23 changes: 18 additions & 5 deletions packages/garbo/src/familiar/barfFamiliar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
cliExecute,
equippedItem,
Familiar,
familiarEquipment,
familiarWeight,
Item,
myFamiliar,
Expand All @@ -13,6 +14,7 @@ import {
} from "kolmafia";
import {
$familiar,
$familiars,
$item,
$items,
$location,
Expand Down Expand Up @@ -46,12 +48,15 @@ type CachedOutfit = {
bonus: number;
};

const outfitCache = new Map<number, CachedOutfit>();
const outfitCache = new Map<number | Familiar, CachedOutfit>();
const outfitSlots = $slots`hat, back, shirt, weapon, off-hand, pants, acc1, acc2, acc3, familiar`;

const SPECIAL_FAMILIARS_FOR_CACHING = $familiars`Jill-of-All-Trades`;
const outfitCacheKey = (f: Familiar) =>
SPECIAL_FAMILIARS_FOR_CACHING.includes(f) ? f : findLeprechaunMultiplier(f);

function getCachedOutfitValues(fam: Familiar) {
const lepMult = findLeprechaunMultiplier(fam);
const currentValue = outfitCache.get(lepMult);
const currentValue = outfitCache.get(outfitCacheKey(fam));
if (currentValue) return currentValue;

const current = myFamiliar();
Expand All @@ -74,7 +79,7 @@ function getCachedOutfitValues(fam: Familiar) {
item: sum(outfit, (eq: Item) => getModifier("Item Drop", eq)),
bonus: sum(outfit, (eq: Item) => bonuses.get(eq) ?? 0),
};
outfitCache.set(lepMult, values);
outfitCache.set(outfitCacheKey(fam), values);
return values;
} finally {
useFamiliar(current);
Expand All @@ -100,8 +105,16 @@ function familiarModifier(
const cachedOutfitWeight = getCachedOutfitValues(familiar).weight;
const totalWeight =
familiarWeight(familiar) + nonOutfitWeightBonus() + cachedOutfitWeight;
const equip = familiarEquipment(familiar);

return numericModifier(familiar, modifier, totalWeight, $item.none);
return SPECIAL_FAMILIARS_FOR_CACHING.includes(familiar)
? numericModifier(
familiar,
modifier,
totalWeight - numericModifier(equip, "Familiar Weight"),
equip,
)
: numericModifier(familiar, modifier, totalWeight, $item.none);
}

function familiarAbilityValue(familiar: Familiar) {
Expand Down
12 changes: 4 additions & 8 deletions packages/garbo/src/familiar/meatFamiliar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Familiar } from "kolmafia";
import {
$familiar,
$familiars,
findFairyMultiplier,
findLeprechaunMultiplier,
have,
Expand Down Expand Up @@ -36,12 +37,7 @@ export function setBestLeprechaunAsMeatFamiliar(): void {
}

export function meatFamiliar(): Familiar {
if (!fam) {
if (have($familiar`Robortender`)) {
fam = $familiar`Robortender`;
} else {
setBestLeprechaunAsMeatFamiliar();
}
}
return fam;
return (fam ??=
$familiars`Robortender, Jill-of-All-Trades`.find(have) ??
findBestLeprechaun());
}
5 changes: 5 additions & 0 deletions packages/garbo/src/outfit/barf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export function barfOutfit(spec: OutfitSpec = {}, sim = false): Outfit {

outfit.familiar ??= barfFamiliar();

if (outfit.familiar === $familiar`Jill-of-All-Trades`) {
outfit.equip($item`LED candle`);
outfit.setModes({ jillcandle: "ultraviolet" });
}

const bjornChoice = chooseBjorn(BonusEquipMode.BARF, outfit.familiar, sim);

outfit.modifier.push(
Expand Down
7 changes: 6 additions & 1 deletion packages/garbo/src/outfit/embezzler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Outfit, OutfitSpec } from "grimoire-kolmafia";
import { toJson } from "kolmafia";
import { $item, $items, $location, Guzzlr } from "libram";
import { $familiar, $item, $items, $location, Guzzlr } from "libram";
import { meatFamiliar } from "../familiar";
import { chooseBjorn } from "./bjorn";
import { bonusGear } from "./dropsgear";
Expand Down Expand Up @@ -45,6 +45,11 @@ export function embezzlerOutfit(
}
}

if (outfit.familiar === $familiar`Jill-of-All-Trades`) {
outfit.equip($item`LED candle`);
outfit.setModes({ jillcandle: "ultraviolet" });
}

useUPCsIfNeeded(outfit);

outfit.bonuses = bonusGear(BonusEquipMode.EMBEZZLER);
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4256,7 +4256,7 @@ __metadata:
eslint: ^8.50.0
eslint-config-garbo: ^0.0.1
kolmafia: ^5.27668.0
libram: ^0.8.17
libram: latest
lint-staged: ^14.0.1
madge: ^6.1.0
prettier: ^3.0.3
Expand Down Expand Up @@ -4307,9 +4307,9 @@ __metadata:
eslint: ^8.50.0
eslint-config-garbo: ^0.0.1
garbo-lib: "*"
grimoire-kolmafia: ^0.3.25
grimoire-kolmafia: latest
kolmafia: ^5.27668.0
libram: ^0.8.17
libram: latest
lint-staged: ^14.0.1
madge: ^6.1.0
prettier: ^3.0.3
Expand Down Expand Up @@ -4484,15 +4484,15 @@ __metadata:
languageName: node
linkType: hard

"grimoire-kolmafia@npm:^0.3.25":
version: 0.3.25
resolution: "grimoire-kolmafia@npm:0.3.25"
"grimoire-kolmafia@npm:latest":
version: 0.3.26
resolution: "grimoire-kolmafia@npm:0.3.26"
dependencies:
core-js: ^3.16.4
peerDependencies:
kolmafia: ^5.27339.0
libram: ^0.8.4
checksum: e470fb3ea12050bdf0a05efedcc737164598a0fe11bbd1c1447e5a5049e05b52270c187520d6fec05795e0a41f0aa363e6553050f77daeff009482c3c2826899
checksum: 2cf49469e215dcbdb68d94d3f1823de81a247c3b594d499577a6f8f907b528c652647e8ee0f8c5386622617a3fed96f0afaa2e4aadc95562ee7f349c74813e8e
languageName: node
linkType: hard

Expand Down Expand Up @@ -4917,14 +4917,14 @@ __metadata:
languageName: node
linkType: hard

"libram@npm:^0.8.17":
version: 0.8.17
resolution: "libram@npm:0.8.17"
"libram@npm:latest":
version: 0.8.18
resolution: "libram@npm:0.8.18"
dependencies:
html-entities: ^2.4.0
peerDependencies:
kolmafia: ^5.27668.0
checksum: cb22fa1650354afa1ae81e5e0423fc89bf78ae31d90150cab3d8655e052ffa8f1026da7ee09535a49c26bd8c327c06f3738b909488b140517f527f00b067dc82
checksum: 412013c609eeb3edd02d247ef4f62ee428d01de6b0efe5d5788273ec9117cd2249b7301ecfb7d5e0991e9813ddebdb4a07c7fb3f2749921c334aaa67e9d8afe8
languageName: node
linkType: hard

Expand Down

0 comments on commit ed5eb53

Please sign in to comment.