Ejemplo n.º 1
0
def doGetTaskRewards(userId, taskId, actionType):
    message = MsgPack()
    message.setCmd("invite_task_receive")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    isCanInvite = config.getCommonValueByKey("canInvite")
    if not isCanInvite:
        message.setResult("code", 100)
        router.sendToUser(message, userId)
    else:
        code, chestId, rewards, taskState = receiveInvitTaskReward(userId, taskId, actionType)
        message.setResult("code", code)
        if code == 0:
            message.setResult("chestId", chestId)
            message.setResult("rewards", rewards)
        message.setResult("taskId", taskId)
        message.setResult("actionType", actionType)
        router.sendToUser(message, userId)

        if len(taskState) > 0 and len(taskState) % OneGroupNum == 0:
            doGetInviteTasks(userId, actionType)
 def _surpassTarget(self, msg, userId, seatId):
     """超越目标"""
     player = self.getPlayer(userId)
     if player and player.userId:
         self._updateSurpassUser(player)
         msg = MsgPack()
         msg.setCmd("m_surpass")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("roomId", self.roomId)
         msg.setResult("tableId", self.tableId)
         msg.setResult("userId", player.userId)
         msg.setResult("bestScore",
                       self._playerBestScore.get(str(userId), 0))
         if self._surpassUser.get(userId, None):
             msg.setResult("target", self._surpassUser.get(userId))
         GameMsg.sendMsg(msg, player.userId)
         if self._logger.isDebug():
             self._logger.debug("_surpassTarget", "userId", userId,
                                "score=",
                                self._playerBestScore.get(str(userId), 0),
                                "playerBestScore=", self._playerBestScore)
Ejemplo n.º 3
0
def sendMsg2client(gameId, userId, type, context, isDisplay=True, npwId='', where=WHERE_REQ):
    if isDisplay == False:
        ftlog.hinfo("newcheckin|sendmsg2client|isDisplay", gameId, userId, type, context, where)
        return

    results = {}
    results['type'] = type  # '3','7'
    results['context'] = context

    mp = MsgPack()
    if where == WHERE_NPW:
        mp.setCmd('game_popwinodws')
        results['action'] = 'newpop_checkin'
        results['npwId'] = npwId
    else:
        mp.setCmd('new_checkin')
    mp.setResult('gameId', gameId)
    mp.setResult('userId', userId)
    mp.updateResult(results)
    router.sendToUser(mp, userId)
    ftlog.debug("newcheckin|sendmsg2client|", gameId, userId, type, context, where, results)
Ejemplo n.º 4
0
 def _doGetShareReward(cls, gameId, userId, clientId, pointId,
                       whereToShare):
     ok, assetList = hall_share3.gainShareReward(gameId, userId, clientId,
                                                 pointId, whereToShare)
     rewards = []
     if ok:
         for atup in assetList:
             rewards.append({
                 'itemId': atup[0].kindId,
                 'name': atup[0].displayName,
                 'url': atup[0].pic,
                 'count': atup[1]
             })
     mp = MsgPack()
     mp.setCmd('hall_share3')
     mp.setResult('action', 'get_share_reward')
     mp.setResult('gameId', gameId)
     mp.setResult('userId', userId)
     mp.setResult('pointId', pointId)
     mp.setResult('rewards', rewards)
     return mp
Ejemplo n.º 5
0
def doGetAllAchievementTasks(userId, honorId):
    """
    获取荣誉任务中一个称号的信息
    """
    message = MsgPack()
    message.setCmd("achievement_tasks")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    if isLimitLevel(userId):
        message.setResult("code", 7)
        router.sendToUser(message, userId)
        return
    if not util.isFinishAllNewbieTask(userId):
        message.setResult("code", 7)
        router.sendToUser(message, userId)
        return
    message.setResult("code", 0)
    tasks = getAllTaskInfo(userId, honorId)  # 勋章Id
    message.setResult("achievementTasks", tasks)  # 里面的成就任务
    message.setResult("honorId", honorId)
    router.sendToUser(message, userId)
