void playsingle_controller::check_time_over(){ bool time_left = gamestate_.tod_manager_.next_turn(gamestate_.gamedata_); it_is_a_new_turn_ = true; if(!time_left) { LOG_NG << "firing time over event...\n"; set_scontext_synced_base sync; pump().fire("time over"); LOG_NG << "done firing time over event...\n"; //if turns are added while handling 'time over' event if (gamestate_.tod_manager_.is_time_left()) { return; } if(non_interactive()) { LOG_AIT << "time over (draw)\n"; ai_testing::log_draw(); } check_victory(); if (is_regular_game_end()) { return; } end_level_data e; e.proceed_to_next_level = false; e.is_victory = false; set_end_level_data(e); } }
void play_controller::check_victory() { if(linger_) { return; } if (is_regular_game_end()) { return; } bool continue_level, found_player, found_network_player, invalidate_all; std::set<unsigned> not_defeated; gamestate().board_.check_victory(continue_level, found_player, found_network_player, invalidate_all, not_defeated, remove_from_carryover_on_defeat_); if (invalidate_all) { gui_->invalidate_all(); } if (continue_level) { return ; } if (found_player || found_network_player) { pump().fire("enemies_defeated"); if (is_regular_game_end()) { return; } } DBG_EE << "victory_when_enemies_defeated: " << victory_when_enemies_defeated_ << std::endl; DBG_EE << "found_player: " << found_player << std::endl; DBG_EE << "found_network_player: " << found_network_player << std::endl; if (!victory_when_enemies_defeated_ && (found_player || found_network_player)) { // This level has asked not to be ended by this condition. return; } if (gui_->video().non_interactive()) { LOG_AIT << "winner: "; for (unsigned l : not_defeated) { std::string ai = ai::manager::get_active_ai_identifier_for_side(l); if (ai.empty()) ai = "default ai"; LOG_AIT << l << " (using " << ai << ") "; } LOG_AIT << std::endl; ai_testing::log_victory(not_defeated); } DBG_EE << "throwing end level exception..." << std::endl; //Also proceed to the next scenario when another player survived. end_level_data el_data; el_data.proceed_to_next_level = found_player || found_network_player; el_data.is_victory = found_player; set_end_level_data(el_data); }
void playsingle_controller::on_replay_end(bool is_unit_test) { if(is_unit_test) { replay_->return_to_play_side(); if(!is_regular_game_end()) { end_level_data e; e.proceed_to_next_level = false; e.is_victory = false; set_end_level_data(e); } } }