Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def end_turn(id_player, id_room):
    print("end turn")
    get(BASE_URL + "/turn_over/" + id_room + "?idPlayer=" + id_player)
Exemplo n.º 3
0
def join_random_room(id_player):
    response = get(BASE_URL + "/random_room?idPlayer=" + id_player)
    return response['idRoom']
Exemplo n.º 4
0
def get_id_player():
    response = get(BASE_URL + "/id_player")
    return response['idPlayer']
Exemplo n.º 5
0
def load_config():
    response = get(BASE_URL + "/config")
    return response['config']