X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=45c43f9c70a27387e20cc65b48fb9a39033fc0d9;hb=fbf5a98f8fd0da951e469003fe87d575a6bb30a4;hp=a901c63f68ccf028063fec9ebc8a21d3313376be;hpb=04b582180c8f86f50f08f5141a2514a1fcda3e01;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index a901c63..45c43f9 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -19,6 +19,7 @@ #include "../app/State.h" #include "../geometry/Point.h" #include "../geometry/Vector.h" +#include "../graphics/Animation.h" #include "../graphics/Menu.h" #include @@ -54,6 +55,7 @@ public: , moveMenu(res->moveIcons) , numHeroes(0) , activeHero(-1) + , attackCursor(-1) , ranAway(false) { } public: @@ -84,8 +86,7 @@ public: graphics::Menu &GetItemMenu() { return itemMenu; } const graphics::Menu &GetItemMenu() const { return itemMenu; } - bool HasMoreHeroes() const { return activeHero < numHeroes; } - void NextHero() { ++activeHero; } + void NextHero(); bool BeforeFirstHero() const { return activeHero < 0; } void PreviousHero() { --activeHero; } void SwapHeroes(int lhs, int rhs); @@ -103,6 +104,7 @@ public: bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; } AttackChoice &ActiveHeroAttackChoice() { return attackChoices[activeHero]; } const AttackChoice &ActiveHeroAttackChoice() const { return attackChoices[activeHero]; } + AttackChoice &AttackChoiceAt(int index) { return attackChoices[index]; } const AttackChoice &AttackChoiceAt(int index) const { return attackChoices[index]; } bool AttackSelectionDone() const { return activeHero >= numHeroes; } @@ -116,6 +118,20 @@ public: bool HeroPositionOccupied(int index) const { return index >= 0 && index < numHeroes; } void SetRunaway() { ranAway = true; } + + struct Order { + Order(int index, bool isMonster) + : index(index), isMonster(isMonster) { } + int index; + bool isMonster; + }; + + void CalculateAttackOrder(); + void NextAttack(); + bool AttacksFinished() const { return attackCursor >= int(attackOrder.size()); } + void CalculateDamage(); + void ApplyDamage(); + const Order &CurrentAttack() const { return attackOrder[attackCursor]; }; void ClearAllAttacks(); public: @@ -124,8 +140,8 @@ public: (screen->w - background->w) / 2, (screen->h - background->h) / 2); } - int BackgroundWidth() const { return background->w; } - int BackgroundHeight() const { return background->h; } + int Width() const { return background->w; } + int Height() const { return background->h; } void RenderBackground(SDL_Surface *screen, const geometry::Vector &offset); void RenderMonsters(SDL_Surface *screen, const geometry::Vector &offset); @@ -149,6 +165,8 @@ private: std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; + std::vector monsterAttacks; + std::vector attackOrder; Hero heroes[4]; graphics::Menu spellMenus[4]; graphics::Menu itemMenu; @@ -160,6 +178,7 @@ private: AttackChoice attackChoices[4]; int numHeroes; int activeHero; + int attackCursor; bool ranAway; };