X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=c294e1a28feda13da5b9f81be3b9e15aa4aecdc3;hb=69123d71dacfdd6592c00ead8b92b6441d0f0228;hp=3f734f84d8ce5bc868f15ad8ea041f2439fce99b;hpb=4170813213bafe6f4a01a79bf42308ddb7f3c545;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 3f734f8..c294e1a 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -18,6 +18,7 @@ #include "../geometry/operators.h" #include "../graphics/Sprite.h" +#include #include using app::Application; @@ -47,6 +48,11 @@ void BattleState::AddHero(const Hero &h) { heroes.push_back(h); } +void BattleState::SwapHeroes(std::vector::size_type lhs, std::vector::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()); @@ -181,7 +187,11 @@ void BattleState::ExitState(Application &ctrl, SDL_Surface *screen) { } void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) { - // TODO: check for victory, defeat or run + // TODO: check for victory or defeat + if (ranAway) { + ctrl.PopState(); // quit the battle scene + return; + } // reset attack choices activeHero = -1; for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { @@ -195,7 +205,7 @@ void BattleState::PauseState(Application &ctrl, SDL_Surface *screen) { } -void BattleState::HandleInput(const Input &input) { +void BattleState::HandleEvents(const Input &input) { } @@ -231,7 +241,7 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { - heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset); + heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 0, 1); } }