Ejemplo n.º 1
0
 def format(self, message, callback):
     isSynced = yield self._waitForSyncItems()
     formatted, settings = (None, None)
     if isSynced:
         data = message.data or {}
         completedQuestIDs = self.getQuestOfThisGroup(
             data.get('completedQuestIDs', set()))
         questsData = getRewardsForQuests(
             message, self.getQuestOfThisGroup(completedQuestIDs))
         questsData['popUpRecords'] = self.getPopUps(message)
         fmt = self._achievesFormatter.formatQuestAchieves(
             questsData, asBattleFormatter=False)
         if fmt is not None:
             operationTime = message.sentTime
             if operationTime:
                 fDatetime = TimeFormatter.getLongDatetimeFormat(
                     time_utils.makeLocalServerTime(operationTime))
             else:
                 fDatetime = 'N/A'
             formatted = g_settings.msgTemplates.format(
                 self.__TEMPLATE_NAME,
                 ctx={
                     'at': fDatetime,
                     'desc': '',
                     'op': fmt
                 })
             settings = self._getGuiSettings(message, self.__TEMPLATE_NAME)
     callback([MessageData(formatted, settings)])
     return
Ejemplo n.º 2
0
 def format(self, message, callback):
     isSynced = yield self._waitForSyncItems()
     messageDataList = []
     if isSynced:
         data = message.data or {}
         completedQuestIDs = self.getQuestOfThisGroup(
             data.get('completedQuestIDs', set()))
         rewards = getRewardsForQuests(message, completedQuestIDs)
         fmt = self._achievesFormatter.formatQuestAchieves(
             rewards, asBattleFormatter=False, processCustomizations=True)
         if fmt is not None:
             templateParams = {
                 'title':
                 backport.text(R.strings.messenger.serviceChannelMessages.
                               wotPlus.freeDirectives.received.title()),
                 'text':
                 fmt
             }
             settings = self._getGuiSettings(message,
                                             self.__MESSAGE_TEMPLATE)
             formatted = g_settings.msgTemplates.format(
                 self.__MESSAGE_TEMPLATE, templateParams)
             messageDataList.append(MessageData(formatted, settings))
     if messageDataList:
         callback(messageDataList)
     callback([MessageData(None, None)])
     return
    def format(self, message, callback=None):
        isSynced = yield self._waitForSyncItems()
        formatted, settings = (None, None)
        if isSynced:
            data = message.data or {}
            completedQuestIDs = self.getQuestOfThisGroup(data.get('completedQuestIDs', set()))
            questsData = getRewardsForQuests(message, self.getQuestOfThisGroup(completedQuestIDs))
            questsData['popUpRecords'] = self.getPopUps(message)
            templateParams = {}
            rate = {}
            exchangeQ = self.__eventsCache.getAllQuests().get(self.__FRONTLINE_PRESTIGE_POINTS_EXCHANGE_TEMPLATE)
            if exchangeQ:
                for b in exchangeQ.getBonuses():
                    rate[b.getName()] = b.getValue()

            crystal = questsData.get(Currency.CRYSTAL, 0)
            if crystal:
                templateParams[Currency.CRYSTAL] = makeHtmlString('html_templates:lobby/battle_results', 'crystal_small_label', {'value': backport.getIntegralFormat(int(crystal))})
                if Currency.CRYSTAL in rate:
                    crystalRate = rate[Currency.CRYSTAL]
                    if crystalRate:
                        templateParams['points'] = int(crystal / crystalRate)
            gold = questsData.get(Currency.GOLD, 0)
            if gold:
                templateParams[Currency.GOLD] = makeHtmlString('html_templates:lobby/battle_results', 'gold_small_label', {'value': backport.getIntegralFormat(int(gold))})
                if Currency.GOLD in rate and 'points' not in templateParams:
                    goldRate = rate[Currency.GOLD]
                    if goldRate:
                        templateParams['points'] = int(gold / goldRate)
            settings = self._getGuiSettings(message, self.__TEMPLATE_NAME)
            formatted = g_settings.msgTemplates.format(self.__TEMPLATE_NAME, templateParams)
        callback([MessageData(formatted, settings)])
        return None
Ejemplo n.º 4
0
 def format(self, message, callback):
     isSynced = yield self._waitForSyncItems()
     if isSynced:
         completedQuestIDs = self.getQuestOfThisGroup(message.data.get('completedQuestIDs', set()))
         questsData = getRewardsForQuests(message, self.getQuestOfThisGroup(completedQuestIDs))
         messages = self.__formatTokenQuests(completedQuestIDs, questsData)
         callback([ MessageData(formattedMessage, self._getGuiSettings(message)) for formattedMessage in messages ])
     else:
         callback([MessageData(None, self._getGuiSettings(message))])
     return
 def __buildMessage(self, questID, message):
     rewards = getRewardsForQuests(message, set((questID,)))
     fmt = self._achievesFormatter.formatQuestAchieves(rewards, asBattleFormatter=False, processCustomizations=True)
     if fmt is not None:
         templateParams = {'achieves': fmt}
         settings = self._getGuiSettings(message, self.__MESSAGE_TEMPLATE)
         formatted = g_settings.msgTemplates.format(self.__MESSAGE_TEMPLATE, templateParams)
         return MessageData(formatted, settings)
     else:
         return
