def createQuest(questType, qID, data, progress=None, expiryTime=None):
    if questType == constants.EVENT_TYPE.PERSONAL_QUEST:
        return PersonalQuest(qID, data, progress, expiryTime)
    if questType == constants.EVENT_TYPE.GROUP:
        return Group(qID, data)
    if questType == constants.EVENT_TYPE.MOTIVE_QUEST:
        return MotiveQuest(qID, data, progress)
    if questType == constants.EVENT_TYPE.RANKED_QUEST:
        return RankedQuest(qID, data, progress)
    if questType == constants.EVENT_TYPE.TOKEN_QUEST:
        if qID.startswith('linkedset_'):
            tokenClass = LinkedSetTokenQuest
        elif isDailyQuest(qID):
            tokenClass = DailyEpicTokenQuest
        else:
            tokenClass = TokenQuest
        return tokenClass(qID, data, progress)
    questClass = Quest
    if qID.startswith('linkedset_'):
        questClass = LinkedSetQuest
    elif isPremium(qID):
        questClass = PremiumQuest
    elif isDailyQuest(qID):
        questClass = DailyQuest
    return questClass(qID, data, progress)
Пример #2
0
def getEventUIDataPacker(event):
    if event.getType() == constants.EVENT_TYPE.TOKEN_QUEST:
        return TokenUIDataPacker(event)
    elif event.getType() == constants.EVENT_TYPE.PERSONAL_QUEST:
        return PrivateMissionUIDataPacker(event)
    elif isPremium(event.getID()) or isDailyQuest(event.getID()):
        return DailyQuestUIDataPacker(event)
    else:
        return BattleQuestUIDataPacker(event) if event.getType(
        ) in constants.EVENT_TYPE.LIKE_BATTLE_QUESTS else None
Пример #3
0
 def getCurrentModeQuestsForVehicle(self, vehicle, notCompleted=False):
     if self.__battleRoyaleController.isBattleRoyaleMode():
         if vehicle.isOnlyForBattleRoyaleBattles:
             return list(self.__battleRoyaleController.getQuests().values())
     if notCompleted:
         quests = [
             q for q in self.getQuestForVehicle(vehicle) if
             not isDailyEpic(q.getGroupID()) and not isDailyQuest(q.getID())
             and not isPremium(q.getID()) and not isRankedQuestID(q.getID())
             and not isBattleRoyale(q.getGroupID()) and q.shouldBeShown()
             and not q.isCompleted()
         ]
         return quests
     return [
         q for q in self.getQuestForVehicle(vehicle)
         if not isDailyEpic(q.getGroupID()) and not isDailyQuest(q.getID())
         and not isPremium(q.getID()) and not isRankedQuestID(q.getID())
         and not isBattleRoyale(q.getGroupID()) and q.shouldBeShown()
     ]
    def getPostBattleInfo(self, svrEvents, pCur, pPrev, isProgressReset,
                          isCompleted, progressData):
        index = 0
        progresses = []
        isQuestDailyQuest = isDailyQuest(str(self.event.getID()))
        if not isProgressReset and not isCompleted:
            for cond in self.event.bonusCond.getConditions().items:
                if isinstance(cond, conditions._Cumulativable):
                    for _, (curProg, totalProg, diff,
                            _) in cond.getProgressPerGroup(pCur,
                                                           pPrev).iteritems():
                        if not isQuestDailyQuest:
                            label = cond.getUserString()
                        else:
                            label = cond.getCustomDescription()
                        if not diff or not label:
                            continue
                        index += 1
                        progresses.append({
                            'progrTooltip':
                            None,
                            'progrBarType':
                            formatters.PROGRESS_BAR_TYPE.SIMPLE,
                            'maxProgrVal':
                            totalProg,
                            'currentProgrVal':
                            curProg,
                            'description':
                            '%d. %s' % (index, label),
                            'progressDiff':
                            '+ %s' % backport.getIntegralFormat(diff),
                            'progressDiffTooltip':
                            TOOLTIPS.QUESTS_PROGRESS_EARNEDINBATTLE
                        })

            if not progresses:
                return
        alertMsg = ''
        if isProgressReset:
            alertMsg = i18n.makeString('#quests:postBattle/progressReset')
        _, awards = ('', None)
        if not isProgressReset and isCompleted:
            awards = self._getBonuses(svrEvents)
        return {
            'title': self.event.getUserName(),
            'descr': self.event.getDescription(),
            'awards': awards,
            'progressList': progresses,
            'alertMsg': alertMsg,
            'questInfo': self.getInfo(svrEvents, pCur, pPrev),
            'personalInfo': [],
            'questType': self.event.getType()
        }
