@drincs/nqtr
Version:
A complete system introducing the concepts of location, time and event, producing the framework of a not-quite-point-and-click adventure game.
1 lines • 2.02 kB
Source Map (JSON)
{"version":3,"sources":["../../src/decorators/QuestDecorator.ts"],"names":["registeredQuests","saveQuest","quest","c","getQuestById","id","e"],"mappings":"AAEO,IAAMA,CAAqD,CAAA,GAS3D,SAASC,EAAUC,CAA0C,CAAA,CACnE,GAAI,KAAA,CAAM,QAAQA,CAAK,CAAA,CAAG,CACzBA,CAAAA,CAAM,QAASC,CAAMF,EAAAA,CAAAA,CAAUE,CAAC,CAAC,EACjC,MACD,CACIH,CAAiBE,CAAAA,CAAAA,CAAM,EAAE,CAC5B,EAAA,OAAA,CAAQ,IAAK,CAAA,CAAA,gBAAA,EAAmBA,EAAM,EAAE,CAAA,uCAAA,CAAyC,CAElFF,CAAAA,CAAAA,CAAiBE,EAAM,EAAE,CAAA,CAAIA,EAC9B,CAOO,SAASE,CAAaC,CAAAA,CAAAA,CAAwC,CACpE,GAAI,CACH,IAAIH,CAAAA,CAAQF,CAAiBK,CAAAA,CAAE,EAC/B,GAAI,CAACH,CAAO,CAAA,CACX,QAAQ,KAAM,CAAA,CAAA,aAAA,EAAgBG,CAAE,CAAA,UAAA,CAAY,EAC5C,MACD,CACA,OAAOH,CACR,OAASI,CAAG,CAAA,CACX,OAAQ,CAAA,KAAA,CAAM,oCAAoCD,CAAE,CAAA,CAAA,CAAIC,CAAC,CAAA,CACzD,MACD,CACD","file":"QuestDecorator.mjs","sourcesContent":["import { QuestInterface } from \"../interface\";\n\nexport const registeredQuests: { [id: string]: QuestInterface } = {};\n\n/**\n * Save a quest in the registered quests. If the quest already exists, it will be overwritten.\n * @param id The id of the quest, it must be unique\n * @param stages The stages of the quest\n * @param props The quest properties\n * @returns The created quest\n */\nexport function saveQuest(quest: QuestInterface | QuestInterface[]) {\n\tif (Array.isArray(quest)) {\n\t\tquest.forEach((c) => saveQuest(c));\n\t\treturn;\n\t}\n\tif (registeredQuests[quest.id]) {\n\t\tconsole.warn(`[NQTR] Quest id ${quest.id} already exists, it will be overwritten`);\n\t}\n\tregisteredQuests[quest.id] = quest;\n}\n\n/**\n * Get a quest by its id.\n * @param id The id of the quest.\n * @returns The quest or undefined if not found.\n */\nexport function getQuestById(id: string): QuestInterface | undefined {\n\ttry {\n\t\tlet quest = registeredQuests[id];\n\t\tif (!quest) {\n\t\t\tconsole.error(`[NQTR] Quest ${id} not found`);\n\t\t\treturn;\n\t\t}\n\t\treturn quest;\n\t} catch (e) {\n\t\tconsole.error(`[NQTR] Error while getting Quest ${id}`, e);\n\t\treturn;\n\t}\n}\n"]}