def __getQuestByDossierRecord(cls, name):
        from gui.server_events import g_eventsCache
        for qID, records in g_eventsCache.getQuestsDossierBonuses().iteritems():
            if (_AB.UNIQUE, name) in records:
                return g_eventsCache.getQuests().get(qID)

        return None
Example #2
0
 def __getFortQuest(cls):
     fortQuests = g_eventsCache.getQuests(
         lambda q: q.getType() == constants.EVENT_TYPE.FORT_QUEST)
     if len(fortQuests):
         return fortQuests.values()[0]
     else:
         return None
Example #3
0
    def _getVehiclesDescrsList(self):
        vehsList = []
        try:
            from gui.server_events import g_eventsCache
            for qIDs in self.__getQuestByDossierRecord(
                    self._name).getChildren().itervalues():
                for qID in qIDs:
                    counterQuest = g_eventsCache.getQuests().get(qID)
                    histBattleCond = counterQuest.preBattleCond.getConditions(
                    ).find('historicalBattleIDs')
                    allVehsCompDescrs = set()
                    for hID in histBattleCond._battlesIDs:
                        hb = g_eventsCache.getHistoricalBattles().get(hID)
                        if hb is not None:
                            allVehsCompDescrs.update(
                                hb.getVehiclesData().keys())

                    vehsList = filter(
                        lambda intCD: not counterQuest.isCompletedByGroup(
                            intCD), allVehsCompDescrs)
                    break

        except Exception:
            pass

        return vehsList
Example #4
0
 def __initWindow(self):
     tabs = []
     if isPotapovQuestEnabled():
         tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_PERSONAL, _QA.TAB_PERSONAL_QUESTS))
     tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_CURRENT, _QA.TAB_COMMON_QUESTS))
     if g_eventsCache.getQuests(lambda x: x.getType() == constants.EVENT_TYPE.CLUBS_QUEST):
         tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_LADDER, _QA.TAB_LADDER_QUESTS))
     if g_settingsCore.serverSettings.getTutorialSetting(TUTORIAL.WAS_QUESTS_TUTORIAL_STARTED):
         tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_BEGINNER, _QA.TAB_BEGINNER_QUESTS))
     self.as_initS({"tabs": tabs})
Example #5
0
 def __onQuestsUpdated(self, *args):
     svrEvents = g_eventsCache.getEvents()
     quest_settings.updateCommonEventsSettings(svrEvents)
     self.as_setDataS({'titleText': QUESTS.QUESTSCONTROL_TITLE,
      'tooltip': TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL})
     premiumIgrVehiclesQuests = g_eventsCache.getQuests(lambda q: q.getStartTimeLeft() <= 0 < q.getFinishTimeLeft() and q.hasPremIGRVehBonus())
     if len(premiumIgrVehiclesQuests):
         storedValue = AccountSettings.getFilter(IGR_PROMO)
         if not storedValue['wasShown']:
             self.fireEvent(events.LoadViewEvent(VIEW_ALIAS.PROMO_PREMIUM_IGR_WINDOW), EVENT_BUS_SCOPE.LOBBY)
 def __initWindow(self):
     tabs = []
     if g_lobbyContext.getServerSettings().isPotapovQuestEnabled():
         tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_PERSONAL, _QA.TAB_PERSONAL_QUESTS))
     tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_CURRENT, _QA.TAB_COMMON_QUESTS))
     if g_eventsCache.getQuests(lambda x: x.getType() == constants.EVENT_TYPE.CLUBS_QUEST):
         tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_LADDER, _QA.TAB_LADDER_QUESTS))
     if self.__isTutorialTabEnabled():
         tabs.append(self.__packTabDataItem(QUESTS.QUESTS_TABS_BEGINNER, _QA.TAB_BEGINNER_QUESTS))
     self.as_initS({'tabs': tabs})
Example #7
0
    def __getBoosterQuests(self):
        result = defaultdict(list)
        quests = g_eventsCache.getQuests(lambda q: q.isAvailable()[0] and not q.isCompleted())
        for q in quests.itervalues():
            bonuses = q.getBonuses('goodies')
            for b in bonuses:
                boosters = b.getBoosters()
                for booster, count in boosters.iteritems():
                    result[q.getID(), q.getUserName()].append((booster, count))

        return result
