Beispiel #1
0
    def getAchievements(self, isInDossier=None):
        result = defaultdict(list)
        for record in layouts.getAchievementsLayout(self.__dossier.getDossierType()):
            try:
                if self.__isAchieveValid(*record):
                    factory = getAchievementFactory(record, self.__dossier)
                    if (
                        factory
                        and factory.isValid()
                        and isInDossier is None
                        or factory.isInDossier()
                        and isInDossier
                        or not factory.isInDossier()
                        and not isInDossier
                    ) and factory.isValid():
                        achieve = factory.create()
                        if achieve is not None:
                            if not isinstance(factory, _SequenceAchieveFactory):
                                achieve = {achieve.getName(): achieve}
                            for a in achieve.itervalues():
                                section = a.getSection()
                                if section is None:
                                    section = getAchieveSection(record)
                                result[section].append(a)

            except Exception:
                LOG_ERROR("There is exception while achievement creating", record)
                LOG_CURRENT_EXCEPTION()
                continue

        return tuple((sorted(result[section]) for section in ACHIEVEMENT_SECTIONS_ORDER))
Beispiel #2
0
    def getAchievements(self, isInDossier=True):
        result = []
        for section in dossiers_utils.getAchievementsLayout(self.dossierType):
            sectionAchieves = []
            for achieveName in section:
                if not dossiers_utils.isAchieveValid(achieveName, self):
                    continue
                try:
                    factory = getAchievementFactory(achieveName, self)
                    if isInDossier is None or factory.isInDossier(
                    ) and isInDossier or not factory.isInDossier(
                    ) and not isInDossier:
                        if isinstance(factory, _SequenceAchieveFactory):
                            sectionAchieves.extend(
                                factory.create(self.proxy).values())
                        else:
                            sectionAchieves.append(factory.create(self.proxy))
                except Exception:
                    LOG_ERROR('There is exception while achievement creating',
                              achieveName)
                    LOG_CURRENT_EXCEPTION()
                    continue

            result.append(tuple(sorted(sectionAchieves)))

        return tuple(result)
Beispiel #3
0
    def getAchievements(self, isInDossier=None):
        result = defaultdict(list)
        for record in layouts.getAchievementsLayout(
                self.__dossier.getDossierType()):
            try:
                if self.__isAchieveValid(*record):
                    factory = getAchievementFactory(record, self.__dossier)
                    if (factory and factory.isValid() and isInDossier is None
                            or factory.isInDossier() and isInDossier
                            or not factory.isInDossier()
                            and not isInDossier) and factory.isValid():
                        achieve = factory.create()
                        if achieve is not None:
                            if not isinstance(factory,
                                              _SequenceAchieveFactory):
                                achieve = {achieve.getName(): achieve}
                            for a in achieve.itervalues():
                                section = a.getSection()
                                if section is None:
                                    section = getAchieveSection(record)
                                result[section].append(a)

            except Exception:
                LOG_ERROR('There is exception while achievement creating',
                          record)
                LOG_CURRENT_EXCEPTION()
                continue

        return tuple((sorted(result[section])
                      for section in ACHIEVEMENT_SECTIONS_ORDER))
Beispiel #4
0
 def buildItem(self, block, name, value = 0, customData = None, vehicleLevel = 0, arenaType = ARENA_GUI_TYPE.RANDOM):
     self._vehicleLevel = vehicleLevel
     self._arenaType = arenaType
     factory = factories.getAchievementFactory((block, name))
     if factory is not None:
         return factory.create(value=value)
     else:
         return
Beispiel #5
0
 def getAchievement(self, record):
     try:
         if self.__isAchieveValid(*record):
             factory = getAchievementFactory(record, self.__dossier)
             if factory is not None:
                 return factory.create()
     except Exception:
         LOG_ERROR('There is exception while achievement creating', record)
         LOG_CURRENT_EXCEPTION()
