didn't account for dead heroes; now does
}
}
+void BattleState::PreviousHero() {
+ --activeHero;
+ while (activeHero >= 0 && heroes[activeHero].Health() == 0) {
+ --activeHero;
+ }
+}
+
void BattleState::SwapHeroes(int lhs, int rhs) {
if (lhs < 0 || lhs >= numHeroes || rhs < 0 || rhs >= numHeroes || lhs == rhs) return;
std::swap(heroes[lhs], heroes[rhs]);
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]; }