Esempio n. 1
0
 def format(cls, condition, event, styler):
     labelKey = None
     if condition.getClanIds() is None:
         if condition.isNegative():
             labelKey = 'notInAnyClan'
         else:
             labelKey = 'inAnyClan'
     else:
         clanDBID = cls.itemsCache.items.stats.clanDBID
         if not condition.isNegative():
             if clanDBID:
                 if clanDBID in condition.getClanIds():
                     labelKey = 'forCurrentClan'
                 else:
                     labelKey = 'notForCurrentClan'
             else:
                 labelKey = 'inClan'
         elif clanDBID and clanDBID in condition.getClanIds():
             labelKey = 'notForCurrentClan'
     if labelKey is not None:
         label = ms('#quests:details/requirements/{}'.format(labelKey))
         style = styler(condition.isAvailable())
         return [packText(style(label))]
     else:
         return []
Esempio n. 2
0
 def format(cls, condition, event, styler = reqStyle):
     style = styler(condition.isAvailable())
     result = []
     if event.getType() not in EVENT_TYPE.LIKE_BATTLE_QUESTS + EVENT_TYPE.LIKE_TOKEN_QUESTS:
         return result
     tokensNeedCount = condition.getNeededCount()
     return [packText(style(_ms(TOOLTIPS.QUESTS_UNAVAILABLE_TOKEN, tokenName=text_styles.neutral(condition.getUserName()), count=tokensNeedCount)))]
Esempio n. 3
0
 def format(cls, condition, event, styler):
     if condition.isPremiumNeeded():
         labelKey = 'premiumAccount'
     else:
         labelKey = 'notPremiumAccount'
     label = ms('#quests:details/requirements/{}'.format(labelKey))
     style = styler(condition.isAvailable())
     return [packText(style(label))]
Esempio n. 4
0
 def format(self, styler):
     style = styler(self._isAvailable)
     result = []
     if self._tokens:
         result = [
             packText(style('#quests:details/requirements/token')),
             packTokens(self._tokens)
         ]
     return result
Esempio n. 5
0
 def format(cls, condition, event, styler):
     style = styler(condition.isAvailable())
     labelKey = '#quests:details/requirements/{}'.format(
         condition.getName())
     result = []
     if condition.isAnyVehicleAcceptable():
         label = ms('{}/all'.format(labelKey))
         result.append(packText(style(label)))
     elif 'types' not in condition.data:
         _, fnations, flevels, fclasses = condition.parseFilters()
         keys, kwargs = [], {}
         if fnations:
             keys.append('nation')
             names = [nations.NAMES[nationId] for nationId in fnations]
             names = [ms('#menu:nations/{}'.format(name)) for name in names]
             kwargs['nation'] = ', '.join(names)
         if fclasses:
             keys.append('type')
             names = [
                 ms('#menu:classes/{}'.format(name)) for name in fclasses
             ]
             kwargs['type'] = ', '.join(names)
         if flevels:
             keys.append('level')
             names = [int2roman(lvl) for lvl in flevels]
             kwargs['level'] = ', '.join(names)
         labelKey = '{}/{}'.format(labelKey, '_'.join(keys))
         if condition.relationValue is None and condition.isNegative():
             labelKey = '{}/not'.format(labelKey)
         label = ms(labelKey, **kwargs)
         label = relate(condition.relation, condition.relationValue, label)
         result.append(packText(style(label)))
     else:
         if condition.isNegative():
             labelKey = '{}/not'.format(labelKey)
         label = ms(labelKey)
         names = [
             vehicle.userName for vehicle in condition.getVehiclesList()
         ]
         result.append(
             packText(style('{}: {}'.format(label, ', '.join(names)))))
     return result
