- if (fakeMoveTimer.JustHit()) {
- if (monsters) {
- if (titleBarText) {
- titleBarText = 0;
- ++cursor;
- while (cursor < battle->MaxMonsters() && !battle->MonsterPositionOccupied(cursor)) {
- ++cursor;
- }
- if (cursor >= battle->MaxMonsters()) {
- battle->ClearAllAttacks();
- ctrl->PopState();
+ CheckAnimations();
+ if (HasAnimationsRunning()) return;
+ ResetAnimation();
+ battle->ApplyDamage();
+ battle->NextAttack();
+ if (battle->AttacksFinished()) {
+ Ctrl().PopState();
+ return;
+ }
+
+ battle->CalculateDamage();
+
+ if (battle->CurrentAttack().IsMonster()) {
+ Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
+ titleBarText = monster.Name();
+ targetAnimation = AnimationRunner(monster.MeleeAnimation());
+ moveAnimation = AnimationRunner(monster.AttackAnimation());
+ monster.SetAnimation(moveAnimation);
+ AddNumberAnimations(battle->MonsterAt(battle->CurrentAttack().index).GetAttackChoice().Selection());
+ } else if (battle->CurrentAttack().IsCapsule()) {
+ Capsule &capsule(battle->GetCapsule());
+ titleBarText = capsule.Name();
+ targetAnimation = AnimationRunner(capsule.MeleeAnimation());
+ moveAnimation = AnimationRunner(capsule.AttackAnimation());
+ capsule.SetAnimation(moveAnimation);
+ AddNumberAnimations(capsule.GetAttackChoice().Selection());
+ } else {
+ Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
+ const AttackChoice &ac(battle->HeroAt(battle->CurrentAttack().index).GetAttackChoice());
+
+ switch (ac.GetType()) {
+ case AttackChoice::SWORD:
+ if (hero.HasWeapon()) {
+ titleBarText = hero.Weapon()->Name();
+ targetAnimation = AnimationRunner(hero.Weapon()->AttackAnimation());
+ } else {
+ titleBarText = "Melee attack!";
+ targetAnimation = AnimationRunner(hero.MeleeAnimation());