Exemplo n.º 1
0
def getGameCount(userId, clientId):
    count = 0
    for gameId in pokerconf.getConfigGameIds():
        if gameId not in gdata.games():
            continue

        gCount = gdata.games()[gameId].getPlayGameInfoByKey(userId, clientId, TYGame.PLAY_COUNT)
        ftlog.debug('hall_simple_invite.getGameCount gameId:', gameId, ' gameCount:', gCount)
        if gCount:
            count += gCount

    ftlog.debug('hall_simple_invite.getGameCount gameIds:', pokerconf.getConfigGameIds()
                , ' gameCount:', count)
    return count
Exemplo n.º 2
0
def _initializeTables(gdatas):
    '''
    初始化所有的桌子对象
    '''
    if _DEBUG:
        debug('initializeTables begin')
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)  # 获取所有房间ids
    if roomids:
        allrooms = gdata.roomIdDefineMap()  # 房间定义映射
        tyrooms = gdata.rooms()  # 所有房间实例字典
        for roomid in roomids:
            room = tyrooms[roomid]
            roomdefine = allrooms[roomid]
            gameins = gdata.games()[roomdefine.gameId]  # 房间游戏实例TYGame
            if _DEBUG:
                debug('initializeTables roomid=', roomid, 'tableCount=',
                      roomdefine.tableCount)
            if roomdefine.tableCount > 0:  # 桌子数
                baseid = roomid * 10000 + 1  # 桌子开始的id
                for x in xrange(roomdefine.tableCount):
                    tableid = baseid + x
                    tableins = gameins.newTable(room, tableid)  # 创建桌子
                    room.maptable[tableid] = tableins  # 桌子映射实例
    if _DEBUG:
        debug('initializeTables end')
Exemplo n.º 3
0
def __initializeTables(gdatas):
    '''
    初始化所有的桌子对象
    '''
    if _DEBUG:
        debug('initializeTables begin')
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)
    if roomids:
        allrooms = gdata.roomIdDefineMap()
        tyrooms = gdata.rooms()
        for roomid in roomids:
            room = tyrooms[roomid]
            roomdefine = allrooms[roomid]
            gameins = gdata.games()[roomdefine.gameId]
            if _DEBUG:
                debug('initializeTables roomid=', roomid, 'tableCount=',
                      roomdefine.tableCount)
            if roomdefine.tableCount > 0:
                baseid = roomid * 10000 + 1
                for x in xrange(roomdefine.tableCount):
                    tableid = baseid + x
                    tableins = gameins.newTable(room, tableid)
                    assert (isinstance(tableins, TYTable))
                    room.maptable[tableid] = tableins
    if _DEBUG:
        debug('initializeTables end')
Exemplo n.º 4
0
def __initializeTables(gdatas):
    '''
    初始化所有的桌子对象
    '''
    if _DEBUG:
        debug('initializeTables begin')
    srvid = gdata.serverId()
    roomids = gdata.srvIdRoomIdListMap().get(srvid, None)
    if roomids:
        allrooms = gdata.roomIdDefineMap()
        tyrooms = gdata.rooms()
        for roomid in roomids:
            room = tyrooms[roomid]
            roomdefine = allrooms[roomid]
            gameins = gdata.games()[roomdefine.gameId]
            if _DEBUG:
                debug('initializeTables roomid=', roomid, 'tableCount=', roomdefine.tableCount)
            if roomdefine.tableCount > 0:
                baseid = roomid * 10000 + 1
                for x in xrange(roomdefine.tableCount):
                    tableid = baseid + x
                    tableins = gameins.newTable(room, tableid)
                    assert (isinstance(tableins, TYTable))
                    room.maptable[tableid] = tableins
    if _DEBUG:
        debug('initializeTables end')
Exemplo n.º 5
0
def getGameCount(userId, clientId):
    count = 0
    for gameId in pokerconf.getConfigGameIds():
        if gameId not in gdata.games():
            continue

        gCount = gdata.games()[gameId].getPlayGameInfoByKey(
            userId, clientId, TYGame.PLAY_COUNT)
        ftlog.debug('hall_simple_invite.getGameCount gameId:', gameId,
                    ' gameCount:', gCount)
        if gCount:
            count += gCount

    ftlog.debug('hall_simple_invite.getGameCount gameIds:',
                pokerconf.getConfigGameIds(), ' gameCount:', count)
    return count
Exemplo n.º 6
0
def _initializeRpcMehodss(gdata_):
    '''
    初始化RPC的命令入口, 获取各个游戏的实例的handler进行注册处理
    分游戏自动搜索自定义的RPC方法
    '''
    ftlog.debug('_initializeRpcMehodss begin')
    mpkgs = ['poker']
    for _, tygame in gdata.games().items():
        mpkgs.append(tygame._packageName)

    for mpkg in mpkgs:
        ftlog.debug('_initializeRpcMehodss package->', mpkg)
        # 注册RCP Server调用入口
        for rpcSevPkg in gdata.SRV_TYPE_PKG_NAME.values():
            pkg = mpkg + '.servers.' + rpcSevPkg + '.rpc'
            methods = decorator._loadDecoratorModuleMethods(pkg, 'markRpcCall')
            for method in methods:
                assert (method in _MARKED_METHOD)
                del _MARKED_METHOD[_MARKED_METHOD.index(method)]
                _registerRpcCall(method)
    for pkg in _SYS_RPC_PACKAGES:
        methods = decorator._loadDecoratorModuleMethods(pkg, 'markRpcCall')
        for method in methods:
            assert (method in _MARKED_METHOD)
            del _MARKED_METHOD[_MARKED_METHOD.index(method)]
            _registerRpcCall(method)

    if _MARKED_METHOD:
        for m in _MARKED_METHOD:
            ftlog.warn('this method marked as RCP, but not in rpc packages !!', getattr(m, decorator._METHOD_MARKE))
    cps = _runenv._rpc_methods.keys()
    cps.sort()
    for cp in cps:
        ftlog.debug('RPC CMD->', cp, _runenv._rpc_methods[cp])
    ftlog.debug('_initializeRpcMehodss end')
Exemplo n.º 7
0
    def __init__(self, roomdefine):
        super(TYBigMatchRoom, self).__init__(roomdefine)
        self.bigmatchId = self.bigRoomId
        self.matchPlugin = gdata.games()[self.gameId].getBigMatchPlugin()

        serverType = gdata.serverType()
        if serverType == gdata.SRV_TYPE_ROOM:
            self.initMatch()  # 此处会给self.match赋值
