def doUserSetStarId(self, userId, gameId, clientId, starId): userdata.setAttr(userId, 'starid', starId) mo = MsgPack() mo.setCmd('set_star_id') mo.setResult('gameId', gameId) mo.setResult('starId', starId) router.sendToUser(mo, userId)
def _broadcastPlayerLeave(self, userId, seatId): msg = MsgPack() msg.setCmd("leave") msg.setResult("gameId", FISH_GAMEID) msg.setResult("userId", userId) msg.setResult("seatId", seatId) GameMsg.sendMsg(msg, self.getBroadcastUids(userId))
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 makeDataChangeNotifyMsg(gameId, userId, changedDataNames): msg = MsgPack() msg.setCmd('update_notify') msg.setResult('gameId', gameId) msg.setResult('userId', userId) msg.setResult('changes', list(translateChangeDataNames(changedDataNames))) return msg
def sendBigMatchBackToListTodoTask(userid, gameId, cache = False, direct=True): """比赛结算界面返回按钮返回时 """ from majiang2.entity.todotasks_builder.todotasks_builder import MahjongTodoTaskBuilder msg = "比赛已结束,点击离开按钮返回比赛列表" task = MahjongTodoTaskBuilder.dict_general_box(userid, msg, cache) retTask = strutil.cloneData(task) buttonLeaveTask = { "content":"离开", "tasks":[ { "action":"trigger_notify", "params":{ "eventName":"UPDATE_MATCH_BACK_TO_LIST" } } ] } retTask['params']['buttons'] = [buttonLeaveTask] mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userid) mo.setResult('tasks', [retTask]) router.sendToUser(mo, userid) return True, None
def sendFreeChipTodoTask(userid, gameId, cache = False, direct = True): """ 推送 免费金币 added by nick.kai.lee Args: userid: 玩家userid cache: action命名是否是缓存形式,默认不缓存 direct: 是否直接发送,False则return dict """ if not TYPlayer.isHuman(userid): return False, None ftlog.debug('sendFreeChipTodoTask:', userid) from majiang2.entity.todotasks_builder.todotasks_builder import MahjongTodoTaskBuilder task = MahjongTodoTaskBuilder.dict_free_chip(userid, cache) if not task: return False, None ftlog.debug('sendFreeChipTodoTask:', task) if False == direct: return True, task mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userid) mo.setResult('tasks', [task]) router.sendToUser(mo, userid) return True, None
def sendMasterGiftTodoTask(userId, gameId, clientId, pic, pay_order, roomId): """ 推送高手礼包弹窗 @param pay_order 挑选商品模板 """ if not TYPlayer.isHuman(userId): return product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, pay_order) if not product: ftlog.error('userId =', userId, 'clientId =', clientId, 'pay_order =', pay_order, 'can not find suitable product!') return todotask = TodoTaskPayOrder(product) task = { 'action': 'cache_wnd_gaoshou', 'params': { 'pic': pic, 'tasks': [todotask.toDict()] } } mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('tasks', [task]) router.sendToUser(mo, userId)
def _notifyMatchRank2(self, player): msg = MsgPack() msg.setCmd('m_rank') ranktops = [] ranktops.append({ 'userId': player.userId, 'name': player.userName, 'score': player.score, 'rank': player.scoreRank }) for i, r in enumerate(player.group.ranktops): ranktops.append({ 'userId': r[0], 'name': r[1], 'score': r[2], 'rank': i + 1 }) if 'momo' in player.clientId: # 解决 momo3.372客户端bug:比赛等待页面JS错误 for _ in xrange(len(ranktops), 10): ranktops.append({ 'userId': 0, 'name': '', 'score': '', 'rank': 0 }) msg.setResult('mranks', ranktops) router.sendToUser(msg, player.userId)
def sendNotify_message(gameId, userId, argd): results = {} results['pic'] = argd['iconAddr'] results['des'] = argd['context'] results['buttonType'] = argd['buttonType'] if argd['buttonType'] in ( '1', '2') else '1' results['todo'] = argd['passthrough'] results['closeTime'] = argd['timelimit'] results['alarmime'] = '0' results['action'] = 'notify_message' results['hideIcon'] = argd.get('hideIcon', '0') if len(argd['passthrough']) > 5: todoTask = eval(argd['passthrough']) results['todo'] = todoTask ftlog.hinfo('notify sendNotify_message passthrough todoTask', gameId, userId, todoTask, type(todoTask), argd['passthrough']) mp = MsgPack() mp.setCmd('game_notice') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.hinfo('notify sendNotify_message', gameId, userId, results)
def doGetMessageCount(self, gameId, userId): mo = MsgPack() privateCount = pkmessage.getPrivateUnReadCount(gameId, userId) globalCount = pkmessage.getGlobalUnReadCount(gameId, userId) mo.setResult('counts', {'global': globalCount, 'private': privateCount, 'led': 0}) mo.setResult('ok', 'true') return mo
def doReceiveSdkNotify(self): """ action: add_friend accept_friend """ paramsDict = runhttp.getDict() ftlog.debug("doReceiveSdkNotify:", paramsDict) appId = paramsDict.get('appId', 0) userId = int(paramsDict.get('userId', 0)) actionType = paramsDict.get('type', '') ext = paramsDict.get('ext', None) msg = paramsDict.get('message', '') mo = MsgPack() mo.setCmd('friend_notify') mo.setResult('gameId', appId) mo.setResult('userId', userId) mo.setResult('action', actionType) mo.setResult('info', msg) if ext != None: try: extjson = json.loads(ext) for k in extjson: mo.setResult(k, extjson[k]) except: pass userdata.clearUserCache(userId) router.sendToUser(mo, userId) # if actionType == 'add_friend': # from poker.entity.biz.message import message # message.send(int(appId), message.MESSAGE_TYPE_SYSTEM, int(userId), msg) return 'success'
def doQiPaiNotify(self, appId, userId, buttonId, rmbs, diamonds): userdata.clearUserCache(userId) if appId > 0 and userId > 0: datachangenotify.sendDataChangeNotify(appId, userId, ['chip', 'diamonds']) msg = MsgPack() msg.setResult('ec', 0) return msg
def doDeliveryProduct(self, uid, orderId, prodId, orderPrice, prodCount, platformOrder, isError, error): ftlog.info('doDeliveryProduct->', uid, orderId, prodId, orderPrice, prodCount, platformOrder, isError, error) userdata.clearUserCache(uid) mo = MsgPack() mo.setCmd('prod_delivery') mo.setParam('userId', uid) mo.setParam('orderId', orderId) mo.setParam('prodId', prodId) mo.setParam('orderPrice', orderPrice) mo.setParam('orderPlatformId', platformOrder) if isError == 'true': mo.setResult('ok', '0') mo.setResult('info', error) mo.setError(1, error) router.sendToUser(mo, uid) return 'success' else: mo.setParam('ok', '1') isSub = runhttp.getParamInt('is_monthly', 0) if isSub: mo.setParam('isSub', isSub) ret = router.queryUtilServer(mo, uid) ftlog.info('doDeliveryProduct->', uid, orderId, prodId, orderPrice, prodCount, platformOrder, isError, error, 'result=', ret) if isinstance(ret, (str, unicode)) and ret.find('error') < 0: return 'success' return 'error'
def make_led_mo(newleds, clientVer, clientId): mo = MsgPack() mo.setCmd('led') if clientVer >= 3.6: if ledWithTodoTask: mo.setKey('result', ledWithTodoTask) return mo.pack() return None if newleds['origLeds']: mo.setKey('result', newleds['origLeds']) if newleds['richLeds']: mo.setKey('result', newleds['richLeds']) mo.setKey('richText', newleds['richLeds']) mo.setResult('gameId', gameId) if gameId == 8: if clientVer < 3.0: # 德州老单包有问题,所有格式都转为没有按钮的LED (也就是type='led') newleds['richLeds']['type'] = 'led' elif newleds['richLeds'][ 'type'] == 'vip' and clientVer == 3.37 and 'hall8' in clientId: # 德州大厅3.37版本BUG: 如果消息中有 richText,则收不到消息 mo.rmKey('richText') if popWinInfo and clientId.startswith('Winpc'): mo.setResult('popWin', popWinInfo) return mo.pack()
def makeStoreConfigResponse(cls, gameId, userId, clientId): mo = MsgPack() mo.setCmd('store_config') mo.setResult('action', 'update') chipShelves = hallstore.storeSystem.getShelvesByClientId( gameId, userId, clientId, 'coin') itemShelves = hallstore.storeSystem.getShelvesByClientId( gameId, userId, clientId, 'item') quickShelves = hallstore.storeSystem.getShelvesByClientId( gameId, userId, clientId, 'quick') diamondShelves = hallstore.storeSystem.getShelvesByClientId( gameId, userId, clientId, 'diamond') mo.setResult( 'coin_list', cls.shelvesToProductIdList(gameId, userId, clientId, chipShelves)) mo.setResult( 'item_list', cls.shelvesToProductIdList(gameId, userId, clientId, itemShelves)) mo.setResult( 'quick_list', cls.shelvesToProductIdList(gameId, userId, clientId, quickShelves)) mo.setResult( 'diamond_list', cls.shelvesToProductIdList(gameId, userId, clientId, diamondShelves)) return mo
def doItemUseOld(self, gameId, userId, itemId, clientId): try: # 老版本只认30这个itemId if itemId == 30: itemId = 2003 itemId = ItemHelper.translateItemId(gameId, 9999, itemId) userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag() item = self._ensureItemExistsOld(userBag, itemId) actionName = ItemHelper.translateUseActionName(item) if actionName: actionResult = userBag.doAction(gameId, item, actionName) router.sendToUser( ItemHelper.makeDoActionResponse(gameId, userId, actionResult), userId) router.sendToUser( ItemHelper.makeItemListResponse(gameId, userId), userId) else: mo = MsgPack() mo.setCmd('bag') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('itemId', itemId) mo.setError(-1, '该道具不能使用') router.sendToUser(mo, userId) except TYBizException, e: self.handleException(itemId, gameId, userId, clientId, e)
def doGetDescription(self, userId): ftlog.debug("<<", "|userId, roomId:", userId, self.roomId, caller=self) mo = MsgPack() mo.setCmd('m_des') mo.setResult('gameId', self.gameId) self.matchPlugin.getMatchInfo(self, userId, mo) router.sendToUser(mo, userId)
def makeResponse(cls, userId, code=0, respmsg=None, notip=False): """ @param notip: 不发送Tip提示 """ if code != ErrorEnum.ERR_OK and respmsg: ftlog.info('PlayerControl.makeResponse:', 'userId=', userId, 'code=', code, 'respmsg=', respmsg) mo = MsgPack() mo.setResult("code", code) # 获取错误码定义的错误提示信息 errinfo = errorinfoTranslate.get(code) # 定制错误信息 if code == None: errinfo = respmsg elif code == ErrorEnum.ERR_WITHDRAW_BALANCE_NOT_ENOUGH: errinfo = cls.getConf('withdraw_money_toofew_errinfo') elif code == ErrorEnum.ERR_WITHDRAW_PROCESSING: errinfo = cls.getConf('withdraw_wait_errinfo') if errinfo: mo.setResult('info', errinfo) if not notip: cls.sendPopTip(userId, errinfo) return mo
def _do_room__des(self, msg): userId = msg.getParam('userId') mp = MsgPack() mp.setCmd('m_des') mp.setResult('gameId', self.gameId) self.getMatchInfo(userId, mp) router.sendToUser(mp, userId)
def sendMNoteMsg(self, noteInfos): for seat, userId, note in noteInfos: if seat.userId == userId: mp = MsgPack() mp.setCmd('m_note') mp.setResult('note', note) self.sendToSeat(mp, seat)
def _onEnterRoomFailed(cls, msg, checkResult, userId, gameId, clientId, roomId=0): '''进入房间失败回调函数''' ftlog.warn("|userId, reason, roomId:", userId, checkResult, roomId, caller=cls) # 调用最小房间金币不够充值提醒的todotask if not roomId: roomId = msg.getParam('candidateRoomId', 0) if checkResult == TYRoom.ENTER_ROOM_REASON_LESS_MIN or checkResult == 104: from hall.entity import hallproductselector product, _ = hallproductselector.selectLessbuyProduct( gameId, userId, clientId, roomId) if product: from hall.entity.todotask import TodoTaskOrderShow todotask = TodoTaskOrderShow.makeByProduct( "金币不够啦,买一个超值礼包吧!", "", product) if todotask: TodoTaskHelper.sendTodoTask(gameId, userId, todotask) mo = MsgPack() mo.setCmd('quick_start') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setError(checkResult, '进入房间失败,请稍后重试') router.sendToUser(mo, userId)
def sendBigMatchBackToListTodoTask(userid, gameId, cache=False, direct=True): """比赛结算界面返回按钮返回时 """ from majiang2.entity.todotasks_builder.todotasks_builder import MahjongTodoTaskBuilder msg = "比赛已结束,点击离开按钮返回比赛列表" task = MahjongTodoTaskBuilder.dict_general_box(userid, msg, cache) retTask = strutil.cloneData(task) buttonLeaveTask = { "content": "离开", "tasks": [{ "action": "trigger_notify", "params": { "eventName": "UPDATE_MATCH_BACK_TO_LIST" } }] } retTask['params']['buttons'] = [buttonLeaveTask] mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userid) mo.setResult('tasks', [retTask]) router.sendToUser(mo, userid) return True, None
def _doTcpPortTuyou(): mo = MsgPack() mo.setCmd('hellotcp') userId = runhttp.getParamInt('userId') nicaiCode = runhttp.getParamStr('nicaiCode', '') clientId = runhttp.getParamStr('clientId', '') if not nicaiCode: mo.setError(3, 'nicai error !') return mo if userId < 1: mo.setError(3, 'userId error !') return mo ftlog.debug('tcpport->userId=', userId, 'nicaiCode=', nicaiCode) HelloTuyou.getNiCaiCode(mo, nicaiCode) ip, port = getGaoFangIp2(userId, clientId) if not ip: ipports = gdata.getUserConnIpPortList() address = ipports[userId % len(ipports)] ip, port = getGaoFangIp(clientId, address[0], address[1]) ftlog.info('doTcpPortTuyou->', userId, ip, port) mo.setResult('tcpsrv', {'ip': ip, 'port': port}) return mo
def sendMarketEstimateTodoTask(userid, gameId, url, des, cache=False, direct=True): """ 推送麻将五星好评Cache 发送五星好评的数据,客户端缓存,什么时候激活五星好评由客户端实现 @param des 五星好评内容 """ if not TYPlayer.isHuman(userid): return False, None ftlog.debug('sendMarketEstimateTodoTask:', userid, url, des, cache, direct) from majiang2.entity.todotasks_builder.todotasks_builder import MahjongTodoTaskBuilder task = MahjongTodoTaskBuilder.dict_market_estimate(userid, url, des, cache) if not task: return False, None if True == direct: mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userid) mo.setResult('tasks', [task]) router.sendToUser(mo, userid) return True, None else: return True, task
def sendFreeChipTodoTask(userid, gameId, cache=False, direct=True): """ 推送 免费金币 added by nick.kai.lee Args: userid: 玩家userid cache: action命名是否是缓存形式,默认不缓存 direct: 是否直接发送,False则return dict """ if not TYPlayer.isHuman(userid): return False, None ftlog.debug('sendFreeChipTodoTask:', userid) from majiang2.entity.todotasks_builder.todotasks_builder import MahjongTodoTaskBuilder task = MahjongTodoTaskBuilder.dict_free_chip(userid, cache) if not task: return False, None ftlog.debug('sendFreeChipTodoTask:', task) if False == direct: return True, task mo = MsgPack() mo.setCmd('majiang_todotasks') mo.setResult('gameId', gameId) mo.setResult('userId', userid) mo.setResult('tasks', [task]) router.sendToUser(mo, userid) return True, None
def makeDecoroationConfigResponse(cls, gameId, userId): itemKindList = hallitem.itemSystem.getAllItemKindByType(TYDecroationItemKind) mo = MsgPack() mo.setCmd('decoration') mo.setResult('action', 'config') mo.setResult('decroations', cls.encodeDecroationItemKindList(gameId, userId, itemKindList)) return mo
def doPutMessage(self, gameId, fromUid, toUid, mtype, msg, ismgr, scope, clientIds): button = runhttp.getParamStr('button', None) button = strutil.loads(button, ignoreException=True) data = None mo = MsgPack() if mtype == 0 and len(msg) > 0 and toUid > 0 and gameId >= 0: # 发送私人消息 # 必须参数 # 1)msg - 消息 # 2)toUid - 接收消息的userId # 3)gameId data = pkmessage.sendPrivate(gameId, toUid, fromUid, msg, button) elif mtype == 1 and len(msg) > 0 and gameId >= 0: # 发送站内消息到全体用户 # 必选参数 # msg - 消息 # gameId data = pkmessage.sendGlobal(gameId, msg, button) elif mtype == 2 and gameId > 0 and len(msg) > 0: # 发送LED # TODO 当前Game服务为4,5,6号 , 每个服务都发送 mo.setCmd('send_led') mo.setParam('msg', msg) mo.setParam('gameId', gameId) mo.setParam('ismgr', 1) router.sendToAll(mo, gdata.SRV_TYPE_UTIL) data = True elif mtype == 3 and gameId > 0 and toUid > 0 and len(msg) > 0: # 封装popwnd # 必选参数 # gameId # toUid 接收弹窗的userId # msg 弹窗消息内容 task = TodoTaskShowInfo(msg, True) mo = TodoTaskHelper.makeTodoTaskMsg(gameId, toUid, task) # 将消息发送给此人 router.sendToUser(mo, toUid) data = True elif mtype == 4 and gameId > 0 and len(msg) > 0 and len(scope) > 0: mo.setCmd('send_led') mo.setParam('msg', msg) ftlog.info('send_led new msg=', msg) mo.setParam('gameId', gameId) ftlog.info('send_led new gameId=', gameId) mo.setParam('ismgr', ismgr) ftlog.info('send_led new ismgr=', ismgr) mo.setParam('scope', scope) ftlog.info('send_led new scope=', scope) mo.setParam('clientIds', clientIds) ftlog.info('send_led new clientIds=', clientIds) router.sendToAll(mo, gdata.SRV_TYPE_UTIL) data = True if data == None: mo.setError(1, 'params error') else: mo.setResult('ok', 'true') return mo
def __playAnimationIfNeed(self, tableInfo): ret = {'playAnimation':False, 'delaySeconds':0} for x in xrange(len(self.seats)) : this_seat = self.seats[x] if this_seat.userId > 0: clientVer = sessiondata.getClientIdVer(this_seat.userId) animationType = self.__getAnimationType(clientVer) if animationType != AnimationType.UNKNOWN: msg = MsgPack() msg.setCmd('m_play_animation') msg.setResult('gameId', self.gameId) msg.setResult('roomId', self.roomId) msg.setResult('tableId', self.tableId) msg.setResult('type', animationType) mnotes = self._match_table_info['mnotes'] isStartStep = mnotes.get('isStartStep', False) # 添加是否是第一个阶段的标志,是的话前端播放开始比赛的动画 msg.setResult('isStartStep', isStartStep) # 组织当前比赛是第几局、共几局的信息 msg.setResult('curMatchStep', self._buildMatchStepInfo(this_seat.userId, tableInfo)) router.sendToUser(msg, this_seat.userId) # ret['delaySeconds'] = self.__getAnimationInter(animationType, isStartStep, clientVer) ret['playAnimation'] = True return ret
def playAnimationIfNeed(self, table): ret = {'playAnimation': False, 'delaySeconds': 0} for seat in table.seats: if not seat.player: continue animationType = self.getAnimationType(table, seat.player.gameClientVer) if animationType != AnimationType.UNKNOWN: msg = MsgPack() msg.setCmd('m_play_animation') msg.setResult('gameId', table.gameId) msg.setResult('roomId', table.roomId) msg.setResult('tableId', table.tableId) msg.setResult('type', animationType) mnotes = table.matchTableInfo['mnotes'] isStartStep = mnotes.get('isStartStep', False) # 添加是否是第一个阶段的标志,是的话前端播放开始比赛的动画 msg.setResult('isStartStep', isStartStep) # 组织当前比赛是第几局、共几局的信息 msg.setResult('curMatchStep', self.buildMatchStepInfo(seat)) self.sendToSeat(msg, seat) curDelay = self.getAnimationInter(animationType, isStartStep, seat.player.gameClientVer) if curDelay > ret['delaySeconds']: ret['delaySeconds'] = curDelay ret['playAnimation'] = True return ret
def doSendLedToUser(userId): gameIdList = onlinedata.getGameEnterIds(userId) if not gameIdList: return clientId = sessiondata.getClientId(userId) _, clientVer, _ = strutil.parseClientId(clientId) for gameId in gameIdList: try: leds = getLedMsgList(gameId) if ftlog.is_debug(): ftlog.debug('hallled.doSendLedToUser gameId=', gameId, 'gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'leds=', leds) if leds: msgDict = leds[0][2] if clientVer >= 3.6: mo = MsgPack() mo.setCmd('led') for k, v in msgDict.iteritems(): mo.setResult(k, v) else: mo = MsgPack() mo.setCmd('led') if gameId in (1, 8): msgDictV2 = translateToMsgDictV2(msgDict) if msgDictV2: mo.setKey('richText', msgDictV2.get('richText')) msgV1 = translateToMsgDictV1(msgDict) if msgV1: gameId = msgDict.get('gameId', leds[0][1]) mo.setKey('result', [[leds[0][0], gameId, msgV1]]) router.sendToUser(mo, userId) except: ftlog.error()
def doCancelCodeCheck(self, gameId, userId, clientId): ''' 取消code_check ''' try: timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) neituiguang.setInviter(status, 0) ftlog.hinfo('neituiguang.statics eventId=', 'CANCEL_INPUT_PRMOTE_CODE', 'userId=', userId, 'clientId=', clientId, 'result=', 'ok') mo = MsgPack() mo.setCmd('promote_info') mo.setResult('action', 'cancel_code_check') mo.setResult('code', 0) router.sendToUser(mo, userId) except Exception, e: if not isinstance(e, TYBizException): ftlog.error() ec, info = (e.errorCode, e.message) if isinstance(e, TYBizException) else (-1, '系统错误') ftlog.hinfo('neituiguang.statics eventId=', 'CANCEL_INPUT_PRMOTE_CODE', 'userId=', userId, 'clientId=', clientId, 'result=', 'failed') router.sendToUser(self.makeErrorResponse('cancel_code_check', ec, info), userId)
def _sendQuestFinished(userId, quest): """发送完成的每日任务""" level = util.getUserLevel(userId) if level < config.getCommonValueByKey("dailyQuestOpenLevel"): return lang = util.getLanguage(userId) mo = MsgPack() mo.setCmd("task") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) mo.setResult("action", "finished") mo.setResult("taskId", quest["taskId"]) # if quest["taskType"] == TaskType.CoinNum and quest["des"].find("%s") >= 0: # des = quest["des"] % util.formatScore(quest["targetsNum"]) # elif quest["des"].find("%d") >= 0: # des = quest["des"] % quest["targetsNum"] # else: # des = quest["des"] questDes = config.getMultiLangTextConf(quest["des"], lang=lang) if questDes.find("%s") >= 0: des = questDes % util.formatScore(quest["targetsNum"], lang=lang) elif questDes.find("%d") >= 0: des = questDes % quest["targetsNum"] elif questDes.count("{}") >= 2: des = questDes.format(quest["gunX"], quest["targetsNum"]) else: des = questDes mo.setResult("des", des) router.sendToUser(mo, userId)
def sendVipCirculateInfo(userId): """ 道具流通数量限制信息 """ levels = {} for level in sorted(map(int, config.getVipConf().keys())): levelDict = {} vipConf = config.getVipConf(level) levelDict["present:1408"] = vipConf.get("vipPresentCount:1408", 0) levelDict["present:1429"] = vipConf.get("vipPresentCount:1429", 0) levelDict["present:1430"] = vipConf.get("vipPresentCount:1430", 0) levelDict["present:1431"] = vipConf.get("vipPresentCount:1431", 0) levelDict["present:14120"] = vipConf.get("vipPresentCount:14120", 0) levelDict["present:14119"] = vipConf.get("vipPresentCount:14119", 0) levelDict["present:1193"] = vipConf.get("vipPresentCount:1193", 0) levelDict["present:1194"] = vipConf.get("vipPresentCount:1194", 0) levelDict["receive:1193"] = vipConf.get("vipReceiveCount:1193", 0) levelDict["receive:1194"] = vipConf.get("vipReceiveCount:1194", 0) levels[level] = levelDict mo = MsgPack() mo.setCmd("fish_circulate_info") mo.setResult("gameId", FISH_GAMEID) mo.setResult("userId", userId) mo.setResult("levels", levels) router.sendToUser(mo, userId)
def doCancelCodeCheck(self, gameId, userId, clientId): ''' 取消code_check ''' try: timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) neituiguang.setInviter(status, 0) ftlog.hinfo('neituiguang.statics eventId=', 'CANCEL_INPUT_PRMOTE_CODE', 'userId=', userId, 'clientId=', clientId, 'result=', 'ok') mo = MsgPack() mo.setCmd('promote_info') mo.setResult('action', 'cancel_code_check') mo.setResult('code', 0) router.sendToUser(mo, userId) except Exception, e: if not isinstance(e, TYBizException): ftlog.error() ec, info = (e.errorCode, e.message) if isinstance( e, TYBizException) else (-1, '系统错误') ftlog.hinfo('neituiguang.statics eventId=', 'CANCEL_INPUT_PRMOTE_CODE', 'userId=', userId, 'clientId=', clientId, 'result=', 'failed') router.sendToUser( self.makeErrorResponse('cancel_code_check', ec, info), userId)
def changeNotify(uid, gid, attrs, broadcastUserIds=None): #attrs={"ud":[{},{}], "gd":[], "items":[]} msg = MsgPack() msg.setCmd("chg") msg.setResult("gameId", FISH_GAMEID) msg.setResult("userId", uid) if "ud" in attrs: ud = {} for item in attrs["ud"]: if item["name"] == "tableChip": from newfish.game import TGFish TGFish.getEventBus().publishEvent( ChipChangeEvent(uid, FISH_GAMEID, 0, item["count"])) ud[item["name"]] = item["count"] msg.setResult("ud", ud) if "gd" in attrs: gd = {} for item in attrs["gd"]: gd[item["name"]] = item["count"] msg.setResult("gd", gd) if "items" in attrs: items = {} for item in attrs["items"]: items[item["name"]] = item["count"] msg.setResult("items", items) if broadcastUserIds: GameMsg.sendMsg(msg, broadcastUserIds) else: GameMsg.sendMsg(msg, uid)
def _doTcpPortTuyou(): mo = MsgPack() mo.setCmd('hellotcp') userId = runhttp.getParamInt('userId') nicaiCode = runhttp.getParamStr('nicaiCode', '') clientId = runhttp.getParamStr('clientId', '') if not nicaiCode: mo.setError(3, 'nicai error !') return mo if userId < 1: mo.setError(3, 'userId error !') return mo ftlog.debug('tcpport->userId=', userId, 'nicaiCode=', nicaiCode) HelloTuyou.getNiCaiCode(mo, nicaiCode) ip, port, wsport = getGaoFangIp2(userId, clientId) if not ip: ipports = gdata.getUserConnIpPortList() address = ipports[userId % len(ipports)] ip, port = getGaoFangIp(clientId, address[0], address[1]) if len(address) > 2 : wsport = address[2] ftlog.info('doTcpPortTuyou->', userId, ip, port) mo.setResult('tcpsrv', {'ip': ip, 'port': port, 'wsport' : wsport}) return mo
def _doInviteeInfo(cls, userId, gameId, clientId): mo = MsgPack() mo.setCmd('hall_invite') mo.setResult('action', 'invitee_info') status = hall_invite.loadUserInviteStatus(userId) mo.setResult('invitees', cls._encodeInvitees(status, clientId)) return mo
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 doHallInfo(self, userId, gameId, clientId): roominfos = hallconf.getHallSessionInfo(gameId, clientId) msg = MsgPack() msg.setCmd('hall_info') msg.setResult('gameId', gameId) msg.setResult('userId', userId) msg.setResult('sessions', roominfos) router.sendToUser(msg, userId)
def doHallGameList(self, userId, gameId, clientId): pages = hallgamelist.getGameList(gameId, userId, clientId) mo = MsgPack() mo.setCmd('hall_game_list') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('pages', pages) router.sendToUser(mo, userId)
def doHallHtmlsInfo(self, userId, gameId, clientId): roominfos = hallconf.getHallHtmlsInfo(clientId) msg = MsgPack() msg.setCmd('htmls_info') msg.setResult('gameId', gameId) msg.setResult('userId', userId) msg.setResult('htmls', roominfos) router.sendToUser(msg, userId)
def doHallLocalNotification(self, userId, gameId, clientId): lnConfig = halllocalnotification.queryLocalNotification(gameId, userId, clientId) mo = MsgPack() mo.setCmd('hall_local_notification') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('notifies', lnConfig) router.sendToUser(mo, userId)
def doGetLiveShowTableList(self, userId, clientId): '''为了效率,贵宾室所有桌子放在一个GT进程里, 在此进程中通过遍历来获取每张桌子的状态 ''' msgRes = MsgPack() msgRes.setCmd("game") msgRes.setResult("action", "live_show_table_list") msgRes.updateResult(self._getVipTableList(userId, clientId, tag="", isLiveShowRoom=True)) router.sendToUser(msgRes, userId)
def doGetDescription(self, userId): if ftlog.is_debug(): ftlog.debug('TYRelaxationMatchRoom.doGetDescription', 'userId=', userId) mo = MsgPack() mo.setCmd('m_des') mo.setResult('gameId', self.gameId) self.matchPlugin.getMatchInfo(self, userId, mo) router.sendToUser(mo, userId)
def doGetDescription(self, userId): if self._logger.isDebug(): self._logger.debug('TYGroupMatchRoom.doGetDescription', 'userId=', userId) mo = MsgPack() mo.setCmd('m_des') mo.setResult('gameId', self.gameId) self.matchPlugin.getMatchInfo(self, userId, mo) router.sendToUser(mo, userId)
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 doLeave(self, userId, msg): ftlog.debug("<<", "|userId, roomId:", userId, self.roomId, caller=self) mo = MsgPack() mo.setCmd('m_leave') mo.setResult('gameId', self.gameId) mo.setResult('roomId', self.roomId) mo.setResult('userId', userId) self.match.leave(userId) router.sendToUser(mo, userId)
def _onEnterCreateRoomFailed(cls, checkResult, userId, gameId, clientId, roomId=0): '''进入创建房间失败回调函数''' ftlog.warn("|userId, reason, roomId:", userId, checkResult, roomId, caller=cls) mo = MsgPack() mo.setCmd('quick_start') mo.setResult('gameId', gameId) mo.setResult('userId', userId) mo.setResult('reason', checkResult) 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 doListInvitee(self, gameId, userId, clientId): timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) invitee = status.encodeInvitee() mo = MsgPack() mo.setCmd('promote_info') mo.setResult('action', 'list_invitee') mo.setResult('invitee', invitee) router.sendToUser(mo, userId)
def doNewUserRewardReceive(self, userId, gameId, clientId): ''' 领取新手启动资金 ''' isSend, startChip, _final = hallstartchip.sendStartChip(userId, gameId, clientId) mo = MsgPack() mo.setCmd('new_user_reward') mo.setResult('action', 'receive') mo.setResult('coin', startChip if isSend else 0) router.sendToUser(mo, userId)
def doChargeNotify(self, gameId, userId, prodId, rmbs, diamonds, clientId): if diamonds > 0: hallvip.userVipSystem.addUserVipExp(gameId, userId, diamonds, 'BUY_PRODUCT', pokerconf.productIdToNumber(prodId)) TGHall.getEventBus().publishEvent(ChargeNotifyEvent(userId, gameId, rmbs, diamonds, prodId, clientId)) mo = MsgPack() mo.setCmd('charge_notify') mo.setResult('userId', userId) mo.setResult('gameId', gameId) return mo