Ejemplo n.º 6
0
    def send_get_award_response(cls, gid, uid, task_id, multi_award):
        task, rewards, err_code = UserTaskData.reward(uid, task_id,
                                                      multi_award)
        ret = {
            "nextTask": task,
            "resetRemainTime": TaskTimeManager.get_daily_task_remain_time(),
            "code": err_code,
        }
        if rewards:
            ret["rewardInfo"] = cls._build_reward_info(rewards)
            if "raw_count" in ret["rewardInfo"]:
                cls._publish_reward_event(uid, ret["rewardInfo"]["raw_count"])

        mo = MsgPack()
        mo.setCmd('dizhu')
        mo.setResult('gameId', gid)
        mo.setResult('userId', uid)
        mo.setResult('action', 'get_segment_task_award')
        for k, v in ret.items():
            mo.setResult(k, v)
        router.sendToUser(mo, uid)
Ejemplo n.º 7
0
 def makeTableManageReq(cls,
                        userId,
                        shadowRoomId,
                        tableId,
                        clientId,
                        action,
                        params=None):
     mpReq = MsgPack()
     mpReq.setCmd("table_manage")
     mpReq.setParam("action", action)
     mpReq.setParam("userId", userId)
     mpReq.setParam("gameId",
                    strutil.getGameIdFromInstanceRoomId(shadowRoomId))
     mpReq.setParam("roomId", shadowRoomId)
     mpReq.setParam("tableId", tableId)
     mpReq.setParam("clientId", clientId)
     if params:
         mpReq.updateParam(params)
     if ftlog.is_debug():
         ftlog.debug(str(mpReq), caller=cls)
     return mpReq
Ejemplo n.º 8
0
def doReceiveAchieveLevelRewards(userId, level):
    """
    称号等级奖励领取
    """
    achLevelClass = AchievementLevel(userId)
    message = MsgPack()
    message.setCmd("achievement_level_reward")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    if isLimitLevel(userId):
        message.setResult("code", 7)
    else:
        code, rewards = achLevelClass.receiveLevelReward(level)
        message.setResult("code", code)
        if code == 0:
            # 当前完成进度
            message.setResult("achLevelRewardInfo",
                              achLevelClass.getCurAchievementLevelReward())
            message.setResult("rewards", rewards)
            updateAchievementModuleTips(userId)
    router.sendToUser(message, userId)
Ejemplo n.º 9
0
 def clearTable(self, table):
     '''
     清理桌子
     '''
     try:
         msg = MsgPack()
         msg.setCmd('table_manage')
         msg.setParam('action', 'm_table_clear')
         msg.setParam('gameId', table.gameId)
         msg.setParam('matchId', table.matchInst.matchId)
         msg.setParam('roomId', table.roomId)
         msg.setParam('tableId', table.tableId)
         msg.setParam('ccrc', table.ccrc)
         if ftlog.is_debug():
             ftlog.debug('MatchTableControllerDizhu.clearTable matchId=',
                         table.matchInst.matchId, 'instId=',
                         table.matchInst.instId, 'roomId=', table.roomId,
                         'tableId=', table.tableId, 'mo=', msg)
         router.sendTableServer(msg, table.roomId)
     except:
         ftlog.error()
Ejemplo n.º 10
0
    def doRoomList(self, userId, gameId):
        msg = runcmd.getMsgPack()
        playMode = msg.getParam('play_mode')
        if playMode is None or playMode == 'default':
            playMode = 'harbin'

        room_infos = self._fetchAllRoomInfos(userId, gameId, playMode)
        vardata = msg.getParam('vardata', 0)
        message = MsgPack()
        message.setCmd('room_list')
        message.setResult('play_mode', playMode)
        message.setResult('gameId', gameId)
        message.setResult('baseUrl', 'http://www.tuyoo.com/')
        if vardata == 0:
            message.setResult('rooms', room_infos)
        else:
            room_list = []
            for info in room_infos:
                room_list.append([info[0], info[1]])
            message.setResult('rooms', room_list)
        router.sendToUser(message, userId)
