diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-12 17:07:44 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-12 17:07:44 -0300 |
commit | 3c383ce7058b09db1ece29e160dd4b481fbaf094 (patch) | |
tree | d3ad8fafb918c58b907ab4e91dcdb5a9fbb85225 /index.js | |
parent | 183a354ce48774d24a1c52cd9cdafa030685325c (diff) |
Tab to view target type menu
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/index.js b/index.js index f493585..c645cfa 100644 --- a/index.js +++ b/index.js @@ -458,6 +458,7 @@ class BattleCharacter extends Sprite { this.isExecutingAction = false this.actionExecuteTime = 0 + this.targetType = null // ally or enemy this.targetCharacter = null this.name = 'Unnamed' @@ -885,7 +886,13 @@ canvas.addEventListener('keypress', evt => { currentMenu.downOption() } else if (currentMenu === targetTypeMenu) { if (evt.keyCode === 13 || evt.which === 32) { - battle.playerCharacter.targetType = targetTypeMenu.getCurrentOption().targetType + 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) { battle.showActionMenu({direction: 1}) } } else if (currentMenu === actionMenu) { @@ -902,6 +909,9 @@ canvas.addEventListener('keypress', evt => { battle.currentMenu = targetTypeMenu battle.changeMenuAnim = {old: actionMenu, direction: -1, time: 1} } + } else if (evt.keyCode === 9) { + battle.currentMenu = targetTypeMenu + battle.changeMenuAnim = {old: actionMenu, direction: -1, time: 1} } else if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e') { if (battle.playerCharacter.atbBar.queuedActions.length) { battle.showTargetMenu() @@ -916,14 +926,17 @@ canvas.addEventListener('keypress', evt => { atbBar.activateOnceGaugeFull() } } else if (evt.keyCode === 8) { - battle.currentMenu = actionMenu - battle.changeMenuAnim = {old: targetMenu, direction: -1, time: 1} + battle.showActionMenu({direction: -1}) } } } else { // TODO: Backspace to cancel chain // TODO: E to execute chain immediately } + + if (evt.keyCode === 9) { // Capture tab, but not everything else (like ctrl-R) + evt.preventDefault() + } }) canvas.focus() |