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)
| 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 | |
| 319 | def create_receive_handler(game: Game, dockers, use_docker: bool, |
no test coverage detected