Пример #1
0
def _onTableWinlose(event):
    status = gamedata.getGameAttrJson(event.userId, DIZHU_GAMEID,
                                      'item.win.progress', {})
    if ftlog.is_debug():
        ftlog.debug('dizhuredenvelope._onTableWinlose userId=', event.userId,
                    'status=', status)
    if event.winlose.isWin:
        changed = False
        roomConf = gdata.getRoomConfigure(event.roomId)
        playMode = roomConf.get('playMode')
        for itemConf in _itemConfList:
            if not itemConf['playModes'] or playMode in itemConf['playModes']:
                changed = True
                itemId = str(itemConf['itemId'])
                winTimes = itemConf['winTimes']
                progress = status.get(itemId, 0) + 1
                status[itemId] = progress
                if progress >= winTimes:
                    flagName = 'item.open.flag:%s' % (itemId)
                    gamedata.setnxGameAttr(event.userId, HALL_GAMEID, flagName,
                                           1)
        if changed:
            gamedata.setGameAttr(event.userId, DIZHU_GAMEID,
                                 'item.win.progress', strutil.dumps(status))
        if ftlog.is_debug():
            ftlog.debug('dizhuredenvelope._onTableWinlose userId=',
                        event.userId, 'status=', status, 'changed=', changed)
Пример #2
0
    def _isObserver(self, userId):
        """
        陈龙和才哥需求: 在德州和三张里观战时, 不能加好友。原因是好多恶意玩家用这个做宣传。
        跟辉哥商量过了, 没什么好办法实现~ 只能在这里写死 gameId

        by WangTao
        """

        locList = onlinedata.getOnlineLocList(userId)
        gameIds = {8, 30}

        for onlineLoc in locList:
            roomId, tableId, seatId = onlineLoc
            onlineGameId = strutil.getGameIdFromInstanceRoomId(roomId)

            if onlineGameId not in gameIds:
                continue

            # 判断是否观战状态。 只适用三张和德州
            if roomId and tableId and seatId:
                roomConf = gdata.getRoomConfigure(roomId)
                maxSeatN = roomConf['tableConf']['maxSeatN']
                if seatId == maxSeatN + 1:  # is observe
                    ftlog.info("FriendTcpHandler._isObserver| is observer"
                               "| userId, loc:", userId, onlineLoc)
                    return True

        return False
Пример #3
0
def provideTimeMatchRankReward(userId, roomId, rank, rankRewards):
    """
    回馈赛上榜发放宝藏奖励到邮件
    """
    treasureConf = config.getTreasureConf(effectType=EffectType.MatchRankRewardAdd)
    if treasureConf:
        kindId = treasureConf["kindId"]
        level, levelConf = getTreasureInfo(userId, kindId)
        if not levelConf:
            return
        refreshTreasureState(userId, kindId)
        treasureData = getTreasure(userId, kindId)
        if treasureData[INDEX_FINISH_COUNT] >= treasureConf["limitCount"]:
            return
        rewards = []
        lang = util.getLanguage(userId)
        ratio = levelConf["params"]["time_match"]
        for _reward in rankRewards:
            if _reward["name"] in config.BULLET_VALUE:
                name = config.BRONZE_BULLET_KINDID
                count = int(math.ceil(_reward["count"] * config.BULLET_VALUE[_reward["name"]] * ratio))
            else:
                name = _reward["name"]
                count = int(math.ceil(_reward["count"] * ratio))
            rewards.append({"name": name, "count": count})
        if rewards:
            matchName = config.getMultiLangTextConf(gdata.getRoomConfigure(roomId).get("name", ""), lang=lang)
            treasureName = config.getMultiLangTextConf(treasureConf["name"], lang=lang)
            message = config.getMultiLangTextConf("ID_CONFIG_TREASURE_TIME_MATCH_RANK", lang=lang)
            message = message.format(matchName, rank, level, treasureName)
            title = config.getMultiLangTextConf("ID_MAIL_TITLE_TREASURE_REWARD", lang=lang)
            mail_system.sendSystemMail(userId, mail_system.MailRewardType.TreasureReward, rewards, message, title)
            activeTreasure(userId, kindId, treasureData)
Пример #4
0
    def _isObserver(self, userId):
        """
        陈龙和才哥需求: 在德州和三张里观战时, 不能加好友。原因是好多恶意玩家用这个做宣传。
        跟辉哥商量过了, 没什么好办法实现~ 只能在这里写死 gameId

        by WangTao
        """

        locList = onlinedata.getOnlineLocList(userId)
        gameIds = {8, 30}

        for onlineLoc in locList:
            roomId, tableId, seatId = onlineLoc
            onlineGameId = strutil.getGameIdFromInstanceRoomId(roomId)

            if onlineGameId not in gameIds:
                continue

            # 判断是否观战状态。 只适用三张和德州
            if roomId and tableId and seatId:
                roomConf = gdata.getRoomConfigure(roomId)
                maxSeatN = roomConf['tableConf']['maxSeatN']
                if seatId == maxSeatN + 1:  # is observe
                    ftlog.info(
                        "FriendTcpHandler._isObserver| is observer"
                        "| userId, loc:", userId, onlineLoc)
                    return True

        return False
