diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-12 17:37:47 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-12 17:38:37 -0300 |
commit | 83190cd8a5b9a45f1e3c0e911e6ca19d4b5ba724 (patch) | |
tree | c4637449f8a2fbc587c7436e896e372dd2485c91 /index.js | |
parent | 702d6870b54851e5d524d201278c482e1860ca66 (diff) |
Access target type menu while no other menu is visible
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/index.js b/index.js index 219df02..294f2b4 100644 --- a/index.js +++ b/index.js @@ -152,7 +152,7 @@ class ATBBar { this.progress -= 1 / this.segmentCount * action.size } else { this.battleCharacter.isExecutingChain = false - if (this.battle.playerCharacter === this.battleCharacter) { + if (this.battle.playerCharacter === this.battleCharacter && !this.battle.currentMenu) { this.battle.showActionMenu({direction: 1}) } } @@ -722,6 +722,11 @@ class Battle { } } + showTargetTypeMenu() { + this.changeMenuAnim = {old: this.currentMenu, direction: -1, time: 1} + this.currentMenu = this.targetTypeMenu + } + showActionMenu({direction}) { this.changeMenuAnim = {old: this.currentMenu, direction, time: 1} if (this.playerCharacter.targetType === 'enemy') { @@ -885,23 +890,32 @@ canvas.addEventListener('keypress', evt => { const { targetTypeMenu, actionMenu, targetMenu, currentMenu } = battle const { atbBar } = battle.playerCharacter - if (!battle.playerCharacter.isExecutingChain && battle.currentMenu) { + + if (currentMenu) { if (evt.keyCode === 38) { currentMenu.upOption() } else if (evt.keyCode === 40) { currentMenu.downOption() - } else if (currentMenu === targetTypeMenu) { - if (evt.keyCode === 13 || evt.which === 32) { - const newTargetType = targetTypeMenu.getCurrentOption().targetType - if (battle.playerCharacter.targetType !== newTargetType) { - battle.playerCharacter.targetType = newTargetType - atbBar.queuedActions.splice(0) // Changed target type, empty queue - } - battle.showActionMenu({direction: 1}) - } else if (evt.keyCode === 8 && battle.playerCharacter.targetType) { + } + } + + if (currentMenu === targetTypeMenu) { + if (evt.keyCode === 13 || evt.which === 32) { + const newTargetType = targetTypeMenu.getCurrentOption().targetType + if (battle.playerCharacter.targetType !== newTargetType) { + battle.playerCharacter.targetType = newTargetType + atbBar.queuedActions.splice(0) // Changed target type, empty queue + } + battle.showActionMenu({direction: 1}) + } else if (evt.keyCode === 8 && battle.playerCharacter.targetType) { + if (battle.playerCharacter.isExecutingChain || battle.playerCharacter.willExecuteChain) { + battle.hideCurrentMenu() + } else { battle.showActionMenu({direction: 1}) } - } else if (currentMenu instanceof ActionMenu) { + } + } else if (!battle.playerCharacter.isExecutingChain && battle.currentMenu) { + if (currentMenu instanceof ActionMenu) { if (evt.keyCode === 37) { currentMenu.decreaseLevel() } else if (evt.keyCode === 39) { @@ -912,13 +926,10 @@ canvas.addEventListener('keypress', evt => { if (atbBar.queuedActions.length) { atbBar.dequeue() } else { - battle.currentMenu = targetTypeMenu - battle.changeMenuAnim = {old: actionMenu, direction: -1, time: 1} + battle.showTargetTypeMenu() } } else if (evt.keyCode === 9) { - // TODO: Do this anywhere - battle.currentMenu = targetTypeMenu - battle.changeMenuAnim = {old: actionMenu, direction: -1, time: 1} + battle.showTargetTypeMenu() } else if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e') { if (battle.playerCharacter.atbBar.queuedActions.length) { battle.showTargetMenu() @@ -947,12 +958,16 @@ canvas.addEventListener('keypress', evt => { } else { atbBar.queuedActions.splice(1) } + } else if (evt.keyCode === 9) { + battle.showTargetTypeMenu() } } else if (battle.playerCharacter.isExecutingChain) { if (evt.keyCode === 8) { atbBar.queuedActions.splice(0) battle.playerCharacter.isExecutingChain = false battle.showActionMenu({direction: -1}) + } else if (evt.keyCode === 9) { + battle.showTargetTypeMenu() } } |