Ejemplo n.º 11
0
def doReceiveMail(userId, mailIds, mailSenderType):
    """
    领取邮件奖励
    :param userId: 玩家Id
    :param mailIds: 空是一键领取
    :param mailSenderType: 邮件类型:1系统邮件,2其他邮件
    """
    message = MsgPack()
    message.setCmd("fishMailReceive")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    code, rewards = _dealMail(userId, mailIds, mailSenderType)
    message.setResult("code", code)
    message.setResult("rewards", rewards)
    mails = getAllMail(userId).get(mailSenderType, [])
    message.setResult("mailType", mailSenderType)
    message.setResult("mails", mails)
    router.sendToUser(message, userId)
    from newfish.game import TGFish
    event = ReceiveMailEvent(userId, FISH_GAMEID)
    TGFish.getEventBus().publishEvent(event)
Ejemplo n.º 12
0
    def getCustomRecords(self, gameId, msg):
        '''获取战绩
        '''
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        userId = msg.getParam("userId")

        records = gamedata.getGameAttr(userId, gameId, "customTableRecords")
        if records:
            records = json.loads(records)
        else:
            records = []
        for record_item in records:
            if not record_item.get("totalPlayNum"):
                record_item['totalPlayNum'] = "-"
        msgRes = MsgPack()
        msgRes.setCmd("game")
        msgRes.updateResult({"action": "get_custom_records"})
        msgRes.setResult("records", records)
        router.sendToUser(msgRes, userId)
Ejemplo n.º 13
0
    def testQuickEnterTable(self):
        '''测试快速进入桌子'''
        gameId = 6
        userId = 1234
        roomId = 60110001
        tableId = 1
        clientId = "tuyoo_4.0_hall6"

        onlinedata.setOnlineState(userId, onlinedata.ONLINE)
        onlinedata.cleanOnlineLoc(userId)

        msg = MsgPack()
        msg.setCmd("quick_start")
        msg.setParam("userId", userId)
        msg.setParam("roomId", roomId)
        msg.setParam("tableId", tableId)
        msg.setParam("clientId", clientId)
        print '=' * 30
        print msg
        DizhuQuickStartDispatcher.dispatchQuickStart(msg)
        print '=' * 30
Ejemplo n.º 14
0
 def sendUserInfoResponse(self, userId, gameId, clientId, loc, isudata,
                          isgdata):
     '''
     仅发送user_info命令, USER的主账户信息和游戏账户信息至客户端
     '''
     mo = MsgPack()
     if isudata:
         mo.setCmd('user_info')
     else:
         mo.setCmd('game_data')
     mo.setResult('gameId', gameId)
     mo.setResult('userId', userId)
     if isudata:
         mo.setResult('udata', halluser.getUserInfo(userId, gameId,
                                                    clientId))
         if loc:
             mo.setResult('loc', loc)
     if isgdata:
         mo.setResult('gdata', halluser.getGameInfo(userId, gameId,
                                                    clientId))
     router.sendToUser(mo, userId)
Ejemplo n.º 15
0
    def onGameGetCustomOptions(self, gameId, msg):
        # def onRoomGetCustomOptions(self, gameId, msg):
        '''在GR处理获取自建桌配置逻辑
        '''
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        msg = runcmd.getMsgPack()
        userId = msg.getParam("userId")

        selectedRoomOptions = self._getSelectedRoomOptions(userId, gameId)

        msgRes = MsgPack()
        msgRes.setCmd("game")
        msgRes.setResult("action", "get_custom_options")
        msgRes.setResult("userId", userId)
        msgRes.setResult("gameId", gameId)
        msgRes.setResult("selectedRoomOptions", selectedRoomOptions)
        msgRes.setResult("customRoomOptions", difangConf.getCustomRoomConf(gameId, 'options'))
        msgRes.setResult("customConfVer", difangConf.getCustomRoomConf(gameId, 'ver'))
        router.sendToUser(msgRes, userId)
