X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=7d65c14a23d8a1d08890ac0d7c52a4512351287c;hb=51c5ffb4958968827b93624f7849c1b7d3a1eacb;hp=b491af862c99485c080c156836d3a2c9e7413b26;hpb=c484a03fda545a6803be63aa0a35f23c26cc8e2f;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index b491af8..7d65c14 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: @@ -102,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; } @@ -115,16 +118,33 @@ 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(); + bool Victory() const; + bool Defeat() const; + public: geometry::Vector CalculateScreenOffset(SDL_Surface *screen) const { return geometry::Vector( (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); @@ -148,6 +168,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; @@ -159,6 +181,7 @@ private: AttackChoice attackChoices[4]; int numHeroes; int activeHero; + int attackCursor; bool ranAway; };