This commit is contained in:
ntr 2018-12-05 16:05:16 +11:00
parent c226e8b933
commit e1acdc6fa7

View File

@ -67,10 +67,9 @@ class CombatSkills extends Phaser.Scene {
if (!shouldUpdate) return false; if (!shouldUpdate) return false;
this.phase = game.phase;
if (game.phase === 'Skill') return this.renderSkillPhase(game); if (game.phase === 'Skill') return this.renderSkillPhase(game);
if (game.phase === 'Target') return this.renderTargetPhase(game); if (game.phase === 'Target') return this.renderTargetPhase(game);
return this.scene.sleep();
} }
renderSkillPhase(game) { renderSkillPhase(game) {
@ -78,8 +77,8 @@ class CombatSkills extends Phaser.Scene {
const addSkill = (i, j, skill, cryp) => { const addSkill = (i, j, skill, cryp) => {
const skillTextPos = skillTextPosition(i, j + 2); const skillTextPos = skillTextPosition(i, j + 2);
const skillObj = new CrypSkill(scene, skillTextPos[0], skillTextPos[1], skill, cryp); const skillObj = new CrypSkill(this, skillTextPos[0], skillTextPos[1], skill, cryp);
this.add(skillObj); this.add.existing(skillObj);
}; };
const team = game.teams.find(t => t.id === account.id); const team = game.teams.find(t => t.id === account.id);
@ -88,7 +87,7 @@ class CombatSkills extends Phaser.Scene {
const namePos = skillTextPosition(i, 0); const namePos = skillTextPosition(i, 0);
// Draw the cryp name // Draw the cryp name
this.add(new CrypName(scene, namePos[0], namePos[1], cryp)); this.add.existing(new CrypName(this, namePos[0], namePos[1], cryp));
// return early if KOd // return early if KOd
if (cryp.hp.base === 0) return true; if (cryp.hp.base === 0) return true;
@ -112,21 +111,21 @@ class CombatSkills extends Phaser.Scene {
// Draw the cryp name // Draw the cryp name
const namePos = skillTextPosition(i, 0); const namePos = skillTextPosition(i, 0);
this.add(new CrypName(scene, namePos[0], namePos[1], cryp)); this.add.existing(new CrypName(this, namePos[0], namePos[1], cryp));
const skillPos = skillTextPosition(i, 2); const skillPos = skillTextPosition(i, 2);
const skillObj = new CrypSkill(scene, skillPos[0], skillPos[1], skill, cryp); const skillObj = new CrypSkill(this, skillPos[0], skillPos[1], skill, cryp);
this.add(skillObj); this.add.existing(skillObj);
}); });
return true; return true;
} }
crypKeyHandler(cryp, iter) { crypKeyHandler(cryp, i) {
if (CRYP_KEY_MAP[iter]) { if (CRYP_KEY_MAP[i]) {
this.input.keyboard.removeListener(CRYP_KEY_MAP[iter]); this.input.keyboard.removeListener(CRYP_KEY_MAP[i]);
if (cryp.skills.length > 0) { // check there are cryp skills if (cryp.skills.length > 0) { // check there are cryp skills
this.input.keyboard.on(CRYP_KEY_MAP[iter], () => { this.input.keyboard.on(CRYP_KEY_MAP[i], () => {
SKILL_KEY_MAP.forEach(k => this.input.keyboard.removeListener(k)); SKILL_KEY_MAP.forEach(k => this.input.keyboard.removeListener(k));
cryp.skills.forEach((skill, i) => { cryp.skills.forEach((skill, i) => {
this.input.keyboard.on(SKILL_KEY_MAP[i], () => { this.input.keyboard.on(SKILL_KEY_MAP[i], () => {