From a1089f4f0987521264f1cdc5193032a453d871c0 Mon Sep 17 00:00:00 2001 From: Tokoeka Date: Fri, 26 Jan 2024 15:31:55 +0000 Subject: [PATCH 1/4] autosell untradables added to a sell filter --- src/actions.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actions.ts b/src/actions.ts index 1824ff1..b804ba0 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -46,7 +46,10 @@ export const actions: { sell: (options: Options) => { return { action: (item: Item) => { - if (wellStocked(`${item}`, 1000, Math.max(100, autosellPrice(item) * 2))) { + if ( + wellStocked(`${item}`, 1000, Math.max(100, autosellPrice(item) * 2)) || + !item.tradeable + ) { autosell(amount(item, options), item); } else { putShop(0, 0, amount(item, options), item); From 7e62346ce3494d7a93e472890026a0c8ce628a32 Mon Sep 17 00:00:00 2001 From: Tokoeka Date: Sun, 28 Jan 2024 11:23:31 +0000 Subject: [PATCH 2/4] add stock option(s) --- README.md | 2 ++ src/actions.ts | 35 +++++++++++++++++++++++++++++++++++ src/options.ts | 9 +++++++++ src/types.ts | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad693f4..63b22a7 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ All options are supported in all tabs, unless specified. They are white space se * `keepN` * Keeps `N` copies of the item after running +* `stockN` + * (only supported by `mall`, `display`, and `closet`). Ensures `N` copies of the item are stocked in the relevant locations, keeps the rest in your inventory * `N` diff --git a/src/actions.ts b/src/actions.ts index b804ba0..48ac2a0 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -2,6 +2,8 @@ import { autosell, autosellPrice, cliExecute, + closetAmount, + displayAmount, Item, itemAmount, mallPrice, @@ -9,6 +11,7 @@ import { putCloset, putDisplay, putShop, + shopAmount, use, wellStocked, } from "kolmafia"; @@ -41,6 +44,17 @@ export const actions: { }; } = { mall: (options: Options) => { + if (options.stock) { + return { + action: (item: Item) => + putShop( + 0, + 0, + Math.min(Math.max(0, (options.stock ?? 0) - shopAmount(item)), amount(item, options)), + item + ), + }; + } return { action: (item: Item) => putShop(0, 0, amount(item, options), item) }; }, sell: (options: Options) => { @@ -58,6 +72,18 @@ export const actions: { }; }, display: (options: Options) => { + if (options.stock) { + return { + action: (item: Item) => + putDisplay( + Math.min( + Math.max(0, (options.stock ?? 0) - displayAmount(item)), + amount(item, options) + ), + item + ), + }; + } return { action: (item: Item) => putDisplay(amount(item, options), item) }; }, use: (options: Options) => { @@ -82,6 +108,15 @@ export const actions: { }; }, closet: (options: Options) => { + if (options.stock) { + return { + action: (item: Item) => + putDisplay( + Math.min(Math.max(0, (options.stock ?? 0) - closetAmount(item)), amount(item, options)), + item + ), + }; + } return { action: (item: Item) => putCloset(amount(item, options), item), }; diff --git a/src/options.ts b/src/options.ts index 6d4aa51..17600eb 100644 --- a/src/options.ts +++ b/src/options.ts @@ -2,6 +2,7 @@ import { Item } from "kolmafia"; export class Options { keep?: number; + stock?: number; target?: string; body?: string; priceUpperThreshold?: number; @@ -18,6 +19,11 @@ export class Options { options.keep = parseInt(keep[1]); continue; } + const stock = optionStr.match(/stock(\d+)/); + if (stock && stock[1]) { + options.stock = parseInt(stock[1]); + continue; + } const target = optionStr.match(/#(.*)/); if (target && target[1]) { options.target = target[1]; @@ -50,6 +56,9 @@ export class Options { if (this.keep) { optionsStr.push(`keep: ${this.keep}`); } + if (this.stock) { + optionsStr.push(`stock: ${this.stock}`); + } if (this.target) { optionsStr.push(`target: ${this.target}`); } diff --git a/src/types.ts b/src/types.ts index 91a4381..af4e1f2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -18,7 +18,7 @@ export function isTabTitle(value: string): value is TabTitle { return ALL_TAB_TITLES.includes(value as TabTitle); } -const ALL_ACTION_OPTIONS = ["keep", "target"] as const; +const ALL_ACTION_OPTIONS = ["keep", "stock", "target"] as const; export type ActionOption = typeof ALL_ACTION_OPTIONS[number]; export function isActionOption(value: string): value is ActionOption { From cd5a71683f438d86cc46255eb8457ff3c4ba8e0b Mon Sep 17 00:00:00 2001 From: JTMintsASU <64926558+CyberfoxStudios@users.noreply.github.com> Date: Sun, 29 Oct 2023 15:20:06 -0700 Subject: [PATCH 3/4] Add `low` action to list items with mallPrice This commit adds a new action `low` that will list the item using kolMafia's mallPrice function. Other changes include: - Adding low to the DEFAULT_ACTIONS string for reference in the help - Updating the readme to clarify various malling options and update TODO list. --- README.md | 9 ++++++--- src/actions.ts | 7 +++++++ src/main.ts | 2 +- src/types.ts | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 63b22a7..3d4b6ad 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,13 @@ Naming a tab involves specifying what to do with all items in that tab by naming ### Actions * `mall` - * This will add the item to your mall store + * This will add the item to your mall store at the maximum possible price +* `low` + * This will add the item to your mall store at the 5th lowest price currently listed * `autosell` * This will autosell the item * `sell` - * This will either autosell the item or add it to your mall store. It will add it to your mall store only if there are less than 1000 stocked at autosell price + * This will either autosell the item or add it to your mall store at the maximum possible price. It will add it to your mall store only if there are less than 1000 stocked at autosell price * `use` * This will use the item * `display` @@ -134,7 +136,8 @@ Use `keeping-tabs debug help` to see a full list of available debug commands. ## TODO -* [ ] Add more mall options (add at fixed price, add at min price, limit the items for sale) +* [ ] Add more mall options (add at fixed price, limit the items for sale) +* [x] Add more mall options (add at min price) * [ ] Add confirmation for kmailing, optionally? * [x] Add option to keep certain number of items (using format of keepN) * [ ] Add `pull` to pull specific items from Hagnks diff --git a/src/actions.ts b/src/actions.ts index 48ac2a0..0c83bcd 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -71,6 +71,13 @@ export const actions: { }, }; }, + low: options => { + return { + action: item => { + putShop(mallPrice(item), 0, amount(item, options), item); + } + }; + }, display: (options: Options) => { if (options.stock) { return { diff --git a/src/main.ts b/src/main.ts index a36bfa9..fa18d9b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,7 +21,7 @@ import { Options } from "./options"; import { actions, filters } from "./actions"; const HIGHLIGHT = isDarkMode() ? "yellow" : "blue"; -const DEFAULT_ACTIONS = "closet use mall autosell display sell kmail fuel collection"; +const DEFAULT_ACTIONS = "closet use mall autosell display sell kmail fuel collection low"; function items(tabId: TabId, type: InventoryType): Item[] { const tab = visitUrl(`${type}.php?which=f${tabId}`); diff --git a/src/types.ts b/src/types.ts index af4e1f2..bb2cf77 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,6 +10,7 @@ export const ALL_TAB_TITLES = [ "closet", "fuel", "collection", + "low", ] as const; export type TabTitle = typeof ALL_TAB_TITLES[number]; export type TabId = number; From 31ee1784ecea31589664dec1e3d65f921c9a05d0 Mon Sep 17 00:00:00 2001 From: Patrick Stalcup Date: Sun, 28 Jan 2024 09:00:11 -0500 Subject: [PATCH 4/4] Fix lint issues --- src/actions.ts | 6 +++--- src/types.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/actions.ts b/src/actions.ts index 0c83bcd..89c92ed 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -71,11 +71,11 @@ export const actions: { }, }; }, - low: options => { + low: (options) => { return { - action: item => { + action: (item) => { putShop(mallPrice(item), 0, amount(item, options), item); - } + }, }; }, display: (options: Options) => { diff --git a/src/types.ts b/src/types.ts index bb2cf77..19873f8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,7 +12,7 @@ export const ALL_TAB_TITLES = [ "collection", "low", ] as const; -export type TabTitle = typeof ALL_TAB_TITLES[number]; +export type TabTitle = (typeof ALL_TAB_TITLES)[number]; export type TabId = number; export function isTabTitle(value: string): value is TabTitle { @@ -20,7 +20,7 @@ export function isTabTitle(value: string): value is TabTitle { } const ALL_ACTION_OPTIONS = ["keep", "stock", "target"] as const; -export type ActionOption = typeof ALL_ACTION_OPTIONS[number]; +export type ActionOption = (typeof ALL_ACTION_OPTIONS)[number]; export function isActionOption(value: string): value is ActionOption { return ALL_ACTION_OPTIONS.includes(value as ActionOption);