Пример #1
0
def addUserScore(userId, rankId, issueNum, score=0):

    issueNum = str(issueNum)

    userData = dizhu_score_ranking.loadUserData(userId, rankId, issueNum)
    if userData:
        ftlog.info('hotfix.addUserScore', 'userId=', userId, 'rankId=', rankId,
                   'issueNum=', issueNum, 'score=', score, 'userData=',
                   userData.toDict())

        try:
            score = int(score)
        except ValueError, e:
            ftlog.warn('hotfix.addUserScore.valueError', 'userId=', userId,
                       'rankId=', rankId, 'issueNum=', issueNum, 'err=', e)
            return

        userData.score += score
        userData.score = max(0, userData.score)

        ret = dizhu_score_ranking.saveUserData(userData)
        rankingDefine = dizhu_score_ranking.getConf().findRankingDefine(rankId)
        rankLimit = rankingDefine.rankLimit if rankingDefine else 3000
        dizhu_score_ranking.insertRanklist(rankId, issueNum, userData.userId,
                                           userData.score, rankLimit)

        ftlog.info('hotfix.addUserScore.over', 'userId=', userId, 'rankId=',
                   rankId, 'issueNum=', issueNum, 'score=', score, 'userData=',
                   userData.toDict())
Пример #2
0
    def _doGetNotReceiveReward(cls, userId, clientId=None):
        mo = MsgPack()
        mo.setCmd('dizhu')
        mo.setResult('action', 'score_reward_tip')

        curIssueNum = dizhu_score_ranking.calcIssueNum()
        mo.setResult('curIssn', curIssueNum)

        rankingConf = dizhu_score_ranking.getConf()
        for rankId, rankingDefine in rankingConf.rankingDefineMap.iteritems():
            if not rankingDefine:
                raise TYBizException(-1, '未知的排行榜')

            rankingInfo = dizhu_score_ranking.loadRankingInfo(rankId)
            hisotryItems = cls.pickHistoryItems(rankingInfo, curIssueNum)
            from poker.entity.dao import sessiondata
            clientId = clientId or sessiondata.getClientId(userId)
            notReceive = cls.buildNotReceived(rankingDefine.rankId,
                                              hisotryItems, userId, clientId)
            if notReceive:
                mo.setResult('rankId', rankId)
                mo.setResult('notReceive', notReceive)
                break

        return mo
Пример #3
0
def doDelUserScore(self, userId, rankId, issueNum, score):
    """
    :param userId: 玩家userId
    :param rankId: 排行榜类型 '0' 万元争霸赛 '1' 千元擂台赛
    :param issueNum: 排行榜期号 格式:20170807
    :param score: 扣除的积分数量
    :return: 返回处理结果信息 
    """
    ret = 0
    if len(issueNum) != 8:
        return self.makeResponse({
            'del_user_score_gdss issueNum Error. rankId': rankId,
            'issueNum=': issueNum
        })

    issueNum = str(issueNum)

    userData = dizhu_score_ranking.loadUserData(userId, rankId, issueNum)
    if userData:
        ftlog.info('del_user_score_gdss del scoreRanking userData=',
                   userData.toDict())

        score = max(0, score)
        userData.score -= score
        userData.score = max(0, userData.score)

        ret = dizhu_score_ranking.saveUserData(userData)
        rankingDefine = dizhu_score_ranking.getConf().findRankingDefine(rankId)
        rankLimit = rankingDefine.rankLimit if rankingDefine else 3000
        dizhu_score_ranking.insertRanklist(rankId, issueNum, userData.userId,
                                           userData.score, rankLimit)

        ftlog.info(
            'del_user_score_gdss del scoreRanking userData success. userData=',
            userData.toDict())
    else:
        ftlog.info('del_user_score_gdss no userData in rankingList userId=',
                   userId, 'rankId=', rankId, 'issueNum=', issueNum)
        return self.makeResponse({
            'init_user_data_gdss no userData in rankingList userId=':
            userId,
            'rankId':
            rankId,
            'issueNum=':
            issueNum
        })

    return self.makeResponse({
        'del_user_score_gdss del scoreRanking userData success. userData=':
        userData.toDict(),
        'execute over ret=':
        ret
    })
