-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated to current Garbo version * calculate `treatOutfit` manually * Added Bill recommended fixes * Trying this again * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: neil <[email protected]> * Requested use map location change * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: neil <[email protected]> * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: neil <[email protected]> * Recommended changes * misc fixes * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: neil <[email protected]> * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: neil <[email protected]> * Fix yarn through yarn up; add limit so bill go mad * Update packages/garbo/package.json Co-authored-by: Skaazi <[email protected]> * Fix yarn.lock * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: Skaazi <[email protected]> * use `skip` limit, not `tries` limit * freeCandy ==> candyMap * only use map if acquire succeeds; don't throw on fail * informative errors * fix lockfile? * Update garbo-lib to libram 0.8.14 and remove 0.8.13 cache * we want things to be profitable, not unprofitable Co-authored-by: Skaazi <[email protected]> * Update packages/garbo/src/resources/candyMap.ts Co-authored-by: Shiverwarp <[email protected]> --------- Co-authored-by: neil <[email protected]> Co-authored-by: horrible little slime <[email protected]> Co-authored-by: Skaazi <[email protected]> Co-authored-by: Skaazi <[email protected]> Co-authored-by: Shiverwarp <[email protected]>
- Loading branch information
1 parent
6481235
commit 96ab039
Showing
9 changed files
with
152 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+267 KB
...bram-npm-0.8.13-62836a88a9-5a32366138.zip → ...bram-npm-0.8.14-5f034cd073-342672a9a5.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { Outfit } from "grimoire-kolmafia"; | ||
import { $familiar, $item, get, getSaleValue, have, maxBy, sum } from "libram"; | ||
import { | ||
canEquip, | ||
getOutfits, | ||
holiday, | ||
mallPrice, | ||
outfitPieces, | ||
outfitTreats, | ||
print, | ||
runChoice, | ||
toItem, | ||
use, | ||
visitUrl, | ||
} from "kolmafia"; | ||
import { GarboTask } from "../tasks/engine"; | ||
import { garboValue } from "../garboValue"; | ||
import { acquire } from "../acquire"; | ||
import { GarboStrategy, Macro } from "../combat"; | ||
|
||
const HOUSE_NUMBERS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; | ||
|
||
let blockHtml = ""; | ||
|
||
function getBlockHtml(): string { | ||
blockHtml ||= visitUrl("place.php?whichplace=town&action=town_trickortreat"); | ||
return blockHtml; | ||
} | ||
|
||
function treatValue(outfit: string): number { | ||
return sum( | ||
Object.entries(outfitTreats(outfit)), | ||
([candyName, probability]) => probability * garboValue(toItem(candyName)), | ||
); | ||
} | ||
|
||
export function getTreatOutfit(): string { | ||
const availableOutfits = getOutfits().filter((name) => | ||
outfitPieces(name).every((piece) => canEquip(piece)), | ||
); | ||
if (!availableOutfits.length) { | ||
print( | ||
"You don't seem to actually have any trick-or-treating outfits available, my friend!", | ||
); | ||
} | ||
return maxBy(availableOutfits, treatValue); | ||
} | ||
|
||
export function treatOutfit(): Outfit { | ||
const outfit = new Outfit(); | ||
const bestTreatOutfit = getTreatOutfit(); | ||
const pieces = outfitPieces(bestTreatOutfit); | ||
for (const piece of pieces) { | ||
if (!outfit.equip(piece)) { | ||
print( | ||
`Could not equip all pieces of trick-or-treating outfit ${bestTreatOutfit}: aborted on ${piece}`, | ||
); | ||
} | ||
} | ||
|
||
outfit.equip($familiar`Trick-or-Treating Tot`); | ||
return outfit; | ||
} | ||
|
||
export function candyRichBlockValue(): number { | ||
const outfitCandyValue = treatValue(getTreatOutfit()); | ||
const totOutfitCandyMultiplier = have($familiar`Trick-or-Treating Tot`) | ||
? 1.6 | ||
: 1; | ||
const bowlValue = (1 / 5) * getSaleValue($item`huge bowl of candy`); | ||
const prunetsValue = have($familiar`Trick-or-Treating Tot`) | ||
? 4 * 0.2 * getSaleValue($item`Prunets`) | ||
: 0; | ||
|
||
const outfitCandyTotal = 3 * outfitCandyValue * totOutfitCandyMultiplier; | ||
return outfitCandyTotal + bowlValue + prunetsValue; | ||
} | ||
|
||
function shouldAcquireCandyMap(): boolean { | ||
return ( | ||
!holiday().includes("Halloween") && | ||
mallPrice($item`map to a candy-rich block`) < 50000 && // Sanity value to prevent mall shenanigans | ||
candyRichBlockValue() > mallPrice($item`map to a candy-rich block`) | ||
); | ||
} | ||
|
||
function useCandyMapTask(): GarboTask { | ||
return { | ||
name: "Acquire Candy Map", | ||
ready: () => shouldAcquireCandyMap(), | ||
completed: () => get("_mapToACandyRichBlockUsed"), | ||
do: (): void => { | ||
if ( | ||
acquire( | ||
1, | ||
$item`map to a candy-rich block`, | ||
candyRichBlockValue() - 1, | ||
false, | ||
) | ||
) { | ||
use($item`map to a candy-rich block`); | ||
} | ||
}, | ||
limit: { skip: 1 }, | ||
spendsTurn: false, | ||
}; | ||
} | ||
|
||
function doCandyTreat(): GarboTask { | ||
return { | ||
name: "Treat", | ||
completed: () => | ||
!get("_mapToACandyRichBlockUsed") || holiday().includes("Halloween"), | ||
outfit: treatOutfit, | ||
do: (): void => { | ||
// We do all treat houses in a row as one task for speed reasons | ||
for (const house of HOUSE_NUMBERS) { | ||
if (getBlockHtml().match(RegExp(`whichhouse=${house}>[^>]*?house_l`))) { | ||
visitUrl( | ||
`choice.php?whichchoice=804&option=3&whichhouse=${house}&pwd`, | ||
); | ||
} else if ( | ||
getBlockHtml().match(RegExp(`whichhouse=${house}>[^>]*?starhouse`)) | ||
) { | ||
visitUrl( | ||
`choice.php?whichchoice=804&option=3&whichhouse=${house}&pwd`, | ||
); | ||
runChoice(2); | ||
visitUrl(`place.php?whichplace=town&action=town_trickortreat`); | ||
} | ||
} | ||
}, | ||
limit: { skip: 1 }, | ||
spendsTurn: false, | ||
combat: new GarboStrategy(Macro.abort()), | ||
}; | ||
} | ||
|
||
export function candyMapTasks(): GarboTask[] { | ||
return [useCandyMapTask(), doCandyTreat()]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./scepter"; | ||
export * from "./candyMap"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters