MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / apply_turn

Method apply_turn

battlecode-engine/src/controller/mod.rs:1125–1141  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers 3

run_game_ansiFunction · 0.45
test_turnFunction · 0.45
test_serializationFunction · 0.45

Calls 6

get_teamMethod · 0.80
cloneMethod · 0.80
get_viewer_unitsMethod · 0.80
flush_viewer_changesMethod · 0.80
otherMethod · 0.45
teamMethod · 0.45

Tested by 2

test_turnFunction · 0.36
test_serializationFunction · 0.36