Exemplo n.º 1
0
def _moveHall51DataBack(userId, gameId, clientId):
    try:
        gameId = HALL_ID
        flag = gamedata.getGameAttrInt(userId, gameId, 'userChipMoveGame')
        ftlog.info('_moveHall51DataBack', userId, gameId, flag)
        if flag > 0:
            # 当前用户登录过HALL51
            chip, exp, charm, coupon = gamedata.getGameAttrs(
                userId, gameId, ['chip', 'exp', 'charm', 'coupon'])
            chip, exp, charm, coupon = strutil.parseInts(
                chip, exp, charm, coupon)
            ftlog.info('_moveHall51DataBack data->', userId, gameId, chip, exp,
                       charm, coupon)
            if charm > 0:
                userdata.incrCharm(userId, charm)
            if exp > 0:
                userdata.incrExp(userId, exp)
            if coupon > 0:
                trueDelta, finalCount = userchip.incrCoupon(
                    userId, gameId, coupon, userchip.ChipNotEnoughOpMode.NOOP,
                    userchip.EVENT_NAME_SYSTEM_REPAIR, 0, clientId)
                ftlog.info('_moveHall51DataBack data coupon->', userId, gameId,
                           coupon, trueDelta, finalCount)
            if chip > 0:
                trueDelta, finalCount = userchip.incrChip(
                    userId, gameId, chip, userchip.ChipNotEnoughOpMode.NOOP,
                    userchip.EVENT_NAME_SYSTEM_REPAIR, 0, clientId)
                ftlog.info('_moveHall51DataBack data chip->', userId, gameId,
                           chip, trueDelta, finalCount)
            gamedata.delGameAttrs(
                userId, gameId,
                ['chip', 'exp', 'charm', 'coupon', 'userChipMoveGame'])
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
    except:
        ftlog.error()
Exemplo n.º 2
0
def _checkSetMedal(userId, roomMutil, basebet, basemulti, isGameStart,
                   winchip):
    winchip = 0 if isGameStart else winchip

    winrate, oldLevel = gamedata.getGameAttrs(userId, DIZHU_GAMEID,
                                              ['winrate', 'level'], False)
    winrate = strutil.loads(winrate, ignoreException=True, execptionValue={})
    if winchip >= 0 or isGameStart:
        _processGamePlayWinTimes(winrate, isGameStart)

    oldLevel = strutil.parseInts(oldLevel)
    detalExp = 0
    if winchip > 0 or isGameStart:
        detalExp = _calUserDetalExp(winchip, roomMutil, basebet, basemulti)
    exp = userdata.incrExp(userId, detalExp)
    explevel = dizhuaccount.getExpLevel(exp)

    gamedata.setGameAttrs(userId, DIZHU_GAMEID, ['winrate', 'level'],
                          [strutil.dumps(winrate), explevel])
    if oldLevel != explevel:
        from dizhu.game import TGDizhu
        TGDizhu.getEventBus().publishEvent(
            UserLevelGrowEvent(DIZHU_GAMEID, userId, oldLevel, explevel))
    if isGameStart:
        # 广告商通知
        pcount = dizhuconf.getAdNotifyPlayCount()
        if pcount > 0 and winrate.get('pt', 0) == pcount:
            sdkclient.adNotifyCallBack(DIZHU_GAMEID, userId)
    nextExp = dizhuaccount.getGameUserNextExp(explevel)
    title = dizhuaccount.getGameUserTitle(explevel)
    return [explevel, exp, detalExp, nextExp, title]
