Click to forget specs

This commit is contained in:
Mashy 2019-01-17 13:22:49 +10:00
parent 65c7d86da2
commit b9ebf89c19
2 changed files with 13 additions and 8 deletions

View File

@ -30,25 +30,24 @@ class StatSheet extends Phaser.Scene {
} }
create(cryp) { create(cryp) {
console.log(cryp);
this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT); this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT);
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.cryp = cryp; this.cryp = cryp;
this.forget = false; this.forget = false;
this.add.text(WIDTH / 10, 0, cryp.name, TEXT.HEADER); 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'); addButton(this, menuX, menuY, () => this.registry.set('crypStats', cryp), 'Stats');
} }
updateData(parent, key, data) { updateData(parent, key, data) {
if (key === 'cryps') { if (key === 'cryps') {
const cryp = data.find(c => c.id === this.cryp.id); const cryp = data.find(c => c.id === this.cryp.id);
this.cryp = cryp; this.addSpecs(cryp);
this.addStats(cryp); if (this.hoverText) this.hoverText.destroy();
} }
} }
addCommonSpecs(cryp) { addSpecs(cryp) {
if (this.specs) this.specs.destroy(true); if (this.specs) this.specs.destroy(true);
this.specs = this.add.group(); this.specs = this.add.group();
const listSpecs = (list, specInfo, i) => { 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) this.specs.add(this.add.text(SPEC_X, SPEC_Y, specInfo.spec, TEXT.NORMAL)
.setInteractive() .setInteractive()
// .on('pointerdown', () => { .on('pointerdown', () => {
// this.registry.get('ws').sendCrypLearn(cryp.id, skill.name); this.registry.get('ws').sendSpecForget(cryp.id, specInfo);
// }) })
.on('pointerover', (pointer) => { .on('pointerover', (pointer) => {
if (!this.forget) { if (!this.forget) {
this.displayText(SPEC_X, SPEC_Y, `Affects ${specInfo.affects} - level ${specInfo.level}`, pointer); this.displayText(SPEC_X, SPEC_Y, `Affects ${specInfo.affects} - level ${specInfo.level}`, pointer);

View File

@ -84,6 +84,11 @@ function createSocket(events) {
send({ method: 'game_joinable_list', params: { } }); send({ method: 'game_joinable_list', params: { } });
} }
function sendSpecForget(id, spec) {
send({ method: 'cryp_unspec', params: { id, spec } });
}
function sendPressR() { function sendPressR() {
send({ method: 'press_r', params: { } }); send({ method: 'press_r', params: { } });
} }
@ -276,6 +281,7 @@ function createSocket(events) {
sendCrypLearn, sendCrypLearn,
sendCrypForget, sendCrypForget,
sendItemUse, sendItemUse,
sendSpecForget,
sendZoneCreate, sendZoneCreate,
sendZoneJoin, sendZoneJoin,
sendZoneClose, sendZoneClose,