X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=daf2c49124a7432c9b5847f81699d35601df63e5;hb=8967f42789c619df6e5874f5c6a9ea4b6b6c33db;hp=0143fe0fac21cefd940e2e9a48fb50dfa7df2321;hpb=68510cd21025741773b6746376a24602be791829;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 0143fe0..daf2c49 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -84,10 +84,10 @@ public: 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 &GetSpellMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); } + const graphics::Menu &GetSpellMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); } + graphics::Menu &GetIkariMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); } + const graphics::Menu &GetIkariMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); } graphics::Menu &GetItemMenu() { return itemMenu; } const graphics::Menu &GetItemMenu() const { return itemMenu; } @@ -95,8 +95,8 @@ public: bool BeforeFirstHero() const { return activeHero < 0; } 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,13 +106,9 @@ 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; } + AttackChoice &MonsterAttackChoiceAt(int index) { assert(index >= 0 && index < MaxMonsters()); return monsters[index].GetAttackChoice(); } + const AttackChoice &MonsterAttackChoiceAt(int index) const { assert(index >= 0 && index < MaxMonsters()); return monsters[index].GetAttackChoice(); } bool AttackSelectionDone() const { return activeHero >= numHeroes; } int NumHeroes() const { return numHeroes; } @@ -176,7 +172,6 @@ private: std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; - std::vector monsterAttacks; std::vector attackOrder; Hero heroes[4]; graphics::Menu itemMenu;