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) {
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);

View File

@ -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,