Skip to content

Commit

Permalink
Fix the willItemsFit bank method
Browse files Browse the repository at this point in the history
  • Loading branch information
beardeddragon5 committed Jan 29, 2024
1 parent 401fb1f commit 9d381f7
Show file tree
Hide file tree
Showing 2 changed files with 333 additions and 49 deletions.
17 changes: 17 additions & 0 deletions src/setup.mts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ export async function setup(ctx: ItemPlaceholderContext) {
}
});

ctx.patch(Bank, 'willItemsFit').replace(function (original, items) {
const useSlots = ctx.settings.section('General').get('use-slots');
if (useSlots) {
const newItems = new Set();
return items.every(({ item }) => {
if (this.items.has(item)) {
return true;
} else {
newItems.add(item);
return this.occupiedSlots + newItems.size <= this.maximumSlots;
}
});
} else {
return original(items);
}
});

const runIfValidItem = (onPlaceholderFound: (item: Item) => void) =>
function <P extends unknown[], T extends (item: Item, ...args: P) => void>(
this: Bank,
Expand Down
Loading

0 comments on commit 9d381f7

Please sign in to comment.