Пример #5
0
    def onMsgTablePlay(self, msg):
        ftlog.debug('|snsId, userId, seatId:', self.snsId, self.userId, self.seatId, 'msg->', msg, caller=self)
        cmd = msg.getCmd()
        if cmd == 'quick_start':
            roomId = msg.getResult('roomId')
            tableId = msg.getResult('tableId')
            roomTypeName = gdata.getRoomConfigure(roomId)['typeName']
            # if roomTypeName in (rooms.tyRoomConst.ROOM_TYPE_NAME_NORMAL,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_QUEUE,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_SNG,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_MTT,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_HUNDREDS,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_DTG) :
            #     if tableId == 0: # 进入队列的返回,忽略
            #         return
            #     else:
            #         self.tableId = tableId

            seatId = msg.getResult('seatId', 0)
            self.seatId = seatId - 1
            if tableId == self.tableId and seatId > 0:
                ftlog.debug('QuickStart', self.snsId, 'OK !', roomId, tableId, seatId)
            else:
                # 快速开始失败
                ftlog.error('QuickStart', self.snsId, self.roomId, self.tableId, msg)
                self.stop()

        action = msg.getResult('action')
        if (cmd == 'table' and action == 'info') or cmd == 'tableInfo':
            self.tableInfoResult = msg.getKey('result')

        if cmd == 'standup':
            userId = msg.getResult('userId')
            reason = msg.getResult('reason')
            if userId == self.userId and reason != TYRoom.LEAVE_ROOM_REASON_CHANGE_TABLE:
                mo = MsgPack()
                mo.setCmdAction('room', 'leave')
                mo.setParam('userId', self.userId)
                mo.setParam('gameId', self.gameId)
                mo.setParam('clientId', self.clientId)
                mo.setParam('roomId', self.bigRoomId)
                self.writeMsg(mo)

        if (cmd == 'room' and action == 'leave') or cmd == 'room_leave':
            self.stop()

        if cmd == 'table_call':
            if action == 'game_start':
                ftlog.debug("table_call game_start |msg:", msg, caller=self)
                self.gameStartResult = msg.getKey('result')
                return

            elif action == 'game_win':
                ftlog.debug("table_call game_win |msg:", msg, caller=self)
                self.sendReadyReq(msg)
                return
Пример #6
0
 def buildLuckyDrawMailMessage(cls, itemconf, roomId):
     '''
     构建邮箱信息
     '''
     conf = getWarmupSystemConfig()
     mail = conf.get('mail', '')
     roomconf = gdata.getRoomConfigure(roomId)
     matchName = roomconf.get('name', '')
     dictionary = {'assets_desc': itemconf.get('desc', ''), 'match_name':matchName}
     return strutil.replaceParams(mail, dictionary)
Пример #7
0
def getMatchRoomSortIndex(roomId, roomInfoMap, timeStamp):
    topIndex = startTime = rewardValue = 0
    roomConf = gdata.getRoomConfigure(roomId)
    if roomConf:
        startTime = getMatchRoomStartTime(roomId, roomInfoMap)
        beginSec = startTime - timeStamp
        topIndex = -beginSec if beginSec > 86400 else roomConf.get(
            'topindex', 0)
        rewardValue = roomConf.get('championreward', 0)
    return [topIndex, -startTime, rewardValue]
Пример #8
0
def collectCtrlRoomIdsByFTPlayMode(ftPlayMode):
    bigRoomIds = gdata.gameIdBigRoomidsMap().get(DIZHU_GAMEID)
    ctrlRoomIds = []
    for bigRoomId in bigRoomIds:
        roomConf = gdata.getRoomConfigure(bigRoomId)
        if ((roomConf.get('typeName') in ('dizhuFT', 'dizhu_friend')) 
            and ftPlayMode == roomConf.get('ftPlayMode')):
            ctrlRoomIds.extend(gdata.bigRoomidsMap().get(bigRoomId, []))
    ctrlRoomIds.sort()
    return ctrlRoomIds
Пример #9
0
def doUserStandUp(userId, roomId, tableId, clientId, reason):
    _, clientVer, _ = strutil.parseClientId(clientId)
    ftlog.debug('table_remote.doUserStandUp userId=', userId, 'roomId=',
                roomId, 'tableId=', tableId, 'clientId=', clientId, 'reason=',
                reason, 'clientVer=', clientVer)
    if reason not in (TableStandUpEvent.REASON_GAME_OVER, ):
        return 0

    chipCount = userchip.getChip(userId)
    roomConf = gdata.getRoomConfigure(roomId) or {'minCoin': 0, 'maxCoin': -1}
    if chipCount < roomConf['minCoin']:
        reason = TableStandUpEvent.REASON_CHIP_NOT_ENOUGHT
        if clientVer >= 3.77:  # 新版救济金弹气泡支持
            processLoseOutRoomV3_77(DIZHU_GAMEID,
                                    userId,
                                    clientId,
                                    roomId,
                                    showMemberTry=False)
        elif clientVer >= 3.7:
            hallpopwnd.processLoseOutRoomV3_7(DIZHU_GAMEID,
                                              userId,
                                              clientId,
                                              roomId,
                                              showMemberTry=False)
        elif clientVer == 3.502:
            processLoseOutRoom(DIZHU_GAMEID, userId, clientId, roomId)
        elif clientVer >= 3.0:
            timestamp = pktimestamp.getCurrentTimestamp()
            benefitsSend, userBenefits = hallbenefits.benefitsSystem.sendBenefits(
                DIZHU_GAMEID, userId, timestamp)
            ftlog.debug('benefitsSend, userBenefits =', benefitsSend,
                        userBenefits)
            zhuanyun = hallpopwnd.makeTodoTaskZhuanyun(DIZHU_GAMEID, userId,
                                                       clientId, benefitsSend,
                                                       userBenefits, roomId)
            if zhuanyun:
                TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, userId, zhuanyun)
            else:
                ttask = TodoTaskHelper.makeBenefitsTodoTask(
                    DIZHU_GAMEID, userId, clientId, benefitsSend, userBenefits)
                if ttask:
                    TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, userId, ttask)
            datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, 'chip')
        else:
            benefitsSend, userBenefits = hallbenefits.benefitsSystem.sendBenefits(
                DIZHU_GAMEID, userId, pktimestamp.getCurrentTimestamp())
            ftlog.debug('benefitsSend, userBenefits =', benefitsSend,
                        userBenefits)
    elif (roomConf['maxCoin'] != -1 and chipCount > roomConf['maxCoin']):
        pass
        # reason = TableStandUpEvent.REASON_CHIP_TOO_MUCH
        # from dizhu.gametable.quick_start import DizhuQuickStartV4_0
        # DizhuQuickStartV4_0._sendTodoTaskJumpHighRoom(userId, roomConf['playMode'], clientId)
    return 1
