Exemple #1
0
 def __doRun(self, settings, state):
     if not settings.enabled:
         return False
     else:
         reqs = _settings.createTutorialElement(settings.reqs)
         if not reqs.isEnabled():
             return False
         descriptor = loadDescriptorData(settings, settings.exParsers)
         if descriptor is None:
             LOG_ERROR('Descriptor is not valid. Tutorial is not available', settings)
             return False
         cache = _cache.TutorialCache(BigWorld.player().name)
         cache.read()
         cache.setSpace(settings.space)
         if state.get('byRequest', False):
             cache.setRefused(False)
         runCtx = RunCtx(cache, **state)
         reqs.prepare(runCtx)
         if not reqs.process(descriptor, runCtx):
             return False
         self.clear()
         if self.__dispatcher is None:
             self.__setDispatcher(settings.dispatcher)
         tutorial = Tutorial(settings, descriptor)
         result = tutorial.run(weakref.proxy(self.__dispatcher), runCtx)
         if result:
             self.__tutorial = tutorial
             self.__tutorial.onStopped += self.__onTutorialStopped
         return result
Exemple #2
0
 def __pe_onGuiCacheSyncCompleted(self, ctx):
     if 'databaseID' in ctx:
         databaseID = ctx['databaseID']
         isFirstStart = databaseID not in self.__loggedDBIDs
         self.__loggedDBIDs.add(databaseID)
     else:
         isFirstStart = False
     cache = _cache.TutorialCache(BigWorld.player().name)
     cache.read()
     runCtx = RunCtx(cache,
                     isFirstStart=isFirstStart,
                     isAfterBattle=self.__afterBattle,
                     **ctx)
     self.__setDispatcher(_LOBBY_DISPATCHER)
     self.__restoreID = _SETTINGS.QUESTS.id
     self.__doAutoRun((_SETTINGS.OFFBATTLE, _SETTINGS.QUESTS), runCtx)
Exemple #3
0
 def run(self, settingsID, state=None):
     """
     Try to run tutorial.
     
     :param settingsID: string containing settings ID of required tutorial.
     :param state: dict(
                     reloadIfRun : bool - just reload tutorial if it's running,
                     afterBattle : bool - tutorial should load scenario that is played
                             when player left battle,
                     initialChapter : str - name of initial chapter,
                     restoreIfRun: bool - current tutorial will be started again
                             if required tutorial stop.
                     globalFlags : dict(GLOBAL_FLAG.* : bool,)
             )
     :return: True if tutorial has started, otherwise - False.
     """
     settings = self.__settings.getSettings(settingsID)
     if settings is None:
         LOG_ERROR('Can not find settings', settingsID)
         return False
     if state is None:
         state = {}
     reloadIfRun = state.pop('reloadIfRun', False)
     restoreIfRun = state.pop('restoreIfRun', False)
     if self.__tutorial is not None and not self.__tutorial.isStopped():
         isCurrent = self.__tutorial.getID() == settings.id
         if reloadIfRun and isCurrent:
             self.__tutorial.invalidateFlags()
             return True
         if restoreIfRun and not isCurrent:
             self.__restoreID = self.__tutorial.getID()
             self.__doStop()
         else:
             LOG_ERROR('Tutorial already is running',
                       self.__tutorial.getID())
             return False
     if self.__dispatcher is None:
         self.__setDispatcher(settings.dispatcher)
     cache = _cache.TutorialCache(BigWorld.player().name)
     cache.read()
     state.setdefault('isAfterBattle', self.__afterBattle)
     state.setdefault('restart', True)
     result = self.__doRun(settings, RunCtx(cache, **state), byRequest=True)
     if not result:
         self.__restoreID = None
     return result