]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectAttackType.cpp
reworked Application's state stack
[l2e.git] / src / battle / states / SelectAttackType.cpp
index c0548132b536c115d5cee98265ce4afd43856ace..c7a65be7a3ade4d69d9c54895d2248d24ac587d0 100644 (file)
@@ -9,25 +9,35 @@
 
 #include "../AttackChoice.h"
 #include "../BattleState.h"
+#include "../../app/Application.h"
 #include "../../app/Input.h"
 #include "../../geometry/operators.h"
 
 #include <stdexcept>
 
+using app::Application;
 using app::Input;
 using geometry::Point;
 using geometry::Vector;
 
 namespace battle {
 
-void SelectAttackType::EnterState(app::Application &c, SDL_Surface *screen) {
+void SelectAttackType::EnterState(Application &c, SDL_Surface *screen) {
        ctrl = &c;
 }
 
-void SelectAttackType::ExitState() {
+void SelectAttackType::ExitState(Application &c, SDL_Surface *screen) {
        ctrl = 0;
 }
 
+void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
+void SelectAttackType::PauseState(Application &ctrl, SDL_Surface *screen) {
+
+}
+
 
 void SelectAttackType::Resize(int width, int height) {
 
@@ -48,15 +58,16 @@ void SelectAttackType::HandleInput(const Input &input) {
        }
 
        if (input.JustPressed(Input::ACTION_A)) {
+               battle->SetAttackType(battle->GetAttackTypeMenu().Selected());
                switch (battle->GetAttackTypeMenu().Selected()) {
                        case AttackChoice::SWORD:
-                               // TODO: switch to next character
+                               battle->NextHero();
                                break;
                        case AttackChoice::MAGIC:
                                // TODO: switch to spell select
                                break;
                        case AttackChoice::DEFEND:
-                               // TODO: switch to next character
+                               battle->NextHero();
                                break;
                        case AttackChoice::IKARI:
                                // TODO: switch to ikari attack select
@@ -68,6 +79,11 @@ void SelectAttackType::HandleInput(const Input &input) {
                                throw std::logic_error("selected invalid attack type");
                }
        }
+
+       if (battle->AttackSelectionDone()) {
+               // TODO: switch to battle animation instead
+               ctrl->PopState();
+       }
 }
 
 void SelectAttackType::UpdateWorld(float deltaT) {