Exemplo n.º 3
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
Exemplo n.º 4
0
    def doWinLose(cls, room, table, seatId, isTimeOutKill=False): # TODO:
        # 计算春天
        dizhuseatId = table.status.diZhu
        if seatId != dizhuseatId: 
            if table.seats[dizhuseatId - 1].outCardCount == 1:
                table.status.chuntian = 2
        else:
            s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN]
            s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN]
            if s1.outCardCount == 0 and s2.outCardCount == 0:
                table.status.chuntian = 2
                 
        # 翻倍计算 叫地主的倍数
        windoubles = table.status.callGrade
        # 炸弹倍数
        windoubles *= pow(2, table.status.bomb)
        # 春天倍数
        windoubles *= table.status.chuntian
        # 底牌倍数
        windoubles *= table.status.baseCardMulti
        # 明牌倍数
        windoubles *= table.status.show
         
        dizhuwin = 0
        if seatId == dizhuseatId:
            dizhuwin = 1
        if seatId == 0 : # 流局
            dizhuwin = 0
            windoubles = 1
        else:
            windoubles = abs(windoubles)
 
        userids = []
        detalChips = []
        seat_coin = []
        baseBetChip = table._match_table_info['baseChip']
        robot_card_count = [0] * len(table.seats)  # 每个座位
        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            userInfo = table._match_table_info['users'][x]
            userids.append(uid)
            if seatId == 0 : # 流局
                detalChip = -baseBetChip
            else:
                if dizhuwin :
                    if x + 1 == dizhuseatId :
                        detalChip = baseBetChip + baseBetChip
                    else:
                        detalChip = -baseBetChip
                else:
                    if x + 1 == dizhuseatId :
                        detalChip = -baseBetChip - baseBetChip
                    else:
                        detalChip = baseBetChip
            detalChip *= windoubles
            detalChips.append(detalChip)
            seat_coin.append(userInfo['score'] + detalChip)
            robot_card_count[x] = table.seats[x].robotCardCount
            ftlog.info('dizhu.game_win userId=', uid, 'roomId=', room.roomId, 'tableId=', table.tableId, 'delta=', detalChip)
        
        ftlog.debug('doWinLose->after room fee->robot_card_count=', robot_card_count)
        punish.Punish.doWinLosePunish(table.runConfig.punishCardCount, table.runConfig.isMatch,
                                      seat_coin, detalChips, robot_card_count)
        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            userInfo = table._match_table_info['users'][x]
            userInfo['score'] = seat_coin[x]
        
        # 返回当前Table的game_win
        moWin = MsgPack()
        moWin.setCmd('table_call')
        moWin.setResult('action', 'game_win')
        moWin.setResult('isMatch', 1)
        moWin.setResult('gameId', table.gameId)
        moWin.setResult('roomId', table.roomId)
        moWin.setResult('tableId', table.tableId)
        moWin.setResult('stat', table.status.toInfoDictExt())
        moWin.setResult('dizhuwin', dizhuwin)
        if seatId == 0:
            moWin.setResult('nowin', 1)
        moWin.setResult('slam', 0)
        moWin.setResult('cards', [seat.cards for seat in table.seats])
 
        roundId = table.gameRound.number
        table.clear(userids)
         
        for x in xrange(len(userids)):
            uid = userids[x]
            mrank = 3
            mtableRanking = 3
            moWin.setResult('seat' + str(x + 1), [detalChips[x], seat_coin[x], 0, 0, 0, 0, mrank, mtableRanking])
             
            #增加经验
            exp = userdata.incrExp(uid, 20)
            explevel = dizhuaccount.getExpLevel(exp)
            gamedata.setGameAttr(uid, table.gameId, 'level', explevel)
            ftlog.debug('AsyncUpgradeHeroMatch.doWinLoseTable add 20 exp, tootle', exp, 'level', explevel)
             
        table.gamePlay.sender.sendToAllTableUser(moWin)
         
        # 发送给match manager
        users = []
        for x in xrange(len(userids)):
            user = {}
            user['userId'] = userids[x]
            user['deltaScore'] = int(detalChips[x])
            user['seatId'] = x + 1
            user['score'] = seat_coin[x]
            users.append(user)
         
        mnr_msg = MsgPack()
        mnr_msg.setCmd('room')
        mnr_msg.setParam('action', 'm_winlose')
        mnr_msg.setParam('gameId', table.gameId)
        mnr_msg.setParam('roomId', table.room.ctrlRoomId)
        mnr_msg.setParam('tableId', table.tableId)
        mnr_msg.setParam('users', users)
            
        # 记录游戏winlose
        try:
            for u in users:
                table.room.reportBiGameEvent("TABLE_WIN", u['userId'], table.roomId, table.tableId, roundId, u['deltaScore'], 0, 0, [], 'table_win')
#                 cls.report_bi_game_event(TyContext.BIEventId.TABLE_WIN, u['userId'], table._rid, table._id, table._roundId, u['deltaScore'], 0, 0, [], 'table_win')                
        except:
            if ftlog.is_debug():
                ftlog.exception()
        router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
