Skip to content

Commit e0f9479

Browse files
committed
attempt note conversion
1 parent a441a0f commit e0f9479

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/plugins/objects/bank/bank-plugin.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { ActionType, RunePlugin } from '@server/plugins/plugin';
22
import { objectIds } from '@server/world/config/object-ids';
3-
import { widgets } from '@server/world/config/widget';
3+
import { widgets, widgetScripts } from '@server/world/config/widget';
44
import { objectAction } from '@server/world/actor/player/action/object-action';
55
import { ItemContainer } from '@server/world/items/item-container';
66
import { itemAction } from '@server/world/actor/player/action/item-action';
7-
import { Item } from '@server/world/items/item';
7+
import { fromNote, Item } from '@server/world/items/item';
88
import { buttonAction } from '@server/world/actor/player/action/button-action';
9+
import { logger } from '@runejs/logger/dist/logger';
10+
import { hasValueNotNull } from '@server/util/data';
911

1012
const buttonIds: number[] = [
1113
92, // as note
@@ -24,6 +26,8 @@ export const openBankInterface: objectAction = (details) => {
2426

2527
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.bank.tabWidget, details.player.inventory);
2628
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.bank.screenWidget, details.player.bank);
29+
details.player.outgoingPackets.updateClientConfig(widgetScripts.bankInsertMode, details.player.settings.bankInsertMode);
30+
details.player.outgoingPackets.updateClientConfig(widgetScripts.bankWithdrawNoteMode, details.player.settings.bankWithdrawNoteMode);
2731
};
2832

2933
export const depositItem: itemAction = (details) => {
@@ -35,17 +39,26 @@ export const depositItem: itemAction = (details) => {
3539
}
3640

3741
// Check if the player has the item
42+
3843
if (!details.player.hasItemInInventory(details.itemId)) {
3944
return;
4045
}
4146

47+
48+
let itemIdToAdd: number = details.itemId;
49+
let fromNoteId: number = fromNote(details.itemId);
50+
if (fromNoteId > -1) {
51+
itemIdToAdd = fromNoteId;
52+
}
53+
4254
let countToRemove: number;
4355
if (details.option.endsWith('all')) {
4456
countToRemove = -1;
4557
} else {
4658
countToRemove = +details.option.replace('deposit-', '');
4759
}
4860

61+
4962
const playerInventory: ItemContainer = details.player.inventory;
5063
const playerBank: ItemContainer = details.player.bank;
5164
const slotsWithItem: number[] = playerInventory.findAll(details.itemId);
@@ -55,13 +68,13 @@ export const depositItem: itemAction = (details) => {
5568
countToRemove = itemAmount;
5669
}
5770

58-
if (!playerBank.canFit({itemId: details.itemId, amount: countToRemove}, true)) {
71+
if (!playerBank.canFit({itemId: itemIdToAdd, amount: countToRemove}, true)) {
5972
details.player.sendMessage('Your bank is full.');
6073
return;
6174
}
6275

6376

64-
const itemToAdd: Item = {itemId: details.itemId, amount: 0};
77+
const itemToAdd: Item = {itemId: itemIdToAdd, amount: 0};
6578
while (countToRemove > 0 && playerInventory.has(details.itemId)) {
6679
const invIndex = playerInventory.findIndex(details.itemId);
6780
const invItem = playerInventory.items[invIndex];
@@ -75,6 +88,7 @@ export const depositItem: itemAction = (details) => {
7588
countToRemove = 0;
7689
}
7790
}
91+
7892
playerBank.addStacking(itemToAdd);
7993

8094

0 commit comments

Comments
 (0)