50 #define LOG_G LOG_STREAM(info, lg::general) 53 #define LOG_NG LOG_STREAM(info, log_engine) 54 #define ERR_NG LOG_STREAM(err, log_engine) 57 #define LOG_RG LOG_STREAM(info, log_enginerefac) 63 std::vector<team>& teams = playcontroller.
get_teams();
66 if(teams.size() < 1) {
70 std::ostringstream report;
76 title =
_(
"Scenario Report");
77 }
else if(res == level_result::type::victory) {
79 report <<
"<b>" <<
_(
"You have emerged victorious!") <<
"</b>";
82 report <<
_(
"You have been defeated!");
86 const bool has_next_scenario = !next_scenario.empty() && next_scenario !=
"null";
88 int persistent_teams = 0;
89 for(
const team&
t : teams) {
100 for(
team&
t : teams) {
101 if(!
t.persistent() ||
t.lost()) {
105 const int finishing_bonus_per_turn = map.
villages().size() *
t.village_gold() +
t.base_income();
106 const int finishing_bonus =
t.carryover_bonus() * finishing_bonus_per_turn *
turns_left;
108 t.set_carryover_gold(
div100rounded((
t.gold() + finishing_bonus) *
t.carryover_percentage()));
110 if(!
t.is_local_human()) {
114 if(persistent_teams > 1) {
115 report <<
"\n\n<b>" <<
t.side_name() <<
"</b>";
120 if(
t.carryover_bonus() != 0) {
121 if(turns_left > -1) {
122 report <<
"\n\n<b>" <<
_(
"Turns finished early: ") << turns_left <<
"</b>\n" 123 <<
"<small>" <<
_(
"Early finish bonus: ") << finishing_bonus_per_turn <<
_(
" per turn") <<
"</small>\n" 124 <<
"<small>" <<
_(
"Total bonus: ") << finishing_bonus <<
"</small>\n";
131 report <<
"\n<small>" <<
_(
"Carryover percentage: ") <<
t.carryover_percentage() <<
"</small>";
134 if(
t.carryover_add()) {
143 symbols[
"gold"] = lexical_cast_default<std::string>(
t.carryover_gold());
147 if(
t.carryover_add()) {
148 if(
t.carryover_gold() > 0) {
150 "You will start the next scenario with $gold on top of the defined minimum starting gold.",
151 "You will start the next scenario with $gold on top of the defined minimum starting gold.",
152 t.carryover_gold(), symbols
157 "You will start the next scenario with the defined minimum starting gold.",
158 "You will start the next scenario with the defined minimum starting gold.",
159 t.carryover_gold(), symbols
164 "You will start the next scenario with $gold or its defined minimum starting gold, " 165 "whichever is higher.",
166 "You will start the next scenario with $gold or its defined minimum starting gold, " 167 "whichever is higher.",
168 t.carryover_gold(), symbols
173 report <<
"\n" << goldmsg;
190 LOG_NG <<
"created objects... " << (SDL_GetTicks() - playcontroller.
get_ticks()) <<
"\n";
196 if(res == level_result::type::quit) {
197 return level_result::type::quit;
225 if(res == level_result::type::quit) {
226 return level_result::type::quit;
229 end_level = playcontroller.get_end_level_data();
231 if(res != level_result::type::observer_end) {
237 playcontroller.maybe_linger();
238 playcontroller.update_savegame_snapshot();
276 #if !defined(ALWAYS_USE_MP_CONTROLLER) 288 LOG_NG <<
"The game was remotely ended\n";
289 return level_result::type::quit;
292 return level_result::type::quit;
294 LOG_NG <<
"The game was aborted\n";
295 return level_result::type::quit;
298 return level_result::type::quit;
301 return level_result::type::quit;
306 return level_result::type::quit;
309 return level_result::type::quit;
316 if(res == level_result::type::quit) {
353 _(
"This scenario has ended. Do you want to continue the campaign?"),
364 return level_result::type::quit;
393 return level_result::type::quit;
421 std::string message =
_(
"Unknown scenario: '$scenario|'");
425 return level_result::type::quit;
434 return level_result::type::victory;
Dialog was closed with the CANCEL button.
void show_message(const std::string &title, const std::string &msg, const std::string &button_caption, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
Shows a message to the user.
bool end_credits
whether to show the standard credits at the end
Class for start-of-scenario saves.
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent ...
std::map< std::string, t_string > string_map
std::string label
Name of the game (e.g.
void expand_scenario()
copies the content of a [scenario] with the correct id attribute from the game config into this objec...
static lg::log_domain log_enginerefac("enginerefac")
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
level_result::type play_scenario(const config &level)
level_result::type play_game()
Error used when game loading fails.
replay_recorder_base & get_replay()
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
level_result::type playsingle_scenario(end_level_data &end_level)
void expand_random_scenario()
takes care of generate_map=, generate_scenario=, map= attributes This should be called before expandi...
bool is_normal_mp_game() const
mp_game_metadata * mp_info_
static lg::log_domain log_engine("engine")
bool goto_mp_wait(bool observe)
Opens the MP Join Game screen and sets the game state according to the changes made.
bool prescenario_save
Should a prescenario be created the next game?
void enable_replay(bool is_unit_test=false)
static CVideo & get_singleton()
const gamemap & get_map() const
bool replay_save
Should a replay save be made?
config & set_snapshot(config snapshot)
virtual void maybe_linger()
static std::string _(const char *str)
std::string get_scenario_id() const
void show() const
Shows the error in a dialog.
constexpr int div100rounded(int num)
Guarantees portable results for division by 100; round half up, to the nearest integer.
This class stores all the data for a single 'side' (in game nomenclature).
std::string half_signed_value(int val)
Sign with Unicode "−" if negative.
level_result::type playmp_scenario(end_level_data &end_level)
void expand_mp_options()
adds values of [option]s into [carryover_sides_start][variables] so that they are applied in the next...
config to_config() const
Builds the snapshot config from members and their respective configs.
void update_label()
sets classification().label to the correct value.
Encapsulates the map of the game.
std::vector< team > & get_teams()
config & get_starting_point()
saved_game_mode::type saved_game
Shows a yes and no button.
void show_carryover_message(playsingle_controller &playcontroller, const end_level_data &end_level, level_result::type res)
bool carryover_report
Should a summary of the scenario outcome be displayed?
std::string campaign
The id of the campaign being played.
Error used for any general game error, e.g.
bool is_multiplayer() const
int number_of_turns() const
Helper class, don't construct this directly.
transient_end_level transient
const config & get_replay_starting_point()
void clean_saves(const std::string &label)
Delete all autosaves of a certain scenario from the default save directory.
std::map< std::string, addon_version_info > addons
the key is the addon_id
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
bool proceed_to_next_level
whether to proceed to the next scenario, equals is_victory in sp.
void expand_mp_events()
adds [event]s from [era] and [modification] into this scenario does NOT expand [option]s because vari...
Additional information on the game outcome which can be provided by WML.
const end_level_data & get_end_level_data() const
void expand_carryover()
merges [carryover_sides_start] into [scenario] and saves the rest into [carryover_sides] Removes [car...
const std::string & next_scenario() const
Class for replay saves (either manually or automatically).
std::string difficulty
The difficulty level the game is being played on.
compression::format save_compression_format()
virtual const game_data * get_game_data() const override
Inherited from filter_context.
const tod_manager & get_tod_manager() const
game_classification & classification()
const std::vector< map_location > & villages() const
Return a list of the locations of villages on the map.
Standard logging facilities (interface).
void convert_to_start_save()
converts a normal savegame form the end of a scenaio to a start-of-scenario savefile for the next sce...
void show_error_message(const std::string &msg, bool message_use_markup)
Shows an error message to the user.
bool goto_mp_staging(ng::connect_engine &engine)
Opens the MP Staging screen and sets the game state according to the changes made.
bool can_start_game() const
A config object defines a single node in a WML file, with access to child nodes.
mp_game_settings & mp_settings()
Multiplayer parameters for this game.
bool save_game_automatic(bool ask_for_overwrite=false, const std::string &filename="")
Saves a game without user interaction, unless the file exists and it should be asked to overwrite it...