]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
added and implemented swap heroes state
[l2e.git] / src / battle / BattleState.cpp
index 3f734f84d8ce5bc868f15ad8ea041f2439fce99b..cbea81a82cb5d1564344abe6e24d757bbca70d0e 100644 (file)
@@ -18,6 +18,7 @@
 #include "../geometry/operators.h"
 #include "../graphics/Sprite.h"
 
+#include <algorithm>
 #include <stdexcept>
 
 using app::Application;
@@ -47,6 +48,11 @@ void BattleState::AddHero(const Hero &h) {
        heroes.push_back(h);
 }
 
+void BattleState::SwapHeroes(std::vector<Hero>::size_type lhs, std::vector<Hero>::size_type rhs) {
+       if (lhs < 0 || lhs >= heroes.size() || rhs < 0 || rhs >= heroes.size() || lhs == rhs) return;
+       std::swap(heroes[lhs], heroes[rhs]);
+}
+
 
 void BattleState::Resize(int w, int h) {
 
@@ -61,7 +67,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) {
                LoadSpellMenu(i);
                ikariMenus.push_back(res->ikariMenuPrototype);
                LoadIkariMenu(i);
-               heroTags[i] = HeroTag(&heroes[i], attackChoices + i, res, HeroTag::Alignment((i + 1) % 2));
+               heroTags[i] = HeroTag(this, i);
        }
 
        int tagHeight(attackTypeMenu.Height());