Skip to content

Commit

Permalink
add "always" defeat_condition
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed May 19, 2014
1 parent 26d60c0 commit 12d190f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/play_controller.cpp
Expand Up @@ -1403,10 +1403,11 @@ void play_controller::check_victory()
for (unit_map::const_iterator i = units_.begin(),
i_end = units_.end(); i != i_end; ++i)
{
if (i->can_recruit()) {
const team& tm = teams_[i->side()-1];
if (i->can_recruit() && tm.defeat_condition() == team::NO_LEADER) {
//DBG_NG << "seen leader for side " << i->side() << "\n";
not_defeated.insert(i->side());
} else if (teams_[i->side()-1].defeat_condition() == team::NO_UNITS) {
} else if (tm.defeat_condition() == team::NO_UNITS) {
//DBG_NG << "side doesn't require leader " << i->side() << "\n";
not_defeated.insert(i->side());
}
Expand Down
4 changes: 4 additions & 0 deletions src/team.cpp
Expand Up @@ -78,6 +78,8 @@ team::DEFEAT_CONDITION team::parse_defeat_condition(const std::string& cond, tea
return team::NO_UNITS;
else if (cond == "never")
return team::NEVER;
else if (cond == "always")
return team::ALWAYS;
else
return def;
//throw game::game_error("Cannot parse string " + cond +" to a DEFEAT_CONDITION");
Expand All @@ -92,6 +94,8 @@ std::string team::defeat_condition_to_string(DEFEAT_CONDITION cond)
return "no_unit";
case team::NEVER:
return "never";
case team::ALWAYS:
return "always";
default:
throw game::game_error("Found corrupted DEFEAT_CONDITION");
}
Expand Down
2 changes: 1 addition & 1 deletion src/team.hpp
Expand Up @@ -33,7 +33,7 @@ class team : public savegame::savegame_config
{
public:
enum CONTROLLER { HUMAN, AI, NETWORK, NETWORK_AI, IDLE, EMPTY };
enum DEFEAT_CONDITION {NO_LEADER, NO_UNITS, NEVER};
enum DEFEAT_CONDITION {NO_LEADER, NO_UNITS, NEVER, ALWAYS};
static DEFEAT_CONDITION parse_defeat_condition(const std::string& cond, team::DEFEAT_CONDITION def);
static std::string defeat_condition_to_string(DEFEAT_CONDITION cond);
private:
Expand Down

0 comments on commit 12d190f

Please sign in to comment.