示例#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
示例#2
0
def showStats(exclude = None, destroyed = False, subtitle = None, audio = None):
    instance = loader.g_loader.tutorial
    if exclude is None:
        exclude = []
    if instance is not None and not instance._tutorialStopped:
        descriptor = doc_loader.loadDescriptorData(TUTORIAL_SETTINGS.BATTLE.descriptorPath)
        if descriptor is not None:
            completed = 0
            chapterIdx = -1
            for idx, chapter in enumerate(descriptor):
                if chapter.hasBonus() and idx not in exclude:
                    completed |= 1 << chapter.getBonusID()
                    chapterIdx = idx

            winTeam = 1
            reason = 0
            if len(exclude):
                winTeam = 2
                if destroyed:
                    reason = FINISH_REASON.EXTERMINATION
                else:
                    reason = FINISH_REASON.TIMEOUT
            instance._cache.setLocalCtx(ExtendedBattleClientCtx(completed, -1, -1, time.time(), chapterIdx, 1, winTeam, reason, 56321, 53, long(time.time())).makeRecord())
            MockVideoContent.subtitleTrack = subtitle
            MockVideoContent.audioTrack = audio
            instance._ctrlFactory._contentQueries['video'] = MockVideoContent
            from tutorial.mock import reloadChapter
            reloadChapter(ab=True)
        else:
            LOG_DEBUG('Tutorial descriptor is invalid.')
    else:
        LOG_DEBUG('Tutorial is not running.')
    return
示例#3
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
示例#4
0
 def run(self):
     self.isRunning = True
     if not self.isSubscribed:
         self.isSubscribed = True
         g_clientUpdateManager.addCallbacks({'stats.tutorialsCompleted': self.__onTutorialCompleted})
         setting = createSettingsCollection().getSettings(self.getVar())
         self._tutorDescriptor = doc_loader.loadDescriptorData(setting)
     self.toggle(isOn=self.isOn(self._bonuses.getCompleted()))
示例#5
0
 def run(self):
     self.isRunning = True
     if not self.isSubscribed:
         self.isSubscribed = True
         g_clientUpdateManager.addCallbacks({'stats.tutorialsCompleted': self.__onTutorialCompleted})
         setting = createSettingsCollection().getSettings(self.getVar())
         self._tutorDescriptor = doc_loader.loadDescriptorData(setting)
     self.toggle(isOn=self.isOn(self._bonuses.getCompleted()))
示例#6
0
def setCompleted(exclude = None):
    instance = loader.g_loader.tutorial
    if exclude is None:
        exclude = []
    if instance is not None and not instance._tutorialStopped:
        descriptor = doc_loader.loadDescriptorData(TUTORIAL_SETTINGS.BATTLE.descriptorPath)
        if descriptor is not None:
            clientCtx = BattleClientCtx.fetch()
            for idx, chapter in enumerate(descriptor):
                if chapter.hasBonus() and idx not in exclude:
                    clientCtx = clientCtx.addMask(1 << chapter.getBonusID())

            clientCtx.setChapterIdx(descriptor.getNumberOfChapters() - 1)
            arena = getattr(BigWorld.player(), 'arena', None)
            if arena is not None:
                BigWorld.player().leaveArena()
        else:
            LOG_DEBUG('Tutorial descriptor is invalid.')
    else:
        LOG_DEBUG('Tutorial is not running.')
    return
示例#7
0
 def __init__(self, settings):
     super(Tutorial, self).__init__()
     self._cache = None
     self.__callbackID = None
     self._currentChapter = None
     self._currentState = None
     self._settings = settings
     self._ctrlFactory = TUTORIAL_SETTINGS.factory(settings.ctrl)
     self._descriptor = doc_loader.loadDescriptorData(settings.descriptorPath, settings.exParsers)
     self._data = None
     self._tutorialStopped = True
     self._nextChapter = False
     self._nextScene = None
     self._funcScene = None
     self._funcInfo = None
     self._flags = None
     self._vars = None
     self._effectsQueue = []
     self._gui = None
     self._bonuses = None
     self._sound = None
     self._initialized = 0
