def getQuestFromName(questName, session=None): if not __isInitialized: init() try: return __questsByName[questName].copy() except KeyError: cxt = {} FilterManager.executeFiltersForEvent("couldNotFindQuest", cxt, session=session, questName=questName) if "quest" in cxt: quest = cxt["quest"] addQuest(quest) return quest.copy() raise Error.Error("The quest '%s' is unknown." % questName, Error.QUEST_NOT_FOUND)
def getSkillFromName(skillName, session=None): "Returns information about a skill given its name." if not __isInitialized: init() try: return __skillsByName[skillName].copy() except KeyError: cxt = {} FilterManager.executeFiltersForEvent("couldNotFindSkill", cxt, session=session, skillName=skillName) if "skill" in cxt: skill = cxt["skill"] addSkill(skill) return skill.copy() raise Error.Error("The skill '%s' is unknown." % skillName, Error.SKILL_NOT_FOUND)
def getSkillFromId(skillId, session=None): "Returns information about a skill given its ID." if not __isInitialized: init() try: return __skillsById[skillId].copy() except KeyError: cxt = {} FilterManager.executeFiltersForEvent("couldNotFindSkill", cxt, session=session, skillId=skillId) if "skill" in cxt: skill = cxt["skill"] addSkill(skill) return skill.copy() raise Error.Error("Skill ID %s is unknown." % skillId, Error.SKILL_NOT_FOUND)
def getCouncilQuestFromLevel(questLevel, session=None): "Returns information about a quest given its name." if not __isInitialized: init() #print "quest map: " + str(__councilQuestsByLevel) try: return __councilQuestsByLevel[questLevel].copy() except KeyError: cxt = {} FilterManager.executeFiltersForEvent("couldNotFindQuest", cxt, session=session, questLevel=questLevel) if "quest" in cxt: quest = cxt["quest"] addQuest(quest) return quest.copy() raise Error.Error( "The guild quest for level '%s' is unknown." % questLevel, Error.QUEST_NOT_FOUND)
def discoverMissingItems(session): from pykollib.request.InventoryRequest import InventoryRequest from pykollib.request.ItemInformationRequest import ItemInformationRequest invRequest = InventoryRequest(session) invRequest.ignoreItemDatabase = True invData = invRequest.doRequest() for item in invData["items"]: if item["id"] not in __itemsById: try: itemRequest = ItemInformationRequest(session, item["id"]) itemData = itemRequest.doRequest() item = itemData["item"] addItem(item) Report.trace("itemdatabase", "Discovered new item: %s" % item["name"]) context = {"item": item} FilterManager.executeFiltersForEvent("discoveredNewItem", context, session=session, item=item) except: pass
def init(): """ Initializes the QkillDatabase. This method should be called before the database is ever accessed as it ensures that the database is populated with all of the data it needs. """ global __isInitialized if __isInitialized == True: return Report.trace("questdatabase", "Initializing the quest database.") returnCode = FilterManager.executeFiltersForEvent( "preInitializeQuestDatabase") if returnCode == FilterManager.FINISHED: Report.trace("questdatabase", "Quest database initialized.") __isInitialized = True return for quest in Quests.quests: addQuest(quest) FilterManager.executeFiltersForEvent("postInitializeQuestDatabase") __isInitialized = True Report.trace("questdatabase", "Quest database initialized.")
def init(): """ Initializes the SkillDatabase. This method should be called before the database is ever accessed as it ensures that the database is populated with all of the data it needs. """ global __isInitialized if __isInitialized == True: return Report.trace("skilldatabase", "Initializing the skill database.") returnCode = FilterManager.executeFiltersForEvent( "preInitializeSkillDatabase") if returnCode == FilterManager.FINISHED: Report.trace("skilldatabase", "Skill database initialized.") __isInitialized = True return for skill in Skills.skills: addSkill(skill) FilterManager.executeFiltersForEvent("postInitializeSkillDatabase") __isInitialized = True Report.trace("skilldatabase", "Skill database initialized.")
def init(): """ Initializes the ItemDatabase. This method should be called before the database is ever accessed as it ensures that the database is populated with all of the data it needs. """ global __isInitialized if __isInitialized == True: return Report.trace("itemdatabase", "Initializing the item database.") returnCode = FilterManager.executeFiltersForEvent( "preInitializeItemDatabase") if returnCode == FilterManager.FINISHED: Report.trace("itemdatabase", "Item database initialized.") __isInitialized = True return for item in Items.items: addItem(item) FilterManager.executeFiltersForEvent("postInitializeItemDatabase") __isInitialized = True Report.trace("itemdatabase", "Item database initialized.")