예제 #1
0
def checkSetMedal(gameId, userId, baseScore, isGameStart, winchip):
    winchip = 0 if isGameStart else winchip

    winrate, oldLevel = gamedata.getGameAttrs(userId, gameId,
                                              ['winrate', 'level'], False)
    winrate = strutil.loads(winrate, ignoreException=True, execptionValue={})
    if winrate is None:
        winrate = {}
    if winchip >= 0 or isGameStart:
        _processGamePlayWinTimes(winrate, isGameStart)
    oldLevel = strutil.parseInts(oldLevel)
    deltaExp = 0
    if winchip > 0 or isGameStart:
        deltaExp = _calUserDetalExp(winchip, baseScore)

    exp = userdata.incrExp(userId, deltaExp)
    explevel, _ = gameexp.getLevelInfo(gameId, exp)
    gamedata.setGameAttrs(userId, gameId, ['winrate', 'level'],
                          [strutil.dumps(winrate), explevel])
    if oldLevel != explevel:
        TYGame(gameId).getEventBus().publishEvent(
            UserLevelGrowEvent(gameId, userId, oldLevel, explevel))
    if isGameStart:
        # 广告商通知
        pcount = commconf.getAdNotifyPlayCount(gameId)
        if pcount > 0 and winrate.get('pt', 0) == pcount:
            sdkclient.adNotifyCallBack(gameId, userId)
    return exp, deltaExp, winrate
예제 #2
0
    def _settlementForGameOver(self, gameResult):
        roomId = gameResult.gameRound.table.roomId
        tableId = gameResult.gameRound.table.tableId
        roundNum = gameResult.gameRound.roundNum
        winUserId = gameResult.gameRound.firstWinSeat.userId
        bombCount = gameResult.gameRound.bombCount
        chuntian = 2 if gameResult.gameRound.isChuntian else 1
        playMode = gameResult.gameRound.table.playMode.name
        topCardList = gameResult.gameRound.topValidCards.cards

        for sst in gameResult.seatStatements:
            # 服务费
            userId = sst.seat.userId
            clientId = sst.seat.player.clientId
            sst.seat.player.score = sst.final
            finalTableChip, finalChip, expInfo, skillScoreInfo \
                = new_table_winlose.doTableWinloseUT(userId, roomId, tableId, roundNum, clientId,
                                                     sst.isWin, sst.winStreak, winUserId, sst == gameResult.dizhuStatement,
                                                     sst.fee, sst.cardNoteFee, sst.delta, sst.systemPaid, sst.winnerTax,
                                                     gameResult.gameRound.baseScore, sst.seat.status.totalMulti,
                                                     bombCount, chuntian, gameResult.slam, playMode, topCardList, fixedFee=sst.fixedFee)
            ftlog.info(
                'SettlementPolicyNormal._settlementForGameOver', 'roomId=',
                gameResult.gameRound.table.roomId, 'tableId=',
                gameResult.gameRound.table.tableId, 'roundId=',
                gameResult.gameRound.roundId, 'cardNoteFee=', sst.cardNoteFee,
                'fee=', sst.fee, 'delta=', sst.delta, 'winnerTax=',
                sst.winnerTax, 'baseScore=', gameResult.gameRound.baseScore,
                'totalMulti=', sst.seat.status.totalMulti, 'sstFinal=',
                sst.final, 'userId=', userId, 'fixedFee=', sst.fixedFee,
                'finalTableChip=', finalTableChip, 'finalChip=', finalChip)
            sst.skillscoreInfo = skillScoreInfo
            sst.seat.player.chip = finalChip
            sst.seat.player.score = sst.final = finalTableChip
            explevel, title = gameexp.getLevelInfo(DIZHU_GAMEID, expInfo[0])
            nextExp = gameexp.getNextLevelExp(DIZHU_GAMEID, explevel)
            sst.expInfo = [explevel, expInfo[0], expInfo[1], nextExp, title]
            pt = sst.seat.player.datas.get('plays', 0)
            sst.seat.player.datas['plays'] = pt + 1
            if sst.isWin:
                wt = sst.seat.player.datas.get('wins', 0)
                sst.seat.player.datas['wins'] = wt + 1
