diff --git a/README.md b/README.md index 3d4b6ad..42998e0 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ All options are supported in all tabs, unless specified. They are white space se * 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 +* `limitN` + * (only supported by `mall` and `sell`) Sets a mall limit of `N` copies per person per day +* `priceN` + * (only supported by `mall` and `sell`) Sets the price for selling in the mall. * `N` @@ -136,7 +140,7 @@ Use `keeping-tabs debug help` to see a full list of available debug commands. ## TODO -* [ ] Add more mall options (add at fixed price, limit the items for sale) +* [x] 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) diff --git a/src/actions.ts b/src/actions.ts index 89c92ed..e5ee7f4 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -48,14 +48,17 @@ export const actions: { return { action: (item: Item) => putShop( - 0, - 0, + options.price ?? 0, + options.limit ?? 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) }; + return { + action: (item: Item) => + putShop(options.price ?? 0, options.limit ?? 0, amount(item, options), item), + }; }, sell: (options: Options) => { return { @@ -66,7 +69,7 @@ export const actions: { ) { autosell(amount(item, options), item); } else { - putShop(0, 0, amount(item, options), item); + putShop(options.price ?? 0, options.limit ?? 0, amount(item, options), item); } }, }; diff --git a/src/options.ts b/src/options.ts index 17600eb..c2e3edb 100644 --- a/src/options.ts +++ b/src/options.ts @@ -3,6 +3,8 @@ import { Item } from "kolmafia"; export class Options { keep?: number; stock?: number; + limit?: number; + price?: number; target?: string; body?: string; priceUpperThreshold?: number; @@ -24,6 +26,16 @@ export class Options { options.stock = parseInt(stock[1]); continue; } + const limit = optionStr.match(/limit(\d+)/); + if (limit && limit[1]) { + options.limit = parseInt(limit[1]); + continue; + } + const price = optionStr.match(/price(\d+)/); + if (price && price[1]) { + options.price = parseInt(price[1]); + continue; + } const target = optionStr.match(/#(.*)/); if (target && target[1]) { options.target = target[1]; @@ -59,6 +71,12 @@ export class Options { if (this.stock) { optionsStr.push(`stock: ${this.stock}`); } + if (this.limit) { + optionsStr.push(`limit: ${this.limit}`); + } + if (this.price) { + optionsStr.push(`price: ${this.price}`); + } if (this.target) { optionsStr.push(`target: ${this.target}`); } diff --git a/src/types.ts b/src/types.ts index 19873f8..0b9ce03 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,15 +12,15 @@ 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 { return ALL_TAB_TITLES.includes(value as TabTitle); } -const ALL_ACTION_OPTIONS = ["keep", "stock", "target"] as const; -export type ActionOption = (typeof ALL_ACTION_OPTIONS)[number]; +const ALL_ACTION_OPTIONS = ["keep", "stock", "limit", "price", "target"] as const; +export type ActionOption = typeof ALL_ACTION_OPTIONS[number]; export function isActionOption(value: string): value is ActionOption { return ALL_ACTION_OPTIONS.includes(value as ActionOption);