Exemplo n.º 1
0
 def _updateDailyQuestModel(self, model, fullUpdate=False):
     _logger.debug('DailyQuestsView::_updateDailyQuestModel')
     isEnabled = isDailyQuestsEnable()
     quests = sorted(self.eventsCache.getDailyQuests().values(),
                     key=dailyQuestsSortFunc)
     newBonusQuests = settings.getNewCommonEvents(
         [q for q in quests if q.isBonus()])
     self._updateRerollEnabledFlag(model)
     with model.dailyQuests.transaction() as tx:
         tx.setIsEnabled(isEnabled)
         if not isEnabled:
             return
         if not fullUpdate and not needToUpdateQuestsInModel(
                 quests + newBonusQuests, tx.getQuests()):
             return
         self.__updateQuestsInModel(tx.getQuests(), quests)
         self.__updateMissionVisitedArray(tx.getMissionsCompletedVisited(),
                                          quests)
         tx.setBonusMissionVisited(not newBonusQuests)
         if self.__festivityController.isEnabled():
             if not AccountSettings.getUIFlag(NY_DAILY_QUESTS_VISITED):
                 tx.setPlayNYQuestLootboxAnimation(True)
                 AccountSettings.setUIFlag(NY_DAILY_QUESTS_VISITED, True)
             if not AccountSettings.getUIFlag(
                     NY_BONUS_DAILY_QUEST_VISITED
             ) and not tx.getBonusMissionVisited():
                 tx.setPlayNYBonusQuestLootboxAnimation(True)
                 AccountSettings.setUIFlag(NY_DAILY_QUESTS_VISITED, True)
                 AccountSettings.setUIFlag(NY_BONUS_DAILY_QUEST_VISITED,
                                           True)
Exemplo n.º 2
0
    def _updateViewModel(self):
        _logger.debug('DailyQuests::UpdatingViewModel')
        newCountdownVal = EventInfoModel.getDailyProgressResetTimeDelta()
        quests = sorted(self.eventsCache.getDailyQuests().values(), key=dailyQuestsSortFunc)
        if not needToUpdateQuestsInModel(quests, self.getViewModel().getQuests()):
            return
        else:
            with self.getViewModel().transaction() as tx:
                tx.setCountdown(newCountdownVal)
                modelQuests = tx.getQuests()
                modelQuests.clear()
                modelQuests.reserve(len(quests))
                for quest in quests:
                    questUIPacker = getEventUIDataPacker(quest)
                    fullQuestModel = questUIPacker.pack()
                    questModel = WidgetQuestModel()
                    preFormattedConditionModel = self._getFirstConditionModelFromQuestModel(fullQuestModel)
                    if preFormattedConditionModel is not None:
                        questModel.setCurrentProgress(preFormattedConditionModel.getCurrent())
                        questModel.setTotalProgress(preFormattedConditionModel.getTotal())
                        questModel.setEarned(preFormattedConditionModel.getEarned())
                        questModel.setDescription(preFormattedConditionModel.getDescrData())
                    questModel.setId(fullQuestModel.getId())
                    questModel.setIcon(fullQuestModel.getIcon())
                    questModel.setCompleted(fullQuestModel.getStatus() == MISSIONS_STATES.COMPLETED)
                    modelQuests.addViewModel(questModel)
                    fullQuestModel.unbind()

                modelQuests.invalidate()
                self.__updateQuestsToBeIndicatedCompleted(tx, quests, self.viewModel.getVisible())
            return
 def _updatePremiumMissionsModel(self, model, fullUpdate=False):
     _logger.debug('DailyQuestsView::_updatePremiumMissionsModel')
     quests = sorted(self.eventsCache.getPremiumQuests().values(), cmp=premMissionsSortFunc)
     isPremAcc = _isPremiumPlusAccount()
     isEnabled = isPremiumQuestsEnable()
     with model.premiumMissions.transaction() as tx:
         tx.setIsPremiumAccount(isPremAcc)
         tx.setIsEnabled(isEnabled)
         if not isPremAcc or not isEnabled:
             return
         missionsModel = tx.getMissions()
         if not fullUpdate and not needToUpdateQuestsInModel(quests, missionsModel):
             return
         self.__updateQuestsInModel(missionsModel, quests)
         self.__updateMissionVisitedArray(tx.getMissionsCompletedVisited(), quests)
 def _updateDailyQuestModel(self, model, fullUpdate=False):
     _logger.debug('DailyQuestsView::_updateDailyQuestModel')
     isEnabled = isDailyQuestsEnable()
     quests = sorted(self.eventsCache.getDailyQuests().values(), key=dailyQuestsSortFunc)
     newBonusQuests = settings.getNewCommonEvents([ q for q in quests if q.isBonus() ])
     self._updateRerollEnabledFlag(model)
     with model.dailyQuests.transaction() as tx:
         tx.setIsEnabled(isEnabled)
         if not isEnabled:
             return
         if not fullUpdate and not needToUpdateQuestsInModel(quests + newBonusQuests, tx.getQuests()):
             return
         self.__updateQuestsInModel(tx.getQuests(), quests)
         self.__updateMissionVisitedArray(tx.getMissionsCompletedVisited(), quests)
         tx.setBonusMissionVisited(not newBonusQuests)