@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
1 lines • 3.48 kB
Source Map (JSON)
{"version":3,"sources":["../../src/classes/DialogueBaseModel.ts"],"names":[],"mappings":";;;AA0BA,IAAqB,oBAArB,MAA2H;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvH,WAAY,CAAA,IAAA,EAA6B,SAAiC,EAAA,YAAA,GAAsD,EAAI,EAAA;AAsBpI;AAAA;AAAA;AAAA,IAAe,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA;AAQf;AAAA;AAAA;AAAA,IAAA,IAAA,CAAA,YAAA,GAAsD,EAAC,CAAA;AA7BnD,IAAI,IAAA,OAAO,SAAS,QAAU,EAAA;AAC1B,MAAA,IAAA,CAAK,IAAO,GAAA,IAAA,CAAA;AACZ,MAAI,IAAA,OAAO,cAAc,QAAU,EAAA;AAC/B,QAAA,IAAA,CAAK,SAAY,GAAA,SAAA,CAAA;AAAA,OAEhB,MAAA;AACD,QAAA,IAAA,CAAK,YAAY,SAAW,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,SAAA,CAAA,EAAA,CAAA;AAAA,OAChC;AACA,MAAA,IAAA,CAAK,YAAe,GAAA,YAAA,CAAA;AAAA,KAEnB,MAAA;AACD,MAAA,IAAA,CAAK,OAAO,IAAK,CAAA,IAAA,CAAA;AACjB,MAAA,IAAI,KAAK,SAAW,EAAA;AAChB,QAAA,IAAA,CAAK,YAAY,IAAK,CAAA,SAAA,CAAA;AAAA,OAC1B;AACA,MAAK,IAAA,CAAA,YAAA,GAAe,IAAK,CAAA,YAAA,IAAgB,EAAC,CAAA;AAAA,KAC9C;AAAA,GACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAuB,GAAA;AACnB,IAAO,OAAA;AAAA,MACH,MAAM,IAAK,CAAA,IAAA;AAAA,MACX,WAAW,IAAK,CAAA,SAAA;AAAA,MAChB,cAAc,IAAK,CAAA,YAAA;AAAA,KACvB,CAAA;AAAA,GACJ;AACJ","file":"DialogueBaseModel.js","sourcesContent":["import { StorageElementType } from \"../types\"\nimport CharacterBaseModel from \"./CharacterBaseModel\"\n\nexport type DialogueData = {\n /**\n * The text of the dialogue.\n */\n text: string\n /**\n * The id of the character that is speaking.\n */\n character?: string\n /**\n * Other parameters that can be stored in the dialogue.\n */\n oltherParams?: Record<string | number | symbol, StorageElementType>\n}\n\n/**\n * Base class for all dialogue models.\n * You can extend this class, but it is not reccomended. You can use the oltherParams property to store any other data you need.\n * @example\n * ```typescript\n * setDialogue(new DialogueBaseModel(\"Hello World\", character))\n * ```\n */\nexport default class DialogueBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel> implements DialogueData {\n /**\n * @param text The text of the dialogue.\n * @param character The id of the character that is speaking. \n * @param oltherParams Other parameters that can be stored in the dialogue.\n */\n constructor(text: string | DialogueData, character?: string | TCharacter, oltherParams: { [key: string]: StorageElementType } = {}) {\n if (typeof text === \"string\") {\n this.text = text\n if (typeof character === \"string\") {\n this.character = character\n }\n else {\n this.character = character?.id\n }\n this.oltherParams = oltherParams\n }\n else {\n this.text = text.text\n if (text.character) {\n this.character = text.character\n }\n this.oltherParams = text.oltherParams || {}\n }\n }\n /**\n * The text of the dialogue.\n */\n text: string = \"\"\n /**\n * The id of the character that is speaking.\n */\n character?: string\n /**\n * Other parameters that can be stored in the dialogue.\n */\n oltherParams: { [key: string]: StorageElementType } = {}\n /**\n * Export the dialogue to a DialogueBaseData object.\n * \n * @returns The data of the dialogue.\n */\n export(): DialogueData {\n return {\n text: this.text,\n character: this.character,\n oltherParams: this.oltherParams\n }\n }\n}\n"]}