def __init__(self):
        self.__cache = []
        for arenaTypeID, arenaType in ArenaType.g_cache.iteritems():
            if arenaType.explicitRequestOnly or not gameplay_ctx.isCreationEnabled(arenaType.gameplayName):
                continue
            try:
                nameSuffix = (
                    ""
                    if arenaType.gameplayName == "ctf"
                    else i18n.makeString("#arenas:type/%s/name" % arenaType.gameplayName)
                )
                self.__cache.append(
                    {
                        "label": "%s - %s" % (arenaType.name, nameSuffix) if len(nameSuffix) else arenaType.name,
                        "name": arenaType.name,
                        "arenaType": nameSuffix,
                        "key": arenaTypeID,
                        "size": arenaType.maxPlayersInTeam,
                        "time": arenaType.roundLength / 60,
                        "description": "",
                        "icon": formatters.getMapIconPath(arenaType),
                    }
                )
            except Exception:
                LOG_ERROR("There is error while reading arenas cache", arenaTypeID, arenaType)
                LOG_CURRENT_EXCEPTION()
                continue

        self.__cache = sorted(self.__cache, key=lambda x: (x["label"].lower(), x["name"].lower()))
示例#2
0
    def __onTrainingsListReceived(self, prebattles):
        result = []
        totalPlayersCount = 0
        for item in prebattles:
            arena = ArenaType.g_cache[item.arenaTypeID]
            totalPlayersCount += item.playersCount
            result.append({'id': item.prbID,
             'comment': item.getCensoredComment(),
             'arena': getArenaFullName(item.arenaTypeID),
             'count': item.playersCount,
             'total': arena.maxPlayersInTeam,
             'owner': item.getCreatorFullName(),
             'icon': formatters.getMapIconPath(arena, prefix='small/'),
             'disabled': not item.isOpened})

        self.as_setListS(result, totalPlayersCount)
示例#3
0
    def onPrbListReceived(self, prebattles):
        listData = []
        playersTotal = 0
        for item in prebattles:
            arena = ArenaType.g_cache[item.arenaTypeID]
            playersTotal += item.playersCount
            listData.append({'id': item.prbID,
             'comment': item.getCensoredComment(),
             'arena': getArenaFullName(item.arenaTypeID),
             'count': item.playersCount,
             'total': arena.maxPlayersInTeam,
             'owner': item.getCreatorFullName(),
             'creatorName': item.creator,
             'creatorClan': item.clanAbbrev,
             'creatorIgrType': item.creatorIgrType,
             'creatorRegion': g_lobbyContext.getRegionCode(item.creatorDbId),
             'icon': formatters.getMapIconPath(arena, prefix='small/'),
             'disabled': not item.isOpened})

        self.sendData(listData, playersTotal)
    def __init__(self):
        self.__cache = []
        for arenaTypeID, arenaType in ArenaType.g_cache.iteritems():
            if arenaType.explicitRequestOnly or not gameplay_ctx.isCreationEnabled(arenaType.gameplayName):
                continue
            try:
                nameSuffix = '' if arenaType.gameplayName == 'ctf' else i18n.makeString('#arenas:type/%s/name' % arenaType.gameplayName)
                self.__cache.append({'label': '%s - %s' % (arenaType.name, nameSuffix) if len(nameSuffix) else arenaType.name,
                 'name': arenaType.name,
                 'arenaType': nameSuffix,
                 'key': arenaTypeID,
                 'size': arenaType.maxPlayersInTeam,
                 'time': arenaType.roundLength / 60,
                 'description': '',
                 'icon': formatters.getMapIconPath(arenaType)})
            except Exception:
                LOG_ERROR('There is error while reading arenas cache', arenaTypeID, arenaType)
                LOG_CURRENT_EXCEPTION()
                continue

        self.__cache = sorted(self.__cache, key=lambda x: (x['label'].lower(), x['name'].lower()))