예제 #1
0
파일: start.py 프로젝트: plafrance/TP4
def main_game(game_id):
    global API
    API.clear()
    last_command_id = 0
    end = False
    data_user = API.user()
    while not end:
        pipes = API.pipes(game_id, last_command_id)
        last_command_id = pipes["last_id"]
        for command in pipes["commands"]:
            if command["type"] == "1" and command["user_id"] == data_user["id"] or command["type"] == "0":
                exec(command["command"])
        if not pipes["commands"]:
            time.sleep(1)
예제 #2
0
파일: start.py 프로젝트: plafrance/TP4
def wait_for_game(game_id):
    global API
    while not API.canStart(game_id):
        API.clear()
        print("Loading...")
        print("""
+--------------------------------------------+
|
| Il y a acctuellement %i/4 personne(s) dans la partie #%s
|
+--------------------------------------------+
        """ % (API.playerInGame(game_id), game_id))
        time.sleep(3)
    API.addPipe(game_id, "print('%s est pret')" % API.user()["username"], 0)
    main_game(game_id)
예제 #3
0
파일: start.py 프로젝트: plafrance/TP4
    while logged["messageCode"] == 3:
        while username == "":
            username = input("Nom d'utilisateur: ").strip()

        while password == "":
            password = getpass.getpass("Mot de passe: ").strip()

        logged = API.login(username, password)

        if(logged["messageCode"] == 3):
            API.clear()
            print(logged["message"])
            username = password = ""


    data_user = API.user()
    API.clear()
    print('''
+--------------------------------------------+
|
| Bienvenue, %s
| Vous avez %i py en se moment
| Nombre de victoire: %i
| Nombre de defaite: %i
|
| a. Jouer
| b. Aller dans le magasin
| c. Quitter
+--------------------------------------------+
    ''' % (data_user['firstname']+" "+data_user['lastname'], int(data_user['money']), int(data_user['win']), int(data_user['loose'])))