From e2f66f4027367814be6087dbd6b07f11e31da580 Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 12 Aug 2018 13:52:26 -0300 Subject: Space/enter to activate once gauge full, E to activate now --- index.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index d02dcf6..ce4cf58 100644 --- a/index.js +++ b/index.js @@ -116,6 +116,12 @@ class ATBBar { // ATB gauge visual update this.visualProgress += 8 * dt * (this.progress - this.visualProgress) + // Start action chain once user has confirmed (willExecuteChain = true) and IP gauge is full enough to execute all actions + if (this.battleCharacter.willExecuteChain && this.progress >= 1 - this.getRemainingSpace() / this.segmentCount) { + this.battleCharacter.willExecuteChain = false + this.battleCharacter.isExecutingChain = true // Will be acknowledged by next if statement + } + // Action chaining if (this.battleCharacter.isExecutingChain && !this.battleCharacter.isExecutingAction) { if (this.queuedActions.length) { @@ -148,12 +154,16 @@ class ATBBar { } this.queuedActions.splice(cutoff) - this.battle.changeMenuAnim = {old: this.battle.currentMenu, direction: 1, time: 1} - this.battle.currentMenu = null + this.battle.hideCurrentMenu() this.battleCharacter.isExecutingChain = true } } + activateOnceGaugeFull() { + this.battle.hideCurrentMenu() + this.battleCharacter.willExecuteChain = true + } + getCutoff() { // Cutoff point in the action queue where ATB does not fill the action let cutoff = 0, segment = 0 @@ -608,6 +618,11 @@ class Battle { this.targetMenu.buildOptions() } + hideCurrentMenu() { + this.changeMenuAnim = {old: this.currentMenu, direction: 1, time: 1} + this.currentMenu = null + } + getAllBattleCharacters() { return this.teams.reduce((acc, team) => acc.concat(team.characters), []) } @@ -724,7 +739,11 @@ canvas.addEventListener('keypress', evt => { } else if (currentMenu === targetMenu) { if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e' || evt.which === 32) { battle.playerCharacter.targetCharacter = currentMenu.getCurrentOption().battleCharacter - atbBar.activate() + if (evt.key.toLowerCase() === 'e') { + atbBar.activate() + } else { + atbBar.activateOnceGaugeFull() + } } else if (evt.keyCode === 8) { battle.currentMenu = actionMenu battle.changeMenuAnim = {old: targetMenu, direction: -1, time: 1} -- cgit 1.3.0-6-gf8a5