Exemplo n.º 5
0
    def doWinLose(cls, room, table, seatId, isTimeOutKill=False): # TODO:
        if not table._match_table_info:
            ftlog.warn('GroupMatch.doWinLoseTable roomId=', room.roomId,
                       'tableId=', table.tableId,
                       'seatId=', seatId,
                       'isTimeOutKill=', isTimeOutKill,
                       'err=', 'not matchTableInfo')
            return

        if ftlog.is_debug():
            ftlog.debug('GroupMatch.doWinLose roomId=', room.roomId,
                        'tableId=', table.tableId,
                        'seatId=', seatId,
                        'isTimeOutKill=', isTimeOutKill,
                        'stageReward=', table.group.stageConf.conf.get('stageReward'))
        
        # 计算春天
        dizhuseatId = table.status.diZhu
        if seatId != dizhuseatId: 
            if table.seats[dizhuseatId - 1].outCardCount == 1:
                table.status.chuntian = 2
        else:
            s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN]
            s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN]
            if s1.outCardCount == 0 and s2.outCardCount == 0:
                table.status.chuntian = 2
                 
        # 翻倍计算 叫地主的倍数
        windoubles = table.status.callGrade
        # 炸弹倍数
        windoubles *= pow(2, table.status.bomb)
        # 春天倍数
        windoubles *= table.status.chuntian
        # 底牌倍数
        windoubles *= table.status.baseCardMulti
        # 明牌倍数
        windoubles *= table.status.show
         
        dizhuwin = 0
        if seatId == dizhuseatId:
            dizhuwin = 1
        if seatId == 0 : # 流局
            dizhuwin = 0
            windoubles = 1
        else:
            windoubles = abs(windoubles)
 
        userids = []
        detalChips = []
        seat_coin = []
        baseBetChip = table._match_table_info['mInfos']['basescore']
        robot_card_count = [0] * len(table.seats)  # 每个座位
        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            userids.append(uid)
            if seatId == 0 : # 流局
                detalChip = -baseBetChip
            else:
                if dizhuwin :
                    if x + 1 == dizhuseatId :
                        detalChip = baseBetChip + baseBetChip
                    else:
                        detalChip = -baseBetChip
                else:
                    if x + 1 == dizhuseatId :
                        detalChip = -baseBetChip - baseBetChip
                    else:
                        detalChip = baseBetChip
            detalChip *= windoubles
            detalChips.append(detalChip)
            seat_coin.append(table._match_table_info['mInfos']['scores'][x] + detalChip)
            robot_card_count[x] = table.seats[x].robotCardCount
            ftlog.info('dizhu.game_win userId=', uid, 'roomId=', room.roomId, 'tableId=', table.tableId, 'delta=', detalChip)
        
        punish.Punish.doWinLosePunish(table.runConfig.punishCardCount, table.runConfig.isMatch,
                                      seat_coin, detalChips, robot_card_count)
        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            table._match_table_info['mInfos']['scores'][x] = seat_coin[x]

        # 返回当前Table的game_win
        moWin = MsgPack()
        moWin.setCmd('table_call')
        moWin.setResult('action', 'game_win')
        moWin.setResult('isMatch', 1)
        moWin.setResult('gameId', table.gameId)
        moWin.setResult('roomId', table.roomId)
        moWin.setResult('tableId', table.tableId)