Ejemplo n.º 16
0
def renameNickname(userId, clientId, nickname):
    """
    修改玩家昵称
    """
    lang = util.getLanguage(userId, clientId)
    surplusCount = util.balanceItem(userId, config.RENAME_KINDID)
    try:
        if surplusCount == 0:
            code = 1
            info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_1", lang=lang) # u"昵称修改失败"
        elif len(nickname) == 0:
            code = 2
            info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_2", lang=lang) # u"昵称不能为空,请重新输入!"
        elif len(nickname.decode("utf-8").encode("gbk", "ignore")) > 16:
            code = 3
            info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_3", lang=lang) # u"昵称过长,请重新输入!"
        elif re.search(u"[^\w\u4e00-\u9fff]+", nickname.decode("utf-8")):
            code = 4
            info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_4", lang=lang) # u"昵称不能含有特殊字符,请重新输入!"
        elif util.isTextCensorLimit(nickname):
            code = 5
            info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_5", lang=lang) # u"昵称含有违规内容,请重新输入!"
        else:
            _consume = [{"name": config.RENAME_KINDID, "count": 1}]
            util.consumeItems(userId, _consume, "ITEM_USE")
            gamedata.setGameAttr(userId, FISH_GAMEID, GameData.nickname, nickname)
            userdata.setAttr(userId, "name", nickname)
            code = 0
            info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_0", lang=lang) # u"昵称修改成功"
    except:
        ftlog.error()
        code = 1
        info = config.getMultiLangTextConf("ID_RENAME_CODE_INFO_1", lang=lang)  # u"昵称修改失败"
    message = MsgPack()
    message.setCmd("rename_nickname")
    message.setResult("gameId", FISH_GAMEID)
    message.setResult("userId", userId)
    message.setResult("info", info)
    message.setResult("code", code)
    router.sendToUser(message, userId)
Ejemplo n.º 17
0
    def notifyMatchStart(self, instId, signers):
        '''
        通知用户比赛开始
        '''
        try:
            self._logger.info('PlayerNotifierDizhu.notifyMatchStart',
                              'instId=', instId, 'userCount=', len(signers))
            mstart = MsgPack()
            mstart.setCmd('m_start')
            mstart.setResult('gameId', self._room.gameId)
            mstart.setResult('roomId', self._room.bigRoomId)

            userIds = [p.userId for p in signers]
            self._logger.info(
                'PlayerNotifierDizhu.notifyMatchStart begin send tcp m_start'
                'instId=', instId, 'userCount=', len(signers))
            if userIds:
                router.sendToUsers(mstart, userIds)
                self._logger.info(
                    'PlayerNotifierDizhu.notifyMatchStart end send tcp m_start'
                    'instId=', instId, 'userCount=', len(signers))

                self._logger.info(
                    'PlayerNotifierDizhu.notifyMatchStart begin send bi report'
                    'instId=', instId, 'userCount=', len(signers))
                sequence = int(instId.split('.')[1])
                datas = {
                    'userIds': userIds,
                    'roomId': self._room.roomId,
                    'sequence': sequence,
                    'index': 0
                }
                FTTimer(2, self.notifyMatchStartDelayReport_, datas)
                self._logger.info(
                    'PlayerNotifierDizhu.notifyMatchStart begin send bi report async'
                    'instId=', instId, 'userCount=', len(signers))
        except:
            self._logger.error(
                'PlayerNotifierDizhu.notifyMatchStart'
                'instId=', instId, 'userCount=', len(signers))
Ejemplo n.º 18
0
 def taskEnd(self, userId=None):
     """
     任务结束
     """
     if not userId:
         self.state = TaskState.TS_End
     tmp_userIds = copy.deepcopy(self.userIds)
     if ftlog.is_debug():
         ftlog.debug("taskEnd", tmp_userIds, self.usersData,
                     self.recordStartTime, int(time.time()))
     for uid in tmp_userIds:
         if userId and userId != uid:
             continue
         if uid not in self.usersData:
             continue
         ranks = self._getRanks(uid)
         reward = False
         dropItems = None
         player = None
         task = self.usersData[uid]["task"]
         userData = self.usersData[uid]
         userData["state"] = TaskState.TS_End
         if ranks and self._checkFinished(userData):
             reward = True
             player = self.table.getPlayer(uid)
             rewardDropId = task["rewards"]
             dropItems = self._sendTaskReward(player,
                                              userData["rewardType"],
                                              rewardDropId)
         msg = MsgPack()
         msg.setCmd("tide_task")
         msg.setResult("gameId", FISH_GAMEID)
         msg.setResult("userId", uid)
         msg.setResult("action", "finish")
         msg.setResult("taskId", task["taskId"])
         msg.setResult("taskType", task["taskType"])
         if reward and player:
             msg.setResult("reward", dropItems)
         GameMsg.sendMsg(msg, uid)
         self.clearTaskData(uid)