Beispiel #6
0
 def getAchievement(self, record):
     try:
         if self.__isAchieveValid(*record):
             factory = getAchievementFactory(record, self.__dossier)
             if factory is not None:
                 return factory.create()
     except Exception:
         LOG_ERROR('There is exception while achievement creating', record)
         LOG_CURRENT_EXCEPTION()
Beispiel #7
0
    def getAchievement(self, achieveName):
        try:
            factory = getAchievementFactory(achieveName, self)
            return factory.create(self.proxy)
        except Exception:
            LOG_ERROR('There is exception while achievement creating', achieveName)
            LOG_CURRENT_EXCEPTION()

        return None
Beispiel #8
0
    def getAchievement(self, achieveName):
        try:
            factory = getAchievementFactory(achieveName, self)
            return factory.create(self.proxy)
        except Exception:
            LOG_ERROR('There is exception while achievement creating',
                      achieveName)
            LOG_CURRENT_EXCEPTION()

        return None
Beispiel #9
0
 def buildItem(self, block, name, value=0, customData=None, vehicleLevel=0, arenaType=ARENA_GUI_TYPE.RANDOM):
     self._vehicleLevel = vehicleLevel
     self._arenaType = arenaType
     totalStats = self.__itemsCache.items.getAccountDossier().getTotalStats()
     if totalStats.isAchievementInLayout((block, name)):
         item = totalStats.getAchievement((block, name))
         if item is not None:
             return item
     factory = factories.getAchievementFactory((block, name))
     return factory.create(value=value) if factory is not None else None
Beispiel #10
0
def _packAchievementsList(achivementsIDs):
    result = []
    for id in achivementsIDs:
        block, achieveName = DB_ID_TO_RECORD[id]
        factory = factories.getAchievementFactory((block, achieveName))
        item = factory.create(value=0)
        result.append({'block': block,
         'type': achieveName,
         'tooltip': TOOLTIPS_CONSTANTS.BATTLE_STATS_ACHIEVS,
         'icon': item.getSmallIcon(),
         'label': item.getUserName()})

    return result
Beispiel #11
0
def _getAchievement(block, record, value):
    if block == ACHIEVEMENT_BLOCK.RARE:
        record = value
        value = 0
    try:
        achieve = getAchievementFactory((block, record)).create(value=value)
        if achieve.isAvailableInQuest():
            return achieve
    except Exception:
        LOG_ERROR('There is error while getting bonus dossier record name')
        LOG_CURRENT_EXCEPTION()

    return None
Beispiel #12
0
    def _showAward(self, ctx):
        LOG_DEBUG('Show personal mission bonus award!', ctx)
        data = ctx[1].data
        achievements = []
        for recordIdx, value in data.get('popUpRecords', []):
            factory = getAchievementFactory(DB_ID_TO_RECORD[recordIdx])
            if factory is not None:
                a = factory.create(value=int(value))
                if a is not None:
                    achievements.append(a)

        if achievements:
            quests_events.showAchievementsAward(achievements)
        return
Beispiel #13
0
    def _showAward(self, ctx):
        achievements = []
        for vehTypeCompDescr, battleResult in ctx[1].data.iteritems():
            for recordIdx, value in battleResult.get('popUpRecords') or {}:
                recordName = DB_ID_TO_RECORD[recordIdx]
                if recordName in POTAPOV_QUESTS_GROUP:
                    factory = getAchievementFactory(recordName)
                    if factory is not None:
                        a = factory.create(value=int(value))
                        if a is not None:
                            achievements.append(a)

        if achievements:
            quests_events.showAchievementsAward(achievements)
Beispiel #14
0
    def _showAward(self, ctx):
        achievements = []
        popUpRecords = ctx[1].data.get('popUpRecords', [])
        for recordIdx, value in popUpRecords:
            recordName = DB_ID_TO_RECORD[recordIdx]
            if recordName in PERSONAL_MISSIONS_GROUP:
                factory = getAchievementFactory(recordName)
                if factory is not None:
                    a = factory.create(value=int(value))
                    if a is not None:
                        achievements.append(a)

        if achievements:
            quests_events.showAchievementsAward(achievements)
        return
