예제 #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
# -*- encoding:utf-8 -*-
#start.py
#Gilbert Paquin
#2014/05/13
#
# Fichier principale

import getpass, time, random
from api import API

#Initialisation de l'API
API = API()
API.clear()

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)

def main_game(game_id):