added team::write_player()
This commit is contained in:
parent
ace44ff441
commit
5bb5ad62ef
2 changed files with 25 additions and 0 deletions
24
src/team.cpp
24
src/team.cpp
|
@ -423,6 +423,30 @@ void team::write(config& cfg) const
|
|||
cfg["action_bonus_count"] = str_cast(action_bonus_count_);
|
||||
}
|
||||
|
||||
//write a [player] tag, similar to game_state::write_player()
|
||||
void team::write_player(config& cfg) const
|
||||
{
|
||||
cfg["name"] = info_.current_player;
|
||||
cfg["save_id"] = info_.save_id;
|
||||
cfg["gold"] = str_cast<int>(gold());
|
||||
cfg["gold_add"] = info_.gold_add ? "yes" : "no";
|
||||
|
||||
//add the units of the recall list
|
||||
foreach(const unit& u, recall_list()) {
|
||||
config& new_unit = cfg.add_child("unit");
|
||||
u.write(new_unit);
|
||||
}
|
||||
|
||||
std::stringstream can_recruit;
|
||||
std::copy(recruits().begin(),recruits().end(),std::ostream_iterator<std::string>(can_recruit,","));
|
||||
std::string can_recruit_str = can_recruit.str();
|
||||
// Remove the trailing comma
|
||||
if(can_recruit_str.empty() == false) {
|
||||
can_recruit_str.resize(can_recruit_str.size()-1);
|
||||
}
|
||||
cfg["can_recruit"] = can_recruit_str;
|
||||
}
|
||||
|
||||
bool team::get_village(const map_location& loc)
|
||||
{
|
||||
villages_.insert(loc);
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
~team() {};
|
||||
|
||||
void write(config& cfg) const;
|
||||
void write_player(config& cfg) const;
|
||||
|
||||
bool get_village(const map_location&);
|
||||
void lose_village(const map_location&);
|
||||
|
|
Loading…
Add table
Reference in a new issue