示例#1
0
playsingle_controller::hotkey_handler::hotkey_handler(playsingle_controller & pc, saved_game & sg)
	: play_controller::hotkey_handler(pc, sg)
	, playsingle_controller_(pc)
	, whiteboard_manager_(pc.get_whiteboard())
{}
示例#2
0
void campaign_controller::show_carryover_message(playsingle_controller& playcontroller, const end_level_data& end_level, const LEVEL_RESULT res)
{
	assert(resources::teams);

	bool has_next_scenario = !resources::gamedata->next_scenario().empty() &&
			resources::gamedata->next_scenario() != "null";
	//maybe this can be the case for scenario that only contain a story and end during the prestart event ?
	if(resources::teams->size() < 1){
		return;
	}

	std::ostringstream report;
	std::string title;

	bool obs = playcontroller.is_observer();

	if (obs) {
		title = _("Scenario Report");
	} else if (res == LEVEL_RESULT::VICTORY) {
		title = _("Victory");
		report << "<b>" << _("You have emerged victorious!") << "</b>\n\n";
	} else {
		title = _("Defeat");
		report <<  _("You have been defeated!") << "\n";
	}

	//We need to write the carryover amount to the team thats why we need non const
	std::vector<team>& teams = *resources::teams;
	int persistent_teams = 0;
	BOOST_FOREACH(const team &t, teams) {
		if (t.persistent()){
			++persistent_teams;
		}
	}

	if (persistent_teams > 0 && ((has_next_scenario && end_level.proceed_to_next_level)||
			state_.classification().campaign_type == game_classification::CAMPAIGN_TYPE::TEST))
	{
		gamemap map = playcontroller.get_map_const();
		tod_manager tod = playcontroller.get_tod_manager_const();
		int turns_left = std::max<int>(0, tod.number_of_turns() - tod.turn());
		BOOST_FOREACH(team &t, teams)
		{
			if (!t.persistent() || t.lost())
			{
				continue;
			}
			int finishing_bonus_per_turn = map.villages().size() * t.village_gold() + t.base_income();
			int finishing_bonus = t.carryover_bonus() ? finishing_bonus_per_turn * turns_left : 0;
			t.set_carryover_gold(div100rounded((t.gold() + finishing_bonus) * t.carryover_percentage()));
			if(!t.is_local_human())
			{
				continue;
			}
			if (persistent_teams > 1) {
				report << "\n<b>" << t.current_player() << "</b>\n";
			}

			report_victory(report, t, finishing_bonus_per_turn, turns_left, finishing_bonus);
		}
	}
示例#3
0
static void show_carryover_message(saved_game& gamestate, playsingle_controller& playcontroller, display& disp, const end_level_data& end_level, const LEVEL_RESULT res){
	bool has_next_scenario = !resources::gamedata->next_scenario().empty() &&
			resources::gamedata->next_scenario() != "null";
	//maybe this can be the case for scenario that only contain a story and end during the prestart event ?
	if(resources::teams->size() < 1){
		return;
	}

	std::ostringstream report;
	std::string title;

	bool obs = playcontroller.is_observer();

	if (obs) {
		title = _("Scenario Report");
	} else if (res == VICTORY) {
		title = _("Victory");
		report << "<b>" << _("You have emerged victorious!") << "</b>\n\n";
	} else {
		title = _("Defeat");
		report <<  _("You have been defeated!") << "\n";
	}

	std::vector<team> teams = playcontroller.get_teams_const();
	int persistent_teams = 0;
	BOOST_FOREACH(const team &t, teams) {
		if (t.persistent()){
			++persistent_teams;
		}
	}

	if (persistent_teams > 0 && ((has_next_scenario && end_level.proceed_to_next_level)||
			gamestate.classification().campaign_type == game_classification::TEST))
	{
		gamemap map = playcontroller.get_map_const();
		// NOTE: this function uses game_config::village_income/game_config::base_income which is teh same for all teams
		// the function that actualy does the carryover (carryover.cpp) uses team.base_income() / team.village_gold() since 1.13
		// which can be different for every team
		int finishing_bonus_per_turn =
				map.villages().size() * game_config::village_income +
				game_config::base_income;
		tod_manager tod = playcontroller.get_tod_manager_const();
		int turns_left = std::max<int>(0, tod.number_of_turns() - tod.turn());
		int finishing_bonus = (end_level.gold_bonus && turns_left > -1) ?
				finishing_bonus_per_turn * turns_left : 0;


		BOOST_FOREACH(const team &t, teams)
		{
			if (!t.persistent() || t.lost() || !t.is_human())
			{
				continue;
			}
			int carryover_gold = div100rounded((t.gold() + finishing_bonus) * end_level.carryover_percentage);

			if (persistent_teams > 1) {
				report << "\n<b>" << t.current_player() << "</b>\n";
			}

			playcontroller.report_victory(report, carryover_gold, t.gold(), finishing_bonus_per_turn, turns_left, finishing_bonus);
		}
	}