@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 • 6.65 kB
Source Map (JSON)
{"version":3,"sources":["../../src/decorators/ActivityDecorator.ts","../../src/decorators/CommitmentDecorator.ts","../../src/decorators/QuestDecorator.ts","../../src/decorators/RoomDecorator.ts"],"names":["registeredActivities","saveActivity","activities","activity","getActivityById","id","e","registeredCommitments","saveCommitment","commitment","c","registeredQuests","saveQuest","quest","registeredRooms","saveRoom","room"],"mappings":"AAEO,IAAMA,CAAAA,CAA4D,EAElE,CAAA,SAASC,EAAaC,CAAqD,CAAA,CAC9E,GAAI,KAAM,CAAA,OAAA,CAAQA,CAAU,CAAG,CAAA,CAC3BA,EAAW,OAAQC,CAAAA,CAAAA,EAAY,CAC3BH,CAAqBG,CAAAA,CAAAA,CAAS,EAAE,CAAIA,CAAAA,EACxC,CAAC,CACD,CAAA,MACJ,CACAH,CAAqBE,CAAAA,CAAAA,CAAW,EAAE,CAAIA,CAAAA,EAC1C,CAOO,SAASE,CAAAA,CAAgBC,EAA2C,CACvE,GAAI,CACA,IAAIF,CAAAA,CAAWH,EAAqBK,CAAE,CAAA,CACtC,GAAI,CAACF,CAAAA,CAAU,CACX,OAAQ,CAAA,KAAA,CAAM,mBAAmBE,CAAE,CAAA,UAAA,CAAY,EAC/C,MACJ,CACA,OAAOF,CACX,CAAA,MACOG,EAAG,CACN,OAAA,CAAQ,MAAM,CAAuCD,oCAAAA,EAAAA,CAAE,GAAIC,CAAC,CAAA,CAC5D,MACJ,CACJ,CC9BO,IAAMC,CAA+D,CAAA,GAQrE,SAASC,CAAAA,CAAeC,EAAyD,CACvF,GAAI,MAAM,OAAQA,CAAAA,CAAU,EAAG,CAC9BA,CAAAA,CAAW,QAASC,CAAMF,EAAAA,CAAAA,CAAeE,CAAC,CAAC,CAAA,CAC3C,MACD,CACIH,CAAAA,CAAsBE,EAAW,EAAE,CAAA,EACtC,QAAQ,IAAK,CAAA,CAAA,qBAAA,EAAwBA,EAAW,EAAE,CAAA,uCAAA,CAAyC,EAE5FF,CAAsBE,CAAAA,CAAAA,CAAW,EAAE,CAAIA,CAAAA,EACxC,CCjBO,IAAME,CAAAA,CAAqD,EAS3D,CAAA,SAASC,EAAUC,CAA0C,CAAA,CACnE,GAAI,KAAM,CAAA,OAAA,CAAQA,CAAK,CAAG,CAAA,CACzBA,EAAM,OAASH,CAAAA,CAAAA,EAAME,EAAUF,CAAC,CAAC,EACjC,MACD,CACIC,EAAiBE,CAAM,CAAA,EAAE,GAC5B,OAAQ,CAAA,IAAA,CAAK,mBAAmBA,CAAM,CAAA,EAAE,yCAAyC,CAElFF,CAAAA,CAAAA,CAAiBE,EAAM,EAAE,CAAA,CAAIA,EAC9B,CClBO,IAAMC,EAAmD,EAAC,CAW1D,SAASC,CAASC,CAAAA,CAAAA,CAAuC,CAC/D,GAAI,KAAA,CAAM,QAAQA,CAAI,CAAA,CAAG,CACxBA,CAAK,CAAA,OAAA,CAASN,GAAMK,CAASL,CAAAA,CAAC,CAAC,CAC/B,CAAA,MACD,CACII,CAAgBE,CAAAA,CAAAA,CAAK,EAAE,CAC1B,EAAA,OAAA,CAAQ,KAAK,CAAkBA,eAAAA,EAAAA,CAAAA,CAAK,EAAE,CAAyC,uCAAA,CAAA,CAAA,CAEhFF,EAAgBE,CAAK,CAAA,EAAE,EAAIA,EAC5B","file":"index.mjs","sourcesContent":["import { ActivityInterface } from \"../interface\"\n\nexport const registeredActivities: { [id: string]: ActivityInterface } = {}\n\nexport function saveActivity(activities: ActivityInterface | ActivityInterface[]) {\n if (Array.isArray(activities)) {\n activities.forEach(activity => {\n registeredActivities[activity.id] = activity\n })\n return\n }\n registeredActivities[activities.id] = activities\n}\n\n/**\n * Get an activity by its id.\n * @param id The id of the activity.\n * @returns The activity or undefined if not found.\n */\nexport function getActivityById(id: string): ActivityInterface | undefined {\n try {\n let activity = registeredActivities[id]\n if (!activity) {\n console.error(`[NQTR] Activity ${id} not found`)\n return\n }\n return activity\n }\n catch (e) {\n console.error(`[NQTR] Error while getting Activity ${id}`, e)\n return\n }\n}\n","import { CommitmentInterface } from \"../interface\";\n\nexport const registeredCommitments: { [id: string]: CommitmentInterface } = {};\nexport const fixedCommitments: { [id: string]: CommitmentInterface } = {};\n\n/**\n * Save a commitment in the registered commitments. If the commitment already exists, it will be overwritten.\n * @param commitment The commitment or commitments to save.\n * @returns\n */\nexport function saveCommitment(commitment: CommitmentInterface | CommitmentInterface[]) {\n\tif (Array.isArray(commitment)) {\n\t\tcommitment.forEach((c) => saveCommitment(c));\n\t\treturn;\n\t}\n\tif (registeredCommitments[commitment.id]) {\n\t\tconsole.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`);\n\t}\n\tregisteredCommitments[commitment.id] = commitment;\n}\n\n/**\n * Get a commitment by its id.\n * @param id The id of the commitment.\n * @returns The commitment or undefined if not found.\n */\nexport function getCommitmentById(id: string): CommitmentInterface | undefined {\n\ttry {\n\t\tlet commitment = registeredCommitments[id];\n\t\tif (!commitment) {\n\t\t\tconsole.error(`[NQTR] Commitment ${id} not found`);\n\t\t\treturn;\n\t\t}\n\t\treturn commitment;\n\t} catch (e) {\n\t\tconsole.error(`[NQTR] Error while getting Commitment ${id}`, e);\n\t\treturn;\n\t}\n}\n","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","import { RoomInterface } from \"../interface\";\n\nexport const registeredRooms: { [id: string]: RoomInterface } = {};\n\n/**\n * Save a room in the registered rooms. If the room already exists, it will be overwritten.\n * @param room The room to save.\n * @returns\n * @example\n * ```ts\n * saveRoom([mcRoom, aliceRoom, annRoom, bathroom, lounge, terrace, gymRoom]);\n * ```\n */\nexport function saveRoom(room: RoomInterface | RoomInterface[]) {\n\tif (Array.isArray(room)) {\n\t\troom.forEach((c) => saveRoom(c));\n\t\treturn;\n\t}\n\tif (registeredRooms[room.id]) {\n\t\tconsole.warn(`[NQTR] Room id ${room.id} already exists, it will be overwritten`);\n\t}\n\tregisteredRooms[room.id] = room;\n}\n\n/**\n * Get a room by its id.\n * @param id The id of the room.\n * @returns The room or undefined if not found.\n */\nexport function getRoomById(id: string): RoomInterface | undefined {\n\ttry {\n\t\tlet room = registeredRooms[id];\n\t\tif (!room) {\n\t\t\tconsole.error(`[NQTR] Room ${id} not found`);\n\t\t\treturn;\n\t\t}\n\t\treturn room;\n\t} catch (e) {\n\t\tconsole.error(`[NQTR] Error while getting Room ${id}`, e);\n\t\treturn;\n\t}\n}\n"]}