Ejemplo n.º 19
0
def sendExpiredGunMsg(userId, mode):
    """
    返回火炮皮肤过期提示
    """
    ownGunSkinsKey = GameData.ownGunSkins  # 最近一次已拥有的皮肤炮列表
    gunSkinIdKey = GameData.gunSkinId if mode == CLASSIC_MODE else GameData.gunSkinId_m  # 用户当前皮肤炮ID
    promptedGunSkinsKey = GameData.promptedGunSkins  # 已发送了过期提示弹窗的皮肤炮
    ownGuns = gamedata.getGameAttrJson(userId, FISH_GAMEID, ownGunSkinsKey, [])
    currentGunIds = getGunIds(userId, mode)[1:]  # 玩家当前拥有的火炮ID
    clientId = util.getClientId(userId)
    allGunIds = config.getAllGunIds(clientId, mode)
    for idx in range(len(ownGuns) - 1, -1, -1):
        if ownGuns[idx] not in allGunIds:
            ownGuns.pop(idx)
    # 当前已过期的皮肤 = 最近一次已拥有皮肤炮 - 当前已拥有皮肤炮
    expiredGuns = list(set(ownGuns) - set(currentGunIds))
    if expiredGuns:
        gunId = gamedata.getGameAttr(userId, FISH_GAMEID, gunSkinIdKey)
        if gunId in expiredGuns:
            expiredGun = gunId
        else:
            expiredGun = expiredGuns[-1]
        gunIds1 = getGunIds(userId, CLASSIC_MODE)[1:]
        gunIds2 = getGunIds(userId, MULTIPLE_MODE)[1:]
        gunIds1.extend(gunIds2)
        gamedata.setGameAttr(userId, FISH_GAMEID, ownGunSkinsKey,
                             json.dumps(list(set(gunIds1))))
        promptedGuns = gamedata.getGameAttrJson(userId, FISH_GAMEID,
                                                promptedGunSkinsKey, [])
        if expiredGun not in promptedGuns:
            promptedGuns.append(expiredGun)
            gamedata.setGameAttr(userId, FISH_GAMEID, promptedGunSkinsKey,
                                 json.dumps(promptedGuns))
            mo = MsgPack()
            mo.setCmd("expired_gun")
            mo.setResult("gameId", FISH_GAMEID)
            mo.setResult("userId", userId)
            mo.setResult("gunId", expiredGun)
            mo.setResult("gameMode", mode)
            router.sendToUser(mo, userId)
Ejemplo n.º 20
0
 def sendFireMsg(self, userId, seatId, extends, params):
     """
     发送开火确认消息
     """
     fPos = params.get("fPos")
     wpId = params.get("wpId")
     bulletId = params.get("bulletId")
     skillId = params.get("skillId")
     timestamp = params.get("timestamp")
     canFire = params.get("canFire")
     reason = params.get("reason")
     clip = params.get("clip")
     skillType = params.get("skillType", 0)
     lockFId = params.get("lockFId", 0)
     fPosx, fPosy = fPos
     retMsg = MsgPack()
     retMsg.setCmd("fire")
     retMsg.setResult("gameId", FISH_GAMEID)
     retMsg.setResult("userId", userId)
     retMsg.setResult("wpId", wpId)
     retMsg.setResult("bulletId", bulletId)
     retMsg.setResult("skillId", skillId)
     retMsg.setResult("skillType", skillType)
     retMsg.setResult("extends", extends)
     retMsg.setResult("timestamp", timestamp)
     retMsg.setResult("reason", reason)
     retMsg.setResult("grandPrixFireCount",
                      self.grandPrixFireCount)  # 大奖赛剩余开火次数
     retMsg.setResult("clip", clip)
     retMsg.setResult("lockFId", lockFId)
     superBullet = self.getFire(bulletId).get(
         "superBullet", {})  # self.isSuperBullet(bulletId)
     retMsg.setResult("superBullet", 1 if superBullet else 0)  # 测试代码
     GameMsg.sendMsg(retMsg, userId)
     if canFire:
         retMsg.setResult("fPosx", fPosx)
         retMsg.setResult("fPosy", fPosy)
         retMsg.setResult("seatId", seatId)
         GameMsg.sendMsg(retMsg, self.table.getBroadcastUids(userId))
