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

Banking fixes #354

Merged
merged 3 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/engine/world/items/item-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { filestore } from '@server/game/game-server';
import { hasValueNotNull } from '@engine/util/data';
import { findItem } from '@engine/config/config-handler';
import { logger } from '@runejs/core';
import { fromNote } from '@engine/world/items/item';


export interface ContainerUpdateEvent {
Expand Down Expand Up @@ -308,7 +309,7 @@ export class ItemContainer {
if(!itemDefinition) {
throw new Error(`Item ID ${ item.itemId } not found!`);
}
if(itemDefinition.stackable || everythingStacks) {
if(itemDefinition.stackable || everythingStacks || fromNote(item) > -1) {
if(this.has(item.itemId)) {
const invItem = this.items[this.findIndex(item.itemId)];
return invItem.amount + item.amount <= 2147483647;
Expand Down
12 changes: 10 additions & 2 deletions src/plugins/objects/bank/bank.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
}

let itemIdToAdd: number = details.itemId;
let stackable: boolean = details.itemDetails.stackable;
if (details.player.settings.bankWithdrawNoteMode) {
const toNoteId: number = toNote(details.itemId);
if (toNoteId > -1) {
itemIdToAdd = toNoteId;
stackable = true;
} else {
details.player.sendMessage('This item can not be withdrawn as a note.');
}
Expand Down Expand Up @@ -154,7 +156,7 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
countToRemove = itemAmount;
}

if (!details.itemDetails.stackable) {
if (!stackable) {
const slots = playerInventory.getOpenSlotCount();
if (slots < countToRemove) {
countToRemove = slots;
Expand All @@ -170,7 +172,13 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
amount: removeFromContainer(playerBank, details.itemId, countToRemove)
};

playerInventory.add({ itemId: itemToAdd.itemId, amount: itemToAdd.amount });
if (stackable) {
playerInventory.add({ itemId: itemToAdd.itemId, amount: itemToAdd.amount });
} else {
for(let count = 0; count < itemToAdd.amount; count++) {
playerInventory.add({ itemId: itemToAdd.itemId, amount: 1 });
}
}

updateBankingInterface(details.player);
};
Expand Down