#         moWin.setResult('stat', dict(zip(tdz_stat_title, table.status)))
        moWin.setResult('stat', table.status.toInfoDictExt())
        moWin.setResult('dizhuwin', dizhuwin)
        if seatId == 0:
            moWin.setResult('nowin', 1)
        moWin.setResult('slam', 0)
        moWin.setResult('cards', [seat.cards for seat in table.seats])
        
        roundId = table.gameRound.number
        table.clear(userids)
         
        for x in xrange(len(userids)):
            uid = userids[x]
            mrank = 3
            mtableRanking = 3
            moWin.setResult('seat' + str(x + 1), [detalChips[x], seat_coin[x], 0, 0, 0, 0, mrank, mtableRanking])

            if detalChips[x] > 0:
                stageRewards = table.group.stageConf.conf.get('stageReward', None) if table.group.stageConf else None
                if stageRewards:
                    contentItems = TYContentItem.decodeList(stageRewards)
                    assetList = dizhu_util.sendRewardItems(uid, contentItems, '', 'DIZHU_STAGE_REWARD', 0)
                    moWin.setResult('stageReward', stageRewards)
                    ftlog.info('stageRewards send. userId=', uid, 'stageRewards=', stageRewards, 'assetList=', assetList)

            #增加经验
            exp = userdata.incrExp(uid, 20)
            explevel = dizhuaccount.getExpLevel(exp)
            gamedata.setGameAttr(uid, table.gameId, 'level', explevel)
            if ftlog.is_debug():
                ftlog.debug('BigMatch.doWinLoseTable',
                            'addExp=', 20,
                            'curExp=', exp,
                            'curLevel=', explevel)
             
        table.gamePlay.sender.sendToAllTableUser(moWin)
         
        # 发送给match manager
        users = []
        for x in xrange(len(userids)):
            user = {}
            user['userId'] = userids[x]
            user['deltaScore'] = int(detalChips[x])
            user['seatId'] = x + 1
            users.append(user)
         
        mnr_msg = MsgPack()
        mnr_msg.setCmd('room')
        mnr_msg.setParam('action', 'm_winlose')
        mnr_msg.setParam('gameId', table.gameId)
        mnr_msg.setParam('matchId', table.room.bigmatchId)
        mnr_msg.setParam('roomId', table.room.ctrlRoomId)
        mnr_msg.setParam('tableId', table.tableId)
        mnr_msg.setParam('users', users)
        mnr_msg.setParam('ccrc', table._match_table_info['ccrc'])
        
        if cls.WINLOSE_SLEEP > 0:
            FTTasklet.getCurrentFTTasklet().sleepNb(cls.WINLOSE_SLEEP)
        # 记录游戏winlose
        try:
            for u in users:
                table.room.reportBiGameEvent('TABLE_WIN', u['userId'], table.roomId,
                                             table.tableId, roundId, u['deltaScore'],
                                             0, 0, [], 'table_win')
        except:
            if ftlog.is_debug():
                ftlog.exception()
        router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