示例#8
0
文件: loader.py 项目: kblw/wot_client
 def __doRun(self, settings, runCtx, byRequest = False):
     if not settings.enabled:
         return False
     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
     runCtx.cache.setSpace(settings.space)
     if byRequest:
         runCtx.cache.setRefused(False)
     reqs.prepare(runCtx)
     if not reqs.process(descriptor, runCtx):
         return False
     self.clear()
     tutorial = Tutorial(settings, descriptor)
     result = tutorial.run(weakref.proxy(self.__dispatcher), runCtx)
     if result:
         self.__tutorial = tutorial
         self.__tutorial.onStopped += self.__onTutorialStopped
     return result
示例#9
0
def showStats(exclude=None, destroyed=False, subtitle=None, audio=None):
    instance = loader.g_loader.tutorial
    if exclude is None:
        exclude = []
    if instance is not None and not instance._tutorialStopped:
        descriptor = doc_loader.loadDescriptorData(
            TUTORIAL_SETTINGS.BATTLE.descriptorPath)
        if descriptor is not None:
            completed = 0
            chapterIdx = -1
            for idx, chapter in enumerate(descriptor):
                if chapter.hasBonus() and idx not in exclude:
                    completed |= 1 << chapter.getBonusID()
                    chapterIdx = idx

            winTeam = 1
            reason = 0
            if len(exclude):
                winTeam = 2
                if destroyed:
                    reason = FINISH_REASON.EXTERMINATION
                else:
                    reason = FINISH_REASON.TIMEOUT
            instance._cache.setLocalCtx(
                ExtendedBattleClientCtx(completed, -1, -1, time.time(),
                                        chapterIdx, 1, winTeam, reason, 56321,
                                        53, long(time.time())).makeRecord())
            MockVideoContent.subtitleTrack = subtitle
            MockVideoContent.audioTrack = audio
            instance._ctrlFactory._contentQueries['video'] = MockVideoContent
            from tutorial.mock import reloadChapter
            reloadChapter(ab=True)
        else:
            LOG_DEBUG('Tutorial descriptor is invalid.')
    else:
        LOG_DEBUG('Tutorial is not running.')
    return
示例#10
0
 def __init__(self, settings):
     super(Tutorial, self).__init__()
     self._cache = None
     self.__callbackID = None
     self._currentChapter = None
     self._currentState = None
     self._settings = settings
     self._ctrlFactory = TUTORIAL_SETTINGS.factory(settings.ctrl)
     self._descriptor = doc_loader.loadDescriptorData(
         settings.descriptorPath, settings.exParsers)
     self._data = None
     self._tutorialStopped = True
     self._nextChapter = False
     self._nextScene = None
     self._funcScene = None
     self._funcInfo = None
     self._flags = None
     self._vars = None
     self._effectsQueue = []
     self._gui = None
     self._bonuses = None
     self._sound = None
     self._initialized = 0
     return
示例#11
0
 def __doRun(self, settings, runCtx, byRequest=False):
     if not settings.enabled:
         return False
     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
     runCtx.cache.setSpace(settings.space)
     if byRequest:
         runCtx.cache.setRefused(False)
     reqs.prepare(runCtx)
     if not reqs.process(descriptor, runCtx):
         return False
     self.clear()
     tutorial = Tutorial(settings, descriptor)
     result = tutorial.run(weakref.proxy(self.__dispatcher), runCtx)
     if result:
         self.__tutorial = tutorial
         self.__tutorial.onStopped += self.__onTutorialStopped
     return result
示例#12
0
def getQuestsDescriptor():
    return doc_loader.loadDescriptorData(TUTORIAL_SETTINGS.QUESTS)
示例#13
0
def getBattleDescriptor():
    return doc_loader.loadDescriptorData(TUTORIAL_SETTINGS.BATTLE_V2)
示例#14
0
def getBattleDescriptor():
    return doc_loader.loadDescriptorData(TUTORIAL_SETTINGS.BATTLE)
示例#15
0
def _getBattleDescriptor():
    return doc_loader.loadDescriptorData(
        TUTORIAL_SETTINGS.BATTLE.descriptorPath)
示例#16
0
def getQuestsDescriptor():
    return doc_loader.loadDescriptorData(TUTORIAL_SETTINGS.QUESTS)