generated from horrible-little-slime/kol-js-starter-with-workflows
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,709 additions
and
2,256 deletions.
There are no files selected for viewing
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,43 @@ | ||
import { buy, Coinmaster, Item, mallPrice, sellPrice, sellsItem } from "kolmafia"; | ||
import { $item } from "libram"; | ||
|
||
export function coinmasterBuyAll( | ||
coinmaster: Coinmaster, | ||
target: Item, | ||
availableCoins: number | ||
): void { | ||
const toBuy = Math.floor(availableCoins / sellPrice(coinmaster, target)); | ||
if (toBuy > 0) { | ||
buy(coinmaster, toBuy, target); | ||
} | ||
} | ||
|
||
function getSellableItem(item: Item) { | ||
if (item === $item`Merc Core deployment orders`) { | ||
return $item`one-day ticket to Conspiracy Island`; | ||
} | ||
return item; | ||
} | ||
|
||
export function coinmasterBest(coin: Item): [Coinmaster, Item] | undefined { | ||
const coinmasters = Coinmaster.all().filter((c) => c.item === coin); | ||
const price = (c: Coinmaster, i: Item) => mallPrice(i) / sellPrice(c, i); | ||
|
||
const availablePurchases = coinmasters | ||
.map((c): [Coinmaster, Item][] => | ||
Item.all() | ||
.filter((i) => sellsItem(c, i) && getSellableItem(i).tradeable) | ||
.map((i) => [c, getSellableItem(i)]) | ||
) | ||
.reduce((arr, results) => [...arr, ...results], []); | ||
|
||
if (availablePurchases.length > 0) { | ||
const best = availablePurchases.reduce((best, current) => | ||
price(...best) < price(...current) ? current : best | ||
); | ||
if (!coin.tradeable || price(...best) > mallPrice(coin)) { | ||
return best; | ||
} | ||
} | ||
return; | ||
} |
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,5 @@ | ||
import { print } from "kolmafia"; | ||
|
||
export function warn(message: string): void { | ||
print(message, "red"); | ||
} |
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
Oops, something went wrong.