X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FVictoryState.cpp;h=64318e0157d87b50afbdd75334ad22647c8a983f;hb=3d69f521b593457304b282e5f23e36ab165288b6;hp=409f0846aa380b4a8153f53a12aaa287f616cda6;hpb=8f4cb4e8ad954ba73fb78a030c969c933a7ed60c;p=l2e.git diff --git a/src/battle/states/VictoryState.cpp b/src/battle/states/VictoryState.cpp index 409f084..64318e0 100644 --- a/src/battle/states/VictoryState.cpp +++ b/src/battle/states/VictoryState.cpp @@ -8,6 +8,7 @@ #include "../../common/Capsule.h" #include "../../common/GameConfig.h" #include "../../common/GameState.h" +#include "../../common/Upgrade.h" #include "../../math/Vector.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" @@ -16,6 +17,8 @@ using app::Application; using app::Input; +using common::GameState; +using common::Upgrade; using graphics::Font; using graphics::Frame; using math::Vector; @@ -42,81 +45,63 @@ void VictoryState::LoadResults() { lines.push_back(""); - vector upgrade; - for (std::vector::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; - upgrade.clear(); - common::Hero &hero = i->Master(); - hero.AddExperience(battle->ExpReward(), upgrade); - LoadResults(hero.Name(), upgrade, lines); - 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::LoadResults( - const char *who, - const vector &upgrade, +void VictoryState::LoadResult( + const Upgrade &u, vector &lines) { std::stringstream s; - for (vector::const_iterator - i(upgrade.begin()), end(upgrade.end()); - i != end; ++i) { - s.str(""); - switch (i->type) { - case common::Hero::UPGRADE_LVL: - s << who << " levels up."; - break; - case common::Hero::UPGRADE_MHP: - s << "Max. HP increases by " << i->amount; - break; - case common::Hero::UPGRADE_MMP: - s << "Max. MP increases by " << i->amount; - break; - case common::Hero::UPGRADE_ATK: - s << "ATK increases by " << i->amount; - break; - case common::Hero::UPGRADE_DFP: - s << "DFP increases by " << i->amount; - break; - case common::Hero::UPGRADE_STR: - s << "STR increases by " << i->amount; - break; - case common::Hero::UPGRADE_AGL: - s << "AGL increases by " << i->amount; - break; - case common::Hero::UPGRADE_INT: - s << "INT increases by " << i->amount; - break; - case common::Hero::UPGRADE_GUT: - s << "GUT increases by " << i->amount; - break; - case common::Hero::UPGRADE_MGR: - s << "MGR increases by " << i->amount; - break; - default: - s << "There's an error in common::Hero::" - "AddExperience()"; - } - lines.push_back(s.str()); + 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 << "ATK 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_RSISTANCE: + 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()); } void VictoryState::OnExitState(SDL_Surface *screen) {