Пример #10
0
def logTableChat(gameId, roomId, tableId, senderUserId, chatText):
    if not chatText:
        return
    if senderUserId <= 0:
        return
    try:
        username = unicode(str(userdata.getAttr(senderUserId, 'name')))
        roomName = unicode(str(gdata.getRoomConfigure(roomId)['name']))
        ftlog.hinfo('tableChatLog gameId=%s; room="%s"; table=%s; userId=%s; name="%s"; msg="%s"' % (
            gameId, roomName, tableId, senderUserId, username, chatText))
    except Exception, e:
        ftlog.exception('exception locals():', locals())
Пример #11
0
def logTableChat(gameId, roomId, tableId, senderUserId, chatText):
    if not chatText:
        return
    if senderUserId <= 0:
        return
    try:
        username = unicode(str(userdata.getAttr(senderUserId, 'name')))
        roomName = unicode(str(gdata.getRoomConfigure(roomId)['name']))
        ftlog.hinfo(
            'tableChatLog gameId=%s; room="%s"; table=%s; userId=%s; name="%s"; msg="%s"'
            % (gameId, roomName, tableId, senderUserId, username, chatText))
    except Exception, e:
        ftlog.exception('exception locals():', locals())
Пример #12
0
    def _sendTodoTaskToUserWithRoomKey(cls, userId, roomId, msg, roomkey):
        if roomId <= 0:
            roomId = msg.getParam('roomId')
            if not roomId:
                return False
        roomconf = gdata.getRoomConfigure(roomId)
        if msg.getParam('mixId'):
            roomconf = cls.getMixConf(roomconf, msg.getParam('mixId'))

        if ftlog.is_debug():
            ftlog.debug("DizhuQuickStart._sendTodoTaskToUserWithRoomKey: roomId=", roomId, "userId=", userId, "roomconf=", roomconf)

        if not roomconf:
            return False
        tip = roomconf.get(roomkey)
        if not tip:
            return False
        cls._sendTodoTaskToUserWithTip(userId, tip)
        return True
Пример #13
0
def routeConnTcpMsgQuery(cmd, userId, roomId, msgpack):
    """
    CONN服务调用, 路由消息到其他的服务
    """
    routeinfo = _cmd_route_map.get(cmd, None)
    if not routeinfo:
        routeinfo = oldcmd.findTargetInfo(cmd)
    ftlog.debug('cmd=', cmd, 'userId=', userId, 'roomId=', roomId, 'routeinfo=', routeinfo, 'msgpack=', msgpack)
    if not routeinfo:
        if cmd in _cmd_notuse_map:
            ftlog.debug('the cmd is not used !!', cmd)
            return
        ftlog.warn('ERROR the cmd not in route map ! cmd.json', cmd, userId, roomId, msgpack)
        return

    if filterCmdAct(cmd, userId, roomId, msgpack):
        return

    mo = None
    notimeoutex = 1  # 不打印CO到其他进程的超时异常
    srvtype = routeinfo['target']

    # 分组大比赛的命令检查路由,部分消息需由UT进行二次分发处理
    if roomId:
        roomConf = gdata.getRoomConfigure(roomId)
        if roomConf and roomConf.get('typeName') == 'group_match':
            act = strutil.getJsonStr(msgpack, 'action', '')
            cmdpath = cmd + '#' + act
            if cmdpath in _cmd_group_match_set:
                srvtype = gdata.SRV_TYPE_UTIL

    if srvtype == gdata.SRV_TYPE_UTIL:
        mo = _communicateServer(_utilServer, userId, userId, msgpack, 'CQ', 1, notimeoutex=notimeoutex)
    elif srvtype == gdata.SRV_TYPE_ROOM:
        mo = _communicateRoomServer(userId, roomId, msgpack, 'CQ', 1, notimeoutex=notimeoutex)
    elif srvtype == gdata.SRV_TYPE_TABLE:
        mo = _communicateTableServer(userId, roomId, msgpack, 'CQ', 1, notimeoutex=notimeoutex)
    elif srvtype == gdata.SRV_TYPE_CENTER:
        mo = _communicateServer(_centerServer, userId, userId, msgpack, 'CQ', 1, notimeoutex=notimeoutex)
    else:
        ftlog.error('ERROR the cmd route false !!', cmd, msgpack)
    ftlog.debug('the cmd route return !!', cmd, 'result=', mo)
Пример #14
0
def _getMatchLed():
    results = []
    matchLed = dizhuconf.getLedNotifyConf()
    for led in matchLed:
        try:
            if led.get("type", '') != "match":
                continue

            matchId = led.get("matchId", None)
            if not matchId:
                continue

            conf = gdata.getRoomConfigure(int(matchId))
            if not conf:
                ftlog.debug('match conf not found id matchId=', matchId)
                continue

            matchConf = conf.get("matchConf", {})

            if not matchConf:
                continue

            startConf = matchConf.get('start')
            if not startConf:
                continue

            ledtext = led.get('ledtext', [])
            matchname = conf.get("name")
            matchreward = _getWinnerReward(matchConf.get("rank.rewards", []))
            result = _getMatchTimeLedText(startConf, ledtext, matchname,
                                          matchreward)

            if result:
                results.append(result)
            #ftlog.debug('matchled get matchId=', matchId, 'result=s', results, 'matchname=', matchname, 'matchreward=', matchreward)
        except:
            ftlog.exception('dizhuled._getMatchLed ledMatchId=',
                            led.get('matchId'))

    return results
