def checkQuestInteractions(self, caller=None):
        self.questInteractionAlowed = False
        if self.uniqueId in UninteractableProps:
            return
        if not (self.questIds or self.completedQuestIds):
            self.questInteractionAllowed = True
            self.setAllowInteract(True)
            return
        currentQuests = localAvatar.getQuests()
        for questId in self.questIds:
            container = QuestLadderDB.getContainer(questId)
            for quest in currentQuests:
                if container.getQuestId() == quest.getQuestId(
                ) or container.hasQuest(quest.getQuestId()):
                    self.questInteractionAllowed = True
                    self.setAllowInteract(True)
                    return

        questHistory = localAvatar.getQuestLadderHistory()
        for questId in self.completedQuestIds:
            qInt = QuestLadderDB.getContainer(questId).getQuestInt()
            if qInt in questHistory:
                self.questInteractionAllowed = True
                self.setAllowInteract(True)
                return

        for questId in self.notCompletedQuestIds:
            qInt = QuestLadderDB.getContainer(questId).getQuestInt()
            if qInt not in questHistory:
                self.questInteractionAllowed = True
                self.setAllowInteract(True)
                return
 def requestInteraction(self, avId, interactType = 0):
     if self.buildingUid == LocationIds.KINGSHEAD_DOOR and not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         base.localAvatar.guiMgr.showNonPayer(quest = 'Restricted_Location', focus = 0)
         return None
     
     if self.questNeeded:
         questHistory = localAvatar.getQuestLadderHistory()
         currentQuests = localAvatar.getQuests()
         container = QuestLadderDB.getContainer(self.questNeeded)
         canEnter = False
         for quest in currentQuests:
             if container.getQuestId() == quest.getQuestId() or container.hasQuest(quest.getQuestId()):
                 canEnter = True
                 continue
         
         if not canEnter:
             if self.buildingUid == LocationIds.UNDEAD_POKER_SHACK:
                 localAvatar.guiMgr.createWarning(PLocalizer.ClubheartsQuestWarning, PiratesGuiGlobals.TextFG6)
             
             return None
         
     
     if avId == base.localAvatar.doId and not base.transitions.fadeOutActive():
         self.fadeOut()
         return ()
     
     DistributedInteractive.DistributedInteractive.requestInteraction(self, avId, interactType)
    def requestInteraction(self, avId, interactType=0):
        if self.buildingUid == LocationIds.KINGSHEAD_DOOR and not Freebooter.getPaidStatus(
                base.localAvatar.getDoId()):
            base.localAvatar.guiMgr.showNonPayer(quest='Restricted_Location',
                                                 focus=0)
            return None

        if self.questNeeded:
            questHistory = localAvatar.getQuestLadderHistory()
            currentQuests = localAvatar.getQuests()
            container = QuestLadderDB.getContainer(self.questNeeded)
            canEnter = False
            for quest in currentQuests:
                if container.getQuestId() == quest.getQuestId(
                ) or container.hasQuest(quest.getQuestId()):
                    canEnter = True
                    continue

            if not canEnter:
                if self.buildingUid == LocationIds.UNDEAD_POKER_SHACK:
                    localAvatar.guiMgr.createWarning(
                        PLocalizer.ClubheartsQuestWarning,
                        PiratesGuiGlobals.TextFG6)

                return None

        if avId == base.localAvatar.doId and not base.transitions.fadeOutActive(
        ):
            self.fadeOut()
            return ()

        DistributedInteractive.DistributedInteractive.requestInteraction(
            self, avId, interactType)
Example #4
0
 def requestBranchReset(self, questId):
     quest = localAvatar.getQuestById(questId)
     self.resetBranch = quest.getBranchParent(localAvatar)
     resetBranchDNA = QuestLadderDB.getContainer(
         self.resetBranch.getQuestId())
     questStr = resetBranchDNA.getStringBefore()
     self.cleanUpQuestDetails(hide=True)
     self.playQuestString(questStr, quitButton=False, confirm=True)
     localAvatar.b_setGameState('NPCInteract',
                                localArgs=[self, True, False])
 def requestBranchReset(self, questId):
     quest = localAvatar.getQuestById(questId)
     self.resetBranch = quest.getBranchParent(localAvatar)
     resetBranchDNA = QuestLadderDB.getContainer(self.resetBranch.getQuestId())
     questStr = resetBranchDNA.getStringBefore()
     self.cleanUpQuestDetails(hide = True)
     self.playQuestString(questStr, quitButton = False, confirm = True)
     localAvatar.b_setGameState('NPCInteract', localArgs = [
         self,
         True,
         False])
