]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectTarget.cpp
extracted battle logic into a class
[l2e.git] / src / battle / states / SelectTarget.cpp
index dc8c1239145f9a7cfbd95828a2c16612eea25e27..f9507a17024966158efca526d50193961bd2c8b4 100644 (file)
@@ -13,6 +13,20 @@ using std::vector;
 
 namespace battle {
 
+SelectTarget::SelectTarget(
+               Battle *battle,
+               SelectAttackType *parent,
+               TargetSelection *selection,
+               const graphics::Sprite *cursorIcon)
+: battle(battle)
+, parent(parent)
+, selection(selection)
+, cursorIcon(cursorIcon)
+, flipFlop(true) {
+
+}
+
+
 void SelectTarget::OnEnterState(SDL_Surface *screen) {
        OnResize(screen->w, screen->h);
 }
@@ -31,21 +45,21 @@ void SelectTarget::OnPauseState(SDL_Surface *screen) {
 
 
 void SelectTarget::OnResize(int width, int height) {
-       Vector<int> offset(battle->ScreenOffset());
+       Vector<int> offset(parent->ScreenOffset());
        cursorOffset = Vector<int>(cursorIcon->Width() / -2, cursorIcon->Height()) + offset;
        // offset the indicator by 1/8th to the right and top
        indicatorOffset = cursorOffset + Vector<int>(cursorIcon->Width() / 8, cursorIcon->Height() / -8);
 
        monsterPositions.clear();
-       monsterPositions.reserve(battle->MaxMonsters());
-       for (int i(0), end(battle->MaxMonsters()); i < end; ++i) {
+       monsterPositions.reserve(battle->NumMonsters());
+       for (int i(0), end(battle->NumMonsters()); i < end; ++i) {
                monsterPositions.push_back(battle->MonsterAt(i).Position());
        }
 
        heroPositions.clear();
        heroPositions.reserve(battle->NumHeroes());
        for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
-               heroPositions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset());
+               heroPositions.push_back(parent->HeroTagPositionAt(i) + parent->HeroTagAt(i).HeroOffset());
        }
 }