def playGame(): registerPlayersAndStartGame() state = next(stub.StreamState(proto.StreamStateReq())) print(state) throw(state.state.throwingPlayer) rnd = random.Random() for x in range(2): throwNext(rnd.randint(1, 3)) p1 = players[rnd.randint(0, len(players) - 1)] setAbgegeben(p1) setAbgegeben(players[rnd.randint(0, len(players) - 1)]) throwNext(rnd.randint(1, 3)) modifyStrafbier() modifyStrafbier(False) setAbgegeben(p1, False) throwNext(rnd.randint(1, 3)) #kick all playersA = [] playersA += [p for p in state.state.spectators] playersA += [p for p in state.state.playerTeamA] playersA += [p for p in state.state.playerTeamB] pnames = [p.name for p in playersA] for pname in pnames: req = proto.KickPlayerReq() req.targeName = pname req.playerName = pname print "kicking " + pname stub.KickPlayer(req) #%% state = next(stub.StreamState(proto.StreamStateReq())) pnames = [p.name for p in state.state.spectators]
def getState(): req = proto.StreamStateReq() resp = stub.StreamState(req) print(next(resp))
def throwNext(strength=1): state = next(stub.StreamState(proto.StreamStateReq())) name = state.state.throwingPlayer print(name + " is throwing") throw(name, strength)
req.targeName = pname req.playerName = pname print "kicking " + pname stub.KickPlayer(req) #%% state = next(stub.StreamState(proto.StreamStateReq())) pnames = [p.name for p in state.state.spectators] if (len(sys.argv) == 2): arg = sys.argv[1] if (arg == "listenS"): sys.stdout.write('listen to state stream ') sys.stdout.flush() req = proto.StreamStateReq() for x in stub.StreamState(req): sys.stdout.write(str(x)) sys.stdout.flush() if (arg == "listenL"): sys.stdout.write('listen to log stream ') sys.stdout.flush() req = proto.LogReq() for x in stub.StreamLog(req): sys.stdout.write(str(x)) sys.stdout.flush() if (arg == "listenV"): sys.stdout.write('listen to video event stream ') sys.stdout.flush()