Example #6
0
    def requestDropQuest(self, questId):
        DistributedQuestAvatar.notify.debug('requestDropQuest: %s (%s)' %
                                            (questId, self.doId))
        container = QuestLadderDB.getContainer(questId)
        parentContainer = QuestLadderDB.getParentContainer(container)
        if parentContainer and parentContainer.isChoice():
            for ctr in parentContainer.getContainers():
                self.sendUpdate('requestDropQuest', [ctr.getQuestId()])

        else:
            self.sendUpdate('requestDropQuest', [questId])
 def requestDropQuest(self, questId):
     DistributedQuestAvatar.notify.debug('requestDropQuest: %s (%s)' % (questId, self.doId))
     container = QuestLadderDB.getContainer(questId)
     parentContainer = QuestLadderDB.getParentContainer(container)
     if parentContainer and parentContainer.isChoice():
         for ctr in parentContainer.getContainers():
             self.sendUpdate('requestDropQuest', [
                 ctr.getQuestId()])
         
     else:
         self.sendUpdate('requestDropQuest', [
             questId])
 def checkQuestInteractions(self, caller = None):
     self.questInteractionAlowed = False
     if self.uniqueId in UninteractableProps:
         return None
     
     if not self.questIds or self.completedQuestIds:
         self.questInteractionAllowed = True
         self.setAllowInteract(True)
         return None
     
     currentQuests = localAvatar.getQuests()
     for questId in self.questIds:
         container = QuestLadderDB.getContainer(questId)
         for quest in currentQuests:
             if container.getQuestId() == quest.getQuestId() or container.hasQuest(quest.getQuestId()):
                 self.questInteractionAllowed = True
                 self.setAllowInteract(True)
                 return None
                 continue
         
     
     questHistory = localAvatar.getQuestLadderHistory()
     for questId in self.completedQuestIds:
         qInt = QuestLadderDB.getContainer(questId).getQuestInt()
         if qInt in questHistory:
             self.questInteractionAllowed = True
             self.setAllowInteract(True)
             return None
             continue
     
     for questId in self.notCompletedQuestIds:
         qInt = QuestLadderDB.getContainer(questId).getQuestInt()
         if qInt not in questHistory:
             self.questInteractionAllowed = True
             self.setAllowInteract(True)
             return None
             continue
Example #9
0
 def __init__(self):
     DirectFrame.__init__(self, relief = None)
     self.crewButtons = { }
     self.crewQuestInts = { }
     imagePos = (-0.45000000000000001, 0.0, -0.29999999999999999)
     self.images = loader.loadModel('models/gui/gui_bpcrew')
     for crewMember in self.crewData:
         uniqueId = crewMember.get('uniqueId')
         memberImage = self.images.find('**/' + crewMember.get('image'))
         containerName = crewMember.get('ladder')
         container = QuestLadderDB.getContainer(containerName)
         self.crewQuestInts[uniqueId] = QuestLadderDB.getAllParentQuestInts(container)
         self.crewButtons[uniqueId] = GuiButton(parent = self, pos = imagePos, state = DGG.DISABLED, image = memberImage, image_scale = 0.17999999999999999, geom_pos = imagePos)
     
     self.accept('clientLogout', self.destroy)
    def __init__(self):
        DirectFrame.__init__(self, relief=None)
        self.crewButtons = {}
        self.crewQuestInts = {}
        imagePos = (-0.45, 0.0, -0.3)
        self.images = loader.loadModel('models/gui/gui_bpcrew')
        for crewMember in self.crewData:
            uniqueId = crewMember.get('uniqueId')
            memberImage = self.images.find('**/' + crewMember.get('image'))
            containerName = crewMember.get('ladder')
            container = QuestLadderDB.getContainer(containerName)
            self.crewQuestInts[uniqueId] = QuestLadderDB.getAllParentQuestInts(container)
            self.crewButtons[uniqueId] = GuiButton(parent=self, pos=imagePos, state=DGG.DISABLED, image=memberImage, image_scale=0.18, geom_pos=imagePos)

        self.accept('clientLogout', self.destroy)
        return
