Given a TurnMessage from a player, apply those changes. Receives the StartTurnMessage for the next player. The time left is the amount of time left for the next player to go, and not the player whose turn you are applying. DO NOT CALL THIS FUNCTION UNLESS YOU ARE THE MANAGER!
(&mut self, turn: &TurnMessage, time_left_ms: i32)
| 1123 | /// |
| 1124 | /// DO NOT CALL THIS FUNCTION UNLESS YOU ARE THE MANAGER! |
| 1125 | pub fn apply_turn(&mut self, turn: &TurnMessage, time_left_ms: i32) -> TurnApplication { |
| 1126 | // Serialize the filtered game state to send to the player |
| 1127 | let (start_turn, start_turn_error) = self.world.apply_turn(turn, time_left_ms); |
| 1128 | // Get the end-turn Karbonite of the team who just moved. Because the turn |
| 1129 | // ended, this is the team whose turn it is not. |
| 1130 | let karbonite = self.world.get_team(self.world.team().other()).karbonite; |
| 1131 | // Serialize the game state to send to the viewer |
| 1132 | let viewer = ViewerMessage { |
| 1133 | changes: turn.changes.clone(), |
| 1134 | units: self.world.get_viewer_units(), |
| 1135 | additional_changes: self.world.flush_viewer_changes(), |
| 1136 | karbonite: karbonite, |
| 1137 | }; |
| 1138 | TurnApplication { |
| 1139 | start_turn, start_turn_error, viewer |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | /// Determines if the game has ended, returning the winning team if so. |
| 1144 | /// |