def sendFriendInviteTodotask(userId, invite_uid, gameId, play_mode, roomId, tableId, info_str, purl): """ 推送牌桌好友邀请的todotask * 版本 3.732 之后,改为麻将自己的todotask """ todotask = TodoTaskQuickStart(gameId, roomId, tableId) todotask.setParam('play_mode', play_mode) client_ver = sessiondata.getClientIdVer(userId) if client_ver < 3.732: show_info_ = TodoTaskShowInfo(info_str, True) show_info_.setSubCmd(todotask) msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_) router.sendToUser(msg, userId) else: task = { 'action': 'pop_wnd_invite', 'params': { 'tasks': [todotask.toDict()], 'invite_uid': invite_uid, 'purl': purl, 'info_str': info_str } } mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('tasks', [task]) router.sendToUser(mo, userId)
def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId): # todo fix the pop wnd to ddz's if not playMode in dizhuconf.PLAYMODE_ALLSET: playMode = dizhuconf.PLAYMODE_DEFAULT chosenRoomId, _ = cls._chooseRoom(userId, DIZHU_GAMEID, playMode) if chosenRoomId: quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId) info_str_ = dizhuconf.getQuickStartErrorMsg( TYRoom.ENTER_ROOM_REASON_GREATER_MAX) show_info_ = TodoTaskShowInfo(info_str_, True) show_info_.setSubCmd(quick_start_) try: if cls._useSelfPopWnd(userId): todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_) Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示', info_str_, todoTaskObj[0], '确定', None, '取消') return except: ftlog.error('_sendTodoTaskJumpHighRoom error userId = ', userId, ' clientId = ', clientId, 'playMode = ', playMode) msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, show_info_) router.sendToUser(msg, userId) else: cls._sendTodoTaskToUser(userId, TYRoom.ENTER_ROOM_REASON_GREATER_ALL)
def onCmdQuickStart1(cls, msg, userId, gameId, roomId, tableId, playMode, clientId): ''' 拦截父类处理的选择房间逻辑,先于父类处理,若选择成功,则不进行父类的选择房间处理逻辑,否则正常走父类的处理逻辑 ''' if not pokerconf.isOpenMoreTable(clientId): ok, loc = cls.checkUserLoc(userId, gameId, roomId, tableId, clientId) if not ok: # 弹框 tipsPlaying = dizhuconf.getPublicConf('tips.playing', '您正在其它房间对局,是否回去?') showInfo = TodoTaskShowInfo(tipsPlaying) showInfo.setSubCmd( TodoTaskQuickStart(loc[0], loc[1], loc[2], loc[3])) TodoTaskHelper.sendTodoTask(gameId, userId, showInfo) ftlog.debug('DizhuQuickStartV4_0.onCmdQuickStart Fail userId=', userId, 'roomId=', roomId, 'tableId=', tableId, 'clientId=', clientId, 'loc=', loc) return if loc: tableId = loc[2] _, version, _ = strutil.parseClientId(clientId) ftlog.debug("DizhuQuickStartV4_0.onCmdQuickStart: clientId=", clientId, "userId=", userId, "roomId=", roomId, "tableId=", tableId, "version=", version, "type:", type(version), "playMode=", playMode) # 地主会优先去匹配比赛的房间,客户端是3.76及更高版本才支持 if (playMode == None or playMode == "match" or playMode == "straightMatch") and roomId == 0 and gameId == 6 and ( version >= 3.76 or (version >= 3.73 and not (clientId in _DIZHU_QMATCH_V3_73_IGNORE))): chose_roomid, ok = cls._chooseDizhuMatchRoom( userId, gameId, playMode) ftlog.debug( "DizhuQuickStartV4_0._chooseDizhuMatchRoom:chosen|room_id=", chose_roomid, "userId=", userId, "ok=", ok) if ok: bigroomid = gdata.getBigRoomId(chose_roomid) ftlog.debug( "DizhuQuickStartV4_0._chooseDizhuMatchRoom: userId=", userId, "roomId=", chose_roomid) cls.notifyQuickGotoDizhuMatch(gameId, userId, bigroomid) return if playMode == "match": playMode = dizhuconf.PLAYMODE_123 super(DizhuQuickStartV4_0, cls).onCmdQuickStart(msg, userId, gameId, roomId, tableId, playMode, clientId) return
def decodeMsgV2(gameId, msgstr): try: header = 'richTextLedMsg' if not msgstr.startswith(header): return None '''msg json 格式示例: { 'richText': { 'text': [{ "color": "RRGGBB", "text": "aaa" },{ "color": "RRGGBB", "text": "bbbccc" }], }, 'excludeUsers': [123456, 32134534], 'type':'led', #type://“led”为无按钮,”watch”为观战 “vip”: quick_start 'roomId':roomId, 'tableId':tableId } ''' # 德州版本的富文本协议 d = json.loads(msgstr[len(header):]) msgDict = {} msgDict['gameId'] = d.get('gameId', gameId) msgDict['text'] = d.get('richText', {}).get('text', []) ledType = d.get('type', 'led') if ledType == 'watch': msgDict['lbl'] = '观战' msgDict['tasks'] = [ TodoTaskObserve(gameId, d.get('roomId', 0), d.get('tableId', 0)).toStr() ] elif ledType == 'vip': msgDict['lbl'] = '进入' msgDict['tasks'] = [ TodoTaskQuickStart(gameId, d.get('roomId', 0), d.get('tableId', 0), d.get('seatId', 0)).toStr() ] excludeUsers = d.get('excludeUsers') if excludeUsers: msgDict['excludeUsers'] = d.get('excludeUsers') return msgDict except: if ftlog.is_debug(): ftlog.debug('hallled.decodeMsgV2 gameId=', gameId, 'msgstr=', msgstr, 'err=', 'JsonLoadException') return None
def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId, **kwargs): if not playMode in dizhuconf.PLAYMODE_ALLSET: playMode = dizhuconf.PLAYMODE_DEFAULT ctrlRoomIds, _ = cls._getQuickStartRoomList(userId, playMode, rankId=kwargs.get('rankId', '-1')) # 快开列表 chosenRoomId, reason, mixId = cls._chooseRoom(userId, ctrlRoomIds, rankId=kwargs.get('rankId', '-1')) if chosenRoomId and reason == ENTER_ROOM_REASON_OK: quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId) quick_start_.setParam('mixId', mixId) info_str_ = dizhuconf.getQuickStartErrorMsg(ENTER_ROOM_REASON_GREATER_MAX) show_info_ = TodoTaskShowInfo(info_str_, True) show_info_.setSubCmd(quick_start_) try: if cls._useSelfPopWnd(userId): todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_) Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示', info_str_, todoTaskObj[0], '确定', None, '取消') return except: ftlog.error('DizhuQuickStart _sendTodoTaskJumpHighRoom error userId = ', userId, ' clientId = ', clientId, 'playMode = ', playMode) msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, show_info_) router.sendToUser(msg, userId) else: cls._sendTodoTaskToUser(userId, ENTER_ROOM_REASON_GREATER_ALL)