Example #11
0
    def avIsReady(self, av):
        from pirates.quest import QuestLadderDB
        questHistory = av.getQuestLadderHistory()
        for questId in self.questIds:
            container = QuestLadderDB.getContainer(questId)
            questInts = QuestLadderDB.getAllParentQuestInts(container)
            thisQuestInHistory = False
            for qInt in questInts:
                if qInt in questHistory:
                    thisQuestInHistory = True
                    break

            if not thisQuestInHistory:
                return False

        return True
Example #12
0
    def setQuestInfoFromOffer(self, offer):
        questId = offer.getQuestId()
        questStrings = PLocalizer.QuestStrings.get(questId, {})
        title = questStrings.get('title', '\n')
        story = questStrings.get('description', '\n')
        timeLimit = 0
        containerDNA = None
        if offer.isLadder():
            containerDNA = QuestLadderDB.getContainer(questId)
            if containerDNA:
                status = ''
                if containerDNA.isChoice():
                    for container in containerDNA.getContainers():
                        status += container.getDescriptionText() + '\n'

                    status = status[0:-1]
                else:
                    status = containerDNA.getDescriptionText()

        else:
            containerDNA = QuestDB.QuestDict[questId]
            status = containerDNA.getDescriptionText(offer.initialTaskStates)
            statusBonus = containerDNA.getDescriptionText(
                offer.initialTaskStates, bonus=True)
            if statusBonus:
                status += PLocalizer.QuestStatusTaskBonus + statusBonus

            timeLimit = containerDNA.getTimeLimit()
        reward = ''
        if containerDNA:
            reward = QuestReward.QuestReward.getDescriptionText(
                containerDNA.getRewards())

        self.titleUnderline.show()
        self.titleLabel['text'] = PLocalizer.QuestItemGuiTitle % {
            'title': title
        }
        questText = '\n\n'
        questText += PLocalizer.QuestItemGuiTask % {'status': status}
        questText += PLocalizer.QuestItemGuiDescription % {'desc': story}
        if len(reward):
            questText += PLocalizer.QuestItemGuiRewards % {'reward': reward}

        self.setItemRewards(containerDNA.getRewards())
        self['text'] = questText
 def setQuestInfoFromOffer(self, offer):
     questId = offer.getQuestId()
     questStrings = PLocalizer.QuestStrings.get(questId, { })
     title = questStrings.get('title', '\n')
     story = questStrings.get('description', '\n')
     timeLimit = 0
     containerDNA = None
     if offer.isLadder():
         containerDNA = QuestLadderDB.getContainer(questId)
         if containerDNA:
             status = ''
             if containerDNA.isChoice():
                 for container in containerDNA.getContainers():
                     status += container.getDescriptionText() + '\n'
                 
                 status = status[0:-1]
             else:
                 status = containerDNA.getDescriptionText()
         
     else:
         containerDNA = QuestDB.QuestDict[questId]
         status = containerDNA.getDescriptionText(offer.initialTaskStates)
         statusBonus = containerDNA.getDescriptionText(offer.initialTaskStates, bonus = True)
         if statusBonus:
             status += PLocalizer.QuestStatusTaskBonus + statusBonus
         
         timeLimit = containerDNA.getTimeLimit()
     reward = ''
     if containerDNA:
         reward = QuestReward.QuestReward.getDescriptionText(containerDNA.getRewards())
     
     self.titleUnderline.show()
     self.titleLabel['text'] = PLocalizer.QuestItemGuiTitle % {
         'title': title }
     questText = '\n\n'
     questText += PLocalizer.QuestItemGuiTask % {
         'status': status }
     questText += PLocalizer.QuestItemGuiDescription % {
         'desc': story }
     if len(reward):
         questText += PLocalizer.QuestItemGuiRewards % {
             'reward': reward }
     
     self.setItemRewards(containerDNA.getRewards())
     self['text'] = questText
 def create(questId, holder, timerReset=False, branchReset=False):
     if QuestDB.QuestDict.has_key(questId):
         questDNA = QuestDB.QuestDict[questId]
         initialTaskStates = questDNA.getInitialTaskStates(holder)
         rewards = questDNA.getRewards()
         if len(rewards) == 0:
             rewards = questDNA.computeRewards(initialTaskStates, holder)
     else:
         questDNA = QuestLadderDB.getContainer(questId)
         initialTaskStates = []
         rewards = []
     if timerReset:
         return QuestTimerResetOffer(questId, questId, initialTaskStates,
                                     rewards)
     if branchReset:
         return QuestBranchResetOffer(questId, questId, initialTaskStates,
                                      rewards)
     return QuestOffer(questId, questId, initialTaskStates, rewards)
 def create(questId, holder, timerReset = False, branchReset = False):
     if QuestDB.QuestDict.has_key(questId):
         questDNA = QuestDB.QuestDict[questId]
         initialTaskStates = questDNA.getInitialTaskStates(holder)
         rewards = questDNA.getRewards()
         if len(rewards) == 0:
             rewards = questDNA.computeRewards(initialTaskStates, holder)
         
     else:
         questDNA = QuestLadderDB.getContainer(questId)
         initialTaskStates = []
         rewards = []
     if timerReset:
         return QuestTimerResetOffer(questId, questId, initialTaskStates, rewards)
     
     if branchReset:
         return QuestBranchResetOffer(questId, questId, initialTaskStates, rewards)
     
     return QuestOffer(questId, questId, initialTaskStates, rewards)
 def getQuestDNA(self):
     return QuestLadderDB.getContainer(self.questId)
 def showQuestRewards(self):
     if hasattr(self, '_questRewardsEarned') and self.containerId:
         container = QuestLadderDB.getContainer(self.containerId)
         self.questRewardGUI = QuestRewardGUI(container, self._questRewardsEarned)
    def setQuestsCompleted(self, menuFlag, completedContainerIds, completedChainedQuestIds, completedQuestIds, completedQuestDoIds):
        questStr = ''
        self.cleanUpQuestDetails()
        
        def handleOption(option, questStr, menuFlag, confirm, animSet):
            self.cleanUpQuestDetails(hide = True)
            self.playQuestString(questStr, quitButton = menuFlag, confirm = True, animSet = animSet)

        if len(completedContainerIds):
            if completedContainerIds[0] in [
                'c3visitJack']:
                return None
            
            if len(completedContainerIds) > 1:
                self.notify.warning('Multiple simultaneous completed quest containers for the same NPC: %s!' % completedContainerIds)
            
            containerId = completedContainerIds[0]
            self.containerId = containerId
            container = QuestLadderDB.getContainer(containerId)
            if container:
                dialogId = container.getDialogAfter()
                if dialogId:
                    self.requestDialog(dialogId)
                    return None
                
                questStr = container.getStringAfter()
                animSet = container.getAnimSetAfter()
                localAvatar.b_setGameState('NPCInteract', localArgs = [
                    self,
                    False,
                    False])
                if hasattr(self, '_questRewardsEarned'):
                    self.questRewardGUI = QuestRewardGUI(container, self._questRewardsEarned)
                    localAvatar.guiMgr.subtitler.setPageChat('', options = [
                        PLocalizer.Continue], callback = handleOption, extraArgs = [
                        questStr,
                        menuFlag,
                        True,
                        animSet])
                else:
                    handleOption(questStr, menuFlag, True, animSet)
                return None
            else:
                self.notify.warning('%s not in QuestLadderDB!' % containerId)
        
        if len(completedChainedQuestIds):
            pass
        1
        if len(completedQuestIds):
            if len(completedContainerIds) == 0:
                questId = completedQuestIds[0]
                quest = QuestDB.QuestDict.get(questId)
                if quest:
                    questStr = quest.getStringAfter()
                    animSet = quest.getAnimSetAfter()
                    self.notify.debug('%s stringAfter: %s' % (questId, questStr))
                    if hasattr(self, '_questRewardsEarned'):
                        print 'GOT questRewardsEarned: %s' % self._questRewardsEarned
                        self.questRewardGUI = QuestRewardGUI(quest, self._questRewardsEarned)
                        localAvatar.guiMgr.subtitler.setPageChat('', options = [
                            PLocalizer.Continue], callback = handleOption, extraArgs = [
                            questStr,
                            menuFlag,
                            True,
                            animSet])
                    else:
                        handleOption(questStr, menuFlag, True, animSet)
                else:
                    self.notify.warning('%s not in QuestDB!' % questId)
            
            localAvatar.b_setGameState('NPCInteract', localArgs = [
                self,
                True,
                False])
        
        if len(completedQuestIds) == 0 and len(completedChainedQuestIds) == 0 and len(completedContainerIds) == 0:
            if not self.hasOpenGUI():
                self.cancelInteraction(base.localAvatar)