Пример #4
0
    def buildTableInfoResp(self, seat, isRobot):
        mp = DizhuTableProtoCommonBase.buildTableInfoResp(self, seat, isRobot)
        winstreak = {}
        playerTask = self.room.winStreakTask.getPlayerTask(seat.player)
        cur = playerTask.progress if playerTask else 0
        if cur >= len(self.room.winStreakTask.taskList):
            cur = 0
        winstreak['cur'] = cur
        winstreak['maxWinStreak'] = playerTask.maxWinStreak if playerTask else 0
        rewards = []
        for task in self.room.winStreakTask.taskList:
            rewards.append(task.reward)
        winstreak['rewards'] = rewards
        winstreak['imgs'] = self.room.winStreakTask.taskPictures
        mp.setResult('winstreak', winstreak)

        # 房间属于哪个积分榜
        scoreRankingConf = dizhu_score_ranking.getConf()
        bigRoomId = gdata.getBigRoomId(self.roomId)
        rankDef = scoreRankingConf.rankDefineForRoomId(bigRoomId)
        if not scoreRankingConf.closed and rankDef and rankDef.switch == 1:
            mp.setResult('scoreboardFlag', rankDef.rankId)

        taskInfo = task_remote.getNewbieTaskInfo(DIZHU_GAMEID, seat.userId, seat.player.playShare.totalCount)
        if taskInfo is not None:
            mp.setResult('newertask', taskInfo)

        winSteakBuff, loseStreakBuff = dizhu_giftbag.checkUserGiftBuff(seat.player.userId)
        if winSteakBuff:
            mp.setResult('buff', 'winSteakBuff')
        elif loseStreakBuff:
            mp.setResult('buff', 'loseStreakBuff')

        dailyPlayCount = new_table_remote.doGetUserDailyPlayCount(seat.userId, DIZHU_GAMEID)
        mp.setResult('dailyPlay', dailyPlayCount)
        if ftlog.is_debug():
            ftlog.debug('normalbase.tableproto.buildTableInfoResp.checkUserGiftBuff',
                        'bigRoomId=', bigRoomId,
                        'winSteakBuff=', winSteakBuff,
                        'loseStreakBuff=', loseStreakBuff,
                        'mp=', mp)
        return mp
def punishUser(userIdList, rankId, issueNum):
    for userId in userIdList:
        oldUserData = dizhu_score_ranking.loadUserData(userId, rankId,
                                                       issueNum)
        if oldUserData:
            ftlog.info('punish cheat user in scoreRanking old_user_info=',
                       oldUserData.toDict())

            userData = dizhu_score_ranking.UserData(userId, rankId, issueNum)
            dizhu_score_ranking.saveUserData(userData)
            rankingDefine = dizhu_score_ranking.getConf().findRankingDefine(
                rankId)
            dizhu_score_ranking.insertRanklist(
                rankId, issueNum, userId, userData.score,
                max(rankingDefine.rankLimit, 500))

            ftlog.info('punish cheat user in scoreRanking userId=', userId,
                       'rankId=', rankId, 'issueNum=', issueNum)
        else:
            ftlog.info('punish cheat user in scoreRanking userId=', userId,
                       'rankId=', rankId, 'issueNum=', issueNum,
                       'no ScoreRanking Data')
    ftlog.info('punish cheat user in scoreRanking. over')