Example #8
0
 def __onQuestsUpdated(self, *args):
     svrEvents = g_eventsCache.getEvents()
     quest_settings.updateCommonEventsSettings(svrEvents)
     self.as_setDataS({
         'titleText': QUESTS.QUESTSCONTROL_TITLE,
         'tooltip': TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL
     })
     premiumIgrVehiclesQuests = g_eventsCache.getQuests(
         lambda q: q.getStartTimeLeft() <= 0 < q.getFinishTimeLeft(
         ) and q.hasPremIGRVehBonus())
     if len(premiumIgrVehiclesQuests):
         storedValue = AccountSettings.getFilter(IGR_PROMO)
         if not storedValue['wasShown']:
             self.fireEvent(
                 events.LoadViewEvent(VIEW_ALIAS.PROMO_PREMIUM_IGR_WINDOW),
                 EVENT_BUS_SCOPE.LOBBY)
Example #9
0
    def getDisplayableData(self, *args):
        qLabels, qProgress = [], []
        premVehQuests = []
        if game_control.g_instance.igr.getRoomType() in (constants.IGR_TYPE.PREMIUM, constants.IGR_TYPE.BASE):
            quests = g_eventsCache.getQuests()
            for q in quests.itervalues():
                if game_control.g_instance.igr.getRoomType() == constants.IGR_TYPE.PREMIUM:
                    template = g_htmlTemplates['html_templates:lobby/tooltips']['igr_quest']
                    if q.accountReqs.hasIGRCondition() and not q.hasPremIGRVehBonus():
                        metaList = q.getBonuses('meta')
                        if len(metaList):
                            qLabels.append(metaList[0].format())
                        winCond = None
                        if q.postBattleCond.getConditions().getName() == 'and':
                            winCond = q.postBattleCond.getConditions().find('win')
                        isWin = winCond.getValue() if winCond is not None else False
                        battlesCond = q.bonusCond.getConditions().find('battles')
                        if battlesCond is not None:
                            curBattles, totalBattles = (0, 0)
                            progress = battlesCond.getProgressPerGroup()
                            if None in progress:
                                curBattles, totalBattles, _, _ = progress[None]
                            qProgress.append([curBattles, totalBattles, i18n.makeString('#quests:igr/tooltip/winsLabel') if isWin else i18n.makeString('#quests:igr/tooltip/battlesLabel')])
                if q.hasPremIGRVehBonus():
                    metaList = q.getBonuses('meta')
                    leftTime = time_utils.getTimeDeltaFromNow(q.getFinishTime())
                    if len(metaList) and leftTime > 0:
                        header = makeHtmlString('html_templates:lobby/tooltips', 'prem_igr_veh_quest_header', ctx={'qLabel': metaList[0].format()})
                        text = i18n.makeString('#tooltips:vehicleIgr/specialAbility')
                        localization = '#tooltips:vehicleIgr/%s'
                        actionLeft = getRentLeftTimeStr(localization, leftTime, timeStyle=TextType.STATS_TEXT)
                        text += '\n' + actionLeft
                        premVehQuests.append({'header': header,
                         'descr': text})

        descriptionTemplate = 'igr_description' if len(qLabels) == 0 else 'igr_description_with_quests'
        igrPercent = (game_control.g_instance.igr.getXPFactor() - 1) * 100
        igrType = game_control.g_instance.igr.getRoomType()
        icon = makeHtmlString('html_templates:igr/iconBig', 'premium' if igrType == constants.IGR_TYPE.PREMIUM else 'basic')
        return {'title': i18n.makeString(TOOLTIPS.IGR_TITLE, igrIcon=icon),
         'description': makeHtmlString('html_templates:lobby/tooltips', descriptionTemplate, {'igrValue': '{0}%'.format(BigWorld.wg_getIntegralFormat(igrPercent))}),
         'quests': map(lambda i: i.format(**template.ctx), qLabels),
         'progressHeader': makeHtmlString('html_templates:lobby/tooltips', 'igr_progress_header', {}),
         'progress': qProgress,
         'premVehQuests': premVehQuests}