Exemplo n.º 8
0
def doTableGameCall(gameId, roomId, tableId, roundId, userId, callValue,
                    isGrab):
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            UserTableCallEvent(gameId, userId, roomId, tableId, callValue,
                               isGrab))
    return 1
Exemplo n.º 9
0
    def __init__(self, roomdefine):
        super(TYBigMatchRoom, self).__init__(roomdefine)
        self.bigmatchId = self.bigRoomId
        self.matchPlugin = gdata.games()[self.gameId].getBigMatchPlugin()

        serverType = gdata.serverType()
        if serverType == gdata.SRV_TYPE_ROOM:
            self.initMatch()  # 此处会给self.match赋值
Exemplo n.º 10
0
 def __call__(self, gameId=0, *args, **kwargs):
     v = None
     if gameId > 0:
         v = gdata.games()[gameId]
     else:
         if self.instance is None:
             self.instance = super(_TYGameCallAble, self).__call__(*args, **kwargs)
         v = self.instance
     return v
Exemplo n.º 11
0
    def __initMatch(self):
        return  # SNG 已下线

        self.matchPlugin = gdata.games()[self.gameId].getSngMatchPlugin()
        self.matchPlugin.initMatchConfs(self.gameId)

        serverType = gdata.serverType()
        if serverType == gdata.SRV_TYPE_ROOM:
            self.matchPlugin.cancelMatch(self)
Exemplo n.º 12
0
def _initializeCommands(gdatas):
    """
    初始化HTTP和TCP, RPC的命令入口, 获取各个游戏的实例的handler进行注册处理
    分游戏自动搜索所需要的handler
    分服务类型自动注册相应的服务handler
    对远程调用接口自动进行local和remote的预处理
    """
    ftlog.debug('initializeCommands begin')
    stype = gdata.serverType()
    for gameId, tygame in gdata.games().items():
        hpkg = gdata.SRV_TYPE_PKG_NAME[stype]
        mpkg = tygame._packageName
        pkg = mpkg + '.servers.' + hpkg
        ftlog.debug('initializeCommands package->', gameId, pkg)
        # 动态查找注册HTTP的命令入口
        hclazzs = decorator._loadDecoratorClass(pkg, 'markHttpHandler')
        for fullName, hclazz in hclazzs.items():
            handler = hclazz()
            if __isHandlerEnable(handler):
                hmts = decorator._findDecoratorMethod(handler, 'markHttpMethod')
                for mt in hmts:
                    __registerHttpMethod(gameId, fullName, handler, mt[0], mt[1])
        # 动态查找注册CMD#ACTION的命令入口
        hclazzs = decorator._loadDecoratorClass(pkg, 'markCmdActionHandler')
        for fullName, hclazz in hclazzs.items():
            handler = hclazz()
            if __isHandlerEnable(handler):
                hmts = decorator._findDecoratorMethod(handler, 'markCmdActionMethod')
                for mt in hmts:
                    __registerCmdActionMethod(gameId, fullName, handler, mt[0], mt[1])

        if stype != gdata.SRV_TYPE_AGENT:
            # 动态查找注册RPC的命令入口
            hclazzs = decorator._loadDecoratorClass(pkg, 'markRpcHandler')
            for fullName, hclazz in hclazzs.items():
                handler = hclazz()
                if __isHandlerEnable(handler):
                    hmts = decorator._findDecoratorMethod(handler, 'markRpcMethod')
                    for mt in hmts:
                        __registerLocalRpcMethod(gameId, fullName, handler, mt[0], mt[1])

            # 查找所有的游戏的RPC Client的, 进行预处理
            for rpcSrvType, rpcSevPkg in gdata.SRV_TYPE_PKG_NAME.items():
                pkg = mpkg + '.servers.' + rpcSevPkg
                hclazzs = decorator._loadDecoratorClass(pkg, 'markRpcHandler')
                for fullName, hclazz in hclazzs.items():
                    handler = hclazz()
                    if __isHandlerEnable(handler):
                        hmts = decorator._findDecoratorMethod(handler, 'markRpcMethod')
                        for mt in hmts:
                            __registerRemoteRpcMethod(gameId, rpcSrvType, fullName, handler, mt[0], mt[1])

    cps = _runenv._cmd_path_methods.keys()
    cps.sort()
    for cp in cps:
        ftlog.debug('TCP CMD->', cp, _runenv._cmd_path_methods[cp])
    ftlog.debug('initializeCommands end')
Exemplo n.º 13
0
 def _unregisterEvents(self):
     for eventType, gameIds in self._interestEventMap.iteritems():
         for gameId in gameIds:
             game = gdata.games().get(gameId)
             if game:
                 game.getEventBus().unsubscribe(eventType, self._handleEvent)
             else:
                 ftlog.warn('TYTaskSystemImpl._registerEvents gameId=', gameId,
                            'err=', 'Not find game')
     self._interestEventMap = {}
Exemplo n.º 14
0
def publishMatchWinloseEvent(userId, gameId, matchId, isGroup, isWin, rank,
                             signinUserCount, rewards, luckyValue):
    ftlog.debug(
        "publishMatchWinloseEvent->gameId, userId, matchId, isWin, rank:",
        gameId, userId, matchId, isWin, rank)
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            MatchWinloseEvent(userId, gameId, matchId, isGroup, isWin, rank,
                              signinUserCount, rewards, luckyValue))
Exemplo n.º 15
0
 def __call__(self, gameId=0, *args, **kwargs):
     v = None
     if gameId > 0:
         v = gdata.games()[gameId]
     else:
         if self.instance is None:
             self.instance = super(_TYGameCallAble,
                                   self).__call__(*args, **kwargs)
         v = self.instance
     return v
Exemplo n.º 16
0
 def _unregisterEvents(self):
     for eventType, gameIds in self._interestEventMap.iteritems():
         for gameId in gameIds:
             game = gdata.games().get(gameId)
             if game:
                 game.getEventBus().unsubscribe(eventType,
                                                self._handleEvent)
             else:
                 ftlog.warn('TYTaskSystemImpl._registerEvents gameId=',
                            gameId, 'err=', 'Not find game')
     self._interestEventMap = {}