Пример #15
0
def sendUserVipBenefits(userId, roomId, minRoomLevel, sendCount, chip):
    if minRoomLevel < 1 or sendCount <= 0:
        return False

    ## room level limit
    bigroomId = gdata.getBigRoomId(roomId)
    roomconf = gdata.getRoomConfigure(bigroomId)
    if not roomconf:
        return False
    roomlevel = roomconf.get('roomLevel', 1)
    if roomlevel < minRoomLevel:
        ftlog.debug('sendUserVipBenefits: roomlevel', 'userId=', userId,
                    'roomlevel=', roomlevel, 'minRoomLevel=', minRoomLevel)
        return False

    ## send number limit
    rediskey = 'vip.benefits'
    data = Redis.readJson(userId, rediskey)
    timestamp = data.get('timestamp', 0)
    counter = data.get('counter', 0)

    now = datetime.datetime.now()
    last = datetime.datetime.fromtimestamp(timestamp)
    if last.year != now.year or last.month != now.month or last.day != now.day:
        counter = 0

    if counter >= sendCount:
        ftlog.debug('sendUserVipBenefits: sendCount', 'userId=', userId,
                    'sendCount=', sendCount, 'counter=', counter)
        return False

    data['counter'] = counter + 1
    data['timestamp'] = Tool.datetimeToTimestamp(now)

    Redis.writeJson(userId, rediskey, data)
    UserInfo.incrChip(userId, 6, chip, 'BENEFITS_VIP_SEND')

    ftlog.debug('sendUserVipBenefits:', 'userId=', userId, 'counter=',
                data['counter'], 'chip=', chip)
    return True
Пример #16
0
 def handleEvent(cls, event):
     ftlog.debug('matchledevent gameId=', event.gameId, 'userId=', event.userId, 'matchId=', event.matchId, 'isWin=', event.isWin, 'rank=', event.rank)
     try:
         matchId = str(event.matchId)
         
         if event.isWin and event.rank == 1:
             matchLed = dizhuconf.getLedNotifyConf()
             for led in matchLed:
                 
                 if matchId == led.get("matchId"):
                     conf = gdata.getRoomConfigure(int(matchId))
                     matchConf = conf.get("matchConf", {})
                     reward = cls.getWinnerReward( matchConf.get("rank.rewards", []) )
                     ftlog.debug('matchledevent matchId=', matchId, 'reward=', reward)
                     if reward:
                         winnername = userdata.getAttr(event.userId, 'name')
                         matchname = conf.get("name")
                         cls.makeLedText(winnername, matchname, reward, led.get("ledtext", {}))
                         cls.clientIds = led.get("clientIds", [])
                         cls.sendEndLed()
     except:
         ftlog.exception()
Пример #17
0
    def doGetQuickEnterRoom(self, userId, gameId, roomId0, tableId0, kindId):
        """
        获取快速进入房间信息
        """
        from newfish.entity.quick_start import FishQuickStart
        reason = FishQuickStart.ENTER_ROOM_REASON_OK
        info = u""
        if not util.isUsableClientVersion(userId):
            reason = FishQuickStart.ENTER_ROOM_REASON_VERSION_DISABLE
        elif game.isShutDown():
            reason = FishQuickStart.ENTER_ROOM_REASON_MAINTENANCE
        if reason != FishQuickStart.ENTER_ROOM_REASON_OK:
            info = FishQuickStart.getFailedInfo(reason, userId, roomId0)
            self.sendQuickEnterInfo(gameId, userId, roomId0, tableId0, kindId, reason, info)
            return
        isIn, roomId, tableId, _ = util.isInFishTable(userId)
        if not isIn:
            if roomId0:             # 用户选择了房间,先判断用户自己选的房间能否进入
                try:
                    reason = FishQuickStart.canQuickEnterRoom(userId, gameId, roomId0, kindId)
                    if reason == FishQuickStart.ENTER_ROOM_REASON_OK:
                        roomId = roomId0
                        tableId = tableId0
                    else:           # 用户选择的房间无法进入
                        roomConf = gdata.getRoomConfigure(roomId0)
                        if roomConf and roomConf.get("typeName") in config.QUICK_START_ROOM_TYPE:   # 系统自动分配
                            roomId, reason = FishQuickStart._chooseRoom(userId, gameId)
                        else:       # 非普通房间无法进入
                            roomId = roomId0
                            tableId = tableId0
                            info = FishQuickStart.getFailedInfo(reason, userId, roomId)
                except Exception as e:
                    roomId, reason = FishQuickStart._chooseRoom(userId, gameId)
                    ftlog.error("doGetQuickEnterRoom error", userId, gameId, roomId0, tableId0, e)
            else:                   # 用户不选择房间,点击快速开始,系统自动分配
                roomId, reason = FishQuickStart._chooseRoom(userId, gameId)

        self.sendQuickEnterInfo(gameId, userId, roomId, tableId, kindId, reason, info)
Пример #18
0
def provideFinishTimeMatchReward(userId, bigRoomId):
    """
    完成回馈赛发放宝藏奖励到邮件
    """
    treasureConf = config.getTreasureConf(effectType=EffectType.MatchRewardAdd)
    if treasureConf:
        kindId = treasureConf["kindId"]
        level, levelConf = getTreasureInfo(userId, kindId)
        if not levelConf:
            return
        refreshTreasureState(userId, kindId)
        treasureData = getTreasure(userId, kindId)
        if treasureData[INDEX_FINISH_COUNT] >= treasureConf["limitCount"]:
            return
        lang = util.getLanguage(userId)
        if str(bigRoomId) in levelConf.get("params", {}):
            matchName = config.getMultiLangTextConf(gdata.getRoomConfigure(bigRoomId).get("name", ""), lang=lang)
            rewards = [{"name": config.CHIP_KINDID, "count": levelConf["params"][str(bigRoomId)]}]
            treasureName = config.getMultiLangTextConf(treasureConf["name"], lang=lang)
            message = config.getMultiLangTextConf("ID_CONFIG_TREASURE_FINISH_TIME_MATCH", lang=lang)
            message = message.format(matchName, level, treasureName)
            title = config.getMultiLangTextConf("ID_MAIL_TITLE_TREASURE_REWARD", lang=lang)
            mail_system.sendSystemMail(userId, mail_system.MailRewardType.TreasureReward, rewards, message, title)
            activeTreasure(userId, kindId, treasureData)