예제 #3
0
    def _settlementForGameOver(self, gameResult):
        roomId = gameResult.gameRound.table.roomId
        tableId = gameResult.gameRound.table.tableId
        roundNum = gameResult.gameRound.roundNum
        winUserId = gameResult.gameRound.firstWinSeat.userId
        bombCount = gameResult.gameRound.bombCount
        chuntian = 2 if gameResult.gameRound.isChuntian else 1
        playMode = gameResult.gameRound.table.playMode.name
        topCardList = gameResult.gameRound.topValidCards.cards

        outCardTimes = []
        for index, sst in enumerate(gameResult.seatStatements):
            seatStatus = sst.seat.status
            outCardTimes.append(seatStatus.outCardTimes)
        maxOutCardTimes = max(outCardTimes)

        for index, sst in enumerate(gameResult.seatStatements):
            # 服务费
            userId = sst.seat.userId
            clientId = sst.seat.player.clientId
            sst.seat.player.score = sst.final
            mixConfRoomId = sst.seat.player.mixConf.get('roomId')

            assist = 0
            validMaxOutCard = 0
            seatStatus = sst.seat.status
            if sst != gameResult.dizhuStatement and len(seatStatus.cards) != 0 and sst.isWin:
                assist = 1
            if seatStatus.outCardTimes == maxOutCardTimes and sst.isWin:
                validMaxOutCard = 1

            finalTableChip, finalChip, expInfo, skillScoreInfo \
                = new_table_winlose.doTableWinloseUT(userId, roomId, tableId, roundNum, clientId,
                                                     sst.isWin, sst.winStreak, winUserId, sst == gameResult.dizhuStatement,
                                                     sst.fee, sst.cardNoteFee, sst.delta, sst.systemPaid, sst.winnerTax,
                                                     gameResult.gameRound.baseScores[index], sst.seat.status.totalMulti,
                                                     bombCount, chuntian, gameResult.slams[index], playMode, topCardList,
                                                     mixConfRoomId=mixConfRoomId, fixedFee=sst.fixedFee, assist=assist,
                                                     outCardSeconds=seatStatus.outCardSeconds, validMaxOutCard=validMaxOutCard)
            ftlog.info('SettlementPolicyMix._settlementForGameOver',
                       'roomId=', gameResult.gameRound.table.roomId,
                       'tableId=', gameResult.gameRound.table.tableId,
                       'roundId=', gameResult.gameRound.roundId,
                       'cardNoteFee=', sst.cardNoteFee,
                       'mixConfRoomId=', mixConfRoomId,
                       'fee=', sst.fee,
                       'fixedFee=', sst.fixedFee,
                       'delta=', sst.delta,
                       'winnerTax=', sst.winnerTax,
                       'baseScore=', gameResult.gameRound.baseScores[index],
                       'totalMulti=', sst.seat.status.totalMulti,
                       'sstFinal=', sst.final,
                       'userId=', userId,
                       'winStreak=', gamedata.getGameAttrInt(sst.seat.player.userId, DIZHU_GAMEID, 'winstreak'),
                       'finalTableChip=', finalTableChip,
                       'finalChip=', finalChip)
            sst.skillscoreInfo = skillScoreInfo
            sst.seat.player.chip = finalChip
            sst.seat.player.score = sst.final = finalTableChip
            explevel, title = gameexp.getLevelInfo(DIZHU_GAMEID, expInfo[0])
            nextExp = gameexp.getNextLevelExp(DIZHU_GAMEID, explevel)
            sst.expInfo = [explevel, expInfo[0], expInfo[1], nextExp, title]
            pt = sst.seat.player.datas.get('plays', 0)
            sst.seat.player.datas['plays'] = pt + 1
            sst.winStreak = gamedata.getGameAttrInt(sst.seat.player.userId, DIZHU_GAMEID, 'winstreak')
            if sst.isWin:
                wt = sst.seat.player.datas.get('wins', 0)
                sst.seat.player.datas['wins'] = wt + 1