Exemplo n.º 17
0
    def __initMatch(self):
        return  # 游轮赛已下线

        self.matchPlugin = gdata.games()[self.gameId].getLtsMatchPlugin()
        self.matchPlugin.initMatchConfs(self.gameId)

        serverType = gdata.serverType()
        if serverType == gdata.SRV_TYPE_TABLE:
            endTimestamp = self.matchPlugin.match_room_confs[
                self.bigRoomId]["end_timestamp"]
            FTTimer(endTimestamp - int(time.time()) + 5, self._checkMatchEnd)
Exemplo n.º 18
0
 def __init__(self, roomdefine):
     super(TYErdayiMatchRoom, self).__init__(roomdefine)
     self.bigmatchId = self.bigRoomId
     self.matchPlugin = gdata.games()[self.gameId].getErdayiMatchPlugin()
     self.match = None
     self.matchMaster = None
     self._logger = Logger()
     self._logger.add('roomId', self.roomId)
     self._logger.add('bigmatchId', self.bigmatchId)
     serverType = gdata.serverType()
     if serverType == gdata.SRV_TYPE_ROOM:
         self.initMatch()  # 此处会给self.match赋值
Exemplo n.º 19
0
 def __init__(self, roomdefine):
     super(TYGroupMatchRoom, self).__init__(roomdefine)
     self.bigmatchId = self.bigRoomId
     self.matchPlugin = gdata.games()[self.gameId].getGroupMatchPlugin()
     self.match = None
     self.matchMaster = None
     self._logger = Logger()
     self._logger.add('roomId', self.roomId)
     self._logger.add('bigmatchId', self.bigmatchId)
     serverType = gdata.serverType()
     if serverType == gdata.SRV_TYPE_ROOM:
         self.initMatch()  # 此处会给self.match赋值
Exemplo n.º 20
0
def publishMatchWinloseEvent(gameId,
                             userId,
                             matchId,
                             isWin,
                             rank,
                             signinUserCount,
                             rewards=None):
    ftlog.debug("<< |gameId, userId, matchId, isWin, rank:", gameId, userId,
                matchId, isWin, rank)
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            MatchWinloseEvent(userId, gameId, matchId, isWin, rank,
                              signinUserCount, rewards))
Exemplo n.º 21
0
 def _registerEvents(self, taskKinds):
     interestEventMap = self._collectInterestEventMap(taskKinds)
     for eventType, gameIds in interestEventMap.iteritems():
         for gameId in gameIds:
             game = gdata.games().get(gameId)
             if game:
                 if ftlog.is_debug():
                     ftlog.debug('RPTaskSystem._registerEvents gameId=',
                                 gameId, 'eventType=', eventType)
                 game.getEventBus().subscribe(eventType, self._handleEvent)
             else:
                 ftlog.warn('RPTaskSystem._registerEvents gameId=', gameId,
                            'eventType=', eventType, 'err=',
                            'Not find game')
Exemplo n.º 22
0
    def _register_events(cls, task_kinds):
        event_map = cls._collect_event_map(task_kinds)
        for event_type, gameIds in event_map.iteritems():
            for gameId in gameIds:
                game = gdata.games().get(gameId)
                if not game:
                    ftlog.warn('SegmentTaskData._register_events gameId=',
                               gameId, 'eventType=', event_type, 'err=',
                               'Not find game')

                if ftlog.is_debug():
                    ftlog.debug('SegmentTaskData._register_events gameId=',
                                gameId, 'eventType=', event_type)
                game.getEventBus().subscribe(event_type, cls.handle_event)
Exemplo n.º 23
0
    def __init__(self, gameId):
        super(DiFangRobotManager, self).__init__()
        res = loadResource('robot_info.json')
        rinfo = strutil.loads(res)
        baseSnsId = rinfo['basesnsid'] + gdata.serverId()
        users = []
        names = ["rb_" + str(gameId) + "_" + str(uid) for uid in xrange(MAX_ROBOT_UID)]
        # names = ["rb_" + str(uid + 1) for uid in xrange(MAX_ROBOT_UID)]
        #         names = rinfo["names"]
        for x in xrange(len(names)):
            name = names[x]
            snsId = baseSnsId + '_' + str(gameId) + "_" + str(x)
            users.append(gdata.games()[gameId].RobotUserClass(None, snsId, name))
        self.freeRobotUsers = users

        ftlog.info('>> |gameId, robot user count:', gameId, len(users), caller=self)
Exemplo n.º 24
0
 def _registerEvents(self):
     for taskKind in self._taskKindMap.values():
         for inspector in taskKind.inspectors:
             for eventType, gameIds in inspector.interestEventMap.iteritems():
                 gameIds = gameIds or gdata.gameIds()
                 for gameId in gameIds:
                     game = gdata.games().get(gameId)
                     if game:
                         game.getEventBus().subscribe(eventType, self._handleEvent)
                         self._addInterestEventType(eventType, gameId)
                         if ftlog.is_debug():
                             ftlog.debug('TYTaskSystemImpl._registerEvents eventType=', eventType,
                                         'gameId=', gameId,
                                         'taskUnitId=', taskKind.taskUnit.taskUnitId)
                     else:
                         ftlog.warn('TYTaskSystemImpl._registerEvents gameId=', gameId,
                                    'err=', 'Not find game')
Exemplo n.º 25
0
def doTableThrowEmojiFrom_3_775(gameId,
                                userId,
                                roomId,
                                bigRoomId,
                                tableId,
                                emojiId,
                                minchip,
                                price,
                                charmDelta,
                                clientId,
                                count,
                                throwWhenChipZero=False):
    assert (count > 0)
    if 0 == price:
        return count, 0, 0

    eventId = 'EMOTICON_%s_CONSUME' % (emojiId.upper())
    costChip = price * count
    trueDelta, final = userchip.incrChipLimit(
        userId, gameId, -costChip, -1, -1,
        daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO, eventId, roomId, clientId)
    # 没有金币则返回0
    if trueDelta == 0:
        return 0, trueDelta, final

    # 真实的发送个数,金币不足也至少发送一次
    realCostChip = abs(trueDelta)
    realCount = max(1, int(math.ceil(realCostChip / price)))
    if realCostChip > 0:
        datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
        bireport.gcoin('out.chip.emoticon', gameId, realCostChip)
        bireport.gcoin('out.smilies.' + emojiId + '.' + str(bigRoomId), gameId,
                       realCostChip)
    # 魅力值
    userdata.incrCharm(userId, charmDelta * realCount)
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            UseTableEmoticonEvent(gameId, userId, roomId, tableId, emojiId,
                                  price, realCount))
    return realCount, trueDelta, final
