UNPKG

@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.25 kB
{"version":3,"sources":["../../src/decorators/CommitmentDecorator.ts"],"names":["registeredCommitments","fixedCommitments","saveCommitment","commitment","c","getCommitmentById","id"],"mappings":"AAEO,IAAMA,EAA+D,EAAC,CAChEC,CAA0D,CAAA,GAOhE,SAASC,CAAAA,CAAeC,CAAyD,CAAA,CACvF,GAAI,KAAM,CAAA,OAAA,CAAQA,CAAU,CAAA,CAAG,CAC9BA,CAAW,CAAA,OAAA,CAASC,CAAMF,EAAAA,CAAAA,CAAeE,CAAC,CAAC,CAAA,CAC3C,MACD,CACIJ,EAAsBG,CAAW,CAAA,EAAE,CACtC,EAAA,OAAA,CAAQ,KAAK,CAAwBA,qBAAAA,EAAAA,CAAAA,CAAW,EAAE,CAAyC,uCAAA,CAAA,CAAA,CAE5FH,EAAsBG,CAAW,CAAA,EAAE,CAAIA,CAAAA,EACxC,CAOO,SAASE,CAAAA,CAAkBC,CAA6C,CAAA,CAC9E,GAAI,CACH,IAAIH,CAAaH,CAAAA,CAAAA,CAAsBM,CAAE,CACzC,CAAA,GAAI,CAACH,CAAAA,CAAY,CAChB,OAAQ,CAAA,KAAA,CAAM,CAAqBG,kBAAAA,EAAAA,CAAE,YAAY,CACjD,CAAA,MACD,CACA,OAAOH,CACR,CAAS,MAAA,CAAA,CAAG,CACX,OAAA,CAAQ,MAAM,CAAyCG,sCAAAA,EAAAA,CAAE,GAAI,CAAC,CAAA,CAC9D,MACD,CACD","file":"CommitmentDecorator.mjs","sourcesContent":["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"]}