X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FVictoryState.cpp;h=59d4495f68c5d4c0c4ef7349b229016235dc83f2;hb=77b070e782e664f9906487d6ee71010f659ce8b5;hp=a0b09ceb5b93d7996c71317f88765b80cce45bad;hpb=e8283bf94624b2f184d50dc1401bf45225c529d6;p=l2e.git diff --git a/src/battle/states/VictoryState.cpp b/src/battle/states/VictoryState.cpp index a0b09ce..59d4495 100644 --- a/src/battle/states/VictoryState.cpp +++ b/src/battle/states/VictoryState.cpp @@ -3,24 +3,33 @@ #include "../Battle.h" #include "../BattleState.h" #include "../Hero.h" +#include "../Resources.h" #include "../../app/Application.h" #include "../../app/Input.h" #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" +#include #include using app::Application; using app::Input; +using common::GameState; +using common::Upgrade; using graphics::Font; using graphics::Frame; using math::Vector; +using std::left; +using std::right; +using std::setfill; +using std::setw; using std::string; +using std::stringstream; using std::vector; namespace battle { @@ -31,40 +40,106 @@ void VictoryState::OnEnterState(SDL_Surface *screen) { } void VictoryState::LoadResults() { + const Resources &res = parent->Res(); lines.clear(); - std::stringstream s; - s << "Gets " << battle->ExpReward() << " EXP"; + stringstream s; + s << res.victoryGetsText << ' ' + << battle->ExpReward() << ' ' + << res.victoryExpText << '.'; lines.push_back(s.str()); s.str(""); - s << "Gets " << battle->GoldReward() << " gold"; + s << res.victoryGetsText << ' ' + << battle->GoldReward() << ' ' + << res.victoryGoldText << '.'; lines.push_back(s.str()); 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 (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()); + LoadResult(*i, lines); } - 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()); - } - } + s.str(""); + s << state.money << ' ' << res.victoryGoldText; + string goldStr = s.str(); lines.push_back(""); s.str(""); - s << parent->Game().state->money << " gold"; + s << right << setw(28) << setfill(' ') << goldStr; + lines.push_back(s.str()); +} + +void VictoryState::LoadResult( + const Upgrade &u, + vector &lines) { + const Resources &res = parent->Res(); + stringstream s; + switch (u.GetType()) { + case Upgrade::LEVEL_UP: + s << left << setw(6) << setfill(' ') << u.Name() + << res.victoryLevelUpText << '.'; + break; + case Upgrade::MAX_HEALTH: + s << res.victoryMHPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::MAX_MAGIC: + s << res.victoryMMPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::ATTACK: + s << res.victoryATPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::DEFENSE: + s << res.victoryDFPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::STRENGTH: + s << res.victorySTRText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::AGILITY: + s << res.victoryAGLText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::INTELLIGENCE: + s << res.victoryINTText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::GUT: + s << res.victoryGUTText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::MAGIC_RESISTANCE: + s << res.victoryMGRText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; + break; + case Upgrade::LEVEL_NEXT: + s << setw(7) << setfill(' ') + << left << u.Name() << ' ' + << res.victoryNextLevelText + << ' ' << u.Amount(); + break; + default: + s << "unknown upgrade type " << u.GetType(); + } lines.push_back(s.str()); }