X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=806b4af59154525475ce3765532dc9600e2c3c6b;hb=93cd8cb0f16c1809d76faa33ed6f281a3276140b;hp=27a3af8ae396cd7082a3860f10484c821f13cc54;hpb=8d3de02319380b5142ac4c88bf54999d4027dba9;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 27a3af8..806b4af 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -16,7 +16,6 @@ #include "Resources.h" #include "SmallHeroTag.h" #include "../app/State.h" -#include "../geometry/Point.h" #include "../geometry/Vector.h" #include "../graphics/Animation.h" #include "../graphics/Menu.h" @@ -78,14 +77,13 @@ public: virtual void UpdateWorld(float deltaT); virtual void Render(SDL_Surface *); - // TODO: turn this mess into a well stuctured interface public: const Resources &Res() const { return *res; } AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } MoveMenu &GetMoveMenu() { return moveMenu; } - graphics::Menu &GetItemMenu() { return itemMenu; } - const graphics::Menu &GetItemMenu() const { return itemMenu; } + graphics::Menu &ItemMenu() { return itemMenu; } + const graphics::Menu &ItemMenu() const { return itemMenu; } void NextHero(); bool BeforeFirstHero() const { return activeHero < 0; } @@ -100,7 +98,7 @@ public: const Monster &MonsterAt(int index) const { assert(index >= 0 && index < NumHeroes()); return monsters[index]; } const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; } - const geometry::Point &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; } + const geometry::Vector &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; } bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; } bool AttackSelectionDone() const { return activeHero >= numHeroes; } @@ -109,9 +107,7 @@ public: int MaxHeroes() const { return 4; } int MaxMonsters() const { return monsters.size(); } - const std::vector > &MonsterPositions() const { return monsterPositions; } bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; } - const std::vector > &HeroesPositions() const { return heroesPositions; } bool HeroPositionOccupied(int index) const { return index >= 0 && index < numHeroes; } void SetRunaway() { ranAway = true; } @@ -143,6 +139,7 @@ public: } int Width() const { return background->w; } int Height() const { return background->h; } + geometry::Vector Size() const { return geometry::Vector(Width(), Height()); } void RenderBackground(SDL_Surface *screen, const geometry::Vector &offset); void RenderMonsters(SDL_Surface *screen, const geometry::Vector &offset); @@ -153,6 +150,8 @@ public: private: void LoadInventory(); + void DecideMonsterAttack(Monster &) const; + void CalculateDamage(const Stats &attackerStats, TargetSelection &targets) const; Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const; private: @@ -162,17 +161,14 @@ private: const Resources *res; AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; - // TODO: combine all data about heros or monsters - std::vector > monsterPositions; - std::vector > heroesPositions; std::vector monsters; std::vector attackOrder; Hero heroes[4]; graphics::Menu itemMenu; HeroTag heroTags[4]; SmallHeroTag smallHeroTags[4]; - geometry::Point heroTagPositions[4]; - geometry::Point smallHeroTagPositions[4]; + geometry::Vector heroTagPositions[4]; + geometry::Vector smallHeroTagPositions[4]; int numHeroes; int activeHero; int attackCursor;