Example #19
0
 def getQuestDNA(self):
     return QuestLadderDB.getContainer(self.questId)
 def showQuestRewards(self):
     if hasattr(self, '_questRewardsEarned') and self.containerId:
         container = QuestLadderDB.getContainer(self.containerId)
         self.questRewardGUI = QuestRewardGUI(container, self._questRewardsEarned)
 def getQuestDNA(self):
     if QuestDB.QuestDict.has_key(self.questId):
         return QuestDB.QuestDict[self.questId]
     else:
         return QuestLadderDB.getContainer(self.questId)
    def setQuestsCompleted(self, menuFlag, completedContainerIds, completedChainedQuestIds, completedQuestIds, completedQuestDoIds):
        questStr = ''
        self.cleanUpQuestDetails()

        def handleOption(option, questStr, menuFlag, confirm, animSet):
            self.cleanUpQuestDetails(hide = True)
            self.playQuestString(questStr, quitButton = menuFlag, confirm = True, animSet = animSet)

        if len(completedContainerIds):
            if completedContainerIds[0] in [
                'c3visitJack']:
                return None

            if len(completedContainerIds) > 1:
                self.notify.warning('Multiple simultaneous completed quest containers for the same NPC: %s!' % completedContainerIds)

            containerId = completedContainerIds[0]
            self.containerId = containerId
            container = QuestLadderDB.getContainer(containerId)
            if container:
                dialogId = container.getDialogAfter()
                if dialogId:
                    self.requestDialog(dialogId)
                    return None

                questStr = container.getStringAfter()
                animSet = container.getAnimSetAfter()
                localAvatar.b_setGameState('NPCInteract', localArgs = [
                    self,
                    False,
                    False])
                if hasattr(self, '_questRewardsEarned'):
                    self.questRewardGUI = QuestRewardGUI(container, self._questRewardsEarned)
                    localAvatar.guiMgr.subtitler.setPageChat('', options = [
                        PLocalizer.Continue], callback = handleOption, extraArgs = [
                        questStr,
                        menuFlag,
                        True,
                        animSet])
                else:
                    handleOption(questStr, menuFlag, True, animSet)
                return None
            else:
                self.notify.warning('%s not in QuestLadderDB!' % containerId)

        if len(completedChainedQuestIds):
            pass
        1
        if len(completedQuestIds):
            if len(completedContainerIds) == 0:
                questId = completedQuestIds[0]
                quest = QuestDB.QuestDict.get(questId)
                if quest:
                    questStr = quest.getStringAfter()
                    animSet = quest.getAnimSetAfter()
                    self.notify.debug('%s stringAfter: %s' % (questId, questStr))
                    if hasattr(self, '_questRewardsEarned'):
                        print 'GOT questRewardsEarned: %s' % self._questRewardsEarned
                        self.questRewardGUI = QuestRewardGUI(quest, self._questRewardsEarned)
                        localAvatar.guiMgr.subtitler.setPageChat('', options = [
                            PLocalizer.Continue], callback = handleOption, extraArgs = [
                            questStr,
                            menuFlag,
                            True,
                            animSet])
                    else:
                        handleOption(questStr, menuFlag, True, animSet)
                else:
                    self.notify.warning('%s not in QuestDB!' % questId)

            localAvatar.b_setGameState('NPCInteract', localArgs = [
                self,
                True,
                False])

        if len(completedQuestIds) == 0 and len(completedChainedQuestIds) == 0 and len(completedContainerIds) == 0:
            if not self.hasOpenGUI():
                self.cancelInteraction(base.localAvatar)
 def getQuestDNA(self):
     if QuestDB.QuestDict.has_key(self.questId):
         return QuestDB.QuestDict[self.questId]
     else:
         return QuestLadderDB.getContainer(self.questId)