move some functionality out of play controller to game_board

This moves some simple code which manipulates the end turn status
of the units on the map.
This commit is contained in:
Chris Beck 2014-06-01 01:54:41 -04:00
parent 5fa083680e
commit 0e7769a12c
5 changed files with 31 additions and 17 deletions

View File

@ -684,12 +684,7 @@ void play_controller::do_init_side(bool is_replay, bool only_visual) {
// Healing/income happen if it's not the first turn of processing,
// or if we are loading a game.
if (!only_visual && turn() > 1) {
BOOST_FOREACH(unit & i, gameboard_.units_) {
if (i.side() == player_number_) {
i.new_turn();
}
}
gameboard_.new_turn(player_number_);
current_team().new_turn();
// If the expense is less than the number of villages owned
@ -1526,3 +1521,26 @@ void play_controller::toggle_accelerated_speed()
gui_->announce(_("Accelerated speed disabled!"), font::NORMAL_COLOR);
}
}
void game_board::new_turn(int player_num) {
BOOST_FOREACH (unit & i, units_) {
if (i.side() == player_num) {
i.new_turn();
}
}
}
void game_board::end_turn(int player_num) {
BOOST_FOREACH (unit & i, units_) {
if (i.side() == player_num) {
i.end_turn();
}
}
}
void game_board::set_all_units_user_end_turn() {
BOOST_FOREACH (unit & i, units_) {
i.set_user_end_turn(true);
}
}

View File

@ -76,6 +76,10 @@ struct game_board {
gamemap map_;
unit_map units_;
void new_turn(int pnum);
void end_turn(int pnum);
void set_all_units_user_end_turn();
};

View File

@ -313,9 +313,7 @@ void playmp_controller::linger()
// stay stuck in linger state when the *next* scenario is over.
gamestate_.classification().completion = "running";
// End all unit moves
BOOST_FOREACH(unit &u, gameboard_.units_) {
u.set_user_end_turn(true);
}
gameboard_.set_all_units_user_end_turn();
//current_team().set_countdown_time(0);
//halt and cancel the countdown timer
reset_countdown();

View File

@ -844,9 +844,7 @@ void playsingle_controller::linger()
gui_->redraw_everything();
// End all unit moves
BOOST_FOREACH (unit & u, gameboard_.units_) {
u.set_user_end_turn(true);
}
gameboard_.set_all_units_user_end_turn();
try {
// Same logic as single-player human turn, but
// *not* the same as multiplayer human turn.

View File

@ -482,11 +482,7 @@ void replay_controller::play_side(){
}
// This is necessary for replays in order to show possible movements.
BOOST_FOREACH(unit &u, gameboard_.units_) {
if (u.side() == player_number_) {
u.new_turn();
}
}
gameboard_.new_turn(player_number_);
update_teams();
update_gui();