Ejemplo n.º 21
0
def doSendLedToUser(userId):
    """
    发送LED消息给玩家(由客户端心跳消息触发,大概15s一次)
    """
    from newfish.entity import util
    gameIdList = onlinedata.getGameEnterIds(userId)
    lastGameId = onlinedata.getLastGameId(userId)
    # if not HALL_GAMEID in gameIdList:
    #     gameIdList.append(HALL_GAMEID)
    # if not lastGameId in gameIdList:
    #     gameIdList.append(lastGameId)

    clientId = sessiondata.getClientId(userId)
    gameIdInClientId = strutil.getGameIdFromHallClientId(clientId)
    if not gameIdInClientId in gameIdList:
        gameIdList.append(gameIdInClientId)
    lang = util.getLanguage(userId, clientId)
    if ftlog.is_debug():
        ftlog.debug("led.doSendLedToUser userId=", userId, "gameIdList=",
                    gameIdList, "clientId=", clientId, "gameIdInClientId=",
                    gameIdInClientId, "lastGameId=", lastGameId)
    for gameId in gameIdList:
        try:
            leds = getLedMsgList(gameId)
            if ftlog.is_debug():
                ftlog.debug("led.doSendLedToUser gameId=", gameId, "userId=",
                            userId, "clientId=", clientId, "leds=", leds)
            if leds:
                for led in leds:
                    if canSendToUser(userId, clientId, led, lang):
                        msgDict = led[2]
                        mo = MsgPack()
                        mo.setCmd("led")
                        for k, v in msgDict.iteritems():
                            mo.setResult(k, v)
                        mo.setResult("scope", led[3])
                        router.sendToUser(mo, userId)
        except:
            ftlog.error("error leds:", leds)
Ejemplo n.º 22
0
def sendExitPluginRemindMsg(userId, gameId, clientId, remindGame, cType):
    '''
    发送快开配置的消息给客户端
    '''
    ftlog.debug('userId:', userId
                , ' gameId:', gameId
                , ' clientId:', clientId
                , ' remindGame:', remindGame
                , ' cType:', cType)
    
    mo = MsgPack()
    mo.setCmd('game')
    mo.setResult('action', 'get_exit_plugin_remind')
    # 快速开始按钮的显示名称
    mo.setResult('name', remindGame.get('name', ''))
    mo.setResult('gameId', gameId)
    mo.setResult('enterGameId', remindGame.get('gameId', 0))
    mo.setResult('userId', userId)
    # 快速开始按钮的行为
    mo.setResult('enter_param', remindGame.get('enter_param', {}))
    # 文案提示
    tips = remindGame.get('tips', {})
    if TYPE_MOST == cType:
        mo.setResult('tips', tips.get('most', ''))
    elif TYPE_LAST == cType:
        mo.setResult('tips', tips.get('last', ''))
    elif TYPE_LEAST == cType:
        mo.setResult('tips', tips.get('least', ''))
    elif TYPE_NEVER == cType:
        mo.setResult('tips', tips.get('never', ''))
        
    router.sendToUser(mo, userId)
            
    ftlog.debug('userId:', userId
                , ' gameId:', gameId
                , ' clientId:', clientId
                , ' message:', mo)
            
    return mo
