]> git.localhorst.tv Git - l2e.git/commitdiff
added spell target select
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 13:18:30 +0000 (15:18 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 10 Aug 2012 13:18:30 +0000 (15:18 +0200)
src/battle/AttackChoice.h
src/battle/states/SelectItem.cpp
src/battle/states/SelectSpell.cpp
src/main.cpp

index 42eb0d3c51c2b40bde00a98e788f34bfa7891169..f36520351b173b97cc1421bab2c7693bd6b0070e 100644 (file)
 
 #include "TargetSelection.h"
 
-namespace common { class Item; }
+namespace common {
+       class Item;
+       class Spell;
+}
 
 namespace battle {
 
@@ -35,6 +38,8 @@ public:
        void SetType(Type t) { type = t; }
        const common::Item *GetItem() const { return (const common::Item *)thing; }
        void SetItem(const common::Item *i) { thing = i; }
+       const common::Spell *GetSpell() const { return (const common::Spell *)thing; }
+       void SetSpell(const common::Spell *s) { thing = s; }
        TargetSelection &Selection() { return selection; }
        const TargetSelection &Selection() const { return selection; }
 
index 97dd63fc33a53d90c32882ba37bba7e2f462d3c0..96def09e1bed6803972feb3521ca0ffe9af5fed4 100644 (file)
@@ -74,9 +74,6 @@ void SelectItem::HandleInput(const Input &input) {
                                }
                                ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().itemTargetCursor));
                        }
-//                     battle->SetAttackType(AttackChoice::ITEM);
-//                     battle->NextHero();
-//                     ctrl->PopState();
                }
        }
        if (input.JustPressed(Input::ACTION_B)) {
index db5bb45981c723727758a85968c9f8cfe947c01d..62e7c4619c4646eaaf81be6f679d84c7b11a8824 100644 (file)
@@ -9,15 +9,18 @@
 
 #include "SelectAttackType.h"
 #include "SelectMoveAction.h"
+#include "SelectTarget.h"
 #include "../BattleState.h"
 #include "../../app/Application.h"
 #include "../../app/Input.h"
+#include "../../common/Spell.h"
 #include "../../geometry/operators.h"
 #include "../../geometry/Point.h"
 #include "../../graphics/Frame.h"
 
 using app::Application;
 using app::Input;
+using common::Spell;
 using geometry::Point;
 using geometry::Vector;
 using graphics::Frame;
@@ -33,7 +36,9 @@ void SelectSpell::ExitState(Application &c, SDL_Surface *screen) {
 }
 
 void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) {
-
+       if (battle->ActiveHeroTargets().HasSelected()) {
+               ctrl.PopState();
+       }
 }
 
 void SelectSpell::PauseState(Application &ctrl, SDL_Surface *screen) {
@@ -48,11 +53,28 @@ void SelectSpell::Resize(int width, int height) {
 
 void SelectSpell::HandleInput(const Input &input) {
        if (input.JustPressed(Input::ACTION_A)) {
-               // TODO: switch to target select
                if (battle->GetSpellMenu().SelectedIsEnabled()) {
-                       battle->SetAttackType(AttackChoice::MAGIC);
-                       battle->NextHero();
-                       ctrl->PopState();
+                       const Spell *spell(battle->GetSpellMenu().Selected());
+                       battle->ActiveHeroTargets().Reset();
+                       if (spell->GetTargetingMode().TargetsAlly()) {
+                               battle->ActiveHeroTargets().SelectHeroes();
+                       } else {
+                               battle->ActiveHeroTargets().SelectEnemies();
+                       }
+                       if (spell->GetTargetingMode().TargetsAll()) {
+                               battle->SetAttackType(AttackChoice::MAGIC);
+                               // TODO: remove item from inventory
+                               battle->ActiveHeroAttackChoice().SetSpell(spell);
+                               battle->NextHero();
+                               ctrl->PopState();
+                       } else {
+                               if (spell->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)) {
index 3c871cd862fc169fba7221ccc3515d80373ad7eb..1289bde1fbc7ad38218c8c90b34f32486fd51f81 100644 (file)
@@ -199,10 +199,11 @@ int main(int argc, char **argv) {
 
                SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
                Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
+               Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
                Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
                battleRes.weaponTargetCursor = &weaponTargetCursor;
                // TODO: add image for magic targeting cursor
-               battleRes.magicTargetCursor = &weaponTargetCursor;
+               battleRes.magicTargetCursor = &magicTargetCursor;
                // TODO: add image for item targeting cursor
                battleRes.itemTargetCursor = &itemTargetCursor;
 
@@ -213,24 +214,28 @@ int main(int argc, char **argv) {
                strongSpell.SetName("Strong");
                strongSpell.SetCost(3);
                strongSpell.SetUsableInBattle();
+               strongSpell.GetTargetingMode().TargetMultipleAllies();
                maxim.AddSpell(&strongSpell);
                selan.AddSpell(&strongSpell);
                Spell strongerSpell;
                strongerSpell.SetName("Stronger");
                strongerSpell.SetCost(8);
                strongerSpell.SetUsableInBattle();
+               strongerSpell.GetTargetingMode().TargetMultipleAllies();
                maxim.AddSpell(&strongerSpell);
                selan.AddSpell(&strongerSpell);
                Spell championSpell;
                championSpell.SetName("Champion");
                championSpell.SetCost(16);
                championSpell.SetUsableInBattle();
+               championSpell.GetTargetingMode().TargetMultipleAllies();
                maxim.AddSpell(&championSpell);
                selan.AddSpell(&championSpell);
                Spell rallySpell;
                rallySpell.SetName("Rally");
                rallySpell.SetCost(10);
                rallySpell.SetUsableInBattle();
+               rallySpell.GetTargetingMode().TargetMultipleAllies();
                maxim.AddSpell(&rallySpell);
                selan.AddSpell(&rallySpell);
                Spell escapeSpell;
@@ -241,23 +246,12 @@ int main(int argc, char **argv) {
                valorSpell.SetName("Valor");
                valorSpell.SetCost(30);
                valorSpell.SetUsableInBattle();
+               valorSpell.GetTargetingMode().TargetMultipleAllies();
                maxim.AddSpell(&valorSpell);
                selan.AddSpell(&valorSpell);
 
                battleRes.spellMenuHeadline = "Please choose a spell.";
                battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
-               battleRes.spellMenuPrototype.Add("Poison   : 2", 0);
-               battleRes.spellMenuPrototype.Add("Warp     : 8", 0, false);
-               battleRes.spellMenuPrototype.Add("Release  : 2", 0);
-               battleRes.spellMenuPrototype.Add("Waken    : 4", 0);
-               battleRes.spellMenuPrototype.Add("Light    : 0", 0, false);
-               battleRes.spellMenuPrototype.Add("Fake     : 4", 0);
-               battleRes.spellMenuPrototype.Add("Trick    : 5", 0);
-               battleRes.spellMenuPrototype.Add("Flash    : 5", 0);
-               battleRes.spellMenuPrototype.Add("Fireball : 6", 0);
-               battleRes.spellMenuPrototype.Add("Vortex   : 7", 0);
-               battleRes.spellMenuPrototype.Add("Blizzard : 8", 0);
-               battleRes.spellMenuPrototype.Add("Spark    : 3", 0);
 
                SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
                Sprite potionIcon(itemIcons, 16, 16);