def _getBonuses(self, svrEvents, bonuses=None, useIconFormat=False):
        bonuses = bonuses or self.event.getBonuses()
        result, simpleBonusesList, customizationsList, vehiclesList, iconBonusesList = (
            [], [], [], [], [])
        for b in bonuses:
            if b.isShowInGUI():
                if b.getName() == 'dossier':
                    for achieve in b.getAchievements():
                        result.append(
                            formatters.packAchieveElementByItem(achieve))

                elif b.getName() == 'customizations':
                    customizationsList.extend(b.getList())
                elif b.getName() == 'vehicles':
                    flist = b.formattedList()
                    if flist:
                        vehiclesList.extend(flist)
                elif b.hasIconFormat() and useIconFormat:
                    iconBonusesList.extend(b.getList())
                else:
                    flist = b.formattedList()
                    if flist:
                        simpleBonusesList.extend(flist)

        if len(customizationsList):
            result.append(formatters.packCustomizations(customizationsList))
        if len(iconBonusesList):
            result.append(formatters.packIconAwardBonusBlock(iconBonusesList))
        if len(vehiclesList) > 0:
            vehiclesLbl, _ = self._joinUpToMax(vehiclesList)
            result.append(
                formatters.packVehiclesBonusBlock(vehiclesLbl,
                                                  str(self.event.getID())))
        if len(simpleBonusesList) > 0:
            result.append(formatters.packSimpleBonusesBlock(simpleBonusesList))
        parents = [
            qID for _, qIDs in self.event.getParents().iteritems()
            for qID in qIDs
        ]
        for qID, q in self._getEventsByIDs(parents, svrEvents
                                           or {}).iteritems():
            result.append(
                formatters.packTextBlock(i18n.makeString(
                    '#quests:bonuses/item/task', q.getUserName()),
                                         questID=qID))

        if len(result):
            return formatters.todict(result)
        return formatters.todict([
            formatters.packTextBlock(
                text_styles.alert('#quests:bonuses/notAvailable'))
        ])
Esempio n. 2
0
    def accumulateBonuses(self, bonus):
        for achieve in bonus.getAchievements():
            self._result.append(formatters.packAchieveElementByItem(achieve))

        for badge in bonus.getBadges():
            self._result.append(formatters.packBadgeElementByItem(badge))