Пример #19
0
    def onMsgTablePlay(self, msg):
        ftlog.debug('|snsId, userId, seatId:',
                    self.snsId,
                    self.userId,
                    self.seatId,
                    'msg->',
                    msg,
                    caller=self)
        cmd = msg.getCmd()
        if cmd == 'quick_start':
            roomId = msg.getResult('roomId')
            tableId = msg.getResult('tableId')
            roomTypeName = gdata.getRoomConfigure(roomId)['typeName']
            # if roomTypeName in (rooms.tyRoomConst.ROOM_TYPE_NAME_NORMAL,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_QUEUE,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_SNG,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_MTT,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_HUNDREDS,
            #                     rooms.tyRoomConst.ROOM_TYPE_NAME_DTG) :
            #     if tableId == 0: # 进入队列的返回,忽略
            #         return
            #     else:
            #         self.tableId = tableId

            seatId = msg.getResult('seatId', 0)
            self.seatId = seatId - 1
            if tableId == self.tableId and seatId > 0:
                ftlog.debug('QuickStart', self.snsId, 'OK !', roomId, tableId,
                            seatId)
            else:
                # 快速开始失败
                ftlog.error('QuickStart', self.snsId, self.roomId,
                            self.tableId, msg)
                self.stop()

        action = msg.getResult('action')
        if (cmd == 'table' and action == 'info') or cmd == 'tableInfo':
            self.tableInfoResult = msg.getKey('result')

        if cmd == 'standup':
            userId = msg.getResult('userId')
            reason = msg.getResult('reason')
            if userId == self.userId and reason != TYRoom.LEAVE_ROOM_REASON_CHANGE_TABLE:
                mo = MsgPack()
                mo.setCmdAction('room', 'leave')
                mo.setParam('userId', self.userId)
                mo.setParam('gameId', self.gameId)
                mo.setParam('clientId', self.clientId)
                mo.setParam('roomId', self.bigRoomId)
                self.writeMsg(mo)

        if (cmd == 'room' and action == 'leave') or cmd == 'room_leave':
            self.stop()

        if cmd == 'table_call':
            if action == 'game_start':
                ftlog.debug("table_call game_start |msg:", msg, caller=self)
                self.gameStartResult = msg.getKey('result')
                return

            elif action == 'game_win':
                ftlog.debug("table_call game_win |msg:", msg, caller=self)
                self.sendReadyReq(msg)
                return
Пример #20
0
def filterMatchSession(gameId, userId, clientId, roomInfoMap, session,
                       timestamp):
    filterRooms = []
    session = strutil.cloneData(session)
    for room in session.get('rooms', []):
        roomId = room.get('id')
        roomConf = gdata.getRoomConfigure(roomId)

        if not roomConf:
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterMatchSession NotRoomConf gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'session=', session.get('session'), 'roomId=', roomId)
            continue

        displayCondDict = room.get('displayCond', {})
        if not canDisplaySessionRoom(gameId, userId, clientId, roomId,
                                     displayCondDict):
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterMatchSession NotCanDisplaySessionRoom gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'roomId=', roomId)
            continue

        if not canDisplayRoom(gameId, userId, clientId, roomId, roomConf):
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterNormalSession NotCanDisplayRoom gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'roomId=', roomId)
            continue

        bigRoomId = gdata.getBigRoomId(roomId)
        if not bigRoomId:
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterMatchSession NotBigRoomId gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'session=', session.get('session'), 'roomId=', roomId)
            continue

        roomInfo = roomInfoMap.get(bigRoomId)

        if not roomInfo:
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterMatchSession NotRoomInfo gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'session=', session.get('session'), 'roomId=', roomId)
            continue

        if isOutofDateMatch(roomConf, roomInfo, timestamp):
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterMatchSession OutofTime gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'startTime=', roomInfo.startTime, 'startType=',
                    roomInfo.startType, 'roomId=', roomId)
            continue

        if isNotShowMatch(roomConf, roomInfo, timestamp):
            if ftlog.is_debug():
                ftlog.debug('dizhuhallinfo.filterMatchSession NotShow gameId=',
                            gameId, 'userId=', userId,
                            'clientId=', clientId, 'session=',
                            session.get('session'), 'roomId=', roomId,
                            'startTime=', roomInfo.startTime)
            continue

        # 根据用户IP进行不同展示,
        if roomConf.get('typeName') == 'dizhu_arena_match':
            arenaContent = getArenaMatchProvinceContent(
                userId,
                int(room['mixId']) if room.get('mixId') else room['id'],
                clientId)

            if arenaContent:
                room['name'] = arenaContent.get('name')
                room['showInfo']['name'] = arenaContent.get('showName')
                room['showInfo']['namezyy'] = arenaContent.get('showNamezzy')
                room['showInfo']['gameDes'] = arenaContent.get('gameDes')

                # if ftlog.is_debug():
                #     d = {}
                #     roomInfo._toDictImpl(d)
                #     ftlog.debug('filterMatchSession roomId=', roomId, 'room=', room, 'roomInfo=', d)

        fillMatchInfo(gameId, userId, clientId, room, roomInfo, timestamp)
        filterRooms.append(room)

    session_rooms = sortMatchRooms(filterRooms, roomInfoMap)
    session['rooms'] = getFeesDiscount(userId, session_rooms)
    session['rooms'] = filterNormalFeesDiscount(userId, session_rooms)
    return session