예제 #4
0
    def _settlementForGameOver(self, gameResult):
        roomId = gameResult.gameRound.table.roomId
        tableId = gameResult.gameRound.table.tableId
        roundNum = gameResult.gameRound.roundNum
        winUserId = gameResult.gameRound.firstWinSeat.userId
        bombCount = gameResult.gameRound.bombCount
        chuntian = 2 if gameResult.gameRound.isChuntian else 1
        playMode = gameResult.gameRound.table.playMode.name
        topCardList = gameResult.gameRound.topValidCards.cards

        outCardTimes = []
        for sst in gameResult.seatStatements:
            seatStatus = sst.seat.status
            outCardTimes.append(seatStatus.outCardTimes)
        maxOutCardTimes = max(outCardTimes)
        
        for sst in gameResult.seatStatements:
            userId = sst.seat.userId
            clientId = sst.seat.player.clientId

            assist = 0
            validMaxOutCard = 0
            seatStatus = sst.seat.status
            if sst != gameResult.dizhuStatement and len(seatStatus.cards) != 0 and sst.isWin:
                assist = 1
            if seatStatus.outCardTimes == maxOutCardTimes and sst.isWin:
                validMaxOutCard = 1

            finalChip, expInfo, skillScoreInfo \
                = new_table_winlose.doFreeTableWinloseUT(userId, roomId, tableId, roundNum, clientId,
                                                         winUserId, sst.isWin, sst.winStreak, sst == gameResult.dizhuStatement,
                                                         sst.delta, sst.final, gameResult.gameRound.baseScore,
                                                         sst.seat.status.totalMulti, bombCount, chuntian, gameResult.slam,
                                                         playMode, topCardList, assist=assist, validMaxOutCard=validMaxOutCard)
            ftlog.info('SettlementPolicyFree._settlementForGameOver',
                       'roomId=', gameResult.gameRound.table.roomId,
                       'tableId=', gameResult.gameRound.table.tableId,
                       'roundId=', gameResult.gameRound.roundId,
                       'winStreak=', sst.winStreak,
                       'fee=', sst.fee,
                       'delta=', sst.delta,
                       'winnerTax=', sst.winnerTax,
                       'baseScore=', gameResult.gameRound.baseScore,
                       'totalMulti=', sst.seat.status.totalMulti,
                       'sstFinal=', sst.final,
                       'userId=', userId,
                       'finalChip=', finalChip)
            sst.skillscoreInfo = skillScoreInfo
            sst.seat.player.chip = finalChip
            sst.seat.player.score = sst.final
            explevel, title = gameexp.getLevelInfo(DIZHU_GAMEID, expInfo[0])
            nextExp = gameexp.getNextLevelExp(DIZHU_GAMEID, explevel)
            sst.expInfo = [explevel, expInfo[0], expInfo[1], nextExp, title]
            pt = sst.seat.player.datas.get('plays', 0)
            sst.seat.player.datas['plays'] = pt + 1
            if sst.isWin:
                wt = sst.seat.player.datas.get('wins', 0)
                sst.seat.player.datas['wins'] = wt + 1
            sst.seat.player.score = sst.final
        ftlog.info('SettlementPolicyFree._settlementForGameOver',
                   'roomId=', gameResult.gameRound.table.roomId,
                   'tableId=', gameResult.gameRound.table.tableId,
                   'roundId=', gameResult.gameRound.roundId,
                   'infos=', [(sst.seat.userId, sst.seat.player.score, sst.delta) for sst in gameResult.seatStatements])