Пример #6
0
    def buildTableInfoResp(self, seat, isRobot):
        roomConf = seat.player.mixConf
        try:
            if not roomConf:
                ftlog.warn('DizhuTableProtoMix.buildTableInfoResp', 'userId=',
                           seat.player.userId, 'clientId=',
                           seat.player.clientId, 'tableId=', seat.tableId,
                           'seatId=', seat.seatId, 'mixId=', seat.player.mixId)
        except:
            pass
        tableConf = roomConf.get('tableConf')
        _, clientVer, _ = strutil.parseClientId(seat.player.clientId)
        mp = self.buildTableMsgRes('table_info')
        playMode = self.table.playMode.name
        if clientVer <= 3.7:
            if playMode == playmodes.PLAYMODE_HAPPY or playMode == playmodes.PLAYMODE_123:
                playMode = 'normal'  # FIX, 客户端happy和123都是normal, grab=1就是欢乐
        mp.setResult('playMode', playMode)
        mp.setResult('isrobot', isRobot)
        mp.setResult('roomLevel', roomConf.get('roomLevel', 1))
        mp.setResult('roomName', roomConf.get('name', ''))
        mp.setResult('isMatch', self.table.room.isMatch)
        mp.setResult('info', self.buildTableBasicInfo())
        mp.setResult('config', self.buildTableBasicConfig(seat.player))
        mp.setResult('stat', self.buildTableStatusInfoForSeat(seat))
        mp.setResult('myCardNote', self.buildTableCardNote(seat))
        mp.setResult('betpoolClose', 1)
        if self.table.gameRound:
            mp.setResult('roundId', self.table.gameRound.roundId)

        _, itemCount = treasurebox.getTreasureRewardItem(
            self.gameId,
            seat.player.mixConf.get('roomId') or self.bigRoomId)

        zeroSumFlag = False
        currentBaseScore = seat.player.mixConf.get('tableConf').get('baseScore') or \
        seat.player.mixConf.get('tableConf').get('basebet') * seat.player.mixConf.get('tableConf').get('basemulti') * seat.player.mixConf.get('roomMutil')
        if self.table.room.roomConf.get('zeroSumFlag', 0) == 1:
            zeroSumFlag = True

        for i, tseat in enumerate(self.table.seats):
            seatinfo = self.buildSeatInfo(seat, tseat)
            if tseat.player:
                seatinfo.update(tseat.player.datas)
                # 记牌器数量
                seatinfo['cardNote'] = tseat.player.getCardNoteCount()
                # 当前table的奖券任务奖励
                seatinfo['count'] = itemCount
                # 比赛分
                seatinfo['mscore'] = tseat.player.score
                tseat.player.cleanDataAfterFirstUserInfo()

                # 动态修改金币数量,过滤版本
                if zeroSumFlag:
                    tseatBaseScore = tseat.player.mixConf.get('tableConf').get('baseScore') or \
                                     tseat.player.mixConf.get('tableConf').get('basebet') * tseat.player.mixConf.get('tableConf').get('basemulti') * tseat.player.mixConf.get('roomMutil')
                    tseatBuyinChip = seatinfo['buyinChip']
                    seatinfo['buyinChip'] = int(
                        float(currentBaseScore) / tseatBaseScore *
                        tseatBuyinChip)

            seatinfo['uid'] = tseat.userId
            mp.setResult('seat%s' % (i + 1), seatinfo)

        # 处理记牌器
        if seat.player and seat.player.getCardNoteCount() < 1:
            # 记牌器开启的配置
            cardNoteChip = tableConf.get('cardNoteChip', 0)
            cardNoteDiamod = tableConf.get('cardNoteDiamond', 0)
            cardNote = dizhuconf.getCardNoteTips(seat.player.userId,
                                                 seat.player.chip,
                                                 seat.player.clientId,
                                                 cardNoteChip, cardNoteDiamod)
            mp.setResult('cardNote', cardNote)

        if not self.table.room.isMatch:
            player = seat.player
            if player and player.userId:
                # 商品信息 TODO
                mp.setResult(
                    'products',
                    tablepay.getProducts(
                        self.gameId, player.userId,
                        seat.player.mixConf.get('roomId') or self.bigRoomId,
                        player.clientId))
                # 互动表情
                emojiConf = emoji.getEmojiConf(
                    self.gameId,
                    seat.player.mixConf.get('roomId') or self.bigRoomId,
                    seat.player.datas.get('vipInfo', {}).get('level', 0))
                if emojiConf:
                    mp.setResult('smiliesConf', emojiConf)

        winstreak = {}
        mixTaskList = self.room.winStreakTask.taskListMap.get(
            seat.player.mixId)
        playerTask = self.room.winStreakTask.getPlayerTask(seat.player)
        cur = playerTask.progress if playerTask else 0
        if cur >= len(mixTaskList):
            cur = 0
        winstreak['cur'] = cur
        rewards = []

        for task in mixTaskList:
            rewards.append(task.reward)
        winstreak['rewards'] = rewards
        winstreak['imgs'] = self.room.winStreakTask.taskPictures
        mp.setResult('winstreak', winstreak)

        # 房间属于哪个积分榜
        scoreRankingConf = dizhu_score_ranking.getConf()
        rankDef = scoreRankingConf.rankDefineForRoomId(self.bigRoomId)
        if not scoreRankingConf.closed and rankDef and rankDef.switch == 1:
            mp.setResult('scoreboardFlag', rankDef.rankId)

        taskInfo = task_remote.getNewbieTaskInfo(
            DIZHU_GAMEID, seat.userId, seat.player.playShare.totalCount)
        if taskInfo is not None:
            mp.setResult('newertask', taskInfo)

        winSteakBuff, loseStreakBuff = dizhu_giftbag.checkUserGiftBuff(
            seat.player.userId)
        if winSteakBuff:
            mp.setResult('buff', 'winSteakBuff')
        elif loseStreakBuff:
            mp.setResult('buff', 'loseStreakBuff')

        dailyPlayCount = new_table_remote.doGetUserDailyPlayCount(
            seat.userId, DIZHU_GAMEID)
        mp.setResult('dailyPlay', dailyPlayCount)
        if ftlog.is_debug():
            ftlog.debug(
                'dizhu.mix.tableproto.buildTableInfoResp.checkUserGiftBuff',
                'winSteakBuff=', winSteakBuff, 'loseStreakBuff=',
                loseStreakBuff, 'mp=', mp)
        return mp