This is a blocking function that waits until it client_id's turn to start the game. It attempts to take the game lock and then checks to see if the client_id matches the next player id. If it does it returns and the player can start running. This also handle
(self, client_id: int)
| 274 | time.sleep(0.1) |
| 275 | |
| 276 | def start_turn(self, client_id: int): |
| 277 | ''' |
| 278 | This is a blocking function that waits until it client_id's turn to |
| 279 | start the game. It attempts to take the game lock and then checks to see |
| 280 | if the client_id matches the next player id. If it does it returns and |
| 281 | the player can start running. |
| 282 | |
| 283 | This also handles waking the docker instances to start computing |
| 284 | ''' |
| 285 | |
| 286 | logging.debug("Client %s: entered start turn", client_id) |
| 287 | exit_well = False |
| 288 | player_index = self.player_id2index(client_id) |
| 289 | while not self.game_over: |
| 290 | if self.turn_events[player_index].wait(timeout=0.1): |
| 291 | self.turn_events[player_index].clear() |
| 292 | assert(self.current_player_index == player_index) |
| 293 | self.times[client_id] += self.time_additional |
| 294 | return True |
| 295 | |
| 296 | return False |
| 297 | |
| 298 | def make_action(self, turn_message: bc.TurnMessage, client_id: int, diff_time: float): |
| 299 | ''' |
no test coverage detected