Пример #5
0
def showMission(eventID, eventType=None):
    from gui.impl.lobby.missions.daily_quests_view import DailyTabs
    if eventType == constants.EVENT_TYPE.C11N_PROGRESSION:
        itemIntCD, vehicleIntCD = parseEventID(eventID)
        service = dependency.instance(ICustomizationService)
        vehicle = service.getItemByCD(vehicleIntCD)
        service.showCustomization(vehicle.invID,
                                  lambda: showProgressiveItemsView(itemIntCD))
        return
    else:
        eventsCache = dependency.instance(IEventsCache)
        quests = eventsCache.getQuests()
        quest = quests.get(eventID)
        if eventID == BattlePassConsts.FAKE_QUEST_ID:
            hideWebBrowserOverlay()
            showMissionsBattlePass()
            return
        if quest is None:
            prefix = events_helpers.getMarathonPrefix(eventID)
            if prefix is not None:
                return showMissionsMarathon(marathonPrefix=prefix)
        if eventType is not None and eventType == constants.EVENT_TYPE.PERSONAL_MISSION:
            showPersonalMission(eventID)
        elif quest is not None:
            if events_helpers.isMarathon(quest.getGroupID()):
                groups = eventsCache.getGroups()
                group = groups.get(quest.getGroupID())
                groupContent = group.getGroupContent(quests)
                mainQuest = group.getMainQuest(groupContent)
                if mainQuest and quest.getID() != mainQuest.getID():
                    showMissionsGrouped(missionID=quest.getID(),
                                        groupID=group.getID(),
                                        anchor=group.getID())
                else:
                    showMissionsGrouped(anchor=group.getID())
            elif events_helpers.isLinkedSet(quest.getGroupID()):
                showMissionsLinkedSet()
            elif events_helpers.isDailyQuest(quest.getID()):
                showDailyQuests(subTab=DailyTabs.QUESTS)
            elif events_helpers.isPremium(quest.getID()):
                showDailyQuests(subTab=DailyTabs.PREMIUM_MISSIONS)
            else:
                showMissionsCategories(missionID=quest.getID(),
                                       groupID=quest.getGroupID(),
                                       anchor=quest.getGroupID())
        return
Пример #6
0
 def questFilter(quest):
     return events_helpers.isDailyQuest(
         quest.getID()) or events_helpers.isPremium(quest.getID())
def _isAvailableForMode(q):
    return not isDailyEpic(q.getGroupID()) and not isDailyQuest(
        q.getID()) and not isPremium(q.getID()) and not isRankedQuestID(
            q.getID()) and not isBattleRoyale(
                q.getGroupID()) and not isFunRandomQuest(q.getID())
