def delStrategy(self, rid): req = { "code": 1015, "rid": rid, "serial": getSerial(), } protocol.sendMessage(self.gw_mac, req)
def delGroup(self, gid): req = { "code": 1007, "gid": gid, "serial": getSerial(), } protocol.sendMessage(self.gw_mac, req)
def sendControlDict(self, group_name, paraDict): # 得到分组 的 信息 gInfo = self.getInfo(group_name) self.gid = gInfo.get("gid") #发出请求 req = { "code": 1006, "gid": self.gid, "serial": getSerial(), "streams": paraDict } protocol.sendMessage(self.gw_mac, req)
def _login(self): user = self.user.value; passwd = self.passwd.value; if not network.isConnected(): network.connect() # plain silly, we need to remove this if network.isConnected(): ans = protocol.sendMessage(TYPE = protocol.LOGIN, USER = user, PASS = passwd) if ans == True: state.logged_in = True state.in_game_select = True return else: title = "Error" err_msg = "Invalid username or password" else: title, err_msg = network.getError() # If the login was incorrect prompt the user CustomDialog(title, err_msg).open()
def startGame(self): ok = protocol.sendMessage(TYPE = protocol.START) print "am trimis start" if ok: state.in_game_lobby = False state.in_game = True
def create(self): ok = protocol.sendMessage(TYPE = protocol.CREATE) if ok: state.in_game_select = False state.in_game_lobby = True state.game_owner = True print "game_ownerrr ", state.game_owner
def join(self): if self.selection: print "join" ok = protocol.sendMessage(TYPE = protocol.JOIN, ID = self.selection.gameID) if ok: state.in_game_select = False state.in_game_lobby = True state.game_owner = False
def send2gw(self): self.delGroup(self.gid) protocol.sendMessage(self.gw_mac, self.gjson)
def send2gw(self): self.delStrategy(self.rid) protocol.sendMessage(self.gw_mac, self.sJson) return
game_lobby_screen = None owner = None # -------- Main Program Loop ----------- while not done: for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # If user clicked close done = True # Flag that we are done so we exit this loop elif state.in_game == True and event.type == pygame.KEYUP: if not world.players[world.me].walking: if event.key == pygame.K_UP: protocol.sendMessage(TYPE = MOVE, DIR = NORTH) elif event.key == pygame.K_DOWN: protocol.sendMessage(TYPE = MOVE, DIR = SOUTH) elif event.key == pygame.K_RIGHT: protocol.sendMessage(TYPE = MOVE, DIR = EAST) elif event.key == pygame.K_LEFT: protocol.sendMessage(TYPE = MOVE, DIR = WEST) elif event.key == pygame.K_b: protocol.sendMessage(TYPE = DROP) elif not state.logged_in: login_screen.event(event) elif state.in_game_select: game_select_screen.event(event)