Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk operations #25

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Bulk operations #25

wants to merge 5 commits into from

Conversation

pstalcup
Copy link
Contributor

No description provided.

Copy link

@horrible-little-slime horrible-little-slime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than an issue with makeBulk looks pretty good

@@ -40,71 +47,81 @@ export function filters(options: Options): (item: Item) => boolean {
return (item: Item) => true;
}

function makeBulk(
bulkOperation: (items: Map<Item, number>) => boolean,
baseAmount?: (item: Item) => number

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check if this variable exists (on line 60) but never use its actual value

src/actions.ts Outdated
sell: (options: Options) => {
const mallAction = makeMall()(options);
const autosellAction = makeBulk(bulkAutosell)(options);

return {
action: (item: Item) => {
if (
wellStocked(`${item}`, 1000, Math.max(100, autosellPrice(item) * 2)) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has that always used the item name? what the fuck?

src/actions.ts Outdated
items.set(
item,
baseAmount && options.stock
? Math.min(Math.max(0, (options.stock ?? 0) - shopAmount(item)), amount(item, options))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
? Math.min(Math.max(0, (options.stock ?? 0) - shopAmount(item)), amount(item, options))
? Math.min(Math.max(0, (options.stock ?? 0) - shopAmount(item)), baseAmount(item, options))

?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also imo make this a clamp

mallItems.set(item, {
quantity: quantity(item),
limit: options.limit,
price: mallOptions?.price ? mallOptions.price(item) : options.price ?? 0,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
price: mallOptions?.price ? mallOptions.price(item) : options.price ?? 0,
price: mallOptions?.price?.(item) ?? options.price ?? 0,

or whatever you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants