From 409fb44793d3b4125155e4d42aae1b629adab91b Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 16 Aug 2018 16:32:29 -0300 Subject: Target most hurt player with cure --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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) + } } } -- cgit 1.3.0-6-gf8a5