Example #10
0
 def __initWindow(self):
     tabs = []
     if g_lobbyContext.getServerSettings().isPotapovQuestEnabled():
         tabs.append(
             self.__packTabDataItem(QUESTS.QUESTS_TABS_PERSONAL,
                                    _QA.TAB_PERSONAL_QUESTS))
     tabs.append(
         self.__packTabDataItem(QUESTS.QUESTS_TABS_CURRENT,
                                _QA.TAB_COMMON_QUESTS))
     if g_eventsCache.getQuests(
             lambda x: x.getType() == constants.EVENT_TYPE.CLUBS_QUEST):
         tabs.append(
             self.__packTabDataItem(QUESTS.QUESTS_TABS_LADDER,
                                    _QA.TAB_LADDER_QUESTS))
     if self.__isTutorialTabEnabled():
         tabs.append(
             self.__packTabDataItem(QUESTS.QUESTS_TABS_BEGINNER,
                                    _QA.TAB_BEGINNER_QUESTS))
     self.as_initS({'tabs': tabs})
Example #11
0
 def __initWindow(self):
     tabs = []
     if isPotapovQuestEnabled():
         tabs.append(
             self.__packTabDataItem(QUESTS.QUESTS_TABS_PERSONAL,
                                    _QA.TAB_PERSONAL_QUESTS))
     tabs.append(
         self.__packTabDataItem(QUESTS.QUESTS_TABS_CURRENT,
                                _QA.TAB_COMMON_QUESTS))
     if g_eventsCache.getQuests(
             lambda x: x.getType() == constants.EVENT_TYPE.CLUBS_QUEST):
         tabs.append(
             self.__packTabDataItem(QUESTS.QUESTS_TABS_LADDER,
                                    _QA.TAB_LADDER_QUESTS))
     if g_settingsCore.serverSettings.getTutorialSetting(
             TUTORIAL.WAS_QUESTS_TUTORIAL_STARTED):
         tabs.append(
             self.__packTabDataItem(QUESTS.QUESTS_TABS_BEGINNER,
                                    _QA.TAB_BEGINNER_QUESTS))
     self.as_initS({'tabs': tabs})
Example #12
0
 def __onQuestsUpdated(self, *args):
     svrEvents = g_eventsCache.getEvents()
     quest_settings.updateCommonEventsSettings(svrEvents)
     btnInfo = _createBtnInfo(QUESTS.QUESTSCONTROL_ADDITIONALTITLE_EMPTY,
                              TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_EMPTY,
                              highlight=False)
     if g_lobbyContext.getServerSettings().isPotapovQuestEnabled():
         if not quest_settings.isNeedToShowHeaderAlert():
             quest_settings.markHeaderAlertAsVisited()
             btnInfo = _createBtnInfo(
                 QUESTS.QUESTSCONTROL_ADDITIONALTITLE_FIRSTRUN,
                 TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_NEW)
         elif g_eventsCache.potapov.hasQuestsForReward():
             btnInfo = _createBtnInfo(
                 QUESTS.QUESTSCONTROL_ADDITIONALTITLE_NEEDRECEIVEDAWARD,
                 TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_RECEIVETHEAWARD,
                 alert=True)
         elif g_eventsCache.potapov.hasQuestsForSelect():
             btnInfo = _createBtnInfo(
                 QUESTS.
                 QUESTSCONTROL_ADDITIONALTITLE_FREESLOTSANDFREEQUESTS,
                 TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_AVAILABLE,
                 alert=True)
     self.as_setDataS({
         'titleText':
         QUESTS.QUESTSCONTROL_TITLE,
         'additionalText':
         text_styles.alert(i18n.makeString(btnInfo.text)),
         'tooltip':
         btnInfo.tooltip
     })
     self.as_isShowAlertIconS(btnInfo.alert, btnInfo.highlight)
     premiumIgrVehiclesQuests = g_eventsCache.getQuests(
         lambda q: q.getStartTimeLeft() <= 0 < q.getFinishTimeLeft(
         ) and q.hasPremIGRVehBonus())
     if len(premiumIgrVehiclesQuests):
         storedValue = AccountSettings.getFilter(IGR_PROMO)
         if not storedValue['wasShown']:
             self.fireEvent(
                 events.LoadViewEvent(VIEW_ALIAS.PROMO_PREMIUM_IGR_WINDOW),
                 EVENT_BUS_SCOPE.LOBBY)