Exemplo n.º 26
0
 def _registerEvents(self):
     for taskKind in self._taskKindMap.values():
         for inspector in taskKind.inspectors:
             for eventType, gameIds in inspector.interestEventMap.iteritems(
             ):
                 gameIds = gameIds or gdata.gameIds()
                 for gameId in gameIds:
                     game = gdata.games().get(gameId)
                     if game:
                         game.getEventBus().subscribe(
                             eventType, self._handleEvent)
                         self._addInterestEventType(eventType, gameId)
                         if ftlog.is_debug():
                             ftlog.debug(
                                 'TYTaskSystemImpl._registerEvents eventType=',
                                 eventType, 'gameId=', gameId,
                                 'taskUnitId=',
                                 taskKind.taskUnit.taskUnitId)
                     else:
                         ftlog.warn(
                             'TYTaskSystemImpl._registerEvents gameId=',
                             gameId, 'err=', 'Not find game')
Exemplo n.º 27
0
    def __initMatch(self):
        # 老框架plugin被PluginCenter reload后XXPlugin类的id会发生变化,为了避免此问题,新框架里matchPlugin不再注册到PluginCenter
        self.matchPlugin = gdata.games()[self.gameId].getMttMatchPlugin()
        lastMatchStartTimeStamp = self.matchPlugin.getMatchStartTime(self.bigRoomId)
        self.matchPlugin.refreshMatchInfo(self.roomDefine)
        self.configChanged = False

        self.__initRedisLua()

        self.matchCounter = {}
        self.ranking = Ranking(self, 0)
        self.state = self.MTT_STATE_IDLE

        serverType = gdata.serverType()
        if serverType == gdata.SRV_TYPE_ROOM:
            nowTimeStamp = int(time.time())
            if lastMatchStartTimeStamp and nowTimeStamp + self.matchPlugin.timedeltaEnterMatch >= lastMatchStartTimeStamp:
                # 重启后房间对象数据会被清空,重启前已经进入比赛房间的玩家需要退票;
                self.matchPlugin.cancelMatch(self, isRestart=True)
            else:  # 报名信息在redis中,重启不会丢失;
                self.state = self.MTT_STATE_READY

            self.doHeartBeat()
Exemplo n.º 28
0
def doTableThrowEmojiFromBursts(gameId, userId, roomId, tableId, emojiId,
                                charmDelta, burstsConf):

    assert (burstsConf.get('cost', {}).get('count', 0) > 0)

    cost = burstsConf.get('cost')
    contentItemList = [cost]
    eventId = 'EMOTICON_%s_CONSUME' % (emojiId.upper())
    assetKindId, count = user_remote.consumeAssets(gameId, userId,
                                                   contentItemList, eventId,
                                                   roomId)
    if assetKindId:
        return 0

    # 魅力值
    userdata.incrCharm(userId, charmDelta * burstsConf.get('count', 1))
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            UseTableEmoticonEvent(gameId, userId, roomId, tableId, emojiId,
                                  cost.get('count', 0),
                                  burstsConf.get('count', 0)))
    return burstsConf.get('count', 0)
Exemplo n.º 29
0
def doTableGameStart(gameId, roomId, tableId, roundId, dizhuUserId,
                     baseCardType, baseScore, userId, **kwargs):
    # 魅力值
    bigRoomId = gdata.roomIdDefineMap()[roomId].bigRoomId
    tbinfo = treasurebox.updateTreasureBoxStart(
        gameId, userId,
        kwargs.get('mixConfRoomId') or bigRoomId)
    # 更新每个人的winrate
    checkSetMedal(gameId, userId, baseScore, True, 0)
    # 更新牌桌的winrate
    roomConfigure = gdata.roomIdDefineMap()[roomId].configure
    if ftlog.is_debug():
        ftlog.debug('comm_table_remote.doTableGameStart userId=', userId,
                    'roomId, tableId, roundId=', roomId, tableId, roundId,
                    'typeName=', roomConfigure.get('typeName'))
    if roomConfigure.get('typeName') in ['dizhu_normal', 'dizhu_mix']:
        increaceChipTableWinrate(gameId, userId, True, 0)
    # 触发每个人的游戏开始事件
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(
            UserTablePlayEvent(gameId, userId, roomId, tableId, baseCardType,
                               dizhuUserId))
    return tbinfo
