remove team check fixed scene swap

This commit is contained in:
Mashy 2018-12-04 20:26:17 +10:00
parent 8df814d1a6
commit 681b9dab4e
4 changed files with 23 additions and 16 deletions

24
client/src/events.js Normal file → Executable file
View File

@ -42,20 +42,22 @@ function registerEvents(registry, events) {
events.on('SEND_ACTIVE_SKILL', function skillActive(cryp) {
const activeSkill = registry.get('activeSkill');
const game = registry.get('game');
const ws = registry.get('ws');
if (activeSkill) {
const target = activeSkill.cryp.account === cryp.account;
if (!target) {
const ws = registry.get('ws');
if (game.phase === 'Skill') {
ws.sendGameSkill(game.id, activeSkill.cryp.id, cryp.account, activeSkill.skill.skill);
} else if (game.phase === 'Target') {
ws.sendGameTarget(game.id, cryp.id, activeSkill.skill.id);
}
activeSkill.setTint(0xff0000);
} else {
activeSkill.clearTint();
// const friendlyTarget = activeSkill.cryp.account === cryp.account;
// if (!friendlyTarget) {
if (game.phase === 'Skill') {
ws.sendGameSkill(game.id, activeSkill.cryp.id, cryp.account, activeSkill.skill.skill);
} else if (game.phase === 'Target') {
ws.sendGameTarget(game.id, cryp.id, activeSkill.skill.id);
}
activeSkill.setTint(0xff0000);
registry.set('activeSkill', null);
// } else if (friendlyTarget && activeSkill.skill.self_targeting) {
// ws.sendGameSkill(game.id, activeSkill.cryp.id, null, activeSkill.skill.skill);
// } else {
// activeSkill.clearTint();
// }
}
});

View File

@ -104,10 +104,7 @@ class Combat extends Phaser.Scene {
}
// update log
// shallow copy because reverse mutates
const content = Array.from(game.log).reverse().join('\n');
// this.log.setText(Array.from(game.log).reverse());
console.log(this.log);
this.log.setText(content);
this.log.setText(Array.from(game.log).reverse());
// has the phase changed?
const phaseChange = (this.registry.get('gamePhase') === game.phase);
if (phaseChange) return false;

View File

@ -11,8 +11,14 @@ class CrypList extends Phaser.Scene {
}
create() {
this.registry.events.off('changedata', this.updateData, this);
this.registry.events.off('setdata', this.updateData, this);
this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this);
if (this.registry.get('cryps')) {
this.renderList();
this.renderGameList();
}
return true;
}
@ -60,7 +66,7 @@ class CrypList extends Phaser.Scene {
if (cryp) {
this.scene.add('StatSheet', StatSheet);
this.scene.run('StatSheet', { cryp });
this.scene.sleep();
this.scene.stop();
}
return true;
}

View File

@ -20,6 +20,8 @@ class StatSheet extends Phaser.Scene {
this.cryp = cryp;
this.stats = new Stats(this, cryp);
this.addControls(cryp);
this.addSkills(cryp);
this.skills = true;
}
addControls(cryp) {