Beispiel #15
0
    def _showAward(self, ctx):
        achievements = []
        popUpRecords = ctx[1].data.get('popUpRecords', {})
        for recordIdx, value in popUpRecords.iteritems():
            recordName = DB_ID_TO_RECORD[recordIdx]
            if recordName in POTAPOV_QUESTS_GROUP:
                factory = getAchievementFactory(recordName)
                if factory is not None:
                    a = factory.create(value=int(value))
                    if a is not None:
                        achievements.append(a)

        if achievements:
            quests_events.showAchievementsAward(achievements)
        return
Beispiel #16
0
    def formattedList(self):
        result = []
        for block, record in self.getRecords():
            try:
                if block in ACHIEVEMENT_BLOCK.ALL:
                    factory = getAchievementFactory((block, record))
                    if factory is not None:
                        achieve = factory.create()
                        if achieve is not None:
                            result.append(achieve.userName)
                else:
                    result.append(i18n.makeString('#quests:details/dossier/%s' % record))
            except Exception:
                LOG_ERROR('There is error while getting bonus dossier record name')
                LOG_CURRENT_EXCEPTION()

        return result
Beispiel #17
0
    def _showAward(self, ctx):
        data = ctx[1].data
        completedQuestIDs = set(data.get('completedQuestIDs', set()))
        achievements = []
        tokens = {}
        for recordIdx, value in data.get('popUpRecords') or {}:
            factory = getAchievementFactory(DB_ID_TO_RECORD[recordIdx])
            if factory is not None:
                a = factory.create(value=int(value))
                if a is not None:
                    achievements.append(a)

        for tokenID, tokenData in (data.get('tokens') or {}).iteritems():
            tokens[tokenID] = tokenData.get('count', 1)

        if len(achievements):
            quests_events.showAchievementsAward(achievements)
        for tID, tCount in tokens.iteritems():
            self.__tryToShowTokenAward(tID, tCount, completedQuestIDs)
Beispiel #18
0
    def formattedList(self):
        result = []
        for block, record in self.getRecords():
            try:
                if block in ACHIEVEMENT_BLOCK.ALL:
                    factory = getAchievementFactory((block, record))
                    if factory is not None:
                        achieve = factory.create()
                        if achieve is not None:
                            result.append(achieve.userName)
                else:
                    result.append(
                        i18n.makeString('#quests:details/dossier/%s' % record))
            except Exception:
                LOG_ERROR(
                    'There is error while getting bonus dossier record name')
                LOG_CURRENT_EXCEPTION()

        return result
Beispiel #19
0
    def getAchievements(self, isInDossier = True):
        result = []
        for section in dossiers_utils.getAchievementsLayout(self.dossierType):
            sectionAchieves = []
            for achieveName in section:
                if not dossiers_utils.isAchieveValid(achieveName, self):
                    continue
                try:
                    factory = getAchievementFactory(achieveName, self)
                    if isInDossier is None or factory.isInDossier() and isInDossier or not factory.isInDossier() and not isInDossier:
                        if isinstance(factory, _SequenceAchieveFactory):
                            sectionAchieves.extend(factory.create(self.proxy).values())
                        else:
                            sectionAchieves.append(factory.create(self.proxy))
                except Exception:
                    LOG_ERROR('There is exception while achievement creating', achieveName)
                    LOG_CURRENT_EXCEPTION()
                    continue

            result.append(tuple(sorted(sectionAchieves)))

        return tuple(result)
Beispiel #20
0
 def buildItem(self, block, name, value = 0, customData = None):
     factory = factories.getAchievementFactory((block, name))
     if factory is not None:
         return factory.create(value=value)
     else:
         return
Beispiel #21
0
 def buildItem(self, block, name, value=0, customData=None):
     factory = factories.getAchievementFactory((block, name))
     if factory is not None:
         return factory.create(value=value)
Beispiel #22
0
def _getAchievement(block, record, value):
    factory = getAchievementFactory((block, record))
    return factory.create(value=value)