]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
added basic defeat state
[l2e.git] / src / battle / BattleState.cpp
index a17732ca8c612c0c3bc810d46c73050e491e46d6..c6f07cd814d9247fae9caa609a14ddebc63b9a79 100644 (file)
@@ -1,8 +1,10 @@
 #include "BattleState.h"
 
 #include "PartyLayout.h"
+#include "states/DefeatState.h"
 #include "states/SelectMoveAction.h"
 #include "states/PerformAttacks.h"
+#include "states/VictoryState.h"
 #include "../app/Application.h"
 #include "../app/Input.h"
 #include "../common/GameState.h"
@@ -119,11 +121,21 @@ void BattleState::OnResumeState(SDL_Surface *screen) {
                return;
        }
        if (battle.Victory()) {
-               Ctrl().PopState();
+               if (alreadyPushed) {
+                       Ctrl().PopState();
+               } else {
+                       Ctrl().PushState(new VictoryState(&battle, this));
+                       alreadyPushed = true;
+               }
                return;
        }
        if (battle.Defeat()) {
-               Ctrl().PopState();
+               if (alreadyPushed) {
+                       Ctrl().PopState();
+               } else {
+                       Ctrl().PushState(new DefeatState(&battle, this));
+                       alreadyPushed = true;
+               }
                return;
        }
        // TODO: this should not push a state while quitting