Exemplo n.º 30
0
def _loadRoomDefines(gdatas):
    '''
    需要整理一个全局的 serverid-roomid-roombaseinfo的大集合
    取得server_rooms.json的配置内容, key为服务ID, value为房间配置内容
    '''
    if _DEBUG:
        debug('loadRoomDefines begin')
    # 首先整理进程ID, 展开多房间进程的进程ID
    srvid_rooms_map = {}
    srvidmap = {}
    allserver = gdata.allServersMap()
    for k in allserver:
        srvid_rooms_map[k] = []
        if k.find('-') > 0:
            assert (k.find(gdata.SRV_TYPE_ROOM) == 0
                    or k.find(gdata.SRV_TYPE_TABLE) == 0)
            tail = '000'
            if k.find(gdata.SRV_TYPE_TABLE) == 0:
                tail = '001'
            ks = k.split('-')
            ps = int(ks[1])
            pe = int(ks[2])
            assert (ps > 0 and ps < 999)
            assert (pe > 0 and pe < 999)
            assert (ps < pe)
            for x in xrange(ps, pe + 1):
                playid = '%03d' % (x)
                sid = ks[0] + playid + ks[3]
                srvidmap[sid + tail] = k
        else:
            if k.find(gdata.SRV_TYPE_ROOM) == 0:
                srvidmap[k + '000'] = k
            if k.find(gdata.SRV_TYPE_TABLE) == 0:
                srvidmap[k] = k

    clsRoomDefine = namedtuple('RoomDefine', [
        'bigRoomId', 'parentId', 'roomId', 'gameId', 'configId', 'controlId',
        'shadowId', 'serverId', 'tableCount', 'shadowRoomIds', 'configure'
    ])

    roomid_define_map = {}
    big_roomids_map = {}
    gameid_big_roomids_map = {}
    # 取得说有挂接的游戏ID, 取得对应GAMEID的房间配置
    gameids = gdata.games().keys()
    if _DEBUG:
        debug('the game ids=', gameids)
    for gid in gameids:
        gameid_big_roomids_map[gid] = []
        roomdict = ftcon.getConfNoCache('GET', 'game:' + str(gid) + ':room:0')
        if roomdict:
            roomdict = strutil.loads(roomdict)
        if not isinstance(roomdict, dict):
            if _DEBUG:
                debug('the game of', gid, 'have no room !')
            continue
        for roomIdStr, configure in roomdict.items():
            bigRoomId = int(roomIdStr)
            gameid, configid = strutil.parseBigRoomId(bigRoomId)

            configure = _auto_change_room_count(configure)
            controlServerCount = int(configure['controlServerCount'])
            controlTableCount = int(configure['controlTableCount'])
            gameServerCount = int(configure['gameServerCount'])
            gameTableCount = int(configure['gameTableCount'])

            assert (gameid == gid)
            assert (configid > 0
                    and configid < 999), '%s,%s' % (roomIdStr, str(configure))
            assert (controlServerCount > 0
                    and controlServerCount < 9), '%s,%s' % (roomIdStr,
                                                            str(configure))
            assert (controlTableCount >= 0
                    and controlTableCount < 9999), '%s,%s' % (roomIdStr,
                                                              str(configure))
            assert (gameServerCount >= 0
                    and gameServerCount < 999), '%s,%s' % (roomIdStr,
                                                           str(configure))
            assert (gameTableCount > 0
                    and gameTableCount < 9999), '%s,%s' % (roomIdStr,
                                                           str(configure))
            assert (not bigRoomId in big_roomids_map)

            extconfig = ftcon.getConfNoCache(
                'GET', 'game:' + str(gid) + ':room:' + str(bigRoomId))
            if extconfig:
                extconfig = strutil.loads(extconfig)
            if isinstance(extconfig, dict):
                configure.update(extconfig)
            gameid_big_roomids_map[gid].append(bigRoomId)
            big_roomids_map[bigRoomId] = []
            for m in xrange(controlServerCount):
                # 自动计算controlId, 重1开始
                controlId = m + 1
                controlRoomId = (bigRoomId * 10 + controlId) * 1000
                shadowRooms = []
                assert (not controlRoomId in big_roomids_map)
                assert (not controlRoomId in roomid_define_map)
                for n in xrange(gameServerCount):
                    # 自动计算shadowId, 重1开始, 此处为桌子运行的房间
                    shadowId = n + 1
                    shadowRoomId = controlRoomId + shadowId
                    assert (not shadowRoomId in roomid_define_map)
                    processId = gdata.SRV_TYPE_TABLE + str(shadowRoomId)
                    serverId = srvidmap[processId]
                    srvid_rooms_map[serverId].append(shadowRoomId)
                    shadowRooms.append(shadowRoomId)
                    roomid_define_map[shadowRoomId] = clsRoomDefine(
                        bigRoomId, controlRoomId, shadowRoomId, gameid,
                        configid, controlId, shadowId, serverId,
                        gameTableCount, tuple([]), configure)
                    if _DEBUG:
                        debug('load room define->bigRoomId=', bigRoomId,
                              'parentId=', controlRoomId, 'roomId=',
                              shadowRoomId, 'gameId=', gameid, 'configId=',
                              configid, 'controlId=', controlId, 'shadowId=',
                              shadowId, 'tableCount=', gameTableCount,
                              'serverId=', serverId)

                # 此处为控制房间
                processId = gdata.SRV_TYPE_ROOM + str(controlRoomId)
                serverId = srvidmap[processId]
                srvid_rooms_map[serverId].append(controlRoomId)
                big_roomids_map[bigRoomId].append(controlRoomId)
                roomid_define_map[controlRoomId] = clsRoomDefine(
                    bigRoomId, 0, controlRoomId, gameid, configid,
                    controlId, 0, serverId, controlTableCount,
                    tuple(shadowRooms), configure)

                if _DEBUG:
                    debug('load room define->bigRoomId=', bigRoomId,
                          'parentId=', 0, 'roomId=', controlRoomId, 'gameId=',
                          gameid, 'configId=', configid, 'controlId=',
                          controlId, 'shadowId=', 0, 'tableCount=',
                          controlTableCount, 'serverId=', serverId,
                          'shadowRooms=', shadowRooms)
        gameid_big_roomids_map[gid].sort()

    # 整理打印配置的内容
    if _DEBUG:
        debug('find big roomids=', big_roomids_map.keys())
    for k, v in big_roomids_map.items():
        if _DEBUG:
            debug('find big room id ', k, 'has childs:', v)
    for k in srvid_rooms_map.keys():
        if not srvid_rooms_map[k]:
            del srvid_rooms_map[k]
        else:
            if _DEBUG:
                debug('find server', k, 'has roomids:', srvid_rooms_map[k])

    gdatas['srvid_roomid_map'] = makeReadonly(srvid_rooms_map)
    gdatas['roomid_define_map'] = makeReadonly(roomid_define_map)
    gdatas['big_roomids_map'] = makeReadonly(big_roomids_map)
    gdatas['gameid_big_roomids_map'] = makeReadonly(gameid_big_roomids_map)
    if _DEBUG:
        debug('loadRoomDefines end')
Exemplo n.º 31
0
def isUserInMatch(roomId, matchInstId, gameId, userId):
    ftlog.debug('isUserInMatch, input: ', roomId, gameId, userId, matchInstId)
    return gdata.games()[gameId].getBigMatchPlugin().isUserInMatch(
        gdata.rooms()[roomId], userId, matchInstId)
Exemplo n.º 32
0
def getMatchAwardListInfo(roomId, gameId, userId):
    ftlog.debug('getMatchAwardListInfo, input: ', roomId, gameId, userId)
    return gdata.games()[gameId].getBigMatchPlugin().getMatchAwardListInfo(
        gdata.rooms()[roomId], userId)
Exemplo n.º 33
0
def getMatchInfoAbstract(roomId, gameId, userId, notAwardList=False):
    ftlog.debug('getMatchInfoAbstract, input: ', roomId, gameId, userId,
                notAwardList)
    return gdata.games()[gameId].getBigMatchPlugin().getMatchInfoAbstract(
        gdata.rooms()[roomId], userId, notAwardList)
Exemplo n.º 34
0
def publishUserTableCallEvent(gameId, userId, roomId, tableId, call, isTrueGrab):
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(UserTableCallEvent(gameId, userId, roomId,
                                                 tableId, call, isTrueGrab))
    return 1