Ejemplo n.º 23
0
    def doConsumeTransaction(self, appId, realGameId, userId, prodId, clientId,
                             prodCount, prodOrderId):
        realGameId = realGameId if realGameId else 9999
        mo = MsgPack()
        mo.setCmd('buy_prod')
        mo.setResult('appId', appId)
        mo.setResult('realGameId', realGameId)
        mo.setResult('userId', userId)
        mo.setResult('prodId', prodId)
        mo.setResult('prodCount', prodCount)
        mo.setResult('prodOrderId', prodOrderId)

        if not prodOrderId:
            mo.setError(1, 'not prodOrderId')
        else:
            try:
                hallstore.storeSystem.buyProduct(appId, realGameId, userId,
                                                 clientId, prodOrderId, prodId,
                                                 prodCount)
            except TYStoreException, e:
                mo.setError(e.errorCode, e.message)
            except:
Ejemplo n.º 24
0
 def sendEnergyProgress(self, fishPool, fpMultiple, roomId, changed, fId=0):
     """
     发送轮盘进度
     """
     if not self._enable(fishPool, fpMultiple):
         return
     fishPool = str(fishPool)
     pwData = self._getData(fishPool, fpMultiple)
     mo = MsgPack()
     mo.setCmd("prize_wheel_progress")
     mo.setResult("gameId", FISH_GAMEID)
     mo.setResult("userId", self.userId)
     mo.setResult("roomId", roomId)
     mo.setResult("fId", fId)
     mo.setResult("progressPct", self._getEnergyPct(fishPool, fpMultiple))
     mo.setResult("state", pwData[PWValueSlot.STATE])
     mo.setResult("progressChanged", changed)
     mo.setResult("curRemainTimes", pwData[PWValueSlot.SPINTIMES])
     GameMsg.sendMsg(mo, self.userId)
     if ftlog.is_debug():
         ftlog.debug("prize_wheel, userId =", self.userId, "fishPool =",
                     fishPool, "fpMultiple =", fpMultiple, "mo =", mo)
Ejemplo n.º 25
0
def takeNewbie7DaysGift(userId, clientId, idx):
    """
    领取7日礼包奖励
    """
    isIn, roomId, tableId, seatId = util.isInFishTable(userId)
    if isIn:
        mo = MsgPack()
        mo.setCmd("table_call")
        mo.setParam("action", "newbie_7_gift_take")
        mo.setParam("gameId", FISH_GAMEID)
        mo.setParam("clientId", clientId)
        mo.setParam("userId", userId)
        mo.setParam("idx", idx)
        mo.setParam("roomId", roomId)
        mo.setParam("tableId", tableId)
        mo.setParam("seatId", seatId)
        router.sendTableServer(mo, roomId)
        return
    level = util.getActivityCheckLevel(userId)
    fireCount = gamedata.getGameAttrJson(userId, FISH_GAMEID,
                                         GameData.fireCount)
    takeGiftRewards(userId, clientId, idx, fireCount, level)
Ejemplo n.º 26
0
def getUpdateInfo(gameId, userId, clientId, version, updateVersion):
    global _updatesMap

    mo = MsgPack()
    mo.setCmd('game')
    mo.setResult('action', 'get_game_update_info')
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    mo.setResult('clientId', clientId)

    updates = _doGetUpdateInfo(gameId, version, updateVersion)

    if ftlog.is_debug():
        ftlog.debug('hall_game_update.getUpdateInfo gameId:', gameId,
                    ' userId:', userId, ' clientId:', clientId, ' version:',
                    version, ' updateVersion:', updateVersion, ' updates:',
                    updates)

    mo.setResult('updates', updates)
    router.sendToUser(mo, userId)

    return updates
