X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=fbaa1d0169f79107b954ba3ece200ca18018454f;hb=2a1d9169e1f6c2dfe0f93ed40d5fb68d3da342af;hp=f5268dda931b1403745f6f15dc6709ddac5f6cf2;hpb=cded7d136b41e22f363ec702f2288491c0006e3a;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index f5268dd..fbaa1d0 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -8,6 +8,7 @@ #ifndef BATTLE_BATTLESTATE_H_ #define BATTLE_BATTLESTATE_H_ +#include "fwd.h" #include "AttackTypeMenu.h" #include "Hero.h" #include "HeroTag.h" @@ -15,35 +16,20 @@ #include "MoveMenu.h" #include "Resources.h" #include "SmallHeroTag.h" +#include "../app/fwd.h" #include "../app/State.h" -#include "../geometry/Point.h" +#include "../common/fwd.h" #include "../geometry/Vector.h" #include "../graphics/Animation.h" +#include "../graphics/fwd.h" #include "../graphics/Menu.h" #include #include #include -namespace app { class Input; } -namespace common { - class Inventory; - class Item; - class Spell; -} -namespace graphics { - class Font; - class Frame; - class Gauge; - class Sprite; -} - namespace battle { -class AttackChoice; -class PartyLayout; -class Stats; - class BattleState : public app::State { @@ -78,7 +64,6 @@ 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; } @@ -100,7 +85,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,7 +94,6 @@ 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; } bool HeroPositionOccupied(int index) const { return index >= 0 && index < numHeroes; } @@ -142,6 +126,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); @@ -152,6 +137,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: @@ -161,16 +148,14 @@ private: const Resources *res; AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; - // TODO: combine all data about heros or monsters - std::vector > monsterPositions; 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;