@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 • 1.97 kB
Source Map (JSON)
{"version":3,"sources":["../../src/decorators/RoomDecorator.ts"],"names":["registeredRooms","saveRoom","room","c","getRoomById","id","e"],"mappings":"AAEO,IAAMA,CAAmD,CAAA,GAWzD,SAASC,EAASC,CAAuC,CAAA,CAC/D,GAAI,KAAA,CAAM,QAAQA,CAAI,CAAA,CAAG,CACxBA,CAAAA,CAAK,QAASC,CAAMF,EAAAA,CAAAA,CAASE,CAAC,CAAC,EAC/B,MACD,CACIH,CAAgBE,CAAAA,CAAAA,CAAK,EAAE,CAC1B,EAAA,OAAA,CAAQ,IAAK,CAAA,CAAA,eAAA,EAAkBA,EAAK,EAAE,CAAA,uCAAA,CAAyC,CAEhFF,CAAAA,CAAAA,CAAgBE,EAAK,EAAE,CAAA,CAAIA,EAC5B,CAOO,SAASE,CAAYC,CAAAA,CAAAA,CAAuC,CAClE,GAAI,CACH,IAAIH,CAAAA,CAAOF,CAAgBK,CAAAA,CAAE,EAC7B,GAAI,CAACH,CAAM,CAAA,CACV,QAAQ,KAAM,CAAA,CAAA,YAAA,EAAeG,CAAE,CAAA,UAAA,CAAY,EAC3C,MACD,CACA,OAAOH,CACR,OAASI,CAAG,CAAA,CACX,OAAQ,CAAA,KAAA,CAAM,mCAAmCD,CAAE,CAAA,CAAA,CAAIC,CAAC,CAAA,CACxD,MACD,CACD","file":"RoomDecorator.mjs","sourcesContent":["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"]}