X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=978581f3062843018925d782ecf63d5de3995d46;hb=76539c6ba0ac1bc6ecd179cd0fc229f40872598b;hp=57c037f0643c4371e51ab78c98b7e8e397327211;hpb=62c0a1d0ac98eb51418e4daa59e80b6cc97b522f;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 57c037f..978581f 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -51,7 +51,9 @@ public: , res(res) , attackTypeMenu(res->attackIcons) , moveMenu(res->moveIcons) - , activeHero(-1) { } + , numHeroes(0) + , activeHero(-1) + , ranAway(false) { } public: void AddMonster(const Monster &); @@ -65,7 +67,7 @@ public: virtual void Resize(int width, int height); - virtual void HandleInput(const app::Input &); + virtual void HandleEvents(const app::Input &); virtual void UpdateWorld(float deltaT); virtual void Render(SDL_Surface *); @@ -74,26 +76,28 @@ public: AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } MoveMenu &GetMoveMenu() { return moveMenu; } - bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); } + bool HasMoreHeroes() const { return activeHero < numHeroes; } void NextHero() { ++activeHero; } bool BeforeFirstHero() const { return activeHero < 0; } void PreviousHero() { --activeHero; } Hero &ActiveHero() { return heroes[activeHero]; } const Hero &ActiveHero() const { return heroes[activeHero]; } - Hero &HeroAt(std::vector::size_type index) { return heroes[index]; } - const Hero &HeroAt(std::vector::size_type index) const { return heroes[index]; } - void SwapHeroes(std::vector::size_type lhs, std::vector::size_type rhs); + Hero &HeroAt(int index) { return heroes[index]; } + const Hero &HeroAt(int index) const { return heroes[index]; } + Monster &MonsterAt(std::vector::size_type index) { return monsters[index]; } + const Monster &MonsterAt(std::vector::size_type index) const { return monsters[index]; } + void SwapHeroes(int lhs, int rhs); const HeroTag &ActiveHeroTag() const { return heroTags[activeHero]; } - const HeroTag &HeroTagAt(std::vector::size_type index) const { return heroTags[index]; } - const geometry::Point &HeroTagPositionAt(std::vector::size_type index) const { return heroTagPositions[index]; } + const HeroTag &HeroTagAt(int index) const { return heroTags[index]; } + const geometry::Point &HeroTagPositionAt(int index) const { return heroTagPositions[index]; } bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; } void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); } AttackChoice &ActiveHeroAttackChoice() { return attackChoices[activeHero]; } const AttackChoice &ActiveHeroAttackChoice() const { return attackChoices[activeHero]; } - const AttackChoice &AttackChoiceAt(std::vector::size_type index) const { return attackChoices[index]; } + const AttackChoice &AttackChoiceAt(int index) const { return attackChoices[index]; } TargetSelection &ActiveHeroTargets() { return attackChoices[activeHero].Selection(); } const TargetSelection &ActiveHeroTargets() const { return attackChoices[activeHero].Selection(); } - bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); } + bool AttackSelectionDone() const { return activeHero >= numHeroes; } graphics::Menu &GetSpellMenu() { return spellMenus[activeHero]; } const graphics::Menu &GetSpellMenu() const { return spellMenus[activeHero]; } @@ -105,9 +109,13 @@ public: 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) { return index >= 0 && index < int(heroes.size()); } - std::vector &Heroes() { return heroes; } - const std::vector &Heroes() const { return heroes; } + bool HeroPositionOccupied(int index) { return index >= 0 && index < numHeroes; } + int NumHeroes() const { return numHeroes; } + std::vector &Monsters() { return monsters; } + const std::vector &Monsters() const { return monsters; } + + void SetRunaway() { ranAway = true; } + void ClearAllAttacks(); public: geometry::Vector CalculateScreenOffset(SDL_Surface *screen) const { @@ -139,14 +147,16 @@ private: std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; - std::vector heroes; - std::vector > spellMenus; + Hero heroes[4]; + graphics::Menu spellMenus[4]; graphics::Menu itemMenu; - std::vector > ikariMenus; + graphics::Menu ikariMenus[4]; HeroTag heroTags[4]; geometry::Point heroTagPositions[4]; AttackChoice attackChoices[4]; + int numHeroes; int activeHero; + bool ranAway; };