diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-12 17:29:01 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-12 17:29:01 -0300 |
commit | 702d6870b54851e5d524d201278c482e1860ca66 (patch) | |
tree | d4b3c6aa9dd6cc9535f9d2d58d33baef3aa45e5d /index.js | |
parent | 2fc1b2285adf74a98269b085da3c8ab419134cb8 (diff) |
Store action menus on characters
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/index.js b/index.js index 55ece5e..219df02 100644 --- a/index.js +++ b/index.js @@ -449,6 +449,9 @@ class BattleCharacter extends Sprite { this.atbBar = new ATBBar(this) this.image.src = 'img/char.png' + this.targetAllyActionMenu = new ActionMenu(battle, 'ally') + this.targetEnemyActionMenu = new ActionMenu(battle, 'enemy') + // State this.isExecutingChain = false @@ -573,9 +576,6 @@ class Battle { this.playerCharacter = this.teams[0].characters[0] - // TODO: These should probably be stored per-character, so selection is saved when you switch to control a different character - this.targetAllyActionMenu = new ActionMenu(this, 'ally') - this.targetEnemyActionMenu = new ActionMenu(this, 'enemy') this.targetMenu = new TargetMenu(this) this.targetTypeMenu = new BaseBattleMenu({options: [ @@ -725,9 +725,9 @@ class Battle { showActionMenu({direction}) { this.changeMenuAnim = {old: this.currentMenu, direction, time: 1} if (this.playerCharacter.targetType === 'enemy') { - this.currentMenu = this.targetEnemyActionMenu + this.currentMenu = this.playerCharacter.targetEnemyActionMenu } else { - this.currentMenu = this.targetAllyActionMenu + this.currentMenu = this.playerCharacter.targetAllyActionMenu } } @@ -901,7 +901,7 @@ canvas.addEventListener('keypress', evt => { } else if (evt.keyCode === 8 && battle.playerCharacter.targetType) { battle.showActionMenu({direction: 1}) } - } else if (currentMenu === actionMenu) { + } else if (currentMenu instanceof ActionMenu) { if (evt.keyCode === 37) { currentMenu.decreaseLevel() } else if (evt.keyCode === 39) { @@ -916,6 +916,7 @@ canvas.addEventListener('keypress', evt => { battle.changeMenuAnim = {old: actionMenu, direction: -1, time: 1} } } else if (evt.keyCode === 9) { + // TODO: Do this anywhere battle.currentMenu = targetTypeMenu battle.changeMenuAnim = {old: actionMenu, direction: -1, time: 1} } else if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e') { @@ -923,7 +924,7 @@ canvas.addEventListener('keypress', evt => { battle.showTargetMenu() } } - } else if (currentMenu === targetMenu) { + } else if (currentMenu instanceof TargetMenu) { if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e' || evt.which === 32) { battle.playerCharacter.targetCharacter = currentMenu.getCurrentOption().battleCharacter if (evt.key.toLowerCase() === 'e') { |