X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=4fd9a15165696399e2100190c51b77b7c1ff44b3;hb=0f5f8a6eaa938f88fd3d1e92dec2462b30840e21;hp=a4f403741e5dd72dfcbe731072a09feecccb8e16;hpb=2a3e39f2960bd359dfc8df8f439281dec30c633a;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index a4f4037..4fd9a15 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -78,25 +78,20 @@ 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 &GetSpellMenu() { return heroes[activeHero].SpellMenu(); } - const graphics::Menu &GetSpellMenu() const { return heroes[activeHero].SpellMenu(); } - graphics::Menu &GetIkariMenu() { return heroes[activeHero].IkariMenu(); } - const graphics::Menu &GetIkariMenu() const { return heroes[activeHero].IkariMenu(); } - 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; } - void PreviousHero() { --activeHero; } + void PreviousHero(); void SwapHeroes(int lhs, int rhs); - Hero &ActiveHero() { return heroes[activeHero]; } - const Hero &ActiveHero() const { return heroes[activeHero]; } + Hero &ActiveHero() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero]; } + const Hero &ActiveHero() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero]; } Hero &HeroAt(int index) { assert(index >= 0 && index < NumHeroes()); return heroes[index]; } const Hero &HeroAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroes[index]; } @@ -106,22 +101,14 @@ public: 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]; } - bool HasChosenAttackType() const { return ActiveHeroAttackChoice().GetType() != AttackChoice::UNDECIDED; } - AttackChoice &ActiveHeroAttackChoice() { return AttackChoiceAt(activeHero); } - const AttackChoice &ActiveHeroAttackChoice() const { return AttackChoiceAt(activeHero); } - AttackChoice &AttackChoiceAt(int index) { assert(index >= 0 && index < NumHeroes()); return heroes[index].GetAttackChoice(); } - const AttackChoice &AttackChoiceAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroes[index].GetAttackChoice(); } - AttackChoice &MonsterAttackChoiceAt(int index) { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; } - const AttackChoice &MonsterAttackChoiceAt(int index) const { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; } + bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; } bool AttackSelectionDone() const { return activeHero >= numHeroes; } int NumHeroes() const { return numHeroes; } 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; } @@ -161,10 +148,9 @@ public: void RenderSmallHeroTags(SDL_Surface *screen, const geometry::Vector &offset); private: - void LoadSpellMenu(std::vector::size_type heroIndex); - void LoadIkariMenu(std::vector::size_type heroIndex); void LoadInventory(); + void DecideMonsterAttack(Monster &); Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const; private: @@ -174,11 +160,7 @@ 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 monsterAttacks; std::vector attackOrder; Hero heroes[4]; graphics::Menu itemMenu;