]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
added "No equit" text to battle resources
[l2e.git] / src / battle / BattleState.cpp
index ad225173fce209625a452265c0913cf5b1d9adda..da3dad6de234f43263860d1e5b3dfdb85e16ea95 100644 (file)
@@ -13,6 +13,7 @@
 #include "../app/Input.h"
 #include "../common/Inventory.h"
 #include "../common/Item.h"
+#include "../common/Spell.h"
 #include "../geometry/operators.h"
 #include "../graphics/Sprite.h"
 
@@ -22,6 +23,7 @@ using app::Application;
 using app::Input;
 using common::Inventory;
 using common::Item;
+using common::Spell;
 using geometry::Point;
 using geometry::Vector;
 using graphics::Menu;
@@ -55,7 +57,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
        heroesLayout->CalculatePositions(background->w, background->h, heroesPositions);
        for (vector<Hero>::size_type i(0), end(heroes.size()); i < end; ++i) {
                spellMenus.push_back(res->spellMenuPrototype);
-               // TODO: insert spell menu entries
+               LoadSpellMenu(i);
                ikariMenus.push_back(res->ikariMenuPrototype);
                // TODO: insert ikari menu entries
                heroTags[i] = HeroTag(&heroes[i], attackChoices + i, res, HeroTag::Alignment((i + 1) % 2));
@@ -69,11 +71,19 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
        heroTagPositions[2] = Point<int>(xOffset, BackgroundHeight() - tagHeight);
        heroTagPositions[3] = Point<int>(xOffset + tagWidth, BackgroundHeight() - tagHeight);
 
-       // TODO: insert item menu entries
        itemMenu = res->itemMenuPrototype;
        LoadInventory();
 }
 
+void BattleState::LoadSpellMenu(vector<Hero>::size_type index) {
+       spellMenus[index].Clear();
+       spellMenus[index].Reserve(HeroAt(index).Spells().size());
+       for (vector<const Spell *>::const_iterator i(HeroAt(index).Spells().begin()), end(HeroAt(index).Spells().end()); i != end; ++i) {
+               bool enabled((*i)->CanUseInBattle() && (*i)->Cost() <= HeroAt(index).Mana());
+               spellMenus[index].Add((*i)->Name(), *i, enabled, 0, (*i)->Cost());
+       }
+}
+
 void BattleState::LoadInventory() {
        const Inventory &inv(*res->inventory);
        itemMenu.Clear();