def __getBonuses(self, tokensQuestsIds): finderFunc = finders.multipleTokenFinder(tokensQuestsIds) resultQuests = self._eventsCache.getHiddenQuests(finderFunc) vehicles = [] achievements = [] hasTankCamo = False hasNationCamo = False for quest in resultQuests.itervalues(): if quest.getBonuses('customizations', []): hasTankCamo = True continue vehicles.extend(quest.getBonuses('vehicles', [])) for bonus in quest.getBonuses('dossier', []): achievements.extend(bonus.getBadges()) for bonus in quest.getBonuses('tokens', []): for token in bonus.getTokens(): if token.endswith(':camouflage'): hasNationCamo = True self.__vehicleAward = first(vehicles) if hasTankCamo or hasNationCamo: if self.__vehicleAward: camouflageIcon = RES_ICONS.getBonusIcon( AWARDS_SIZES.BIG, 'camouflage') else: camouflageIcon = RES_ICONS.MAPS_ICONS_PERSONALMISSIONS_AWARDS_110X110_CAMOUFLAGE if hasTankCamo and hasNationCamo: tooltipKeys = ( TOOLTIPS.PERSONALMISSIONS_AWARDS_CAMOUFLAGEALL_HEADER, TOOLTIPS.PERSONALMISSIONS_AWARDS_CAMOUFLAGEALL_BODY) elif hasTankCamo: tooltipKeys = ( TOOLTIPS.PERSONALMISSIONS_AWARDS_CAMOUFLAGEONLY_HEADER, TOOLTIPS.PERSONALMISSIONS_AWARDS_CAMOUFLAGEONLY_BODY) else: tooltipKeys = ( TOOLTIPS.PERSONALMISSIONS_AWARDS_CAMOUFLAGENATION_HEADER, TOOLTIPS.PERSONALMISSIONS_AWARDS_CAMOUFLAGENATION_BODY) camouflageAward = { 'imgSource': camouflageIcon, 'itemName': 'camouflage', 'tooltip': makeTooltip(*tooltipKeys) } else: camouflageAward = None return (sorted(achievements, reverse=True), camouflageAward)
def updateProgress(self, eventsCache): qp = eventsCache.questsProgress self.__isUnlocked = False for quest in self.__initialQuests.itervalues(): if quest.isUnlocked(): self.__isUnlocked = True break hiddenQuests = eventsCache.getHiddenQuests() operationTokensFinder = finders.multipleTokenFinder( self.__info['tokens']) self.__tokens, self.__bonuses = {}, {} quest = finders.getQuestByTokenAndBonus( hiddenQuests, operationTokensFinder, finders.operationCompletionBonusFinder(self)) if quest is not None: for token in quest.accountReqs.getTokens(): if token.getID() in self.__info['tokens']: self.__tokens[token.getID()] = (qp.getTokenCount( token.getID()), token.getNeededCount()) self.__bonuses.setdefault(token.getID(), []).extend(quest.getBonuses()) else: LOG_ERROR( 'Main token quest was not found for Personal missions operation!', self.getID()) self.__hasRequiredVehicles = False self.__freeTokensCount = 0 self.__freeTokensTotalCount = 0 for quests in self.__quests.itervalues(): for quest in quests.itervalues(): tokenBonuses = quest.getBonuses('tokens') for bonus in tokenBonuses: if bonus.getName() == 'freeTokens': bonusCount = bonus.getCount() self.__freeTokensTotalCount += bonusCount if quest.isFullCompleted(): self.__freeTokensCount += bonusCount tokenCount = qp.getTokenCount(finders.PERSONAL_MISSION_COMPLETE_TOKEN % (self.getCampaignID(), self.getID())) self.__isAwardAchieved = tokenCount > 0 return