def showMissionAward(quest, ctx): def handleEvent(): prbDispatcher = g_prbLoader.getDispatcher() if prbDispatcher is not None and prbDispatcher.getFunctionalState().isNavigationDisabled(): SystemMessages.pushI18nMessage('#system_messages:queue/isInQueue', type=SystemMessages.SM_TYPE.Error) return False else: showMissionsCategories() return True eventName = recruit_helper.getSourceIdFromQuest(quest.getID()) or anniversary_helper.getEventNameByQuest(quest) if eventName in _EVENTS_REWARD_WINDOW: ctx['quest'] = quest ctx['eventName'] = eventName rewardWindow = _EVENTS_REWARD_WINDOW[eventName](ctx) rewardWindow.load() else: bonuses = getMissionInfoData(quest).getSubstituteBonuses() if bonuses: lootboxes = getLootboxesFromBonuses(bonuses) if lootboxes: for lootboxId, lootboxInfo in lootboxes.iteritems(): if lootboxId in NewYearLootBoxes.ALL(): continue showLootboxesAward(lootboxId=lootboxId, lootboxCount=lootboxInfo['count'], isFree=lootboxInfo['isFree']) else: missionAward = awards.MissionAward(quest, ctx, handleEvent) if missionAward.getAwards(): shared_events.showMissionAwardWindow(missionAward)
def _initRewardsList(self): with self.getViewModel().transaction() as tx: rewardsList = tx.rewardsList.getItems() if self._quest is not None: bonuses = getMissionInfoData( self._quest).getSubstituteBonuses() bonuses.sort(key=self._keySortOrder) formatter = PackRentVehiclesAwardComposer( ADDITIONAL_AWARDS_COUNT, getPackRentVehiclesAwardPacker()) for index, bonus in enumerate( formatter.getFormattedBonuses(bonuses)): rendererModel = RewardRendererModel() with rendererModel.transaction() as rewardTx: rewardTx.setIcon(bonus.get('imgSource', '')) labelStr = bonus.get('label', '') or '' rewardTx.setLabelStr(labelStr) rewardTx.setTooltipId(index) rewardsList.addViewModel(rendererModel) self.__items[index] = TooltipData( tooltip=bonus.get('tooltip', None), isSpecial=bonus.get('isSpecial', False), specialAlias=bonus.get('specialAlias', ''), specialArgs=bonus.get('specialArgs', None)) tx.setShowRewards(bool(self.__items)) return
def _packBlocks(self, *args, **kwargs): items = super(ScheduleQuestTooltipData, self)._packBlocks() items.append(formatters.packTitleDescBlock(text_styles.highTitle(TOOLTIPS.QUESTS_SCHEDULE_HEADER), text_styles.standard(TOOLTIPS.QUESTS_SCHEDULE_DESCRIPTION), padding=formatters.packPadding(bottom=3))) eventID = args[0] items.append(self._getBody(eventID)) event = findFirst(lambda q: q.getID() == eventID, self._questController.getAllAvailableQuests()) timerMsg = missions_helper.getMissionInfoData(event).getTimerMsg() if timerMsg: items.append(formatters.packTextBlockData(timerMsg)) return items
def _getBonuses(self): if self._quest is not None: allBonuses = getMissionInfoData(self._quest).getSubstituteBonuses() bonuses = [ bonus for bonus in allBonuses if bonus.getName() != 'vehicles' ] vehBonus = getTutorialBonuses('vehicles', self._vehicles) bonuses.extend(vehBonus) return bonuses else: return []
def _getBodyData(self): cardsList = [] for e in self._events: eventID = e.getID() if eventID in self._cachedInfo: missionData = self._cachedInfo[eventID] else: missionData = getMissionInfoData(e) self._cachedInfo[eventID] = missionData cardsList.append(missionData.getInfo()) return {'missions': cardsList, 'dummy': {'iconSource': RES_ICONS.MAPS_ICONS_LIBRARY_ALERTBIGICON, 'htmlText': text_styles.alert(_ms(QUESTS.MISSIONS_NOTASKSBODY_DUMMY_TEXT)), 'alignCenter': False, 'btnVisible': True, 'btnLabel': QUESTS.MISSIONS_NOTASKSBODY_DUMMY_BTNLABEL, 'btnTooltip': '', 'btnEvent': 'ResetFilterEvent', 'btnLinkage': BUTTON_LINKAGES.BUTTON_BLACK}} if not cardsList and self._suitableEvents else {'missions': cardsList}
def _getBodyData(self): cardsList = [] for e in self._events: eventID = e.getID() if eventID in self._cachedInfo: missionData = self._cachedInfo[eventID] else: missionData = getMissionInfoData(e) self._cachedInfo[eventID] = missionData cardsList.append(missionData.getInfo()) isPremEnabled = self.__isPremiumEnabled() isAllCompleted = self._completedQuestsCount == self._totalQuestsCount timeStr = self.__getDailyResetStatus() completeTitle = text_styles.missionStatusAvailable(backport.text(R.strings.quests.premiumQuests.body.complete(), time=timeStr) if isAllCompleted else '') return {'missions': cardsList, 'title': text_styles.promoTitle(QUESTS.PREMIUMQUESTS_BODY_TITLE), 'description': text_styles.highlightText(QUESTS.PREMIUMQUESTS_BODY_DESCRIPTION), 'buttonDetails': QUESTS.PREMIUMQUESTS_BODY_BUTTONDETAILS, 'icon': backport.image(R.images.gui.maps.icons.premacc.icons.premium_256x242()), 'hasPremium': isPremEnabled, 'completeTitle': completeTitle, 'uiDecoration': backport.image(R.images.gui.maps.icons.premacc.quests.background())}
def showMissionAward(quest, ctx): eventName = recruit_helper.getSourceIdFromQuest( quest.getID()) or anniversary_helper.getEventNameByQuest(quest) if eventName in _EVENTS_REWARD_WINDOW: ctx['quest'] = quest ctx['eventName'] = eventName rewardWindow = _EVENTS_REWARD_WINDOW[eventName](ctx) rewardWindow.load() else: bonuses = getMissionInfoData(quest).getSubstituteBonuses() if bonuses: lootboxes = getLootboxesFromBonuses(bonuses) if lootboxes: for lootboxId, lootboxInfo in lootboxes.iteritems(): showLootboxesAward(lootboxId=lootboxId, lootboxCount=lootboxInfo['count'], isFree=lootboxInfo['isFree']) else: missionAward = awards.MissionAward(quest, ctx, showMissionsCategories) if missionAward.getAwards(): shared_events.showMissionAwardWindow(missionAward)
def getAwards(self): bonuses = getMissionInfoData(self._quest).getSubstituteBonuses() return getAwardsWindowBonuses(bonuses)
def preformatEventBonuses( event, bonusFormatter=CurtailingAwardsComposer(DEFAULT_AWARDS_COUNT)): bonuses = getMissionInfoData(event).getSubstituteBonuses() return bonusFormatter.getFormattedBonuses(bonuses, size=AWARDS_SIZES.BIG)