Ejemplo n.º 6
0
 def format(self, message, callback):
     isSynced = yield self._waitForSyncItems()
     formattedMessage = None
     if isSynced:
         yearPosition = AccountSettings.getSettings(RANKED_YEAR_POSITION)
         completedIDs = message.data.get('completedQuestIDs', set())
         rewardsData = getRewardsForQuests(message, self.getQuestOfThisGroup(completedIDs))
         if yearPosition is not None and rewardsData:
             formattedMessage = self.__formatFullMessage(yearPosition, rewardsData)
         else:
             formattedMessage = self.__formatShortMessage()
     callback([MessageData(formattedMessage, self._getGuiSettings(message))])
     return
Ejemplo n.º 7
0
 def format(self, message, callback):
     isSynced = yield self._waitForSyncItems()
     messages = [MessageData(None, None)]
     if isSynced and message.data:
         data = message.data
         completedQuestIDs = self.getQuestOfThisGroup(data.get('completedQuestIDs', set()))
         rewards = getRewardsForQuests(message, completedQuestIDs)
         if rewards:
             achieves = self._achievesFormatter.formatQuestAchieves(rewards, asBattleFormatter=False)
             formatted = g_settings.msgTemplates.format(self.__MESSAGE_TEMPLATE, ctx={'achieves': achieves})
             settings = self._getGuiSettings(message, self.__MESSAGE_TEMPLATE)
             messages = [MessageData(formatted, settings)]
     callback(messages)
     return
Ejemplo n.º 8
0
    def format(self, message, callback):
        isSynced = yield self._waitForSyncItems()
        messageDataList = []
        templateName = self._DEFAULT_TEMPLATE
        if isSynced:
            data = message.data or {}
            dataQuestIDs = data.get('completedQuestIDs', set())
            dataQuestIDs.update(data.get('rewardsGottenQuestIDs', set()))
            completedQuestIDs = self.getQuestOfThisGroup(dataQuestIDs)
            pmQuestsIDs = set(
                (qID for qID in completedQuestIDs
                 if personal_missions.g_cache.isPersonalMission(qID)))
            rewards = getRewardsForQuests(message, completedQuestIDs)
            potapovQuestID = data.get('potapovQuestID', None)
            if potapovQuestID is not None:
                rewards.update({'potapovQuestID': potapovQuestID})
            rewards['popUpRecords'] = self.getPopUps(message)
            specialMessage = self.__formatSpecialMissions(
                completedQuestIDs, pmQuestsIDs, message, rewards)
            fmt = self._achievesFormatter.formatQuestAchieves(
                rewards,
                asBattleFormatter=False,
                processCustomizations=not specialMessage)
            if fmt is not None:
                templateParams = {'achieves': fmt}
                campaigns = set()
                for qID in pmQuestsIDs:
                    pmID = personal_missions.g_cache.getPersonalMissionIDByUniqueID(
                        qID)
                    mission = self.__eventsCache.getPersonalMissions(
                    ).getAllQuests()[pmID]
                    campaigns.add(mission.getCampaignID())

                if campaigns:
                    templateName = self.__PERSONAL_MISSIONS_CUSTOM_TEMPLATE
                    campaignNameKey = 'both' if len(
                        campaigns) == 2 else 'c_{}'.format(first(campaigns))
                    templateParams['text'] = backport.text(
                        R.strings.messenger.serviceChannelMessages.
                        battleResults.personalMissions.dyn(campaignNameKey)())
                settings = self._getGuiSettings(message, templateName)
                formatted = g_settings.msgTemplates.format(
                    templateName, templateParams)
                messageDataList.append(MessageData(formatted, settings))
            messageDataList.extend(specialMessage)
        if messageDataList:
            callback(messageDataList)
        else:
            callback([MessageData(None, None)])
        return
Ejemplo n.º 9
0
 def format(self, message, callback):
     isSynced = yield self._waitForSyncItems()
     messages = [MessageData(None, None)]
     if isSynced and message.data:
         data = message.data
         completedQuestIDs = self.getQuestOfThisGroup(data.get('completedQuestIDs', set()))
         rewards = getRewardsForQuests(message, completedQuestIDs)
         tokensCount = rewards.get('tokens', {}).get(NY_GIFT_SYSTEM_PROGRESSION_TOKEN, {}).get('count', 0)
         if tokensCount:
             achieves = backport.text(R.strings.ny.giftSystem.progressionToken())
             formatted = g_settings.msgTemplates.format(self.__MESSAGE_TEMPLATE, ctx={'achieves': achieves})
             settings = self._getGuiSettings(message, self.__MESSAGE_TEMPLATE)
             messages = [MessageData(formatted, settings)]
     callback(messages)
     return