def doRoomQuickStart(self, roomId, userId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] if isinstance(room, DizhuRoom): room.handleMsg(msg) else: msg = runcmd.getMsgPack() room.doQuickStart(msg) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doRoomMatchWinLose(self, roomId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] if isinstance(room, DizhuRoom): room.handleMsg(msg) else: room.doWinlose(msg)
def doRoomDes(self, roomId, userId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] if isinstance(room, DizhuRoom): room.handleMsg(msg) else: room.doGetDescription(userId)
def doActivityExchangeOld(self, gameId, userId, clientId, activityId, action): msg = runcmd.getMsgPack() ftlog.debug('doActivityExchangeOld msg=', msg) result = activity.activitySystem.handleActivityRequest(userId, gameId, clientId, msg) mo = ActivityTcpHelper.getOldResponseMsg(result, gameId, userId, activityId, action) ftlog.debug('doActivityExchangeOld res=', mo) router.sendToUser(mo, userId)
def doDuobaoProduct(self): ''' 一元夺宝商品 ''' if ftlog.is_debug(): ftlog.debug('doDuobaoProduct enter') msg = runcmd.getMsgPack() gameId = msg.getParam("gameId") userId = msg.getParam("userId") from hall.entity import hall1yuanduobao productList = hall1yuanduobao.duobaoProduct(userId) msg = MsgPack() msg.setCmd('hall_duobao') msg.setResult('action', 'duobao_product') msg.setResult('gameId', gameId) msg.setResult('userId', userId) msg.setResult('productList', productList) router.sendToUser(msg, userId) if ftlog.is_debug(): ftlog.debug('doDuobaoProduct', 'userId=', userId, 'productList=', productList)
def doMatchSave(self, userId, gameId, roomId, matchId): ''' 保存比赛进度 ''' msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) gdata.rooms()[roomId].doMatchSave(userId, gameId, roomId, matchId, msg)
def doDuobaoBet(self): ''' 一元夺宝下注 ''' msg = runcmd.getMsgPack() gameId = msg.getParam("gameId") userId = msg.getParam("userId") duobaoId = msg.getParam("duobaoId") issue = msg.getParam("issue") num = msg.getParam("num") ec = 0 info = '投注成功' luckyCodeList = [] myBetCount = 0 totalBetCount = 0 coupon = 0 try: from hall.entity import hall1yuanduobao luckyCodeList, myBetCount, totalBetCount, coupon = hall1yuanduobao.duobaoBet(userId, duobaoId, issue, num) except TYBizException, e: ec = e.errorCode info = e.message ftlog.info('doDuobaoBet failer', 'userId=', userId, 'duobaoId=', duobaoId, 'issue=', issue, 'num=', num, 'ec=', ec, 'info=', info)
def doDuobaoHistory(self): ''' 一元夺宝往期得主 ''' msg = runcmd.getMsgPack() gameId = msg.getParam("gameId") userId = msg.getParam("userId") duobaoId = msg.getParam("duobaoId") pageId = msg.getParam("pageId") ec = 0 info = '查询成功' historyList = [] try: from hall.entity import hall1yuanduobao historyList = hall1yuanduobao.duobaoHistory(userId, duobaoId, pageId) except TYBizException, e: ec = e.errorCode info = e.message ftlog.info('doDuobaoHistory failer', 'userId=', userId, 'duobaoId=', duobaoId, 'pageId=', pageId, 'ec=', ec, 'info=', info)
def doDuobaoMyRecord(self): ''' 一元夺宝查询我的夺宝记录 ''' msg = runcmd.getMsgPack() gameId = msg.getParam("gameId") userId = msg.getParam("userId") pageId = msg.getParam("pageId") recordList = [] totalLength = 0 ec = 0 info = '查询成功' try: from hall.entity import hall1yuanduobao recordList, totalLength = hall1yuanduobao.duobaoMyRecord(userId, pageId) except TYBizException, e: ec = e.errorCode info = e.message ftlog.info('doDuobaoMyRecord failer', 'userId=', userId, 'pageId=', pageId, 'ec=', ec, 'info=', info)
def doRoomLeave(self, roomId, userId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] if isinstance(room, DizhuRoom): room.handleMsg(msg) else: room.doLeave(userId, msg)
def doExchange(self, gameId, userId): try: msg = runcmd.getMsgPack() couponId = msg.getParam('id') phone = msg.getParam('phone') if not phone: phone = msg.getParam('phoneNumber') if not phone: pp = msg.getParam('params', {}) if isinstance(pp, dict): phone = pp.get('phoneNumber') if not phone: if ftlog.is_debug(): ftlog.debug('ExchangeHandler.doExchange gameId=', gameId, 'userId=', userId, 'couponId=', couponId, 'phone=', phone) raise TYBizException(-1, 'Please input phone number') _trueDelta, final = self._getCouponService().exchangeCouponItem( userId, couponId, phone=phone) mo = MsgPack() mo.setCmd('exchange') mo.setResult('action', 'exchange') mo.setResult('id', couponId) mo.setResult('info', '兑换请求处理成功') mo.setResult('quan_left', final) router.sendToUser(mo, userId) except TYBizException, e: mo = MsgPack() mo.setCmd('exchange') mo.setError(e.errorCode, e.message) router.sendToUser(mo, userId)
def doReplaySave(self, userId, roomId, tableId, roundId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] if isinstance(table, DizhuTableCtrl): return table.proto.handleMsg(msg) else: mo = MsgPack() mo.setCmd('table') mo.setResult('action', 'replay_save') try: gameRound, savedUserIds = table.findGameRound(roundId) if gameRound and gameRound.findSeatByUserId(userId): if not gameRound.gameOverTimestamp: raise TYBizException(-1, '牌局还没结束') if userId in savedUserIds: raise TYBizException(-1, '牌局已经保存') replay_service.saveVideo(userId, gameRound) savedUserIds.add(userId) else: raise TYBizException(-1, '没有找到该牌局') except TYBizException, e: mo.setResult('code', e.errorCode) mo.setResult('info', e.message) router.sendToUser(mo, userId) return mo
def doRoomMatchList(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) page = msg.getParam("page", 0) num = msg.getParam("number", 0) tag = msg.getParam("tag", "all") gdata.rooms()[roomId].doGetMatchList(userId, page, num, tag)
def doDuobaoReward(self): ''' 一元夺宝领奖 ''' msg = runcmd.getMsgPack() gameId = msg.getParam("gameId") userId = msg.getParam("userId") duobaoId = msg.getParam("duobaoId") issue = msg.getParam("issue") ec = 0 info = '领取成功' reward = {} try: from hall.entity import hall1yuanduobao reward = hall1yuanduobao.duobaoReward(userId, duobaoId, issue) except TYBizException, e: ec = e.errorCode info = e.message ftlog.info('doubaoReward failer', 'userId=', userId, 'duobaoId=', duobaoId, 'issue=', issue, 'ec=', ec, 'info=', info)
def doExchange(self, gameId, userId): try: msg = runcmd.getMsgPack() couponId = msg.getParam('id') phone = msg.getParam('phone') if not phone: phone = msg.getParam('phoneNumber') if not phone: pp = msg.getParam('params', {}) if isinstance(pp, dict): phone = pp.get('phoneNumber') if not phone: if ftlog.is_debug(): ftlog.debug('ExchangeHandler.doExchange gameId=', gameId, 'userId=', userId, 'couponId=', couponId, 'phone=', phone) raise TYBizException(-1, 'Please input phone number') _trueDelta, final = self._getCouponService().exchangeCouponItem(userId, couponId, phone=phone) mo = MsgPack() mo.setCmd('exchange') mo.setResult('action', 'exchange') mo.setResult('id', couponId) mo.setResult('info', '兑换请求处理成功') mo.setResult('quan_left', final) router.sendToUser(mo, userId) except TYBizException, e: mo = MsgPack() mo.setCmd('exchange') mo.setError(e.errorCode, e.message) router.sendToUser(mo, userId)
def doSportlotteryBet(self): '''体育竞猜下注''' if ftlog.is_debug(): ftlog.debug('doSportlotteryBet enter') msg = runcmd.getMsgPack() gameId = msg.getParam("gameId") clientId = msg.getParam("clientId") userId = msg.getParam('userId') date = msg.getParam('date') matchId = msg.getParam('uuid') party = msg.getParam('party') # 1主胜 2 平 3客胜 coin = msg.getParam('coin') type = msg.getParam('type') # 1足球 0篮球 ec = 0 info = '投注成功' userChip = 0 try: userChip = hallsportlottery.sportlotteryBet( gameId, clientId, userId, date, matchId, party, coin) self.doSportDetail(userId, date, matchId, type, gameId) except TYBizException, e: ec = e.errorCode info = e.message ftlog.info('doSportlotteryBet failer', 'userId=', userId, 'date=', date, 'matchId=', matchId, 'party=', party, 'coin=', coin, 'ec=', ec, 'info=', info)
def doRoomMatchList(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) page = msg.getParam("page", 0) num = msg.getParam("number", 0) tag = msg.getParam("tag", "all") gdata.rooms()[roomId].doGetMatchList(userId, page, num, tag)
def doRoomQuickStart(self, roomId, tableId0, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) gdata.rooms()[roomId].doQuickStart(msg) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doRoomQuickStart(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) gdata.rooms()[roomId].doQuickStart(msg) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def _handleSigninFeeNotEnoughException(cls, room, ex, uid, mo): payOrder = ex.fee.getParam('payOrder') clientId = sessiondata.getClientId(uid) clientOs, _clientVer, _ = strutil.parseClientId(clientId) msg = runcmd.getMsgPack() ddzver = msg.getParam('ddzver', 0) if msg else 0 ftlog.debug("groupmatch._handleSigninFeeNotEnoughException", "userId", uid, "_clientVer=", _clientVer) if ddzver >= 3.772: cls._handleSigninFeeNotEnoughException_V3_772(room, ex, uid, mo) return if payOrder: clientOs = clientOs.lower() product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder) if product: buyType = '' btnTxt = '' if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID and clientOs == 'winpc': user_diamond = userdata.getAttrInt(uid, 'diamond') if user_diamond >= int(product.priceDiamond): buyType = 'consume' btnTxt = '兑换' else: buyType = 'charge' btnTxt = '去充值' orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType) orderShow.setParam('sub_action_btn_text', btnTxt) mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, orderShow) router.sendToUser(mo, uid) return True mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, TodoTaskShowInfo(ex.fee.failure)) router.sendToUser(mo, uid)
def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """用户加入自建牌桌 """ loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts( lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table') sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) else: msg = runcmd.getMsgPack() createTableNo = msg.getParam('createTableNo', 0) if not createTableNo: return tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo( createTableNo) if not tableId0 or not roomId0: sendPopTipMsg(userId, "找不到您输入的房间号") return msg = runcmd.getMsgPack() msg.setParam("shadowRoomId", roomId0) msg.setParam("roomId", roomId0) msg.setParam("tableId", tableId0) msg.setCmdAction("room", "join_create_table") router.sendRoomServer(msg, roomId0) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doTableTreasureBox(self, userId, roomId, tableId, seatId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] if isinstance(table, DizhuTableCtrl): table.proto.handleMsg(msg) else: table.doTableTreasureBox(userId, seatId)
def doRoomReturnQueue(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) gdata.rooms()[roomId].doReturnQueue(userId) mo = MsgPack() mo.setCmd('room') mo.setResult('action', 'return_queue') router.responseQurery(mo)
def doGetDuobaoProductList(self): """ 获取夺宝产品列表 @return: """ msg = runcmd.getMsgPack() userId = msg.getParam("userId") DuobaoUTServerHelper.handle_get_product_list(userId)
def doTableSit(self, userId, roomId, tableId, seatId0, clientId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] table.doSit(msg, userId, seatId0, clientId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, str(tableId), str(userId))
def doTableLeave(self, userId, roomId, tableId, clientId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] table.doLeave(msg, userId, clientId) if router.isQuery() : mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, str(tableId), str(userId))
def doDeliveryProduct(self, gameId, realGameId, userId, orderId, prodId, chargeType, chargeMap, consumeMap): msg = runcmd.getMsgPack() isSub = msg.getParam('isSub', 0) orderPlatformId = msg.getParam('orderPlatformId', '') return self.deliveryProduct(gameId, realGameId, userId, orderId, prodId, chargeType, chargeMap, consumeMap, isSub, orderPlatformId)
def doHallNoticeReward(self, userId, gameId, clientId): ftlog.debug("doHallNoticeReward:", userId, gameId, clientId) from hall.entity.newpopwnd import noticeReward from poker.protocol import runcmd msg = runcmd.getMsgPack() noticeReward(userId, gameId, clientId, msg) if ftlog.is_debug(): ftlog.debug("hall_notice_reward:", userId, gameId, clientId)
def doRoomReturnQueue(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) gdata.rooms()[roomId].doReturnQueue(userId) mo = MsgPack() mo.setCmd('room') mo.setResult('action', 'return_queue') router.responseQurery(mo)
def doRoomLeaveMatch(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) tableId = msg.getParam("tableId", 0) gdata.rooms()[roomId].doLeaveMatch(userId, tableId) mo = MsgPack() mo.setCmd('room') mo.setResult('action', 'leave_match') router.responseQurery(mo)
def doActivityFanfanle(self, gameId, userId, clientId, activityId, action): msg = runcmd.getMsgPack() ftlog.debug('doActivityFanfanle msg=', msg) result = activity.activitySystem.handleActivityRequest( userId, gameId, clientId, msg) mo = ActivityTcpHelper.getOldResponseMsg(result, gameId, userId, activityId, action) ftlog.debug('doActivityFanfanle res=', mo) router.sendToUser(mo, userId)
def doExchangeAuditResult(self, userId, exchangeId, result): try: msg = runcmd.getMsgPack() ftlog.debug('doExchangeAuditResult msg=', msg) from hall.entity import hallexchange hallexchange.handleExchangeAuditResult(userId, exchangeId, result) except: ftlog.error('HallExchangeHandler.doExchangeAuditResult userId=', userId, 'exchangeId=', exchangeId, 'result=', result)
def doGetDaysRewardMonth(self, gameId, userId, clientId): msg = runcmd.getMsgPack() days = msg.getParam('days') try: mo = MsgPack() MonthCheckinStatus = monthcheckin.getDaysReward( userId, days, gameId) mo.setCmd('month_checkin') if not MonthCheckinStatus: mo.setResult('userId', userId) mo.setResult('tip', 'maybe is script') ftlog.info('maybe is script userId =', userId) router.sendToUser(mo, userId) return mo.setResult('action', 'getDaysReward') mo.setResult('checkinDateList', [ d.strftime('%Y%m%d') for d in MonthCheckinStatus.checkinDateList ]) daysRewards = [] for days, rewardContent in enumerate(monthcheckin.getConf().get( 'daysRewards', [])): reward = rewardContent.get('reward') monthRange = monthcheckin.getMonthRange() if rewardContent.get('days') < monthRange: monthRange = rewardContent.get('days') daysRewards.append({ 'days': monthRange, 'desc': reward.get('desc'), 'picUrl': reward.get('picUrl'), 'state': self.calcDaysRewardState(MonthCheckinStatus, monthRange) }) ftlog.debug('doGetDaysRewardMonth daysRewards monthRange =', monthRange) mo.setResult('daysRewards', daysRewards) mo.setResult('supplementCheckinDateList', [ d.strftime('%Y%m%d') for d in MonthCheckinStatus.supplementCheckinDateList ]) mo.setResult('rewardDaysList', MonthCheckinStatus.rewardDaysList) ftlog.debug('doGetDaysRewardMonth userId =', userId, 'gameId =', gameId, 'clientId =', clientId, 'daysRewards =', daysRewards) router.sendToUser(mo, userId) datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc']) except MonthCheckinException, e: mo = MsgPack() mo.setCmd('month_checkin') mo.setResult('action', 'getDaysReward') mo.setError(e.errorCode, e.message) router.sendToUser(mo, userId) ftlog.warn('doGetDaysRewardMonth ' + str(e))
def _handleSigninException(cls, room, ex, uid, mo): msg = runcmd.getMsgPack() ddzver = msg.getParam('ddzver', 0) if msg else 0 if ddzver < 3.772: infoTodotask = TodoTaskShowInfo(ex.message) mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, infoTodotask) router.sendToUser(mo, uid) else: cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.message, None)
def doRoomLeaveMatch(self, roomId, userId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) tableId = msg.getParam("tableId", 0) gdata.rooms()[roomId].doLeaveMatch(userId, tableId) mo = MsgPack() mo.setCmd('room') mo.setResult('action', 'leave_match') router.responseQurery(mo)
def doTableChat(self, userId, roomId, tableId, seatId, isFace, voiceIdx, chatMsg): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] if isinstance(table, DizhuTableCtrl): table.proto.handleMsg(msg) else: table.doTableChat(userId, seatId, isFace, voiceIdx, chatMsg)
def _handleSigninException(self, ex, userId, mp): msg = runcmd.getMsgPack() ddzver = msg.getParam('ddzver', 0) if msg else 0 if ddzver < 3.772: infoTodotask = TodoTaskShowInfo(ex.message) mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, infoTodotask) router.sendToUser(mp, userId) else: self.sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.message, None)
def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode): """用户加入自建牌桌 """ loc = onlinedata.checkUserLoc(userId, clientId, gameId) lgameId, lroomId, ltableId, lseatId = loc.split('.') lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId) if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0: ftlog.warn('create_table error, user in table') sendPopTipMsg(userId, "请稍候,正在进桌...") config = { "type": "quickstart", "pluginParams": { "roomId": lroomId, "tableId": ltableId, "seatId": lseatId } } todotask = TodoTaskEnterGameNew(lgameId, config) mo = MsgPack() mo.setCmd('todo_tasks') mo.setResult('gameId', gameId) mo.setResult('pluginId', lgameId) mo.setResult('userId', userId) mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask)) router.sendToUser(mo, userId) else: msg = runcmd.getMsgPack() createTableNo = msg.getParam('createTableNo', 0) if not createTableNo: return tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(createTableNo) if not tableId0 or not roomId0: sendPopTipMsg(userId, "找不到您输入的房间号") return msg = runcmd.getMsgPack() msg.setParam("shadowRoomId", roomId0) msg.setParam("roomId", roomId0) msg.setParam("tableId", tableId0) msg.setCmdAction("room", "join_create_table") router.sendRoomServer(msg, roomId0) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doActivityDdzFundCheck(self, gameId, userId, clientId, activityId, action): ''' 地主基金活动协议 ''' msg = runcmd.getMsgPack() ftlog.debug('doActivityDdzFundCheck msg=', msg) result = activity.activitySystem.handleActivityRequest(userId, gameId, clientId, msg) mo = ActivityTcpHelper.getOldResponseMsg(result, gameId, userId, activityId, action) ftlog.debug('doActivityDdzFundCheck res=', mo) router.sendToUser(mo, userId)
def doRoomGetPlayingTableList(self, roomId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) result = gdata.rooms()[roomId].doGetPlayingTableList() if router.isQuery(): mo = MsgPack() mo.setCmd("room") mo.setResult("action", "playingTableList") mo.updateResult(result) router.responseQurery(mo)
def doRoomSigIn(self, roomId, userId, signinParams): msg = runcmd.getMsgPack() if ftlog.is_debug(): ftlog.debug('msg=', msg, 'mode=', gdata.mode(), caller=self) if not signinParams and gdata.enableTestHtml(): room = gdata.rooms()[roomId] signinParams = gamedata.getGameAttrJson(userId, room.gameId, 'test.signinParams') gdata.rooms()[roomId].doSignin(userId, signinParams)
def doExchangeAuditResult(self, userId, exchangeId, result): try: msg = runcmd.getMsgPack() ftlog.debug('doExchangeAuditResult msg=', msg) from hall.entity import hallexchange hallexchange.handleExchangeAuditResult(userId, exchangeId, result) except: ftlog.error('HallExchangeHandler.doExchangeAuditResult userId=', userId, 'exchangeId=', exchangeId, 'result=', result)
def doJoinCreateTable(self, userId, gameId, roomId): """加入自建桌 """ msg = runcmd.getMsgPack() ftlog.debug('RoomTcpHandler.doJoinCreateTable msg=', userId, gameId, roomId, msg, caller=self) room = gdata.rooms()[roomId] self._doJoinCreateTable(room, msg) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doActivityListOld(self, gameId, userId, clientId): msg = runcmd.getMsgPack() ftlog.debug('doActivityListOld msg=', msg) activityList = activity.activitySystem.getActivityList(gameId, userId, clientId) mo = MsgPack() mo.setCmd('activity_list') mo.setResult("gameId", gameId) mo.setResult("userId", userId) mo.setResult("list", activityList) ftlog.debug("doActivityList, mo=", mo) router.sendToUser(mo, userId)
def doTableCall(self, userId, roomId, tableId, clientId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] action = msg.getParam('action') seatId = msg.getParam('seatId', -1) # 旁观时没有seatId参数 assert isinstance(seatId, int) table.doTableCall(msg, userId, seatId, action, clientId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, str(tableId), str(userId))
def getRoomOnlineInfoDetails(self, roomId): msg = runcmd.getMsgPack() cp = gdata.curProcess.cpu_percent() datas = {'cpu': cp} if roomId in gdata.rooms(): room = gdata.rooms()[roomId] ucount, pcount, users = room.getRoomOnlineInfoDetail() datas[roomId] = [ucount, pcount, users] else: datas[roomId] = 'not on this server' msg.setResult('datas', datas) return msg
def doTableStandUp(self, userId, roomId, tableId, seatId, clientId): ''' 此命令一定是由客户端发送的命令, 如果是内部控制命令,那么需要进行区分命令,不能混合调用 主要是为了避免站起的原因混乱, ''' msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] table.doStandUp(msg, userId, roomId, tableId, seatId, TableStandUpEvent.REASON_USER_CLICK_BUTTON, clientId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, str(tableId), str(userId))
def doActivity5ExchangeItemList(self, gameId, userId, clientId): msg = runcmd.getMsgPack() ftlog.debug('doActivity5ExchangeItemList msg=', msg) exchangeList = _doActivity5ExchangeItemList(gameId, userId, clientId) mo = MsgPack() mo.setCmd('act') mo.setResult("gameId", gameId) mo.setResult("userId", userId) mo.setResult("action", "exchange_item_list") mo.updateResult(exchangeList) ftlog.debug("doActivity5ExchangeItemList, mo=", mo) router.sendToUser(mo, userId)
def doActivity5PrizeMsgList(self, gameId, userId, clientId): msg = runcmd.getMsgPack() ftlog.debug('doActivity5PrizeMsgList msg=', msg) prizeList = _doActivity5PrizeMsgList(gameId, userId, clientId) mo = MsgPack() mo.setCmd('act') mo.setResult("gameId", gameId) mo.setResult("userId", userId) mo.setResult("action", "prize_msg_list") mo.setResult("list", prizeList) ftlog.debug("doActivity5PrizeMsgList, mo=", mo) router.sendToUser(mo, userId)
def doTableManage(self, roomId, tableId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] action = msg.getParam('action') result = table.doTableManage(msg, action) if router.isQuery(): mo = MsgPack() mo.setCmd('table_manage') mo.setResult('action', action) mo.updateResult(result) router.responseQurery(mo)
def signinNextMatch(self, gameId, userId): """报名下一场比赛 """ msg = runcmd.getMsgPack() roomId = msg.getParam('room_id', 0) ctlRoomIds = [bigRoomId * 10000 + 1000 for bigRoomId in gdata.gameIdBigRoomidsMap()[gameId]] if roomId in ctlRoomIds: room = gdata.rooms()[roomId] if room: signinParams = gamedata.getGameAttrJson(userId, room.gameId, 'test.signinParams') room.doSignin(userId, signinParams) else: ftlog.info('=======signinNextMatch==Trace==', roomId, userId)
def getMenuList(self, gameId, userId, clientId): msg = runcmd.getMsgPack() ftlog.debug('getMenuList msg=', msg) menuList = hallmenulist.getClientMenuList(clientId) menu_settings = hallmenulist.getClientCustomMenuSetting(gameId, userId, clientId, menuList) mo = MsgPack() mo.setCmd('menu_list') mo.setResult("gameId", gameId) mo.setResult("userId", userId) mo.setResult("menus", menuList) mo.setResult("menu_settings", menu_settings) router.sendToUser(mo, userId)
def doCreateTable(self, userId, gameId, roomId): """自建桌创建 1.通过roomId得到房间对象 2.得到合适的tableId,然后sit """ ftlog.info("<< doCreateTable | userId, clientId, roomId, msg:", userId, gameId, roomId) msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] self._doCreateTable(room, msg, gameId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doFriendCall(self, gameId, userId): ftlog.debug('doFriendCall...') cmd = runcmd.getMsgPack() # router.sendToUser(mo, userId) # clientId = runcmd.getClientId(cmd) action = cmd.getParam('action') if action == 'invite_to_game': # 邀请好友牌桌游戏 enterParams = cmd.getParam('enterParams') note = cmd.getParam('note') invitees = cmd.getParam('invitees') self.processInvitees(enterParams, note, invitees, userId, gameId) return elif action == 'answer_to_invite': # 对好友邀请的应答 inviter = cmd.getParam('inviter') answer = cmd.getParam('answer') self.processInviteAnswser(inviter, answer, userId, gameId) return elif action in ['get_friends_rank', 'get_friend_tip_info', 'praise_friend']: from hall.entity import hallvip try: vip = hallvip.userVipSystem.getUserVip(userId).vipLevel.level except: vip = 0 cmd.setParam('vip', vip) elif action == 'add_friend': if self._isObserver(userId): show_info_task = TodoTaskShowInfo("对不起,旁观时不能加好友哦~") TodoTaskHelper.sendTodoTask(gameId, userId, show_info_task) return # if not clientId: # clientId = sessiondata.getClientId(userId) params = cmd._ht['params'] tcp_params = strutil.cloneData(params) del tcp_params['authorCode'] del params['action'] del params['gameId'] params['appId'] = gameId # params['from_tcp'] = 1 import json params['tcp_params'] = json.dumps(tcp_params) url = self.action_urls[action] ftlog.debug('handleFriendCall post', url, params) sdkclient._requestSdk(url, params, needresponse=False)
def doMatchState(self, userId, gameId, roomId): msg = runcmd.getMsgPack() match_id = msg.getParam("match_id") if match_id: # 老比赛,由于前端新比赛也会发此消息,但没有match_id导致的问题,这里处理下 state = gdata.rooms()[roomId].getMatchState(userId, gameId, match_id) current_ts = int(time.time()) msg = MsgPack() msg.setCmd('match_state') msg.setResult('gameId', gameId) msg.setResult('userId', userId) msg.setResult('state', state) msg.setResult('match_id', match_id) msg.setResult('current_ts', current_ts) router.sendToUser(msg, userId)
def doHandleCommonRoomCmdAction(self, userId, gameId, roomId, clientId): room = gdata.rooms()[roomId] msg = runcmd.getMsgPack() params = msg.getKey('params') params.update({'room': room}) if ftlog.is_debug(): ftlog.debug("<< |userId, gameId, roomId, clientId, msg:", userId, gameId, roomId, clientId, msg, caller=self) TYPluginCenter.event(msg, gameId) if router.isQuery(): mo = runcmd.newOkMsgPack(1) router.responseQurery(mo)
def doGetCreateTableRecord(self, userId, gameId, clientId): """全量请求牌桌记录 """ msg = runcmd.getMsgPack() startRecordIndex = msg.getParam('startRecordIndex', None) if not startRecordIndex: startRecordIndex = 0 endRecordIndex = msg.getParam('endRecordIndex', None) if not endRecordIndex: endRecordIndex = 19 MJCreateTableRecord.sendAllRecordToUser(userId, gameId, startRecordIndex, endRecordIndex) if router.isQuery() : mo = runcmd.newOkMsgPack(1) router.responseQurery(mo, '', str(userId))
def doGetSoldierForUser(self, userId, gameId, clientId): ''' 客户端点击事件 获取用户的历史小兵信息 ''' msg = runcmd.getMsgPack() issue = msg.getParam('issue') if ftlog.is_debug(): ftlog.debug('doGetSoldierForUser.userId:', userId , ' gameId:', gameId , ' clientId:', clientId , ' issue:', issue) result, _, _ = hallroulette.doGetSoldierIdForUser(userId, gameId, clientId, issue) mo = rouletteHelper.makeRouletteQueryResponse(gameId, userId, clientId, 'issue_user', result) router.sendToUser(mo, userId)
def doHandleCommonRoomCmdAction(self, gameId, roomId, userId, clientId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] tableId = msg.getParam("tableId") if tableId: table = room.maptable[tableId] else: table = None params = msg.getKey('params') params.update({'room': room, 'table': table}) if ftlog.is_debug(): ftlog.debug("<< |userId, gameId, roomId, tableId, clientId, msg:", userId, gameId, roomId, clientId, msg, caller=self) TYPluginCenter.event(msg, gameId)
def doRoomGM(self, roomId): msg = runcmd.getMsgPack() if ftlog.is_debug(): ftlog.info('doRoomGM msg=', msg, caller=self) room = gdata.rooms()[roomId] result = {} params = msg.getKey('params') params.update({'room': room}) evmsg = TYPluginUtils.updateMsg(cmd='EV_ROOM_GM', params=params, result=result) TYPluginCenter.event(evmsg, room.gameId) if router.isQuery(): mo = TYPluginUtils.updateMsg(cmd='room', result=result) router.responseQurery(mo)