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

Method make_action

battlecode-manager/server.py:298–316  ·  view source on GitHub ↗

Take action data and give it to the engine Args: data: the data received from the stream

(self, turn_message: bc.TurnMessage, client_id: int, diff_time: float)

Source from the content-addressed store, hash-verified

296 return False
297
298 def make_action(self, turn_message: bc.TurnMessage, client_id: int, diff_time: float):
299 '''
300 Take action data and give it to the engine
301 Args:
302 data: the data received from the stream
303
304 '''
305 # get the time left of the next player to go
306 next_index = (self.player_id2index(client_id) + 1) % len(self.players)
307 next_client_id = self.players[next_index]['id']
308 projected_time_ms = int(1000 * (self.times[next_client_id] + self.time_additional))
309
310 # interact with the engine
311 application = self.manager.apply_turn(turn_message, projected_time_ms)
312 self.last_message = application.start_turn.to_json()
313 self.viewer_messages.append(application.viewer.to_json())
314 self.manager_viewer_messages.append(self.manager.manager_viewer_message())
315 self.times[client_id] -= diff_time
316 return
317
318
319def create_receive_handler(game: Game, dockers, use_docker: bool,

Callers 1

player_handlerMethod · 0.80

Calls 3

player_id2indexMethod · 0.95
apply_turnMethod · 0.45

Tested by

no test coverage detected