Exemplo n.º 35
0
def publishMatchWinloseEvent(gameId, userId, matchId, isWin, rank, signinUserCount, rewards=None):
    ftlog.debug("<< |gameId, userId, matchId, isWin, rank:", gameId, userId, matchId, isWin, rank)
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(MatchWinloseEvent(userId, gameId, matchId, isWin, rank, signinUserCount, rewards))
Exemplo n.º 36
0
def publishReplayViewEvent(gameId, userId, videoId):
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(ReplayViewEvent(gameId, userId, videoId))
Exemplo n.º 37
0
def _initializeCommands(gdatas):
    """
    初始化HTTP和TCP, RPC的命令入口, 获取各个游戏的实例的handler进行注册处理
    分游戏自动搜索所需要的handler
    分服务类型自动注册相应的服务handler
    对远程调用接口自动进行local和remote的预处理
    """
    ftlog.debug('initializeCommands begin')
    stype = gdata.serverType()
    for gameId, tygame in gdata.games().items():
        hpkg = gdata.SRV_TYPE_PKG_NAME[stype]
        mpkg = tygame._packageName
        pkg = mpkg + '.servers.' + hpkg
        ftlog.debug('initializeCommands package->', gameId, pkg)
        # 动态查找注册HTTP的命令入口
        hclazzs = decorator._loadDecoratorClass(pkg, 'markHttpHandler')
        for fullName, hclazz in hclazzs.items():
            handler = hclazz()
            if __isHandlerEnable(handler):
                hmts = decorator._findDecoratorMethod(handler,
                                                      'markHttpMethod')
                for mt in hmts:
                    __registerHttpMethod(gameId, fullName, handler, mt[0],
                                         mt[1])
        # 动态查找注册CMD#ACTION的命令入口
        hclazzs = decorator._loadDecoratorClass(pkg, 'markCmdActionHandler')
        for fullName, hclazz in hclazzs.items():
            handler = hclazz()
            if __isHandlerEnable(handler):
                hmts = decorator._findDecoratorMethod(handler,
                                                      'markCmdActionMethod')
                for mt in hmts:
                    __registerCmdActionMethod(gameId, fullName, handler, mt[0],
                                              mt[1])

        if stype != gdata.SRV_TYPE_AGENT:
            # 动态查找注册RPC的命令入口
            hclazzs = decorator._loadDecoratorClass(pkg, 'markRpcHandler')
            for fullName, hclazz in hclazzs.items():
                handler = hclazz()
                if __isHandlerEnable(handler):
                    hmts = decorator._findDecoratorMethod(
                        handler, 'markRpcMethod')
                    for mt in hmts:
                        __registerLocalRpcMethod(gameId, fullName, handler,
                                                 mt[0], mt[1])

            # 查找所有的游戏的RPC Client的, 进行预处理
            for rpcSrvType, rpcSevPkg in gdata.SRV_TYPE_PKG_NAME.items():
                pkg = mpkg + '.servers.' + rpcSevPkg
                hclazzs = decorator._loadDecoratorClass(pkg, 'markRpcHandler')
                for fullName, hclazz in hclazzs.items():
                    handler = hclazz()
                    if __isHandlerEnable(handler):
                        hmts = decorator._findDecoratorMethod(
                            handler, 'markRpcMethod')
                        for mt in hmts:
                            __registerRemoteRpcMethod(gameId, rpcSrvType,
                                                      fullName, handler, mt[0],
                                                      mt[1])

    cps = _runenv._cmd_path_methods.keys()
    cps.sort()
    for cp in cps:
        ftlog.debug('TCP CMD->', cp, _runenv._cmd_path_methods[cp])
    ftlog.debug('initializeCommands end')
Exemplo n.º 38
0
def _getFriendGameInfo(userId, gameIds, for_level_info, for_winchip, for_online_info=1):
    uid = int(userId)
    datas = {}
    gid, rid, tid, sid = 0, 0, 0, 0
    state = daoconst.OFFLINE
    if for_online_info:
        loclist = onlinedata.getOnlineLocList(uid)
        state = onlinedata.getOnlineState(uid)
        if len(loclist) > 0:
            _rid, _tid, _sid = loclist[0]
            # gid表示用户在哪个游戏中
            gid = strutil.getGameIdFromInstanceRoomId(_rid)
            # 检查是否可加入游戏
            if TYGame(gid).canJoinGame(userId, _rid, _tid, _sid):
                # rid/tid/sid表示用户所在的游戏是否可加入游戏
                # 分享出来的都是可以加入游戏的牌桌信息
                rid = _rid
                tid = _tid
                sid = _sid
            if ftlog.is_debug():
                ftlog.debug('getFriendGameInfo userId:', userId, ' gameId:', gid, ' roomId:', _rid, ' tableId:', _tid,
                            ' seatId:', _sid, ' can not join game....')
        if state == daoconst.OFFLINE:
            offline_time = gamedata.getGameAttr(uid, HALL_GAMEID, 'offlineTime')
            if not offline_time:  # 取不到离线时间,取上线时间
                offline_time = userdata.getAttr(uid, 'authorTime')
            if offline_time:
                offline_time = pktimestamp.parseTimeMs(offline_time)
                delta = datetime.now() - offline_time
                delta = delta.days * 24 * 60 + delta.seconds / 60  # 分钟数
            else:  # 异常情况
                delta = 24 * 60
            datas['offline_time'] = delta if delta > 0 else 1
        if rid > 0:
            try:
                room = gdata.roomIdDefineMap().get(rid, None)
                if room:
                    datas['room_name'] = room.configure['name']
            except:
                ftlog.error()
    # 构造回传给SDK的游戏数据
    datas.update({'uid': uid, 'gid': gid, 'rid': rid, 'tid': tid, 'sid': sid, 'state': state})

    if for_level_info:
        datas['level_game_id'] = 0
        datas['level'] = 0
        datas['level_pic'] = ''
        try:
            for gameId in gameIds:
                if gameId not in gdata.games():
                    continue
                dashifen_info = gdata.games()[gameId].getDaShiFen(uid, '')
                if dashifen_info:
                    level = dashifen_info['level']
                    if level > 0 and level > datas['level']:
                        datas['level_game_id'] = gameId
                        datas['level'] = level
                        level_pic = dashifen_info.get('picbig')
                        datas['level_pic'] = level_pic if level_pic else dashifen_info.get('pic')
        except:
            ftlog.error()

    if for_winchip:
        datas['winchip'] = 0
        datas['winchips'] = 0
        try:
            for gameId in gameIds:
                winchips, todaychips = gamedata.getGameAttrs(userId, gameId, ['winchips', 'todaychips'], False)
                winchips = strutil.parseInts(winchips)
                yest_winchip = 0
                todaychips = strutil.loads(todaychips, ignoreException=True)
                if todaychips and 'today' in todaychips and 'chips' in todaychips and 'last' in todaychips:
                    if pktimestamp.formatTimeDayInt() == todaychips['today']:
                        yest_winchip = todaychips['last']
                    elif pktimestamp.formatTimeYesterDayInt() == todaychips['today']:
                        yest_winchip = todaychips['chips']
                datas['winchip'] += yest_winchip
                datas['winchips'] += winchips
        except:
            ftlog.error()
    return datas
