def update(self, questIdList, quest, newQuest): if quest and isinstance(quest, Quest.Quest): if newQuest: localAvatar.questStatus.assignQuest(quest) container = localAvatar.questStatus.getContainer(quest.questId) if not container: container = localAvatar.getQuestById(quest.questId) container.viewedInGUI = False for button in self.buttons: button.destroy() self.buttons = [] self.trees = {} for questId in questIdList: path = QuestLadderDB.getFamePath(questId) if path: pathName = path[0].getName() tree = self.trees.get(pathName) self.trees[pathName] = self.__makeTree(path, tree) else: path = QuestLadderDB.getFortunePath(questId) if path: pathName = path[0].getName() tree = self.trees.get(pathName) self.trees[pathName] = self.__makeTree(path, tree) else: path = [QuestDB.QuestDict.get(questId)] self.trees[questId] = self.__makeTree(path, tree=None) treeList = self.orderTrees() for tree in treeList: self.__makeButtons(self.getCanvas(), tree) self.repack() return
def questObjMod(quests, object, av, repository): for currQuestInt in quests: currId = QuestDB.getQuestIdFromQuestInt(currQuestInt) if currId: containerDNA = QuestDB.QuestDict.get(currId) else: containerDNA = QuestLadderDB.getContainerFromQuestInt(currQuestInt) questModInfo = containerDNA.getQuestMod() questObjId = None if questModInfo: questObjId = questModInfo[0] if questObjId in [object.getUniqueId(), object.getSpawnPosIndex()]: questInterestId = av.hasQuestNPCInterest(object.getUniqueId()) if QuestLadderDB.questIntInHistory(currQuestInt, av.getQuestLadderHistory()): return questModInfo[3] elif questInterestId: questObj = repository.doId2do.get(questInterestId) if questObj and questObj.isComplete(): return questModInfo[3] return questModInfo[2] else: return questModInfo[1] QuestLadderDB.questIntInHistory(currQuestInt, av.getQuestLadderHistory())
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 questObjMod(quests, object, av, repository): for currQuestInt in quests: currId = QuestDB.getQuestIdFromQuestInt(currQuestInt) if currId: containerDNA = QuestDB.QuestDict.get(currId) else: containerDNA = QuestLadderDB.getContainerFromQuestInt(currQuestInt) questModInfo = containerDNA.getQuestMod() questObjId = None if questModInfo: questObjId = questModInfo[0] if questObjId in [ object.getUniqueId(), object.getSpawnPosIndex()]: questInterestId = av.hasQuestNPCInterest(object.getUniqueId()) if QuestLadderDB.questIntInHistory(currQuestInt, av.getQuestLadderHistory()): return questModInfo[3] elif questInterestId: questObj = repository.doId2do.get(questInterestId) if questObj and questObj.isComplete(): return questModInfo[3] return questModInfo[2] else: return questModInfo[1] QuestLadderDB.questIntInHistory(currQuestInt, av.getQuestLadderHistory())
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 __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
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)
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
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])
def update(self, questIdList, quest, newQuest): if quest and isinstance(quest, Quest.Quest): if newQuest: localAvatar.questStatus.assignQuest(quest) container = localAvatar.questStatus.getContainer(quest.questId) if not container: container = localAvatar.getQuestById(quest.questId) container.viewedInGUI = False for button in self.buttons: button.destroy() self.buttons = [] self.trees = { } for questId in questIdList: path = QuestLadderDB.getFamePath(questId) if path: pathName = path[0].getName() tree = self.trees.get(pathName) self.trees[pathName] = self._QuestTitleList__makeTree(path, tree) continue path = QuestLadderDB.getFortunePath(questId) if path: pathName = path[0].getName() tree = self.trees.get(pathName) self.trees[pathName] = self._QuestTitleList__makeTree(path, tree) continue path = [ QuestDB.QuestDict.get(questId)] self.trees[questId] = self._QuestTitleList__makeTree(path, tree = None) treeList = self.orderTrees() for tree in treeList: self._QuestTitleList__makeButtons(self.getCanvas(), tree) self.repack()
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
def setOffers(self, offers): z = 1.0 self.destroyQuestButtons() self.title = DirectLabel(parent=self, relief=None, text=PLocalizer.InteractQuest, text_align=TextNode.ACenter, text_scale=0.07, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=1, pos=(0, 0, z - 0.08), text_font=PiratesGlobals.getPirateOutlineFont()) gui = loader.loadModel('models/gui/avatar_chooser_rope') topPanel = gui.find('**/avatar_c_A_top') topPanelOver = gui.find('**/avatar_c_A_top_over') middlePanel = gui.find('**/avatar_c_A_middle') middlePanelOver = gui.find('**/avatar_c_A_middle_over') bottomPanel = gui.find('**/avatar_c_A_bottom') bottomPanelOver = gui.find('**/avatar_c_A_bottom_over') for i, offer in zip(range(len(offers)), offers): if i == 0: image = ( topPanel, topPanel, topPanelOver, topPanel) textPos = (0, -0.02) z -= 0.19 else: image = ( middlePanel, middlePanel, middlePanelOver, middlePanel) textPos = (0, -0.015) if i == 1: z -= 0.11 else: z -= 0.105 questLadder = QuestLadderDB.getLadder(offer.questId) questLadderName = questLadder.getName() if questLadderName: questTitle = PLocalizer.QuestStrings.has_key(questLadderName) and 'title' in PLocalizer.QuestStrings[questLadderName].keys() and PLocalizer.QuestStrings[questLadderName]['title'] else: if PLocalizer.QuestStrings.has_key(offer.questId): questTitle = 'title' in PLocalizer.QuestStrings[offer.questId].keys() and PLocalizer.QuestStrings[offer.questId]['title'] else: questTitle = offer.getTitle() if isinstance(offer, QuestOffer.QuestTimerResetOffer) or isinstance(offer, QuestOffer.QuestBranchResetOffer): questTitle = 'Reset ' + questTitle questButton = DirectButton(parent=self, relief=None, pressEffect=0, text=questTitle, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, text_scale=PiratesGuiGlobals.TextScaleLarge, text_pos=textPos, textMayChange=0, image=image, image_scale=0.4, pos=(0, 0, z), command=self.seeQuestDetails, extraArgs=[offer]) self.questButtons.append(questButton) z -= 0.155 questButton = DirectButton(parent=self, relief=None, pressEffect=0, text=PLocalizer.lBack, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, text_scale=PiratesGuiGlobals.TextScaleLarge, text_pos=(0, 0.033), textMayChange=0, image=(bottomPanel, bottomPanel, bottomPanelOver, bottomPanel), image_scale=0.4, pos=(0, 0, z), command=self.callback, extraArgs=[QuestConstants.CANCEL_QUEST]) self.questButtons.append(questButton) gui.removeNode() return
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 setOffers(self, offers): z = 1.0 self.destroyQuestButtons() self.title = DirectLabel(parent = self, relief = None, text = PLocalizer.InteractQuest, text_align = TextNode.ACenter, text_scale = 0.070000000000000007, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 1, pos = (0, 0, z - 0.080000000000000002), text_font = PiratesGlobals.getPirateOutlineFont()) gui = loader.loadModel('models/gui/avatar_chooser_rope') topPanel = gui.find('**/avatar_c_A_top') topPanelOver = gui.find('**/avatar_c_A_top_over') middlePanel = gui.find('**/avatar_c_A_middle') middlePanelOver = gui.find('**/avatar_c_A_middle_over') bottomPanel = gui.find('**/avatar_c_A_bottom') bottomPanelOver = gui.find('**/avatar_c_A_bottom_over') for (i, offer) in zip(range(len(offers)), offers): if i == 0: image = (topPanel, topPanel, topPanelOver, topPanel) textPos = (0, -0.02) z -= 0.19 else: image = (middlePanel, middlePanel, middlePanelOver, middlePanel) textPos = (0, -0.014999999999999999) if i == 1: z -= 0.11 else: z -= 0.105 questLadder = QuestLadderDB.getLadder(offer.questId) questLadderName = questLadder.getName() if questLadderName and PLocalizer.QuestStrings.has_key(questLadderName) and 'title' in PLocalizer.QuestStrings[questLadderName].keys(): questTitle = PLocalizer.QuestStrings[questLadderName]['title'] elif PLocalizer.QuestStrings.has_key(offer.questId) and 'title' in PLocalizer.QuestStrings[offer.questId].keys(): questTitle = PLocalizer.QuestStrings[offer.questId]['title'] else: questTitle = offer.getTitle() if isinstance(offer, QuestOffer.QuestTimerResetOffer) or isinstance(offer, QuestOffer.QuestBranchResetOffer): questTitle = 'Reset ' + questTitle questButton = DirectButton(parent = self, relief = None, pressEffect = 0, text = questTitle, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = textPos, textMayChange = 0, image = image, image_scale = 0.40000000000000002, pos = (0, 0, z), command = self.seeQuestDetails, extraArgs = [ offer]) self.questButtons.append(questButton) z -= 0.155 questButton = DirectButton(parent = self, relief = None, pressEffect = 0, text = PLocalizer.lBack, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_pos = (0, 0.033000000000000002), textMayChange = 0, image = (bottomPanel, bottomPanel, bottomPanelOver, bottomPanel), image_scale = 0.40000000000000002, pos = (0, 0, z), command = self.callback, extraArgs = [ QuestConstants.CANCEL_QUEST]) self.questButtons.append(questButton) gui.removeNode()
def localTeleport(self, locationName=None): lastTgtFound = False if self.lastLocalTeleportLoc == None and locationName == None: lastTgtFound = True search = True while search: if locationName: search = False numNamedIsles = 0 for currIsle in base.cr.activeWorld.islands.values(): if len(currIsle.name) > 0: numNamedIsles += 1 if locationName or currIsle.name == locationName or lastTgtFound == True: currInteractive = base.cr.interactionMgr.getCurrentInteractive( ) if currInteractive: currInteractive.requestExit() questStateSpawnIdx = QuestLadderDB.getPreferredAreaSpawnNode( currIsle.getUniqueId(), localAvatar) teleportPos = base.cr.activeWorld.getPlayerSpawnPt( currIsle.getDoId(), index=questStateSpawnIdx) if teleportPos == None: teleportPos = (0, 0, 0, 0, 0, 0) self.localTeleportEffect(teleportPos, currIsle) self.lastLocalTeleportLoc = currIsle.getDoId() return None elif currIsle.getDoId( ) == self.lastLocalTeleportLoc and locationName == None: lastTgtFound = True continue locationName == None if numNamedIsles == 0: return None continue
def localTeleport(self, locationName = None): lastTgtFound = False if self.lastLocalTeleportLoc == None and locationName == None: lastTgtFound = True search = True while search: if locationName: search = False numNamedIsles = 0 for currIsle in base.cr.activeWorld.islands.values(): if len(currIsle.name) > 0: numNamedIsles += 1 if locationName or currIsle.name == locationName or lastTgtFound == True: currInteractive = base.cr.interactionMgr.getCurrentInteractive() if currInteractive: currInteractive.requestExit() questStateSpawnIdx = QuestLadderDB.getPreferredAreaSpawnNode(currIsle.getUniqueId(), localAvatar) teleportPos = base.cr.activeWorld.getPlayerSpawnPt(currIsle.getDoId(), index = questStateSpawnIdx) if teleportPos == None: teleportPos = (0, 0, 0, 0, 0, 0) self.localTeleportEffect(teleportPos, currIsle) self.lastLocalTeleportLoc = currIsle.getDoId() return None elif currIsle.getDoId() == self.lastLocalTeleportLoc and locationName == None: lastTgtFound = True continue locationName == None if numNamedIsles == 0: return None continue
def presentQuestOffer(self, offers, ladder = False): if self.questMenuGUI: DistributedQuestGiver.notify.warning('setQuestOffer: old questMenu GUI still around') self.cleanUpQuestMenu() self.cleanUpQuestDetails() def handleSelection(offer, self = self, offers = offers): self.cleanUpQuestMenu() if offer == QuestConstants.CANCEL_QUEST: index = QuestConstants.CANCEL_QUEST else: index = offers.index(offer) self.sendOfferResponse(index, ladder) def handleOption(option, offer): base.test = self self.ignore('lastSubtitlePage') self.adjustNPCCamera('back') if option == PLocalizer.Accept: handleSelection(offer) elif self.questMenuGUI: self.questMenuGUI.show() self.cleanUpQuestDetails(hide = True) def displayQuestDetails(offer): self.questDetailGUI = QuestDetailGUI(offer, None) self.questDetailGUI.showPanel() base.questdet = self.questDetailGUI def displayBranchDetails(offer): self.selectedOffer = offer self.cleanUpQuestDetails() self.questDetailGUI = QuestDetailGUI(offer, None) self.questDetailGUI.showPanel() base.questdet = self.questDetailGUI def displayBranchOptions(offer, callback, descCallback): self.branchMenuGUI = BranchMenuGUI.BranchMenuGUI(offer, callback, descCallback) def handleBranchOption(option): if option == PLocalizer.Accept: if self.selectedOffer: self.sendOfferResponse(0, ladder, self.selectedOffer) self.adjustNPCCamera('back') self.cleanUpQuestDetails(hide = True) self.cleanUpBranchMenu() if self.questMenuGUI: self.questMenuGUI.show() def describeQuest(offer): self.adjustNPCCamera('forward') questDNA = offer.getQuestDNA() if questDNA: if isinstance(offer, QuestOffer.QuestTimerResetOffer): self.requestQuestReset(offer.getQuestId()) return None elif isinstance(offer, QuestOffer.QuestBranchResetOffer): self.requestBranchReset(offer.getQuestId()) return None questStr = questDNA.getStringBefore() if questDNA.isBranch(): self.acceptOnce('lastSubtitlePage', displayBranchOptions, [ offer, None, displayBranchDetails]) localAvatar.guiMgr.subtitler.setPageChat(questStr, options = [ PLocalizer.Decline, PLocalizer.Accept], callback = handleBranchOption) else: self.acceptOnce('lastSubtitlePage', displayQuestDetails, [ offer]) localAvatar.guiMgr.subtitler.setPageChat(questStr, options = [ PLocalizer.Decline, PLocalizer.Accept], callback = handleOption, extraArgs = [ offer]) def questFull(arg): self.cleanUpQuestMenu() self.sendOfferResponse(QuestConstants.CANCEL_QUEST, ladder) inv = base.localAvatar.getInventory() numWorkQuests = 0 if inv: questList = inv.getQuestList() for questId in questList: if not QuestLadderDB.getFamePath(questId): numWorkQuests += 1 continue hasStoryQuest = False for offer in offers: if QuestLadderDB.getFamePath(offer.getQuestId()): hasStoryQuest = True continue if not hasStoryQuest and numWorkQuests > QuestConstants.MAXIMUM_MERC_WORK: self.questMenuGUI = PDialog.PDialog(text = PLocalizer.QuestFull, style = OTPDialog.Acknowledge, command = questFull) else: self.questMenuGUI = QuestMenuGUI.QuestMenuGUI(offers, handleSelection, describeQuest) localAvatar.currentStoryQuests = [] self.clearOffer()
def hasQuestOffersForLocalAvatar(self): av = localAvatar inventory = av.getInventory() selfId = self.getQuestGiverId() if inventory: numInProgress = 0 for quest in inventory.getQuestList(): questType = self.QuestIconDontCare if quest.tasks is None: self.notify.warning('quest %s: does not contain a dna; potential for crash.' % quest.getQuestId()) return False for (task, taskState) in zip(quest.tasks, quest.taskStates): if isinstance(task, QuestTaskDNA.VisitTaskDNA): if task.npcId == selfId: questStatus = self.QuestIconComplete return (questType, questStatus) task.npcId == selfId if quest.canBeReturnedTo(selfId): isComplete = False if quest.isComplete(): container = localAvatar.questStatus.getContainer(quest.getQuestId()) if container and container.parent and container.parent.isChoice(): isComplete = True for q in container.parent.getContainers(): if q.quest and not q.quest.isComplete(): isComplete = False continue else: isComplete = True if isComplete: questStatus = self.QuestIconComplete return (questType, questStatus) else: numInProgress += 1 else: self.notify.warning('avatar does not have inventory yet') return False offerDict = { } fromQuests = [] prereqExcludes = base.config.GetString('exclude-prereq-quests', '') for (questId, questDNA) in QuestDB.QuestDict.items(): if prereqExcludes and questId in prereqExcludes: continue passed = True for prereq in questDNA.prereqs: if not prereq.giverCanGive(selfId): passed = False break if not prereq.avIsReady(localAvatar): passed = False break if questDNA.minLevel > localAvatar.level: passed = False break if not base.cr.questDependency.checkDependency(questId, localAvatar.getQuestLadderHistory(), 1): passed = False break boolWeapLvlCheck = (questDNA.weapLvlType != None) & (questDNA.minWeapLevel > 0) if boolWeapLvlCheck & (questDNA.minWeapLevel > getLevelFromTotalReputation(questDNA.weapLvlType, inventory.getReputation(questDNA.weapLvlType))[0]): passed = False break if questDNA.getAcquireOnce(): history = localAvatar.getQuestLadderHistory() questLadderId = base.cr.questDynMap.findQuestLadderInt(questId) containsLadderId = history.count(questLadderId) if containsLadderId: passed = False break if questDNA.getHoliday() is not None: holidayId = questDNA.getHoliday() if base.cr.newsManager and not base.cr.newsManager.getHoliday(holidayId): passed = False break not base.cr.newsManager.getHoliday(holidayId) if questDNA.prereqs and passed: fromQuests.append(questDNA) continue if len(fromQuests): inventory = av.getInventory() if inventory: questsLeft = [] questList = inventory.getQuestList() for questDNA in fromQuests: questId = questDNA.questId if not av.questStatus.hasLadderQuestId(questId): continue if _[1] not in [ x.questId for x in questList ]: questsLeft.append(questDNA) continue [] fromQuests = questsLeft if fromQuests: questType = self.QuestIconWork for quest in fromQuests: if QuestLadderDB.getFamePath(quest.questId): questType = self.QuestIconStory break continue questStatus = self.QuestIconNew return (questType, questStatus) if numInProgress: questStatus = self.QuestIconProgress return (questType, questStatus) return False
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)
def getQuestDNA(self): return QuestLadderDB.getContainer(self.questId)
def _QuestTitleList__getText(self, indent, questId, isContainer = False): text = ' ' * (indent - 1) localizerText = None if not isContainer: localizerText = PLocalizer.QuestStrings.get(questId) if localizerText: text += localizerText.get('title', questId) else: text += questId elif indent == 0: format = 'questTitle2%s' else: format = '%s' localizerText = PLocalizer.QuestStrings.get(questId) if localizerText: text += format % localizerText.get('title', questId) else: text += format % questId localAvatar.questStatus.forceInit() container = localAvatar.questStatus.getContainer(questId) if not container: container = localAvatar.getQuestById(questId) if not container: return text if container.isComplete(showComplete = True): quest = localAvatar.getQuestById(container.getQuestId()) if quest and quest.getTasks() and not filter(lambda x: isinstance(quest.getTasks()[0], x), [ VisitTaskDNA, DeliverItemTaskDNA]): text += ' questComplete' + PLocalizer.QuestTitleComplete + '' elif not container.viewedInGUI: text += ' questNew' + PLocalizer.QuestTitleNew + '' elif not isContainer: progressList = container.getTaskProgress() for prog in progressList: progress = prog[0] goal = prog[1] if progress < goal: quest = localAvatar.getQuestById(container.getQuestId()) if goal > 1 and quest and quest.getTasks() and not isinstance(quest.getTasks()[0], DowsingRodTaskDNA): text += ' questPercent%d of %d' % (progress, goal) not isinstance(quest.getTasks()[0], DowsingRodTaskDNA) text += ' questComplete' + PLocalizer.QuestTitleComplete + '' elif container.isChoice(): (count, total, length) = container.getProgress(showComplete = True) if total == length: text += ' questPercent%d of %d' % (count, total) else: text += ' questPercent%d of %d (of %d)' % (count, total, length) format = ' questPercent%s' if localizerText: text += format % localizerText.get('items', 'Items') else: text += format % 'Items' else: for quest in localAvatar.getQuests(): if container.hasQuest(quest.getQuestId()): questId = quest.getQuestId() break (compCont, cont) = QuestLadderDB.getPercentComplete(container.getName(), questId) compNum = 0 if compCont > 0 and cont > 0: compNum = int((float(compCont) / float(cont)) * 100.0) text += ' questPercent%d%%' % compNum return text
def getQuestDNA(self): if QuestDB.QuestDict.has_key(self.questId): return QuestDB.QuestDict[self.questId] else: return QuestLadderDB.getContainer(self.questId)