def endCLientGame(self, msg): if _DEBUG: debug("In synClientInfo @@@ msg = ", msg) mi = self.checker1.check(msg) if mi.error: ftlog.error('endCLientGame the msg params error !', mi.error) else: #todo 1: add loc 2:客户端上行的第一条end_game消息作为判断依据,对双方结算 room = tyglobal.rooms()[mi.roomId] if room.maptable.has_key(mi.tableId): table = room.maptable.pop(mi.tableId) for userid in table.playersInfo.keys(): mo = MsgPack() mo.setCmd('end_game') mo.setResult('result', 'ok') mo.setResult('gameResult', msg.getParamStr('gameResult')) if _DEBUG: debug("OUT endCLientGame @@@ table_info = ", msg) tyrpcconn.sendToUser(userid, mo) rpcproxy = getRpcProxy(9993, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE) rpcproxy.srvgame.doReportGameResult(msg.getParamStr('gameResult'), tyglobal.gameId()) else: pass # mo = MsgPack() # mo.setCmd('end_game') # mo.setResult('result', 'has finished') # mo.setResult('msg', msg) # if _DEBUG: # debug("OUT endCLientGame @@@ table_info = ", msg) # tyrpcconn.sendToUser(mi.userid, mo) return 1
def _onTimeout(self, lostUserId): if _DEBUG: debug("In MiniMatchProcess @@@@ onTimeOut, lostUserId = ", lostUserId) room = tyglobal.rooms()[self._roomId] if room.maptable.has_key(self.tableId): table = room.maptable.pop(self.tableId) self.table_msgId = table.tableMsgId if lostUserId == self.userId_a: self.winnerId = self.userId_b mo = MsgPack() mo.setCmd('end_game') mo.setResult('winnerId', self.winnerId) mo.setResult('userId_a', self.userId_a) mo.setResult('userId_b', self.userId_b) mo.setResult('table_msgId', self.table_msgId) if _DEBUG: debug("OUT end_game @@@ winnerId = ", self.winnerId) tyrpcconn.sendToUser(self.winnerId, mo) rpcproxy = getRpcProxy(9993, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE) rpcproxy.srvgame.doReportGameResult(mo, tyglobal.gameId()) else: self.winnerId = self.userId_a mo = MsgPack() mo.setCmd('end_game') mo.setResult('winnerId', self.winnerId) mo.setResult('userId_a', self.userId_a) mo.setResult('userId_b', self.userId_b) mo.setResult('table_msgId', self.table_msgId) if _DEBUG: debug("OUT end_game @@@ self.winnerId = ", self.winnerId) tyrpcconn.sendToUser(self.winnerId, mo) rpcproxy = getRpcProxy(9993, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE) rpcproxy.srvgame.doReportGameResult(mo, tyglobal.gameId())
def doJoinBigMatchQueue(self, msg): ''' 制定游戏加入匹配队列 ''' if _DEBUG: debug('doJoinBigMatchQueue->', msg) mi = self.basechecker.check(msg) if mi.error: ftlog.error('doJoinBigMatchQueue the msg params error !', mi.error) mo = MsgPack() mo.setCmd('join_big_queue') mo.setResult('userId', mi.userId) mo.setResult('result', 'msg params error') tyrpcconn.sendToUser(mi.userId, mo) else: sex = _rpc_user_info.getUserSexInfo(mi.userId) rpcproxy = getRpcProxy(9992, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE) rfc = rpcproxy.srvhttp.doGetUserBigGameDemandInfo(mi.userId) demandSex = "rand" if not rfc.getResult() is None: demandSex = rfc.getResult() if _DEBUG: debug('doJoinBigMatchQueue-> demandSex =', demandSex) if sex == 1: result = DaoCasualGameMatch.joinBigMatchQueueMaleHash( mi.userId, demandSex[0]) else: result = DaoCasualGameMatch.joinBigMatchQueueFemaleHash( mi.userId, demandSex[0]) if result == 1024: mo = MsgPack() mo.setCmd('join_big_queue') mo.setResult('userId', mi.userId) mo.setResult('result', 'already in queue') tyrpcconn.sendToUser(mi.userId, mo) elif result == 1: mo = MsgPack() mo.setCmd('join_big_queue') mo.setResult('userId', mi.userId) mo.setResult('result', 'ok') tyrpcconn.sendToUser(mi.userId, mo) return 1