diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-16 16:32:29 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-16 16:32:29 -0300 |
commit | 409fb44793d3b4125155e4d42aae1b629adab91b (patch) | |
tree | 4fb633dc0236cd09db8db3b0abf49a076dca3ed4 | |
parent | d01cafba4ae56121ddd18ce6b46f7857ad2db2b8 (diff) |
Target most hurt player with cure
-rw-r--r-- | index.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/index.js b/index.js index 37859c8..39517f5 100644 --- a/index.js +++ b/index.js @@ -522,6 +522,15 @@ class TargetMenu extends BaseBattleMenu { buildOptions(targetType) { this.options = this.battle.playerCharacter.getValidTargets(targetType) .map(char => ({label: char.name, battleCharacter: char})) + + // If the top action is a 'cure' action, pick the character with the least health by default. + // TODO: Some property like "healsAlive" on the action itself, so things like potions (which target one) are also affected by this + if (last(this.battle.playerCharacter.atbBar.queuedActions).chain === 'cure') { + const allies = this.battle.playerCharacter.team.characters + const aliveCharacter = allies.find(c => !c.dead) + const mostHurtCharacter = allies.reduce((a, b) => (b.hp < a.hp && !b.dead ? b : a), aliveCharacter) + this.currentOptionIndex = this.options.findIndex(opt => opt.battleCharacter === mostHurtCharacter) + } } } |