Пример #8
0
 def __getBattleQuestsVO(self, vehicle):
     quests = [ q for q in self._questController.getQuestForVehicle(vehicle) if not isDailyEpic(q.getGroupID()) and not isDailyQuest(q.getID()) and not isPremium(q.getID()) and not isRankedQuestID(q.getID()) ]
     totalCount = len(quests)
     completedQuests = len([ q for q in quests if q.isCompleted() ])
     festivityFlagData = self._festivityController.getHangarQuestsFlagData()
     if totalCount > 0:
         if completedQuests != totalCount:
             label = _ms(MENU.hangarHeaderBattleQuestsLabel(LABEL_STATE.ACTIVE), total=totalCount - completedQuests)
         else:
             label = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_QUESTS_ALL_DONE)
         commonQuestsIcon = festivityFlagData.icon or RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_QUESTS_AVAILABLE
     else:
         commonQuestsIcon = festivityFlagData.iconDisabled or RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_QUESTS_DISABLED
         label = ''
     quests = [self._headerQuestFormaterVo(totalCount > 0, commonQuestsIcon, label, HANGAR_HEADER_QUESTS.QUEST_TYPE_COMMON, flag=festivityFlagData.flagBackground, tooltip=TOOLTIPS_CONSTANTS.QUESTS_PREVIEW, isTooltipSpecial=True)]
     return self._wrapQuestGroup(HANGAR_HEADER_QUESTS.QUEST_GROUP_COMMON, '', quests)
Пример #9
0
    def _packBlocks(self, *args, **kwargs):
        items = super(QuestsPreviewTooltipData, self)._packBlocks()
        vehicle = g_currentVehicle.item
        quests = sorted([
            q for q in self._questController.getQuestForVehicle(vehicle)
            if not q.isCompleted() and self.__eventProgression.questPrefix
            not in q.getID() and not isDailyQuest(q.getID())
            and not isPremium(q.getID()) and not isRankedQuestID(q.getID())
        ],
                        key=events_helpers.questsSortFunc)
        if quests:
            items.append(
                self._getHeader(
                    len(quests), vehicle.shortUserName,
                    R.strings.tooltips.hangar.header.quests.description.
                    vehicle()))
            for quest in quests:
                bonusNames = []
                for bonus in quest.getBonuses():
                    if bonus.getName() == 'battleToken':
                        bonusNames.extend(
                            _StringTokenBonusFormatter().format(bonus))
                    bonusFormat = bonus.format()
                    if bonusFormat:
                        if isinstance(bonus, CustomizationsBonus):
                            for item in bonus.getCustomizations():
                                itemTypeName = item.get('custType')
                                if itemTypeName == 'projection_decal':
                                    itemTypeName = GUI_ITEM_TYPE_NAMES[
                                        GUI_ITEM_TYPE.PROJECTION_DECAL]
                                elif itemTypeName == 'personal_number':
                                    itemTypeName = GUI_ITEM_TYPE_NAMES[
                                        GUI_ITEM_TYPE.PERSONAL_NUMBER]
                                bonusFmt = _ms(
                                    ITEM_TYPES.customization(itemTypeName))
                                bonusNames.append(bonusFmt)

                        else:
                            bonusNames.extend(bonusFormat.split(', '))

                isAvailable, _ = quest.isAvailable()
                items.append(
                    self._packQuest(quest.getUserName(), bonusNames,
                                    isAvailable))
                if len(items) > _MAX_QUESTS_PER_TOOLTIP:
                    break

            rest = len(quests) - len(items) + 1
            if rest > 0:
                items.append(self._getBottom(rest))
        else:

            def _filter(q):
                return q.getType(
                ) not in constants.EVENT_TYPE.SHARED_QUESTS and not q.isCompleted(
                )

            allQuests = self._eventsCache.getQuests(filterFunc=_filter)
            if allQuests:
                items.append(
                    self._getHeader(
                        len(quests), vehicle.shortUserName,
                        R.strings.tooltips.hangar.header.quests.description.
                        vehicle()))
                items.append(
                    self._getBody(TOOLTIPS.HANGAR_HEADER_QUESTS_EMPTY_VEHICLE))
            else:
                items.append(
                    self._getHeader(
                        len(quests), vehicle.shortUserName,
                        R.strings.tooltips.hangar.header.quests.description()))
                items.append(self._getBody(
                    TOOLTIPS.HANGAR_HEADER_QUESTS_EMPTY))
            items.append(self._getBottom(0))
        return items