Esempio n. 6
0
 def format(cls, condition, event, styler):
     style = styler(condition.isAvailable())
     if condition.average:
         titleKey = '#quests:details/requirements/dossierAvgValue'
     else:
         titleKey = '#quests:details/requirements/dossierValue'
     block, record = condition.recordName
     battleMode = cls._dossierBlock2BattleMode(block)
     labelKey = '#quests:details/dossier/{}/{}'.format(battleMode, record)
     label = ms(titleKey, label=ms(labelKey))
     label = relate(condition.relation, condition.relationValue, label)
     return [packText(style(label))]
Esempio n. 7
0
 def format(cls, condition, event, styler):
     igrTypes = condition.getIgrTypes()
     if IS_CHINA:
         key = 'igr'
     elif igrTypes.issubset({IGR_TYPE.BASE}):
         key = 'igrBasic'
     elif igrTypes.issubset({IGR_TYPE.PREMIUM}):
         key = 'igrPremium'
     else:
         key = 'igr'
     label = ms('#quests:details/requirements/{}'.format(key))
     style = styler(condition.isAvailable())
     return [
         packText(
             makeHtmlString('html_templates:lobby/quests', 'playInIgr',
                            {'label': style(label)}))
     ]
Esempio n. 8
0
    def format(self, group, event, isNested=False):
        """ Format the requirement body.
        """
        result = []
        total, passed = (0, 0)
        separator = getSeparator(group.getName())
        gatheringFmts = self.createGatheringFormatters()
        for condition in group.getSortedItems():
            conditionName = condition.getName()
            if conditionName in GROUP_TYPE.ALL():
                branch, bpassed, btotal = self.format(condition,
                                                      event,
                                                      isNested=True)
                total += btotal
                passed += bpassed
            else:
                if conditionName in gatheringFmts:
                    fmt = gatheringFmts.get(conditionName)
                    fmt.gather(condition, event)
                    branch = []
                elif self.hasFormatter(conditionName):
                    fmt = self.getConditionFormatter(conditionName)
                    branch = fmt.format(condition, event, self._styler)
                else:
                    branch = []
                if branch:
                    total += 1
                    if condition.isAvailable():
                        passed += 1
            if branch:
                self._iconize(condition.isAvailable(), isNested, branch)
                result.extend(branch)

        for fmt in gatheringFmts.itervalues():
            branch = fmt.format(self._styler)
            if branch:
                total += 1
                self._iconize(fmt.isAvailable(), isNested, branch)
                result.extend(branch)

        if separator:
            result = intersperse(result, packText(separator))
        return (result, passed, total)
Esempio n. 9
0
    def _format(self, group, event, isNested = False):
        """ Recursive format method that should be called for each condition group.
        """
        result = []
        separator = getSeparator(group.getName())
        for condition in group.getSortedItems():
            branch = []
            if not condition.isAvailable():
                conditionName = condition.getName()
                if conditionName in GROUP_TYPE.ALL():
                    branch = self._format(condition, event, isNested=True)
                else:
                    fmt = self.getConditionFormatter(conditionName)
                    if fmt:
                        branch = fmt.format(condition, event, reqStyle)
                result.extend(branch)
                if not isNested and branch:
                    branch[0].update(bullet=TOOLTIPS.QUESTS_UNAVAILABLE_BULLET)

        if separator:
            result = intersperse(result, packText(text_styles.standard(separator)))
        return result
Esempio n. 10
0
 def format(cls, condition, event, styler):
     style = styler(condition.isAvailable())
     key = '#quests:details/requirements/vehicle/%s' % (
         'receivedMultXp' if condition.getValue() else 'notReceivedMultXp')
     label = ms(key, mult=cls.itemsCache.items.shop.dailyXPFactor)
     return [packText(style(label))]
Esempio n. 11
0
 def format(cls, condition, event, styler):
     relation, value = condition.relation, condition.relationValue
     label = ms('#quests:details/requirements/globalRating')
     label = relate(relation, value, label)
     style = styler(condition.isAvailable())
     return [packText(style(label))]