Ejemplo n.º 27
0
    def doHallSigns(self):
        msg = runcmd.getMsgPack()
        ftlog.debug('msg=', msg)
        gameId = msg.getParam("gameId")
        userId = msg.getParam("userId")

        msgRes = MsgPack()
        msgRes.setCmd('m_signs')
        msgRes.setResult('gameId', gameId)
        msgRes.setResult('userId', userId)
        signs = {}
        for roomdef in gdata.roomIdDefineMap().values():
            if roomdef.shadowId == 0 and roomdef.configure.get('ismatch'):
                roomId = roomdef.roomId
                issignin = daobase.executeTableCmd(roomId, 0, 'SISMEMBER',
                                                   'signs:' + str(roomId),
                                                   userId)
                if issignin:
                    signs[roomdef.bigRoomId] = 1

        msgRes.setResult('signs', signs)
        router.sendToUser(msgRes, userId)
Ejemplo n.º 28
0
 def userReconnect(self, table, seat):
     '''
     用户坐下
     '''
     try:
         msg = MsgPack()
         msg.setCmd('table_manage')
         msg.setParam('action', 'm_user_reconn')
         msg.setParam('gameId', table.gameId)
         msg.setParam('matchId', table.group.area.matchId)
         msg.setParam('roomId', table.roomId)
         msg.setParam('tableId', table.tableId)
         msg.setParam('userId', seat.player.userId)
         msg.setParam('seatId', seat.seatId)
         msg.setParam('ccrc', table.ccrc)
         router.sendTableServer(msg, table.roomId)
     except:
         self._logger.error('TableControllerDizhu.userReconnect',
                            'groupId=', table.group.groupId, 'tableId=',
                            table.tableId, 'userId=',
                            seat.player.userId if seat.player else 0,
                            'userIds=', table.getUserIdList())
def sendHallGameList2_handler(cls, userId, gameId, clientId):
    from poker.util import strutil
    _, clientVer, _ = strutil.parseClientId(clientId)
    template = hallgamelist2.getUITemplate(gameId, userId, clientId)
    if template is None:
        ftlog.exception('sendHallGameList2 error, please check clientId:',
                        clientId)
    else:
        _games, pages, innerGames = HallHelper.encodeHallUITemplage2(
            gameId, userId, clientId, template)
        from hall.servers.util import gamelistipfilter
        _games, pages, innerGames = gamelistipfilter.filtergamelist(
            clientVer, _games, pages, innerGames, userId, clientId)
        mo = MsgPack()
        mo.setCmd('hall_game_list')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('games', _games)
        mo.setResult('pages', pages)
        if clientVer >= 3.76:
            mo.setResult('innerGames', innerGames)
        router.sendToUser(mo, userId)
Ejemplo n.º 30
0
def sendFishCheckinInfo(userId, continueWindow=0):
    """
    发送签到详情
    :param continueWindow: 0:用户点击签到请求 1:客户端登录时自动请求
    """
    if util.isVersionLimit(userId):
        return
    checkinDay = gamedata.getGameAttrInt(userId, FISH_GAMEID,
                                         GameData.checkinDay)
    isCheckin = weakdata.getDayFishData(userId, "isCheckin", 0)
    code = 1
    if (continueWindow and isCheckin):
        code = 2
    elif util.isFinishAllNewbieTask(userId):
        code = 0
        if not isCheckin:
            if checkinDay == len(config.getCheckinConf()):
                checkinDay = 0
                gamedata.setGameAttr(userId, FISH_GAMEID, GameData.checkinDay,
                                     checkinDay)
            module_tip.addModuleTipEvent(userId, "checkin", checkinDay)
    mo = MsgPack()
    mo.setCmd("fishCheckin")
    mo.setResult("gameId", FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("loginDays",
                 gamedata.getGameAttr(userId, FISH_GAMEID, GameData.loginDays))
    mo.setResult("day", checkinDay if isCheckin else checkinDay + 1)
    mo.setResult("checkin", isCheckin)
    rewards = []
    for rewardConf in config.getCheckinConf().values():
        if util.isChestRewardId(rewardConf["shareReward"]["name"]):
            rewards.append(rewardConf["shareReward"])
        else:
            rewards.append(rewardConf["normalReward"])
    mo.setResult("rewards", rewards)
    mo.setResult("continueWindow", continueWindow)
    mo.setResult("code", code)
    router.sendToUser(mo, userId)