- if (titleBarText) {
- titleBarText = 0;
- ++cursor;
- if (cursor == battle->NumHeroes()) {
- cursor = 0;
- monsters = true;
- }
- } else {
- const AttackChoice &ac(battle->AttackChoiceAt(cursor));
- switch (ac.GetType()) {
- case AttackChoice::SWORD:
- titleBarText = battle->HeroAt(cursor).HasWeapon() ? battle->HeroAt(cursor).Weapon()->Name() : "Gauntlet";
- break;
- case AttackChoice::MAGIC:
- titleBarText = ac.GetSpell()->Name();
- break;
- case AttackChoice::DEFEND:
- titleBarText = "Defends.";
- break;
- case AttackChoice::IKARI:
- titleBarText = ac.GetItem()->HasIkari() ? ac.GetItem()->GetIkari()->Name() : "No Ikari?";
- break;
- case AttackChoice::ITEM:
- titleBarText = ac.GetItem()->Name();
- break;
- case AttackChoice::UNDECIDED:
- titleBarText = "WTF???";
- break;
+ if (battle->HeroAt(order[cursor].index).Health() > 0) break;
+ }
+ ++cursor;
+ }
+
+ if (cursor >= int(order.size())) {
+ battle->ClearAllAttacks();
+ ctrl->PopState();
+ return;
+ }
+
+ if (order[cursor].isMonster) {
+ const Monster &monster(battle->MonsterAt(order[cursor].index));
+ titleBarText = monster.Name();
+ moveAnimation = 0;
+ } else {
+ Hero &hero(battle->HeroAt(order[cursor].index));
+ const AttackChoice &ac(battle->AttackChoiceAt(order[cursor].index));
+
+ switch (ac.GetType()) {
+ case AttackChoice::SWORD:
+ titleBarText = hero.HasWeapon() ? hero.Weapon()->Name() : "Melee attack!";
+ moveAnimation = hero.AttackAnimation();
+ break;
+ case AttackChoice::MAGIC:
+ titleBarText = ac.GetSpell()->Name();
+ moveAnimation = hero.SpellAnimation();
+ break;
+ case AttackChoice::DEFEND:
+ titleBarText = "Defends.";
+ moveAnimation = 0;
+ break;
+ case AttackChoice::IKARI:
+ if (ac.GetItem()->HasIkari()) {
+ titleBarText = ac.GetItem()->GetIkari()->Name();
+ if (ac.GetItem()->GetIkari()->IsMagical()) {
+ moveAnimation = hero.SpellAnimation();
+ } else {
+ moveAnimation = hero.AttackAnimation();
+ }