X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FVictoryState.cpp;h=e2cc99fb27cc3e7799d0dde3728958c4a1f45538;hb=b9e715649b41cb69ea1b2d2a588522541eb87b46;hp=a0b09ceb5b93d7996c71317f88765b80cce45bad;hpb=e8283bf94624b2f184d50dc1401bf45225c529d6;p=l2e.git diff --git a/src/battle/states/VictoryState.cpp b/src/battle/states/VictoryState.cpp index a0b09ce..e2cc99f 100644 --- a/src/battle/states/VictoryState.cpp +++ b/src/battle/states/VictoryState.cpp @@ -8,7 +8,7 @@ #include "../../common/Capsule.h" #include "../../common/GameConfig.h" #include "../../common/GameState.h" -#include "../../common/Hero.h" +#include "../../common/Upgrade.h" #include "../../math/Vector.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" @@ -17,6 +17,8 @@ using app::Application; using app::Input; +using common::GameState; +using common::Upgrade; using graphics::Font; using graphics::Frame; using math::Vector; @@ -31,6 +33,7 @@ void VictoryState::OnEnterState(SDL_Surface *screen) { } void VictoryState::LoadResults() { + // TODO: localization lines.clear(); std::stringstream s; @@ -43,28 +46,62 @@ void VictoryState::LoadResults() { lines.push_back(""); - for (std::vector::const_iterator - i(battle->HeroesBegin()), end(battle->HeroesEnd()); + GameState &state = *parent->Game().state; + vector upgrade; + battle->ApplyRewards(state, upgrade); + for (std::vector::const_iterator + i(upgrade.begin()), end(upgrade.end()); i != end; ++i) { - if (i->Health() <= 0) continue; - const common::Hero &hero = i->Master(); - s.str(""); - s << hero.Name() << " next level " << hero.NextLevel(); - lines.push_back(s.str()); - } - - if (battle->HasCapsule()) { - const Capsule &capsule = battle->GetCapsule(); - if (capsule.Health() > 0) { - s.str(""); - s << capsule.Name() << " next level " << capsule.Master().NextLevel(); - lines.push_back(s.str()); - } + LoadResult(*i, lines); } lines.push_back(""); s.str(""); - s << parent->Game().state->money << " gold"; + s << state.money << " gold"; + lines.push_back(s.str()); +} + +void VictoryState::LoadResult( + const Upgrade &u, + vector &lines) { + std::stringstream s; + switch (u.GetType()) { + case Upgrade::LEVEL_UP: + s << u.Name() << " levels up."; + break; + case Upgrade::MAX_HEALTH: + s << "Max. HP increases by " << u.Amount(); + break; + case Upgrade::MAX_MAGIC: + s << "Max. MP increases by " << u.Amount(); + break; + case Upgrade::ATTACK: + s << "ATP increases by " << u.Amount(); + break; + case Upgrade::DEFENSE: + s << "DFP increases by " << u.Amount(); + break; + case Upgrade::STRENGTH: + s << "STR increases by " << u.Amount(); + break; + case Upgrade::AGILITY: + s << "AGL increases by " << u.Amount(); + break; + case Upgrade::INTELLIGENCE: + s << "INT increases by " << u.Amount(); + break; + case Upgrade::GUT: + s << "GUT increases by " << u.Amount(); + break; + case Upgrade::MAGIC_RESISTANCE: + s << "MGR increases by " << u.Amount(); + break; + case Upgrade::LEVEL_NEXT: + s << u.Name() << " next level " << u.Amount(); + break; + default: + s << "unknown upgrade type " << u.GetType(); + } lines.push_back(s.str()); }