Exemplo n.º 6
0
    def doWinLose(cls, room, table, seatId, isTimeOutKill=False):
        if not table._match_table_info:
            ftlog.warn('ErdayiMatch.doWinLoseTable roomId=', room.roomId,
                       'tableId=', table.tableId, 'seatId=', seatId,
                       'isTimeOutKill=', isTimeOutKill, 'err=',
                       'not matchTableInfo')
            return

        # 计算春天
        dizhuseatId = table.status.diZhu
        if seatId != dizhuseatId:
            if table.seats[dizhuseatId - 1].outCardCount == 1:
                table.status.chuntian = 2
        else:
            s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN]
            s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN]
            if s1.outCardCount == 0 and s2.outCardCount == 0:
                table.status.chuntian = 2

        # 翻倍计算 叫地主的倍数
        windoubles = table.status.callGrade
        # 炸弹倍数
        windoubles *= pow(2, table.status.bomb)
        # 春天倍数
        windoubles *= table.status.chuntian
        # 底牌倍数
        windoubles *= table.status.baseCardMulti
        # 明牌倍数
        windoubles *= table.status.show

        dizhuwin = 0
        if seatId == dizhuseatId:
            dizhuwin = 1
        if seatId == 0:  # 流局
            dizhuwin = 0
            windoubles = 1
        else:
            windoubles = abs(windoubles)

        userids = [seat.userId for seat in table.seats]
        seat_coin = [0] * len(table.seats)
        detalChips = [0] * len(table.seats)
        baseBetChip = table._match_table_info['step']['basescore']
        robot_card_count = [0] * len(table.seats)  # 每个座位

        # 计算所有农民的输赢
        for i, player in enumerate(table.players):
            userids.append(player.userId)
            if seatId == 0:
                detalChips[i] = -baseBetChip
            if i + 1 == dizhuseatId:
                continue
            detalChip = baseBetChip * windoubles
            # 计算本农民的倍数
            seatMulti = max(table.seats[i].seatMulti, 1) * max(
                table.seats[dizhuseatId - 1].seatMulti, 1)
            detalChip *= seatMulti
            if dizhuwin:
                detalChip *= -1
            detalChips[i] = detalChip
            detalChips[dizhuseatId - 1] -= detalChip
            if ftlog.is_debug():
                ftlog.debug('ErdayiMatch.doWinLoseTable roomId=', room.roomId,
                            'tableId=', table.tableId, 'seatId=', seatId,
                            'dizhuseatId=', dizhuseatId, 'detalChip=',
                            detalChip, 'dizhuDetalChip=',
                            detalChips[dizhuseatId - 1])

        punish.Punish.doWinLosePunish(table.runConfig.punishCardCount,
                                      table.runConfig.isMatch, seat_coin,
                                      detalChips, robot_card_count)
        seat_coin = [0] * len(table.seats)
        for i, seatInfo in enumerate(table._match_table_info['seats']):
            seat_coin[i] = seatInfo['score']
        # 返回当前Table的game_win
        moWin = MsgPack()
        moWin.setCmd('table_call')
        moWin.setResult('action', 'game_win')
        moWin.setResult('isMatch', 1)
        moWin.setResult('gameId', table.gameId)
        moWin.setResult('roomId', table.roomId)
        moWin.setResult('tableId', table.tableId)
        #         moWin.setResult('stat', dict(zip(tdz_stat_title, table.status)))
        moWin.setResult('stat', table.status.toInfoDictExt())
        moWin.setResult('dizhuwin', dizhuwin)
        if seatId == 0:
            moWin.setResult('nowin', 1)
        moWin.setResult('slam', 0)
        moWin.setResult('cards', [seat.cards for seat in table.seats])

        roundId = table.gameRound.number
        table.clear(userids)

        for i, player in enumerate(table.players):
            uid = player.userId
            mrank = 3
            mtableRanking = 3
            moWin.setResult('seat' + str(player.seatId), [
                detalChips[i], seat_coin[i], 0, 0, 0, 0, mrank, mtableRanking
            ])
            if not player.isAI:
                #增加经验
                exp = userdata.incrExp(uid, 20)
                explevel = dizhuaccount.getExpLevel(exp)
                gamedata.setGameAttr(uid, table.gameId, 'level', explevel)
                if ftlog.is_debug():
                    ftlog.debug('ErdayiMatch.doWinLoseTable', 'addExp=', 20,
                                'curExp=', exp, 'curLevel=', explevel)

        table.gamePlay.sender.sendToAllTableUser(moWin)

        # 发送给match manager
        users = []
        for i, player in enumerate(table.players):
            if not player.isAI:
                user = {}
                user['userId'] = player.userId
                user['deltaScore'] = int(detalChips[i])
                user['seatId'] = player.seatId
                users.append(user)

        mnr_msg = MsgPack()
        mnr_msg.setCmd('room')
        mnr_msg.setParam('action', 'm_winlose')
        mnr_msg.setParam('gameId', table.gameId)
        mnr_msg.setParam('matchId', table.room.bigmatchId)
        mnr_msg.setParam('roomId', table.room.ctrlRoomId)
        mnr_msg.setParam('tableId', table.tableId)
        mnr_msg.setParam('users', users)
        mnr_msg.setParam('ccrc', table._match_table_info['ccrc'])

        if cls.WINLOSE_SLEEP > 0:
            FTTasklet.getCurrentFTTasklet().sleepNb(cls.WINLOSE_SLEEP)
        # 记录游戏winlose
        try:
            for u in users:
                table.room.reportBiGameEvent('TABLE_WIN', u['userId'],
                                             table.roomId, table.tableId,
                                             roundId, u['deltaScore'], 0, 0,
                                             [], 'table_win')
        except:
            if ftlog.is_debug():
                ftlog.exception()
        router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
