def play_players_turn(self, player: Player): """wrapper function, extends the main update loop""" # debug(f"Play move of player {player.name} [pid: {player.id}]") self.updata_map() if self.check_win_condition(player): self.winner = player self.update_player_properties(player) player.has_lost = self.check_lose_condition(player) if player.has_lost: self.destroy_player(player) return if player.player_type == PlayerType.HUMAN: ai_game_status = AI_GameStatus() self.construct_game_status(player, ai_game_status) ai_move = AI_Move() self.human_interface.request_move(ai_game_status, ai_move, player.id) else: ai_worker = threading.Thread(target=self.spawn_ai_thread, args=(player, )) ai_worker.start()
def spawn_ai_thread(self, player): ai_game_status = AI_GameStatus() ai_move = AI_Move() self.construct_game_status(player, ai_game_status) self.ai_interface.do_a_move(ai_game_status, ai_move, player.id)