]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
fixed a bug in BattleState::PreviousHero()
[l2e.git] / src / battle / BattleState.cpp
index 65bdb9180b56e86dbff54a64a5f21f356f06f4e7..50121049651fc4b0a4deacb7c40554dcdc21400a 100644 (file)
@@ -59,6 +59,13 @@ void BattleState::NextHero() {
        }
 }
 
+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]);