51 #define LOG_G LOG_STREAM(info, lg::general)
54 #define LOG_NG LOG_STREAM(info, log_engine)
55 #define ERR_NG LOG_STREAM(err, log_engine)
58 #define LOG_RG LOG_STREAM(info, log_enginerefac)
62 int finishing_bonus_per_turn,
int turns_left,
int finishing_bonus)
67 if (turns_left > -1) {
68 report <<
"\n\n<b>" <<
_(
"Turns finished early: ") << turns_left <<
"</b>\n"
69 <<
"<small>" <<
_(
"Early finish bonus: ") << finishing_bonus_per_turn <<
_(
" per turn") <<
"</small>\n"
70 <<
"<small>" <<
_(
"Total bonus: ") << finishing_bonus <<
"</small>\n";
86 symbols[
"gold"] = lexical_cast_default<std::string>(t.
carryover_gold());
93 "You will start the next scenario with $gold "
94 "on top of the defined minimum starting gold.",
95 "You will start the next scenario with $gold "
96 "on top of the defined minimum starting gold.",
101 "You will start the next scenario with "
102 "the defined minimum starting gold.",
103 "You will start the next scenario with "
104 "the defined minimum starting gold.",
109 "You will start the next scenario with $gold "
110 "or its defined minimum starting gold, "
111 "whichever is higher.",
112 "You will start the next scenario with $gold "
113 "or its defined minimum starting gold, "
114 "whichever is higher.",
119 report <<
"\n" << goldmsg;
133 std::ostringstream
report;
139 title =
_(
"Scenario Report");
140 }
else if (res == LEVEL_RESULT::VICTORY) {
141 title =
_(
"Victory");
142 report <<
"<b>" <<
_(
"You have emerged victorious!") <<
"</b>\n\n";
145 report <<
_(
"You have been defeated!") <<
"\n";
150 int persistent_teams = 0;
151 for (
const team &
t : teams) {
163 for (
team &
t : teams)
165 if (!
t.persistent() ||
t.lost())
169 int finishing_bonus_per_turn = map.
villages().size() *
t.village_gold() +
t.base_income();
170 int finishing_bonus =
t.carryover_bonus() * finishing_bonus_per_turn *
turns_left;
171 t.set_carryover_gold(
div100rounded((
t.gold() + finishing_bonus) *
t.carryover_percentage()));
172 if(!
t.is_local_human())
176 if (persistent_teams > 1) {
177 report <<
"\n<b>" <<
t.side_name() <<
"</b>\n";
180 report_victory(report,
t, finishing_bonus_per_turn, turns_left, finishing_bonus);
192 LOG_NG <<
"created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) <<
"\n";
210 end_level = playcontroller.get_end_level_data_const();
215 playcontroller.maybe_linger();
236 end_level = playcontroller.get_end_level_data_const();
238 if(res != LEVEL_RESULT::OBSERVER_END)
244 playcontroller.maybe_linger();
245 playcontroller.update_savegame_snapshot();
267 LEVEL_RESULT
res = LEVEL_RESULT::VICTORY;
281 #if !defined(ALWAYS_USE_MP_CONTROLLER)
282 if (game_type != game_classification::CAMPAIGN_TYPE::MULTIPLAYER ||
is_replay_) {
296 LOG_NG <<
"The game was aborted\n";
345 _(
"This scenario has ended. Do you want to continue the campaign?"),
377 if (!connect_engine->can_start_game() || (
game_config::debug && game_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER)) {
386 connect_engine->start_game();
427 return LEVEL_RESULT::VICTORY;
void show_error_message(CVideo &video, const std::string &message, bool message_use_markup)
Shows an error message to the user.
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 ...
mp_campaign_info * mp_info_
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...
const config & game_config_
static void report_victory(std::ostringstream &report, team &t, int finishing_bonus_per_turn, int turns_left, int finishing_bonus)
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.
mp::ui::result goto_mp_connect(CVideo &video, ng::connect_engine &engine, const config &game_config, twesnothd_connection *wesnothd_connection, const std::string &game_name)
Opens mp::connect screen and sets game state according to the changes made.
int div100rounded(int num)
Guarantees portable results for division by 100; round towards 0.
std::set< std::string > connected_players
players and observers
replay_recorder_base & get_replay()
static int report(lua_State *L, int status)
double carryover_bonus() const
void show(CVideo &video)
Shows the error in a dialog.
void expand_random_scenario()
takes care of generate_map=, generate_scenario=, map= attributes This should be called before expandi...
static lg::log_domain log_engine("engine")
bool prescenario_save
Should a prescenario be created the next game?
void show_transient_message(CVideo &video, 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.
bool replay_save
Should a replay save be made?
config & set_snapshot(config snapshot)
LEVEL_RESULT playmp_scenario(end_level_data &end_level)
int carryover_gold() const
const gamemap & get_map_const() const
static std::vector< team > *& teams
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.
static UNUSEDNOWARN std::string _(const char *str)
std::map< std::string, t_string > string_map
std::vector< team > * teams
void expand_mp_options()
adds values of [option]s into [carryover_sides_start][variables] so that they are applied in the next...
int carryover_percentage() const
Dialog is closed with the cancel button.
void show_message(CVideo &video, const std::string &title, const std::string &message, const std::string &button_caption, const bool auto_close, const bool message_use_markup)
Shows a message to the user.
void update_label()
sets classification().label to the correct value.
Encapsulates the map of the game.
LEVEL_RESULT playsingle_scenario(end_level_data &end_level)
twesnothd_connection & wesnothd_connection
bool carryover_report
Should a summary of the scenario outcome be displayed?
config & get_starting_pos()
Error used for any general game error, e.g.
LEVEL_RESULT play_scenario(const config &level)
mp::ui::result goto_mp_wait(CVideo &video, saved_game &state, const config &game_config, twesnothd_connection *wesnothd_connection, bool observe)
Opens mp::wait screen and sets game state according to the changes made.
transient_end_level transient
void show_carryover_message(playsingle_controller &playcontroller, const end_level_data &end_level, LEVEL_RESULT res)
const tdata_cache & tdata_
void clean_saves(const std::string &label)
Delete all autosaves of a certain scenario.
const std::string & next_scenario() const
std::string get_scenario_id()
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.
void expand_carryover()
merges [carryover_sides_start] into [scenario] and saves the rest into [carryover_sides] Removes [car...
const tod_manager & get_tod_manager_const() const
static void save(LexState *ls, int c)
Class for replay saves (either manually or automatically).
compression::format save_compression_format()
game_classification & classification()
bool is_normal_mp_game() const
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...
GLsizei GLenum GLuint GLuint GLsizei char * message
bool carryover_add() const
A config object defines a single node in a WML file, with access to child nodes.
boost::scoped_ptr< connect_engine > connect_engine_ptr
Helper class, don't construct this directly.
mp_game_settings & mp_settings()
Multiplayer parameters for this game.
const std::vector< map_location > & villages() const
Return a list of the locations of villages on the map.
GLsizei const GLcharARB ** string
bool save_game_automatic(CVideo &video, 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...
Shows a yes and no button.
int number_of_turns() const
const config & get_replay_starting_pos()