From b9ebf89c190aa13cf44ad44e51303b05259ebdb8 Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 17 Jan 2019 13:22:49 +1000 Subject: [PATCH] Click to forget specs --- client/src/scenes/specsheet.js | 15 +++++++-------- client/src/socket.js | 6 ++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/src/scenes/specsheet.js b/client/src/scenes/specsheet.js index 5112b193..2ee5f445 100644 --- a/client/src/scenes/specsheet.js +++ b/client/src/scenes/specsheet.js @@ -30,25 +30,24 @@ class StatSheet extends Phaser.Scene { } create(cryp) { - console.log(cryp); this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT); this.registry.events.on('changedata', this.updateData, this); this.cryp = cryp; this.forget = false; this.add.text(WIDTH / 10, 0, cryp.name, TEXT.HEADER); - this.addCommonSpecs(cryp); + this.addSpecs(cryp); addButton(this, menuX, menuY, () => this.registry.set('crypStats', cryp), 'Stats'); } updateData(parent, key, data) { if (key === 'cryps') { const cryp = data.find(c => c.id === this.cryp.id); - this.cryp = cryp; - this.addStats(cryp); + this.addSpecs(cryp); + if (this.hoverText) this.hoverText.destroy(); } } - addCommonSpecs(cryp) { + addSpecs(cryp) { if (this.specs) this.specs.destroy(true); this.specs = this.add.group(); const listSpecs = (list, specInfo, i) => { @@ -57,9 +56,9 @@ class StatSheet extends Phaser.Scene { this.specs.add(this.add.text(SPEC_X, SPEC_Y, specInfo.spec, TEXT.NORMAL) .setInteractive() - // .on('pointerdown', () => { - // this.registry.get('ws').sendCrypLearn(cryp.id, skill.name); - // }) + .on('pointerdown', () => { + this.registry.get('ws').sendSpecForget(cryp.id, specInfo); + }) .on('pointerover', (pointer) => { if (!this.forget) { this.displayText(SPEC_X, SPEC_Y, `Affects ${specInfo.affects} - level ${specInfo.level}`, pointer); diff --git a/client/src/socket.js b/client/src/socket.js index cf7a5f5d..e947278a 100644 --- a/client/src/socket.js +++ b/client/src/socket.js @@ -84,6 +84,11 @@ function createSocket(events) { send({ method: 'game_joinable_list', params: { } }); } + function sendSpecForget(id, spec) { + send({ method: 'cryp_unspec', params: { id, spec } }); + } + + function sendPressR() { send({ method: 'press_r', params: { } }); } @@ -276,6 +281,7 @@ function createSocket(events) { sendCrypLearn, sendCrypForget, sendItemUse, + sendSpecForget, sendZoneCreate, sendZoneJoin, sendZoneClose,