Exemplo n.º 7
0
    def doWinLose(cls, room, table, seatId, isTimeOutKill=False):  # TODO:

        if not table._match_table_info:
            ftlog.warn('BigMatch.doWinLoseTable roomId=', room.roomId,
                       'tableId=', table.tableId, 'seatId=', seatId,
                       'isTimeOutKill=', isTimeOutKill, 'not matchTableInfo')
            return

        # 计算春天
        dizhuseatId = table.status.diZhu
        if seatId != dizhuseatId:
            if table.seats[dizhuseatId - 1].outCardCount == 1:
                table.status.chuntian = 2
        else:
            s1 = table.seats[(dizhuseatId - 1 + 1) % table.maxSeatN]
            s2 = table.seats[(dizhuseatId - 1 + 2) % table.maxSeatN]
            if s1.outCardCount == 0 and s2.outCardCount == 0:
                table.status.chuntian = 2

        # 翻倍计算 叫地主的倍数
        windoubles = table.status.callGrade
        # 炸弹倍数
        windoubles *= pow(2, table.status.bomb)
        # 春天倍数
        windoubles *= table.status.chuntian
        # 底牌倍数
        windoubles *= table.status.baseCardMulti
        # 明牌倍数
        windoubles *= table.status.show

        dizhuwin = 0
        if seatId == dizhuseatId:
            dizhuwin = 1
        if seatId == 0:  # 流局
            dizhuwin = 0
            windoubles = 1
        else:
            windoubles = abs(windoubles)

#         matchlog('Match->doWinLose dizhuwin=', dizhuwin , 'dizhuseatId=', dizhuseatId, 'windoubles=', windoubles)
        userids = []
        detalChips = []
        seat_coin = []
        baseBetChip = table._match_table_info['mInfos']['basescore']
        robot_card_count = [0] * len(table.seats)  # 每个座位
        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            userids.append(uid)
            if seatId == 0:  # 流局
                detalChip = -baseBetChip
            else:
                if dizhuwin:
                    if x + 1 == dizhuseatId:
                        detalChip = baseBetChip + baseBetChip
                    else:
                        detalChip = -baseBetChip
                else:
                    if x + 1 == dizhuseatId:
                        detalChip = -baseBetChip - baseBetChip
                    else:
                        detalChip = baseBetChip
            detalChip *= windoubles
            detalChips.append(detalChip)
            seat_coin.append(table._match_table_info['mInfos']['scores'][x] +
                             detalChip)
            robot_card_count[x] = table.seats[x].robotCardCount
            ftlog.info('dizhu.game_win userId=', uid, 'roomId=', room.roomId,
                       'tableId=', table.tableId, 'delta=', detalChip)

        ftlog.debug('doWinLose->after room fee->robot_card_count=',
                    robot_card_count)
        #         table.punishClass().doWinLosePunish(table, seat_coin, detalChips)
        punish.Punish.doWinLosePunish(table.runConfig.punishCardCount,
                                      table.runConfig.isMatch, seat_coin,
                                      detalChips, robot_card_count)
        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            table._match_table_info['mInfos']['scores'][x] = seat_coin[x]

        # 返回当前Table的game_win
        moWin = MsgPack()
        moWin.setCmd('table_call')
        moWin.setResult('action', 'game_win')
        moWin.setResult('isMatch', 1)
        moWin.setResult('gameId', table.gameId)
        moWin.setResult('roomId', table.roomId)
        moWin.setResult('tableId', table.tableId)
        #         moWin.setResult('stat', dict(zip(tdz_stat_title, table.status)))
        moWin.setResult('stat', table.status.toInfoDictExt())
        moWin.setResult('dizhuwin', dizhuwin)
        if seatId == 0:
            moWin.setResult('nowin', 1)
        moWin.setResult('slam', 0)
        moWin.setResult('cards', [seat.cards for seat in table.seats])

        roundId = table.gameRound.number
        table.clear(userids)

        for x in xrange(len(table.seats)):
            uid = table.seats[x].userId
            mrank = 3
            mtableRanking = 3
            moWin.setResult('seat' + str(x + 1), [
                detalChips[x], seat_coin[x], 0, 0, 0, 0, mrank, mtableRanking
            ])

            #增加经验
            exp = userdata.incrExp(uid, 20)
            explevel = dizhuaccount.getExpLevel(exp)
            gamedata.setGameAttr(uid, table.gameId, 'level', explevel)
            ftlog.debug('BigMatch.doWinLoseTable add 20 exp, tootle', exp,
                        'level', explevel)

