]> git.localhorst.tv Git - l2e.git/commitdiff
added target selection to select ikari state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 15:16:58 +0000 (17:16 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 15:16:58 +0000 (17:16 +0200)
src/battle/AttackChoice.h
src/battle/states/SelectIkari.cpp

index f36520351b173b97cc1421bab2c7693bd6b0070e..8cba2353a164bccfd155672dd9c9fc5df291aa0c 100644 (file)
@@ -11,6 +11,7 @@
 #include "TargetSelection.h"
 
 namespace common {
+       class Ikari;
        class Item;
        class Spell;
 }
index 85b61c79d24443dc02be1396e07e7c81b39e06cc..c4fb5000b60c33a532b9363b97fdfa495f6ec70e 100644 (file)
@@ -8,15 +8,19 @@
 #include "SelectIkari.h"
 
 #include "SelectAttackType.h"
+#include "SelectTarget.h"
 #include "../BattleState.h"
 #include "../../app/Application.h"
 #include "../../app/Input.h"
+#include "../../common/Ikari.h"
+#include "../../common/Item.h"
 #include "../../geometry/Point.h"
 #include "../../geometry/operators.h"
 #include "../../graphics/Frame.h"
 
 using app::Application;
 using app::Input;
+using common::Ikari;
 using geometry::Point;
 using geometry::Vector;
 using graphics::Frame;
@@ -32,7 +36,9 @@ void SelectIkari::ExitState(Application &c, SDL_Surface *screen) {
 }
 
 void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
-
+       if (battle->ActiveHeroTargets().HasSelected()) {
+               ctrl.PopState();
+       }
 }
 
 void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) {
@@ -47,11 +53,28 @@ void SelectIkari::Resize(int width, int height) {
 
 void SelectIkari::HandleInput(const Input &input) {
        if (input.JustPressed(Input::ACTION_A)) {
-               // TODO: switch to target select
-               if (battle->GetIkariMenu().SelectedIsEnabled()) {
-                       battle->SetAttackType(AttackChoice::IKARI);
-                       battle->NextHero();
-                       ctrl->PopState();
+               if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) {
+                       const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari());
+                       battle->ActiveHeroTargets().Reset();
+                       if (ikari->GetTargetingMode().TargetsAlly()) {
+                               battle->ActiveHeroTargets().SelectHeroes();
+                       } else {
+                               battle->ActiveHeroTargets().SelectEnemies();
+                       }
+                       if (ikari->GetTargetingMode().TargetsAll()) {
+                               battle->SetAttackType(AttackChoice::MAGIC);
+                               // TODO: remove item from inventory
+                               battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected());
+                               battle->NextHero();
+                               ctrl->PopState();
+                       } else {
+                               if (ikari->GetTargetingMode().TargetsSingle()) {
+                                       battle->ActiveHeroTargets().SetSingle();
+                               } else {
+                                       battle->ActiveHeroTargets().SetMultiple();
+                               }
+                               ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().magicTargetCursor));
+                       }
                }
        }
        if (input.JustPressed(Input::ACTION_B)) {