def play_game(id_player, id_room, config): nb_actions = 0 while True: status_room = get(BASE_URL + "/status_room/" + id_room) if status_room['status'] == 3: status_game = get(BASE_URL + "/status_game/" + id_room + "?idPlayer=" + id_player) if status_game['turnPlayer'] == id_player: if nb_actions == 0: nb_actions = status_game['maxNbActions'] print("Nb actions : %s" % (str(nb_actions))) do_action(id_player, id_room, status_game) nb_actions -= 1 if nb_actions == 0: end_turn(id_player, id_room) time.sleep(1)
def end_turn(id_player, id_room): print("end turn") get(BASE_URL + "/turn_over/" + id_room + "?idPlayer=" + id_player)
def join_random_room(id_player): response = get(BASE_URL + "/random_room?idPlayer=" + id_player) return response['idRoom']
def get_id_player(): response = get(BASE_URL + "/id_player") return response['idPlayer']
def load_config(): response = get(BASE_URL + "/config") return response['config']