#include "../../common/Spell.h"
#include "../../geometry/operators.h"
#include "../../geometry/Point.h"
+#include "../../graphics/Animation.h"
#include "../../graphics/Font.h"
#include "../../graphics/Frame.h"
void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
- // TODO: push battle animation if enemy is faster
}
void PerformAttacks::ExitState(Application &c, SDL_Surface *screen) {
ctrl->PopState();
}
} else {
+ if (cursor == 0) {
+ if (battle->HeroAt(battle->NumHeroes() - 1).AttackAnimation()) {
+ battle->HeroAt(battle->NumHeroes() - 1).AttackAnimation()->Stop();
+ }
+ if (battle->HeroAt(battle->NumHeroes() - 1).SpellAnimation()) {
+ battle->HeroAt(battle->NumHeroes() - 1).SpellAnimation()->Stop();
+ }
+ }
titleBarText = battle->MonsterAt(cursor).Name();
}
} else {
+ const AttackChoice &ac(battle->AttackChoiceAt(cursor));
if (titleBarText) {
titleBarText = 0;
+
+ switch (ac.GetType()) {
+ case AttackChoice::SWORD:
+ if (battle->HeroAt(cursor).AttackAnimation()) {
+ battle->HeroAt(cursor).AttackAnimation()->Start(*this);
+ }
+ break;
+ case AttackChoice::MAGIC:
+ if (battle->HeroAt(cursor).SpellAnimation()) {
+ battle->HeroAt(cursor).SpellAnimation()->Start(*this);
+ }
+ break;
+ case AttackChoice::DEFEND:
+ break;
+ case AttackChoice::IKARI:
+ if (ac.GetItem()->HasIkari()) {
+ if (ac.GetItem()->GetIkari()->IsMagical()) {
+ if (battle->HeroAt(cursor).SpellAnimation()) {
+ battle->HeroAt(cursor).SpellAnimation()->Start(*this);
+ }
+ } else {
+ if (battle->HeroAt(cursor).AttackAnimation()) {
+ battle->HeroAt(cursor).AttackAnimation()->Start(*this);
+ }
+ }
+ }
+ break;
+ case AttackChoice::ITEM:
+ break;
+ case AttackChoice::UNDECIDED:
+ break;
+ }
+
++cursor;
if (cursor == battle->NumHeroes()) {
cursor = 0;
monsters = true;
}
} else {
- const AttackChoice &ac(battle->AttackChoiceAt(cursor));
+ if (cursor > 0) {
+ if (battle->HeroAt(cursor - 1).AttackAnimation()) {
+ battle->HeroAt(cursor - 1).AttackAnimation()->Stop();
+ }
+ if (battle->HeroAt(cursor - 1).SpellAnimation()) {
+ battle->HeroAt(cursor - 1).SpellAnimation()->Stop();
+ }
+ }
switch (ac.GetType()) {
case AttackChoice::SWORD:
titleBarText = battle->HeroAt(cursor).HasWeapon() ? battle->HeroAt(cursor).Weapon()->Name() : "Gauntlet";
battle->RenderBackground(screen, offset);
battle->RenderMonsters(screen, offset);
battle->RenderHeroes(screen, offset);
- // render small tags
+ battle->RenderSmallHeroTags(screen, offset);
RenderTitleBar(screen, offset);
}