49 #define LOG_G LOG_STREAM(info, lg::general) 52 #define LOG_NG LOG_STREAM(info, log_engine) 53 #define ERR_NG LOG_STREAM(err, log_engine) 56 #define LOG_RG LOG_STREAM(info, log_enginerefac) 62 std::vector<team>& teams = playcontroller.
get_teams();
65 if(teams.size() < 1) {
69 std::ostringstream report;
75 title =
_(
"Scenario Report");
76 }
else if(res == LEVEL_RESULT::VICTORY) {
78 report <<
"<b>" <<
_(
"You have emerged victorious!") <<
"</b>";
81 report <<
_(
"You have been defeated!");
85 const bool has_next_scenario = !next_scenario.empty() && next_scenario !=
"null";
87 int persistent_teams = 0;
88 for(
const team&
t : teams) {
99 for(
team&
t : teams) {
100 if(!
t.persistent() ||
t.lost()) {
104 const int finishing_bonus_per_turn = map.
villages().size() *
t.village_gold() +
t.base_income();
105 const int finishing_bonus =
t.carryover_bonus() * finishing_bonus_per_turn *
turns_left;
107 t.set_carryover_gold(
div100rounded((
t.gold() + finishing_bonus) *
t.carryover_percentage()));
109 if(!
t.is_local_human()) {
113 if(persistent_teams > 1) {
114 report <<
"\n\n<b>" <<
t.side_name() <<
"</b>";
119 if(
t.carryover_bonus() != 0) {
120 if(turns_left > -1) {
121 report <<
"\n\n<b>" <<
_(
"Turns finished early: ") << turns_left <<
"</b>\n" 122 <<
"<small>" <<
_(
"Early finish bonus: ") << finishing_bonus_per_turn <<
_(
" per turn") <<
"</small>\n" 123 <<
"<small>" <<
_(
"Total bonus: ") << finishing_bonus <<
"</small>\n";
130 report <<
"\n<small>" <<
_(
"Carryover percentage: ") <<
t.carryover_percentage() <<
"</small>";
133 if(
t.carryover_add()) {
142 symbols[
"gold"] = lexical_cast_default<std::string>(
t.carryover_gold());
146 if(
t.carryover_add()) {
147 if(
t.carryover_gold() > 0) {
149 "You will start the next scenario with $gold on top of the defined minimum starting gold.",
150 "You will start the next scenario with $gold on top of the defined minimum starting gold.",
151 t.carryover_gold(), symbols
156 "You will start the next scenario with the defined minimum starting gold.",
157 "You will start the next scenario with the defined minimum starting gold.",
158 t.carryover_gold(), symbols
163 "You will start the next scenario with $gold or its defined minimum starting gold, " 164 "whichever is higher.",
165 "You will start the next scenario with $gold or its defined minimum starting gold, " 166 "whichever is higher.",
167 t.carryover_gold(), symbols
172 report <<
"\n" << goldmsg;
189 LOG_NG <<
"created objects... " << (SDL_GetTicks() - playcontroller.
get_ticks()) <<
"\n";
194 LEVEL_RESULT res = playcontroller.
play_scenario(starting_point);
195 if(res == LEVEL_RESULT::QUIT) {
196 return LEVEL_RESULT::QUIT;
224 if(res == LEVEL_RESULT::QUIT) {
225 return LEVEL_RESULT::QUIT;
228 end_level = playcontroller.get_end_level_data();
230 if(res != LEVEL_RESULT::OBSERVER_END) {
236 playcontroller.maybe_linger();
237 playcontroller.update_savegame_snapshot();
259 LEVEL_RESULT res = LEVEL_RESULT::VICTORY;
275 #if !defined(ALWAYS_USE_MP_CONTROLLER) 287 LOG_NG <<
"The game was remotely ended\n";
288 return LEVEL_RESULT::QUIT;
291 return LEVEL_RESULT::QUIT;
293 LOG_NG <<
"The game was aborted\n";
294 return LEVEL_RESULT::QUIT;
297 return LEVEL_RESULT::QUIT;
300 return LEVEL_RESULT::QUIT;
305 return LEVEL_RESULT::QUIT;
308 return LEVEL_RESULT::QUIT;
315 if(res == LEVEL_RESULT::QUIT) {
352 _(
"This scenario has ended. Do you want to continue the campaign?"),
363 return LEVEL_RESULT::QUIT;
381 if(
state_.
mp_settings().saved_game == mp_game_settings::SAVED_GAME_MODE::MIDGAME) {
382 state_.
mp_settings().saved_game = mp_game_settings::SAVED_GAME_MODE::SCENARIO_START;
392 return LEVEL_RESULT::QUIT;
420 std::string message =
_(
"Unknown scenario: '$scenario|'");
424 return LEVEL_RESULT::QUIT;
433 return LEVEL_RESULT::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...
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.
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)
LEVEL_RESULT playmp_scenario(end_level_data &end_level)
std::string get_scenario_id() const
void show() const
Shows the error in a dialog.
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.
int div100rounded(int num)
Guarantees portable results for division by 100; round half up, to the nearest integer.
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()
LEVEL_RESULT playsingle_scenario(end_level_data &end_level)
config & get_starting_point()
Shows a yes and no button.
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.
LEVEL_RESULT play_scenario(const config &level)
bool is_multiplayer() const
int number_of_turns() const
Helper class, don't construct this directly.
transient_end_level transient
void show_carryover_message(playsingle_controller &playcontroller, const end_level_data &end_level, LEVEL_RESULT res)
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...
static void save(LexState *ls, int c)
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...