const std::string carryover::to_string(){ std::string side = ""; side.append("Side " + save_id_ + ": gold " + std::to_string(gold_) + " recruits " + get_recruits(false) + " units "); for(const config & u_cfg : recall_list_) { side.append(u_cfg["name"].str() + ", "); } return side; }
void carryover::to_config(config& cfg){ config& side = cfg.add_child("side"); side["save_id"] = save_id_; side["gold"] = gold_; side["add"] = add_; side["current_player"] = current_player_; side["previous_recruits"] = get_recruits(false); side.add_child("variables", variables_); for(const config & u_cfg : recall_list_) { side.add_child("unit", u_cfg); } }
/** * Redoes this action. * @return true on success; false on an error. */ bool recruit_action::redo(int side) { game_display & gui = *resources::screen; team ¤t_team = resources::gameboard->teams()[side-1]; map_location loc = route.front(); map_location from = recruit_from; const std::string & name = u_type.base_id(); //search for the unit to be recruited in recruits if ( !util::contains(get_recruits(side, loc), name) ) { ERR_NG << "Trying to redo a recruit for side " << side << ", which does not recruit type \"" << name << "\"\n"; assert(false); return false; } current_team.last_recruit(name); const std::string &msg = find_recruit_location(side, loc, from, name); if ( msg.empty() ) { //MP_COUNTDOWN: restore recruitment bonus current_team.set_action_bonus_count(1 + current_team.action_bonus_count()); resources::recorder->redo(replay_data); replay_data.clear(); set_scontext_synced sync; recruit_unit(u_type, side, loc, from, true, false); // Quick error check. (Abuse of [allow_undo]?) if ( loc != route.front() ) { ERR_NG << "When redoing a recruit at " << route.front() << ", the location was moved to " << loc << ".\n"; // Not really fatal, I suppose. Just update the action so // undoing this works. route.front() = loc; } sync.do_final_checkup(); } else { gui2::show_transient_message(gui.video(), "", msg); return false; } return true; }