- 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();
+ moveAnimation = monster.AttackAnimation();
+ targetAnimation = monster.MeleeAnimation();
+ // TODO: add number animations
+ } else {
+ Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
+ const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
+
+ switch (ac.GetType()) {
+ case AttackChoice::SWORD:
+ if (hero.HasWeapon()) {
+ titleBarText = hero.Weapon()->Name();
+ targetAnimation = hero.Weapon()->AttackAnimation();
+ } else {
+ titleBarText = "Melee attack!";
+ targetAnimation = hero.MeleeAnimation();