Exemplo n.º 39
0
def __loadRoomDefines(gdatas):
    '''
    需要整理一个全局的 serverid-roomid-roombaseinfo的大集合
    取得server_rooms.json的配置内容, key为服务ID, value为房间配置内容
    '''
    if _DEBUG:
        debug('loadRoomDefines begin')
    # 首先整理进程ID, 展开多房间进程的进程ID
    srvid_rooms_map = {}
    srvidmap = {}
    allserver = gdata.allServersMap()
    for k in allserver:
        srvid_rooms_map[k] = []
        if k.find('-') > 0:
            assert (k.find(gdata.SRV_TYPE_ROOM) == 0 or k.find(gdata.SRV_TYPE_TABLE) == 0)
            tail = '000'
            if k.find(gdata.SRV_TYPE_TABLE) == 0:
                tail = '001'
            ks = k.split('-')
            ps = int(ks[1])
            pe = int(ks[2])
            assert (ps > 0 and ps < 999)
            assert (pe > 0 and pe < 999)
            assert (ps < pe)
            for x in xrange(ps, pe + 1):
                playid = '%03d' % (x)
                sid = ks[0] + playid + ks[3]
                srvidmap[sid + tail] = k
        else:
            if k.find(gdata.SRV_TYPE_ROOM) == 0:
                srvidmap[k + '000'] = k
            if k.find(gdata.SRV_TYPE_TABLE) == 0:
                srvidmap[k] = k

    clsRoomDefine = namedtuple('RoomDefine', ['bigRoomId', 'parentId', 'roomId', 'gameId',
                                              'configId', 'controlId', 'shadowId', 'serverId',
                                              'tableCount', 'shadowRoomIds', 'configure'])
    roomid_define_map = {}
    big_roomids_map = {}
    gameid_big_roomids_map = {}
    # 取得说有挂接的游戏ID, 取得对应GAMEID的房间配置
    gameids = gdata.games().keys()
    if _DEBUG:
        debug('the game ids=', gameids)
    for gid in gameids:
        gameid_big_roomids_map[gid] = []
        roomdict = ftcon.getConfNoCache('GET', 'game:' + str(gid) + ':room:0')
        if roomdict:
            roomdict = strutil.loads(roomdict)
        if not isinstance(roomdict, dict):
            if _DEBUG:
                debug('the game of', gid, 'have no room !')
            continue
        for roomIdStr, configure in roomdict.items():
            bigRoomId = int(roomIdStr)
            gameid, configid = strutil.parseBigRoomId(bigRoomId)

            configure = __auto_change_room_count(configure)
            controlServerCount = int(configure['controlServerCount'])
            controlTableCount = int(configure['controlTableCount'])
            gameServerCount = int(configure['gameServerCount'])
            gameTableCount = int(configure['gameTableCount'])

            assert (gameid == gid)
            assert (configid > 0 and configid < 999), '%s,%s' % (roomIdStr, str(configure))
            assert (controlServerCount > 0 and controlServerCount < 9), '%s,%s' % (roomIdStr, str(configure))
            assert (controlTableCount >= 0 and controlTableCount < 9999), '%s,%s' % (roomIdStr, str(configure))
            assert (gameServerCount >= 0 and gameServerCount < 999), '%s,%s' % (roomIdStr, str(configure))
            assert (gameTableCount > 0 and gameTableCount < 9999), '%s,%s' % (roomIdStr, str(configure))
            assert (not bigRoomId in big_roomids_map)

            extconfig = ftcon.getConfNoCache('GET', 'game:' + str(gid) + ':room:' + str(bigRoomId))
            if extconfig:
                extconfig = strutil.loads(extconfig)
            if isinstance(extconfig, dict):
                configure.update(extconfig)

            gameid_big_roomids_map[gid].append(bigRoomId)
            big_roomids_map[bigRoomId] = []
            for m in xrange(controlServerCount):
                # 自动计算controlId, 重1开始
                controlId = m + 1
                controlRoomId = (bigRoomId * 10 + controlId) * 1000
                shadowRooms = []
                assert (not controlRoomId in big_roomids_map)
                assert (not controlRoomId in roomid_define_map)
                for n in xrange(gameServerCount):
                    # 自动计算shadowId, 重1开始, 此处为桌子运行的房间
                    shadowId = n + 1
                    shadowRoomId = controlRoomId + shadowId
                    assert (not shadowRoomId in roomid_define_map)
                    processId = gdata.SRV_TYPE_TABLE + str(shadowRoomId)
                    serverId = srvidmap[processId]
                    srvid_rooms_map[serverId].append(shadowRoomId)
                    shadowRooms.append(shadowRoomId)
                    roomid_define_map[shadowRoomId] = clsRoomDefine(bigRoomId, controlRoomId, shadowRoomId, gameid,
                                                                    configid, controlId, shadowId, serverId,
                                                                    gameTableCount, tuple([]), configure)
                    if _DEBUG:
                        debug('load room define->bigRoomId=', bigRoomId, 'parentId=', controlRoomId,
                              'roomId=', shadowRoomId, 'gameId=', gameid, 'configId=', configid,
                              'controlId=', controlId, 'shadowId=', shadowId, 'tableCount=', gameTableCount,
                              'serverId=', serverId)

                # 此处为控制房间
                processId = gdata.SRV_TYPE_ROOM + str(controlRoomId)
                serverId = srvidmap[processId]
                srvid_rooms_map[serverId].append(controlRoomId)
                big_roomids_map[bigRoomId].append(controlRoomId)
                roomid_define_map[controlRoomId] = clsRoomDefine(bigRoomId, 0, controlRoomId, gameid,
                                                                 configid, controlId, 0, serverId,
                                                                 controlTableCount, tuple(shadowRooms), configure)
                if _DEBUG:
                    debug('load room define->bigRoomId=', bigRoomId, 'parentId=', 0,
                          'roomId=', controlRoomId, 'gameId=', gameid, 'configId=', configid,
                          'controlId=', controlId, 'shadowId=', 0, 'tableCount=', controlTableCount,
                          'serverId=', serverId, 'shadowRooms=', shadowRooms)
        gameid_big_roomids_map[gid].sort()

    # 整理打印配置的内容
    if _DEBUG:
        debug('find big roomids=', big_roomids_map.keys())
    for k, v in big_roomids_map.items():
        if _DEBUG:
            debug('find big room id ', k, 'has childs :', v)
    for k in srvid_rooms_map.keys():
        if not srvid_rooms_map[k]:
            del srvid_rooms_map[k]
        else:
            if _DEBUG:
                debug('find server', k, 'has roomids :', srvid_rooms_map[k])

    gdatas['srvid_roomid_map'] = makeReadonly(srvid_rooms_map)
    gdatas['roomid_define_map'] = makeReadonly(roomid_define_map)
    gdatas['big_roomids_map'] = makeReadonly(big_roomids_map)
    gdatas['gameid_big_roomids_map'] = makeReadonly(gameid_big_roomids_map)
    if _DEBUG:
        debug('loadRoomDefines end')