Пример #21
0
def filterNormalSession(gameId, userId, clientId, roomInfoMap, session,
                        timestamp):
    filterRooms = []
    session = strutil.cloneData(session)
    timestamp = pktimestamp.getCurrentTimestamp()
    for room in session.get('rooms', []):
        roomId = room.get('id')
        roomConf = gdata.getRoomConfigure(roomId)

        if not roomConf:
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterNormalSession NotRoomConf gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'roomId=', roomId)
            continue

        displayCondDict = room.get('displayCond', {})
        if not canDisplaySessionRoom(gameId, userId, clientId, roomId,
                                     displayCondDict):
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterNormalSession NotCanDisplaySessionRoom gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'roomId=', roomId)
            continue

        if not canDisplayRoom(gameId, userId, clientId, roomId, roomConf):
            if ftlog.is_debug():
                ftlog.debug(
                    'dizhuhallinfo.filterNormalSession NotCanDisplayRoom gameId=',
                    gameId, 'userId=', userId, 'clientId=', clientId,
                    'roomId=', roomId)
            continue

        if roomConf.get('ismatch'):
            roomInfo = roomInfoMap.get(roomId)
            if not roomInfo:
                if ftlog.is_debug():
                    ftlog.debug(
                        'dizhuhallinfo.filterNormalSession NotRoomInfo gameId=',
                        gameId, 'userId=', userId, 'clientId=', clientId,
                        'roomId=', roomId)
                continue

            if isOutofDateMatch(roomConf, roomInfo, timestamp):
                if ftlog.is_debug():
                    ftlog.debug(
                        'dizhuhallinfo.filterNormalSession OutofTime gameId=',
                        gameId, 'userId=', userId, 'clientId=', clientId,
                        'startTime=', roomInfo.startTime, 'startType=',
                        roomInfo.startType, 'roomId=', roomId)
                continue

            room['isMatch'] = True
            nextTimeDisplay = buildMatchTimeForDisplay(roomInfo, True,
                                                       timestamp)
            if nextTimeDisplay:
                showInfo = room.get('showInfo', {})
                showInfo['extendInfo'] = nextTimeDisplay
                room['showInfo'] = showInfo

            #######
            #  根据用户IP进行不同展示,
            if roomConf.get('typeName') == 'dizhu_arena_match':
                arenaContent = getArenaMatchProvinceContent(
                    userId,
                    int(room['mixId']) if room.get('mixId') else room['id'],
                    clientId)
                if arenaContent:
                    room['name'] = arenaContent.get('name')
                    room['showInfo']['name'] = arenaContent.get('showName')
                    room['showInfo']['namezyy'] = arenaContent.get(
                        'showNamezzy')
                    room['showInfo']['gameDes'] = arenaContent.get('gameDes')

        filterRooms.append(room)
        if ftlog.is_debug():
            ftlog.debug('dizhuhallinfo.filterNormalSession ok gameId=', gameId,
                        'userId=', userId, 'clientId=', clientId, 'roomId=',
                        roomId, 'room.showInfo', room['showInfo'])
    session['rooms'] = filterRooms
    return session
Пример #22
0
def routeConnTcpMsgQuery(cmd, userId, roomId, msgpack):
    """
    CONN服务调用, 路由消息到其他的服务
    """
    routeinfo = _cmd_route_map.get(cmd, None)
    if not routeinfo:
        routeinfo = oldcmd.findTargetInfo(cmd)
    ftlog.debug('cmd=', cmd, 'userId=', userId, 'roomId=', roomId,
                'routeinfo=', routeinfo, 'msgpack=', msgpack)
    if not routeinfo:
        if cmd in _cmd_notuse_map:
            ftlog.debug('the cmd is not used !!', cmd)
            return
        ftlog.warn('ERROR the cmd not in route map ! cmd.json', cmd, userId,
                   roomId, msgpack)
        return

    if filterCmdAct(cmd, userId, roomId, msgpack):
        return

    mo = None
    notimeoutex = 1  # 不打印CO到其他进程的超时异常
    srvtype = routeinfo['target']

    # 分组大比赛的命令检查路由,部分消息需由UT进行二次分发处理
    if roomId:
        roomConf = gdata.getRoomConfigure(roomId)
        if roomConf and roomConf.get('typeName') == 'group_match':
            act = strutil.getJsonStr(msgpack, 'action', '')
            cmdpath = cmd + '#' + act
            if cmdpath in _cmd_group_match_set:
                srvtype = gdata.SRV_TYPE_UTIL

    if srvtype == gdata.SRV_TYPE_UTIL:
        mo = _communicateServer(_utilServer,
                                userId,
                                userId,
                                msgpack,
                                'CQ',
                                1,
                                notimeoutex=notimeoutex)
    elif srvtype == gdata.SRV_TYPE_ROOM:
        mo = _communicateRoomServer(userId,
                                    roomId,
                                    msgpack,
                                    'CQ',
                                    1,
                                    notimeoutex=notimeoutex)
    elif srvtype == gdata.SRV_TYPE_TABLE:
        mo = _communicateTableServer(userId,
                                     roomId,
                                     msgpack,
                                     'CQ',
                                     1,
                                     notimeoutex=notimeoutex)
    elif srvtype == gdata.SRV_TYPE_CENTER:
        mo = _communicateServer(_centerServer,
                                userId,
                                userId,
                                msgpack,
                                'CQ',
                                1,
                                notimeoutex=notimeoutex)
    else:
        ftlog.error('ERROR the cmd route false !!', cmd, msgpack)
    ftlog.debug('the cmd route return !!', cmd, 'result=', mo)
Пример #23
0
 def isMatchRoom(cls, roomId):
     roomConf = gdata.getRoomConfigure(roomId)
     return roomConf.get('typeName') in ('group_match', 'arena_match')
Пример #24
0
 def isAsyncUpgradeHeroMatch(cls, roomId):
     '''
     是否是异步升级赛
     '''
     roomConf = gdata.getRoomConfigure(roomId)
     return (roomConf.get('typeName', '') == 'async_upgrade_hero_match')
