+void BattleState::ApplyDamage() {
+ if (attackCursor < 0) return;
+ AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : AttackChoiceAt(CurrentAttack().index));
+ TargetSelection &ts(ac.Selection());
+ if (ts.TargetsEnemies()) {
+ for (int i(0); i < MaxMonsters(); ++i) {
+ if (ts.IsBad(i)) {
+ MonsterAt(i).SubtractHealth(ts.GetAmount(i));
+ }
+ }
+ } else {
+ for (int i(0); i < NumHeroes(); ++i) {
+ if (ts.IsSelected(i) && MonsterAt(i).Health() > 0) {
+ HeroAt(i).SubtractHealth(ts.GetAmount(i));
+ }
+ }
+ }
+}
+