Exemplo n.º 40
0
def getMatchInfoAbstract(roomId, gameId, userId, notAwardList=False):
    ftlog.debug('getMatchInfoAbstract, input: ', roomId, gameId, userId, notAwardList)
    return gdata.games()[gameId].getBigMatchPlugin().getMatchInfoAbstract(gdata.rooms()[roomId], userId, notAwardList)
Exemplo n.º 41
0
def isUserInMatch(roomId, matchInstId, gameId, userId):
    ftlog.debug('isUserInMatch, input: ', roomId, gameId, userId, matchInstId)
    return gdata.games()[gameId].getBigMatchPlugin().isUserInMatch(gdata.rooms()[roomId], userId, matchInstId)
Exemplo n.º 42
0
def getMatchAwardListInfo(roomId, gameId, userId):
    ftlog.debug('getMatchAwardListInfo, input: ', roomId, gameId, userId)
    return gdata.games()[gameId].getBigMatchPlugin().getMatchAwardListInfo(gdata.rooms()[roomId], userId)
Exemplo n.º 43
0
def _getFriendGameInfo(userId,
                       gameIds,
                       for_level_info,
                       for_winchip,
                       for_online_info=1):
    uid = int(userId)
    datas = {}
    gid, rid, tid, sid = 0, 0, 0, 0
    state = daoconst.OFFLINE
    if for_online_info:
        loclist = onlinedata.getOnlineLocList(uid)
        state = onlinedata.getOnlineState(uid)
        if len(loclist) > 0:
            _rid, _tid, _sid = loclist[0]
            # gid表示用户在哪个游戏中
            gid = strutil.getGameIdFromInstanceRoomId(_rid)
            # 检查是否可加入游戏
            if TYGame(gid).canJoinGame(userId, _rid, _tid, _sid):
                # rid/tid/sid表示用户所在的游戏是否可加入游戏
                # 分享出来的都是可以加入游戏的牌桌信息
                rid = _rid
                tid = _tid
                sid = _sid
            if ftlog.is_debug():
                ftlog.debug('getFriendGameInfo userId:', userId, ' gameId:',
                            gid, ' roomId:', _rid, ' tableId:', _tid,
                            ' seatId:', _sid, ' can not join game....')
        if state == daoconst.OFFLINE:
            offline_time = gamedata.getGameAttr(uid, HALL_GAMEID,
                                                'offlineTime')
            if not offline_time:  # 取不到离线时间,取上线时间
                offline_time = userdata.getAttr(uid, 'authorTime')
            if offline_time:
                offline_time = pktimestamp.parseTimeMs(offline_time)
                delta = datetime.now() - offline_time
                delta = delta.days * 24 * 60 + delta.seconds / 60  # 分钟数
            else:  # 异常情况
                delta = 24 * 60
            datas['offline_time'] = delta if delta > 0 else 1
        if rid > 0:
            try:
                room = gdata.roomIdDefineMap().get(rid, None)
                if room:
                    datas['room_name'] = room.configure['name']
            except:
                ftlog.error()
    # 构造回传给SDK的游戏数据
    datas.update({
        'uid': uid,
        'gid': gid,
        'rid': rid,
        'tid': tid,
        'sid': sid,
        'state': state
    })

    if for_level_info:
        datas['level_game_id'] = 0
        datas['level'] = 0
        datas['level_pic'] = ''
        try:
            for gameId in gameIds:
                if gameId not in gdata.games():
                    continue
                dashifen_info = gdata.games()[gameId].getDaShiFen(uid, '')
                if dashifen_info:
                    level = dashifen_info['level']
                    if level > 0 and level > datas['level']:
                        datas['level_game_id'] = gameId
                        datas['level'] = level
                        level_pic = dashifen_info.get('picbig')
                        datas[
                            'level_pic'] = level_pic if level_pic else dashifen_info.get(
                                'pic')
        except:
            ftlog.error()

    if for_winchip:
        datas['winchip'] = 0
        datas['winchips'] = 0
        try:
            for gameId in gameIds:
                winchips, todaychips = gamedata.getGameAttrs(
                    userId, gameId, ['winchips', 'todaychips'], False)
                winchips = strutil.parseInts(winchips)
                yest_winchip = 0
                todaychips = strutil.loads(todaychips, ignoreException=True)
                if todaychips and 'today' in todaychips and 'chips' in todaychips and 'last' in todaychips:
                    if pktimestamp.formatTimeDayInt() == todaychips['today']:
                        yest_winchip = todaychips['last']
                    elif pktimestamp.formatTimeYesterDayInt(
                    ) == todaychips['today']:
                        yest_winchip = todaychips['chips']
                datas['winchip'] += yest_winchip
                datas['winchips'] += winchips
        except:
            ftlog.error()
    return datas
Exemplo n.º 44
0
def publishMyFTFinishEvent(gameId, userId, roomId, tableId, ftId):
    eventBus = gdata.games()[gameId].getEventBus()
    if eventBus:
        eventBus.publishEvent(MyFTFinishEvent(gameId, userId, roomId, tableId, ftId))