#         nhWin = []
#         table.makeBroadCastUsers(nhWin)
#         tasklet.sendUdpToMainServer(moWin, nhWin)
        table.gamePlay.sender.sendToAllTableUser(moWin)

        # 发送给match manager
        users = []
        for x in xrange(len(table.seats)):
            user = {}
            user['userId'] = table.seats[x].userId
            user['deltaScore'] = int(detalChips[x])
            user['seatId'] = x + 1
            users.append(user)

        mnr_msg = MsgPack()
        mnr_msg.setCmd('room')
        mnr_msg.setParam('action', 'm_winlose')
        mnr_msg.setParam('gameId', table.gameId)
        mnr_msg.setParam('matchId', table.room.bigmatchId)
        mnr_msg.setParam('roomId', table.room.ctrlRoomId)
        mnr_msg.setParam('tableId', table.tableId)
        mnr_msg.setParam('users', users)
        mnr_msg.setParam('ccrc', table._match_table_info['ccrc'])

        if cls.WINLOSE_SLEEP > 0:
            FTTasklet.getCurrentFTTasklet().sleepNb(cls.WINLOSE_SLEEP)

        # 记录游戏winlose
        try:
            for u in users:
                table.room.reportBiGameEvent("TABLE_WIN", u['userId'],
                                             table.roomId, table.tableId,
                                             roundId, u['deltaScore'], 0, 0,
                                             [], 'table_win')
#                 cls.report_bi_game_event(TyContext.BIEventId.TABLE_WIN, u['userId'], table._rid, table._id, table._roundId, u['deltaScore'], 0, 0, [], 'table_win')
        except:
            if ftlog.is_debug():
                ftlog.exception()
#         serverids = tasklet.gdata.map_room_servers[table.room.bigmatchId]
#         mainClient = tasklet.gdata.clientmap[serverids[0]]
#         mainClient.sendMessage2(None, mnr_msg.pack())
        router.sendRoomServer(mnr_msg, table.room.ctrlRoomId)
Exemplo n.º 8
0
def do_xq_creat_new_user(snsId, chessExp, totalNum, winNum, loseNum, drawNum):
    
    uid = daobase.executeMixCmd('incrby', 'global.userid', 1)
    #assert(uid > 148670897)
    ct = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
    datas = {
             'password' : 'ty' + str(random.randint(100000, 999999)),
             'mdevid' : '',
             'isbind' : 1,
             'snsId' : snsId,
             'name' : '',
             'source' : '',
             'purl' : 'http://ddz.image.tuyoo.com/avatar/head_china.png',
             'address' : '',
             'sex' : 0,
             'state' : 0,
             'payCount' : 0,
             'snsinfo' : '',
             'vip' : 0,
             'dayang' : 0,
             'idcardno' : '',
             'phonenumber' : '',
             'truename' : '',
             'detect_phonenumber' : '',
             'email' : '',
             'createTime' : ct,
             'userAccount' : '',
             'clientId' : PCCLIENTID,
             'appId' : 9999,
             'bindMobile' : '',
             'mac' : '',
             'idfa' : '',
             'imei' : '',
             'androidId' : '',
             'uuid' : '',
             'userId' : uid,
             "lang" : '',
             "country" : "",
             "signature" : "",
             "agreeAddFriend" : 1,
#              "aliveTime" :  ct,
#              "exp" : 0,
#              "charm" : 0,
#              "diamond" : 0,
#              "chip" : 3000,
#              "coin" : 0
             }
#     attrlist = []
#     valuelist = []
#     for k, v in datas.items() :
#         attrlist.append(k)
#         valuelist.append(v)

    ftlog.info('PCXQ_USER', 'creat new user of->', uid, snsId)
    # userdata._setAttrsForce(uid, datas)
    userdata.setAttrs(uid, datas)
    userchip.incrChip(uid, 3, 3000, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userchip.incrCoin(uid, 3, 0, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userchip.incrDiamond(uid, 3, 0, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userchip.incrCoupon(uid, 3, 0, daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, 'SYSTEM_REPAIR', 0, PCCLIENTID)
    userdata.incrCharm(uid, 0)
    userdata.incrExp(uid, 0)
    
    ikey = 'item2:9999:' + str(uid)
    for k, v in itemdatas.items() :
        daobase.executeUserCmd(uid, 'hset', ikey, k, v)
    daobase._executeKeyMapCmd('set', 'snsidmap:' + str(snsId), uid)
    
    creat_gamedata(uid, chessExp, totalNum, winNum, loseNum, drawNum)