]> git.localhorst.tv Git - l2e.git/commitdiff
handle dead hero in BattleState
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 11 Aug 2012 19:16:33 +0000 (21:16 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 11 Aug 2012 19:16:33 +0000 (21:16 +0200)
src/battle/BattleState.cpp
src/battle/BattleState.h
test-data/dekar.png
test-data/guy.png
test-data/maxim.png
test-data/selan.png

index 6fac152e64b87e94acc7d132b29c1e2878012de8..6aeaae5f7e4ee98ac845c79c26f558abefba03c4 100644 (file)
@@ -51,6 +51,13 @@ void BattleState::AddHero(const Hero &h) {
        ++numHeroes;
 }
 
+void BattleState::NextHero() {
+       ++activeHero;
+       while (activeHero < numHeroes && 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]);
@@ -259,7 +266,8 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset)
 
 void BattleState::RenderHeroes(SDL_Surface *screen, const Vector<int> &offset) {
        for (int i(0); i < numHeroes; ++i) {
-               heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 0, 1);
+               int row(heroes[i].Health() > 0 ? 0 : 2);
+               heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 1, row);
        }
 }
 
index a901c63f68ccf028063fec9ebc8a21d3313376be..b491af862c99485c080c156836d3a2c9e7413b26 100644 (file)
@@ -84,8 +84,7 @@ public:
        graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
        const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
 
-       bool HasMoreHeroes() const { return activeHero < numHeroes; }
-       void NextHero() { ++activeHero; }
+       void NextHero();
        bool BeforeFirstHero() const { return activeHero < 0; }
        void PreviousHero() { --activeHero; }
        void SwapHeroes(int lhs, int rhs);
index 3771245319a8ff7e093144e1494ed27bb60a1282..5671f49445569258b32ad3b11abf9be35b6a1ebb 100644 (file)
Binary files a/test-data/dekar.png and b/test-data/dekar.png differ
index c6fa7f5ef1edd7efb98bfd4772427c94f92aeabd..a292ec1b859ab53dbdd6d376da6b46e0ee6e0082 100644 (file)
Binary files a/test-data/guy.png and b/test-data/guy.png differ
index e7e20bdadad7a729529d205138a217d4d4e17252..bb195c1bec00a87b2878a2ee94e32651e8c311e7 100644 (file)
Binary files a/test-data/maxim.png and b/test-data/maxim.png differ
index 8b46f8882887ceeb8ddcc3ae88b6484ca00d2291..7da4e59b7e32c4475361277a782ba35d3d0bb22a 100644 (file)
Binary files a/test-data/selan.png and b/test-data/selan.png differ