Пример #25
0
def fillMatchInfo(gameId, userId, clientId, room, roomInfo, timestamp):
    # TODO 过滤地主版本
    if ftlog.is_debug():
        ftlog.debug('dizhuhallinfo.fillMatchInfo:', 'userId=', userId, 'room=',
                    room, 'roomInfo=', roomInfo.__dict__, 'roomInf.fees=',
                    roomInfo.fees)
    room['signupState'] = isSignin(userId, roomInfo)
    if roomInfo.startType == MatchType.TIMING:
        room['matchType'] = 'TIMING'
    else:
        room['matchType'] = 'USER_COUNT'

    # 按规则显示人数信息
    roomconf = gdata.getRoomConfigure(roomInfo.roomId)
    tipinfo = roomconf.get('matchListPeopleNumberTip', '暂未开始报名')
    isArena = roomconf.get('typeName') in ('arena_match', 'dizhu_arena_match')
    peopleNumberBase = max(roomInfo.playerCount, roomInfo.signinCount)
    if ftlog.is_debug():
        ftlog.debug('dizhuhallinfo.fillMatchInfo:', 'userId=', userId,
                    'roomId=', roomInfo.roomId, 'isArena=', isArena,
                    'peopleNumberBase=', peopleNumberBase)
    if isArena:
        peopleNumber = str(peopleNumberBase * 9)
        startTime = roomconf.get('matchConf', {}).get('startTime')
        stopTime = roomconf.get('matchConf', {}).get('stopTime')
        if ftlog.is_debug():
            ftlog.debug('dizhuhallinfo.fillMatchInfo:ArenaMatch', 'userId=',
                        userId, 'roomId=', roomInfo.roomId, 'startTime=',
                        startTime, 'stopTime=', stopTime, 'peopleNumber=',
                        peopleNumber)
        if checkTime(startTime, stopTime):
            room['peopleNumber'] = peopleNumber
        else:
            room['peopleNumber'] = tipinfo
    else:
        if roomInfo.startType == MatchType.TIMING:
            peopleNumber = str(roomInfo.playerCount + roomInfo.signinCount)
            curstamp = pktimestamp.getCurrentTimestamp()
            if ftlog.is_debug():
                ftlog.debug('dizhuhallinfo.fillMatchInfo:MatchType.TIMING',
                            'userId=', userId, 'roomId=', roomInfo.roomId,
                            'peopleNumber=', peopleNumber,
                            'roomInfo.startTime=', roomInfo.startTime,
                            'roomInfo.signinTime=', roomInfo.signinTime,
                            'curstamp=', curstamp)
            if not roomInfo.startTime or not roomInfo.signinTime:
                room['peopleNumber'] = peopleNumber
            else:
                if curstamp < roomInfo.signinTime:  # 报名未开始
                    room['peopleNumber'] = tipinfo
                else:
                    room['peopleNumber'] = peopleNumber

        elif roomInfo.startType == MatchType.USER_COUNT:
            peopleNumber = str(peopleNumberBase)
            if ftlog.is_debug():
                ftlog.debug('dizhuhallinfo.fillMatchInfo:MatchType.USER_COUNT',
                            'userId=', userId, 'roomId=', roomInfo.roomId,
                            'peopleNumber=', peopleNumber,
                            'roomInfo.playerCount=', roomInfo.playerCount,
                            'roomInfo.signinCount=', roomInfo.signinCount)
            room[
                'peopleNumber'] = peopleNumber if roomInfo.playerCount > 0 else '0'
        else:
            room['peopleNumber'] = '0'

    if ftlog.is_debug():
        ftlog.debug('dizhuhallinfo.fillMatchInfo:result', 'userId=', userId,
                    'roomId=', roomInfo.roomId, 'room.peopleNumber=',
                    room.get('peopleNumber'))

    ## 报名费自动填充
    # signupFee = room.get('signupFee', {})
    # if not signupFee.get('desc'):
    #     signupFee['desc'] = buildFeeDisplay(room, roomInfo)
    # room['signupFee'] = signupFee

    nextTimeDisplay = buildMatchTimeForDisplay(roomInfo, False, timestamp)
    if nextTimeDisplay:
        room['condition'] = nextTimeDisplay

    if roomInfo.startTime:
        room['matchStamp'] = roomInfo.startTime
        room['nowStamp'] = timestamp

        startTimeDT = datetime.fromtimestamp(roomInfo.startTime)
        ## 格式化比赛时间字符串
        matchCondition = room.get('matchCondition', {})
        matchCondition['bottom'] = startTimeDT.strftime('%H:%M')

        ## 根据配置生成,年月日日期字符串
        conditionType = matchCondition.get('type')
        if conditionType == 'datetime':
            datetimeTopDate = dizhuconf.getPublic().get('datetime_topdate')
            try:
                matchCondition['top'] = startTimeDT.strftime(datetimeTopDate)
            except:
                matchCondition['top'] = startTimeDT.strftime('%m月%d日')