Example #13
0
 def __onQuestsUpdated(self, *args):
     svrEvents = g_eventsCache.getEvents()
     quest_settings.updateCommonEventsSettings(svrEvents)
     btnInfo = _createBtnInfo(QUESTS.QUESTSCONTROL_ADDITIONALTITLE_EMPTY, TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_EMPTY, highlight=False)
     if isPotapovQuestEnabled():
         if not quest_settings.isNeedToShowHeaderAlert():
             quest_settings.markHeaderAlertAsVisited()
             btnInfo = _createBtnInfo(QUESTS.QUESTSCONTROL_ADDITIONALTITLE_FIRSTRUN, TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_NEW)
         elif g_eventsCache.potapov.hasQuestsForReward():
             btnInfo = _createBtnInfo(QUESTS.QUESTSCONTROL_ADDITIONALTITLE_NEEDRECEIVEDAWARD, TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_RECEIVETHEAWARD, alert=True)
         elif g_eventsCache.potapov.hasQuestsForSelect():
             btnInfo = _createBtnInfo(QUESTS.QUESTSCONTROL_ADDITIONALTITLE_FREESLOTSANDFREEQUESTS, TOOLTIPS.PRIVATEQUESTS_QUESTCONTROL_AVAILABLE, alert=True)
     self.as_setDataS({'titleText': QUESTS.QUESTSCONTROL_TITLE,
      'additionalText': text_styles.alert(i18n.makeString(btnInfo.text)),
      'tooltip': btnInfo.tooltip})
     self.as_isShowAlertIconS(btnInfo.alert, btnInfo.highlight)
     premiumIgrVehiclesQuests = g_eventsCache.getQuests(lambda q: q.getStartTimeLeft() <= 0 < q.getFinishTimeLeft() and q.hasPremIGRVehBonus())
     if len(premiumIgrVehiclesQuests):
         storedValue = AccountSettings.getFilter(IGR_PROMO)
         if not storedValue['wasShown']:
             self.fireEvent(events.LoadViewEvent(VIEW_ALIAS.PROMO_PREMIUM_IGR_WINDOW))
    def _getVehiclesDescrsList(self):
        vehsList = []
        try:
            from gui.server_events import g_eventsCache
            for qIDs in self.__getQuestByDossierRecord(self._name).getChildren().itervalues():
                for qID in qIDs:
                    counterQuest = g_eventsCache.getQuests().get(qID)
                    histBattleCond = counterQuest.preBattleCond.getConditions().find('historicalBattleIDs')
                    allVehsCompDescrs = set()
                    for hID in histBattleCond._battlesIDs:
                        hb = g_eventsCache.getHistoricalBattles().get(hID)
                        if hb is not None:
                            allVehsCompDescrs.update(hb.getVehiclesData().keys())

                    vehsList = filter(lambda intCD: not counterQuest.isCompletedByGroup(intCD), allVehsCompDescrs)
                    break

        except Exception:
            pass

        return vehsList
Example #15
0
 def _getEvents(cls):
     return g_eventsCache.getQuests(
         lambda x: x.getType() == EVENT_TYPE.CLUBS_QUEST)
Example #16
0
 def _getEvents(cls):
     return g_eventsCache.getQuests(lambda x: x.getType() == EVENT_TYPE.CLUBS_QUEST)
Example #17
0
 def __getFortQuest(cls):
     fortQuests = g_eventsCache.getQuests(lambda q: q.getType() == constants.EVENT_TYPE.FORT_QUEST)
     if len(fortQuests):
         return fortQuests.values()[0]
     else:
         return None
Example #18
0
 def __getQuestByDossierRecord(cls, name):
     from gui.server_events import g_eventsCache
     for qID, records in g_eventsCache.getQuestsDossierBonuses().iteritems(
     ):
         if (_AB.UNIQUE, name) in records:
             return g_eventsCache.getQuests().get(qID)