From c8b19d287528556a0d2fd5020dcbb51429fc168e Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 6 Mar 2019 11:58:28 +1000 Subject: [PATCH] Fixed varibox for new structure --- client/src/scenes/item.list.js | 23 ++++++++++++----------- client/src/socket.js | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/src/scenes/item.list.js b/client/src/scenes/item.list.js index 01db0c23..511a9ef6 100644 --- a/client/src/scenes/item.list.js +++ b/client/src/scenes/item.list.js @@ -197,17 +197,18 @@ class ItemList extends Phaser.Scene { this.add.existing(itemBox); }); - vbox.free.forEach((item, i) => { - const ITEM_X = ITEM_WIDTH * 1.1 * (i % BOX_COLUMNS) + BOX_X + ITEM_WIDTH * 0.5; - const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / BOX_COLUMNS) + BOX_Y + ITEM_HEIGHT * 0.5; - const clickFn = () => { - this.registry.set('itemInfo', item); - ws.sendVboxAccept(vbox.instance, i); - }; - const itemBox = new Item(this, item, i, ITEM_X, ITEM_Y, ITEM_WIDTH, ITEM_HEIGHT); - itemBox.on('pointerdown', clickFn); - - this.add.existing(itemBox); + vbox.free.forEach((type, i) => { + type.forEach((item, j) => { + const ITEM_X = ITEM_WIDTH * 1.1 * j + BOX_X + ITEM_WIDTH * 0.5; + const ITEM_Y = ITEM_HEIGHT * 1.1 * i + BOX_Y + ITEM_HEIGHT * 0.5; + const clickFn = () => { + this.registry.set('itemInfo', item); + ws.sendVboxAccept(vbox.instance, i, j); + }; + const itemBox = new Item(this, item, i, ITEM_X, ITEM_Y, ITEM_WIDTH, ITEM_HEIGHT); + itemBox.on('pointerdown', clickFn); + this.add.existing(itemBox); + }); }); // Restore previous combiner item slots diff --git a/client/src/socket.js b/client/src/socket.js index 37f18af7..db2c34fe 100644 --- a/client/src/socket.js +++ b/client/src/socket.js @@ -93,8 +93,8 @@ function createSocket(events) { send({ method: 'player_state', params: { instance_id: instanceId } }); } - function sendVboxAccept(instanceId, i) { - send({ method: 'player_vbox_accept', params: { instance_id: instanceId, index: i } }); + function sendVboxAccept(instanceId, i, j) { + send({ method: 'player_vbox_accept', params: { instance_id: instanceId, group: i, index: j } }); } function sendVboxApply(instanceId, crypId, index) {