Пример #26
0
    def handleEvent(cls, event):
        try:
            winlose = event.winlose
            if not winlose.isWin:
                # 失败不弹出
                return
            if event.skillLevelUp:
                # 升段不弹出
                return

            clientGiftVer = SessionDizhuVersion.getVersionNumber(event.userId)
            if clientGiftVer >= 3.824:
                # 新礼包过滤老礼包
                from poker.entity.configure import gdata
                roomConf = gdata.getRoomConfigure(event.roomId)
                newTypeOfGift = roomConf.get('newTypeOfGift', 0) if roomConf else None
                if ftlog.is_debug():
                    ftlog.debug('ChargeLead handleEvent', 'roomId=', event.roomId,
                                'clientVer=', clientGiftVer, 'newTypeOfGift=', newTypeOfGift,
                                'roomConf=', roomConf, 'newTypeOfGift=', newTypeOfGift)
                if newTypeOfGift:
                    return

            winstreak = gamedata.getGameAttr(event.userId, event.gameId, 'winstreak') or 0

            # 纪录连胜日志, 方便以后线上查询
            ftlog.debug('[<ChargeLead>UserTableWinloseEvent|isWin=True]Dizhu',
                       'gameId=', event.gameId,
                       'userId=', event.userId,
                       'roomId=', event.roomId,
                       'slam=', winlose.slam,
                       'chunTian=', winlose.chunTian,
                       'skillLevelUp=', event.skillLevelUp,
                       'mixConfRoomId=', event.mixConfRoomId,
                       'winstreak=', winstreak)
            
            clientId = sessiondata.getClientId(event.userId)
            _, clientVer, _ = strutil.parseClientId(clientId)

            # 当玩家取得3的倍数连胜时或达成春天、大满贯(及以上倍数)取胜时弹出高手礼包
            if winstreak % 3 == 0 or winlose.slam or winlose.chunTian:
                if ftlog.is_debug():
                    ftlog.debug('ChargeLead.handleEvent gameId=', event.gameId,
                                'userId=', event.userId,
                                'roomId=', event.roomId,
                                'winstreak=', winstreak,
                                'mixConfRoomId=', event.mixConfRoomId,
                                'clientId=', clientId)

                if clientVer >= 3.7:
                    todotask = hallpopwnd.makeTodoTaskWinBuy(event.gameId, event.userId, clientId, event.mixConfRoomId or event.roomId)
                    if todotask:
                        todotask.setParam('delay', 3)
                        TodoTaskHelper.sendTodoTask(event.gameId, event.userId, todotask)
                else:
                    product, _ = hallproductselector.selectWinleadProduct(event.gameId, event.userId, clientId, event.mixConfRoomId or event.roomId)
                    if not product:
                        ftlog.warn('ChargeLead.handleEvent NotFoundProduct gameId=', event.gameId,
                                   'userId=', event.userId,
                                   'roomId=', event.roomId,
                                   'winstreak=', winstreak,
                                   'mixConfRoomId=', event.mixConfRoomId,
                                   'clientId=', clientId)
                        return
                    cls.sendChargeLeadToDoTask(event.gameId, event.userId, product)
        except:
            ftlog.exception()
Пример #27
0
 def getRoomConfKey(self, key):
     roomConf = gdata.getRoomConfigure(self.roomId)
     return roomConf[key]
Пример #28
0
 def getRoomConfigWitBighRoomId(cls, roomId):
     '''
     获取房间ID的配置
     :param roomId 配置中的ID,如:6015
     '''
     return gdata.getRoomConfigure(roomId)
Пример #29
0
    def getMatchStates(cls, room, userId, player, mo):
        match = cls.getMatch(room.roomId)
        if not match:
            mo.setError(1, u'非比赛房间')
            return
        if player and player.matchInst.match != match:
            mo.setError(1, u'非比赛房间')
            ftlog.warn('ArenaMatchIF.getMatchStates room=', room.roomId,
                       'matchId=', match.matchId, 'userId=', userId,
                       'player.match=', player.matchInst.matchId, 'diff match')
            return
        inst = player.matchInst if player else match.currentInstance
        state = cls.translateState(inst.state) if inst else 0
        mo.setResult('roomId', room.roomId)
        mo.setResult('state', state)
        curPlayer = 0
        if player and player.stage:
            curPlayer = player.stage.stageConf.totalUserCount
        else:
            if inst and inst.state == MatchInstance.STATE_STARTED:
                maxUserCount = int(inst.matchConf.stages[0].totalUserCount)
                minUserCount = maxUserCount - max(1, int(maxUserCount * 0.15))
                curPlayer = random.randint(minUserCount, maxUserCount -
                                           1)  #inst.getSigninCount()

        mo.setResult('inst', inst.instId)
        mo.setResult('curPlayer', curPlayer)
        mo.setResult('curTimeLeft', 0)
        mo.setResult('startTime', '')

        bigRoomId = gdata.getBigRoomId(room.roomId)
        roomInfo = dizhuhallinfo.loadAllRoomInfo(DIZHU_GAMEID).get(bigRoomId)
        roomconf = gdata.getRoomConfigure(bigRoomId)

        peopleNumberBase = max(roomInfo.playerCount, roomInfo.signinCount)
        peopleNumber = max(peopleNumberBase * 9 - random.randint(80, 88), 0)
        startTime = roomconf.get('matchConf', {}).get('startTime')
        stopTime = roomconf.get('matchConf', {}).get('stopTime')
        # Arena比赛在开赛时间之内
        if cls.checkTime(startTime, stopTime):
            mo.setResult('onlinePlayerCount', peopleNumber)
            mo.setResult('signinPlayerCount', peopleNumber)
        else:
            mo.setResult('onlinePlayerCount',
                         roomInfo.playerCount if roomInfo else 0)
            mo.setResult('signinPlayerCount',
                         roomInfo.signinCount if roomInfo else 0)

        if ftlog.is_debug():
            ftlog.debug('ArenaMatchIF.getMatchStates room=', room.roomId,
                        'matchId=', match.matchId, 'userId=', userId,
                        'player=', player, 'stageIndex=',
                        player.stage.index if player and player.stage else -1)

        if not player or not player.stage:
            return

        tcount = 1
        allcount = player.stage.stageConf.totalUserCount
        rank = player.rank
        if player.seat:
            rank = player.tableDisplayRank
        waitInfo = {
            'uncompleted': tcount,  # 还有几桌未完成
            'tableRunk': '%d/3' % player.tableRank,  # 本桌排名
            'runk': '%d/%d' % (rank, allcount),  # 总排名
            'chip': player.score,  # 当前积分
        }
        if player.state == MatchPlayer.STATE_WAIT and player.stage.index != 0:
            waitInfo['info'] = '您已经成功晋级,请等待其他玩家完成本轮比赛'
        mo.setResult('waitInfo', waitInfo)
        mo.setResult('progress', 0)