]> git.localhorst.tv Git - l2e.git/commitdiff
moved popping of battle state into battle state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 20:24:03 +0000 (22:24 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 20:24:03 +0000 (22:24 +0200)
src/battle/BattleState.cpp
src/battle/BattleState.h
src/battle/states/RunState.cpp

index b3ad20ede3ef4a15aec0ffb214aeccc8a74dfbba..c294e1a28feda13da5b9f81be3b9e15aa4aecdc3 100644 (file)
@@ -187,7 +187,11 @@ void BattleState::ExitState(Application &ctrl, SDL_Surface *screen) {
 }
 
 void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) {
-       // TODO: check for victory, defeat or run
+       // TODO: check for victory or defeat
+       if (ranAway) {
+               ctrl.PopState(); // quit the battle scene
+               return;
+       }
        // reset attack choices
        activeHero = -1;
        for (vector<Hero>::size_type i(0), end(heroes.size()); i < end; ++i) {
index e3ecca915cfaa967ad4b9c765edd313c696d267c..e94ed417b689807e580bf20a6925d0371327ef59 100644 (file)
@@ -51,7 +51,8 @@ public:
        , res(res)
        , attackTypeMenu(res->attackIcons)
        , moveMenu(res->moveIcons)
-       , activeHero(-1) { }
+       , activeHero(-1)
+       , ranAway(false) { }
 
 public:
        void AddMonster(const Monster &);
@@ -109,6 +110,8 @@ public:
        std::vector<Hero> &Heroes() { return heroes; }
        const std::vector<Hero> &Heroes() const { return heroes; }
 
+       void SetRunaway() { ranAway = true; }
+
 public:
        geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
                return geometry::Vector<int>(
@@ -147,6 +150,7 @@ private:
        geometry::Point<int> heroTagPositions[4];
        AttackChoice attackChoices[4];
        int activeHero;
+       bool ranAway;
 
 };
 
index 7fdc0665c82b6bd09bc64fa2c31d033ae728ad8c..6f4325a0b72d0f3850b334c83fe8fe321c771316 100644 (file)
@@ -49,8 +49,8 @@ void RunState::Resize(int width, int height) {
 
 void RunState::HandleEvents(const Input &input) {
        if (timer.Finished()) {
+               battle->SetRunaway();
                ctrl->PopState(); // pop self
-               ctrl->PopState(); // pop battle
        }
 }