@drincs/nqtr 0.2.14 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/{RoomInterface-BOE1uacE.d.mts → RoomInterface-C7Sg80EF.d.mts} +7 -6
  2. package/dist/{RoomInterface-BswqipsF.d.ts → RoomInterface-D7qXKwBI.d.ts} +7 -6
  3. package/dist/{StageInterface-DgeEtkqv.d.mts → StageInterface-DmLgfrk4.d.mts} +3 -3
  4. package/dist/{StageInterface-DgeEtkqv.d.ts → StageInterface-DmLgfrk4.d.ts} +3 -3
  5. package/dist/classes/CommitmentBaseModel.d.mts +1 -1
  6. package/dist/classes/CommitmentBaseModel.d.ts +1 -1
  7. package/dist/classes/CommitmentStoredClass.d.mts +2 -2
  8. package/dist/classes/CommitmentStoredClass.d.ts +2 -2
  9. package/dist/classes/index.d.mts +2 -2
  10. package/dist/classes/index.d.ts +2 -2
  11. package/dist/classes/index.js +1 -1
  12. package/dist/classes/index.js.map +1 -1
  13. package/dist/classes/index.mjs +1 -1
  14. package/dist/classes/index.mjs.map +1 -1
  15. package/dist/classes/navigation/LocationBaseModel.d.mts +2 -2
  16. package/dist/classes/navigation/LocationBaseModel.d.ts +2 -2
  17. package/dist/classes/navigation/LocationBaseModel.js +1 -1
  18. package/dist/classes/navigation/LocationBaseModel.js.map +1 -1
  19. package/dist/classes/navigation/LocationBaseModel.mjs +1 -1
  20. package/dist/classes/navigation/LocationBaseModel.mjs.map +1 -1
  21. package/dist/classes/navigation/LocationStoredClass.d.mts +2 -2
  22. package/dist/classes/navigation/LocationStoredClass.d.ts +2 -2
  23. package/dist/classes/navigation/LocationStoredClass.js +1 -1
  24. package/dist/classes/navigation/LocationStoredClass.js.map +1 -1
  25. package/dist/classes/navigation/LocationStoredClass.mjs +1 -1
  26. package/dist/classes/navigation/LocationStoredClass.mjs.map +1 -1
  27. package/dist/classes/navigation/MapBaseModel.d.mts +1 -1
  28. package/dist/classes/navigation/MapBaseModel.d.ts +1 -1
  29. package/dist/classes/navigation/MapStoredClass.d.mts +1 -1
  30. package/dist/classes/navigation/MapStoredClass.d.ts +1 -1
  31. package/dist/classes/navigation/RoomBaseModel.d.mts +2 -2
  32. package/dist/classes/navigation/RoomBaseModel.d.ts +2 -2
  33. package/dist/classes/navigation/RoomBaseModel.js.map +1 -1
  34. package/dist/classes/navigation/RoomBaseModel.mjs.map +1 -1
  35. package/dist/classes/navigation/RoomStoredClass.d.mts +2 -2
  36. package/dist/classes/navigation/RoomStoredClass.d.ts +2 -2
  37. package/dist/classes/navigation/RoomStoredClass.js.map +1 -1
  38. package/dist/classes/navigation/RoomStoredClass.mjs.map +1 -1
  39. package/dist/classes/quest/QuestBaseModel.d.mts +1 -1
  40. package/dist/classes/quest/QuestBaseModel.d.ts +1 -1
  41. package/dist/classes/quest/QuestBaseModel.js.map +1 -1
  42. package/dist/classes/quest/QuestBaseModel.mjs.map +1 -1
  43. package/dist/classes/quest/QuestStoredClass.d.mts +1 -1
  44. package/dist/classes/quest/QuestStoredClass.d.ts +1 -1
  45. package/dist/classes/quest/QuestStoredClass.js.map +1 -1
  46. package/dist/classes/quest/QuestStoredClass.mjs.map +1 -1
  47. package/dist/classes/quest/StageBaseModel.d.mts +1 -1
  48. package/dist/classes/quest/StageBaseModel.d.ts +1 -1
  49. package/dist/classes/quest/StageBaseModel.js +1 -1
  50. package/dist/classes/quest/StageBaseModel.js.map +1 -1
  51. package/dist/classes/quest/StageBaseModel.mjs +1 -1
  52. package/dist/classes/quest/StageBaseModel.mjs.map +1 -1
  53. package/dist/classes/quest/StageStoredClass.d.mts +1 -1
  54. package/dist/classes/quest/StageStoredClass.d.ts +1 -1
  55. package/dist/classes/quest/StageStoredClass.js.map +1 -1
  56. package/dist/classes/quest/StageStoredClass.mjs.map +1 -1
  57. package/dist/decorators/CommitmentDecorator.d.mts +2 -2
  58. package/dist/decorators/CommitmentDecorator.d.ts +2 -2
  59. package/dist/decorators/QuestDecorator.d.mts +1 -1
  60. package/dist/decorators/QuestDecorator.d.ts +1 -1
  61. package/dist/decorators/RoomDecorator.d.mts +2 -2
  62. package/dist/decorators/RoomDecorator.d.ts +2 -2
  63. package/dist/decorators/index.d.mts +2 -2
  64. package/dist/decorators/index.d.ts +2 -2
  65. package/dist/index.d.mts +2 -2
  66. package/dist/index.d.ts +2 -2
  67. package/dist/index.js.map +1 -1
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/interface/ActivityInterface.d.mts +2 -2
  70. package/dist/interface/ActivityInterface.d.ts +2 -2
  71. package/dist/interface/CommitmentInterface.d.mts +2 -2
  72. package/dist/interface/CommitmentInterface.d.ts +2 -2
  73. package/dist/interface/CommitmentProps.d.mts +2 -2
  74. package/dist/interface/CommitmentProps.d.ts +2 -2
  75. package/dist/interface/index.d.mts +2 -2
  76. package/dist/interface/index.d.ts +2 -2
  77. package/dist/interface/navigation/LocationInterface.d.mts +2 -2
  78. package/dist/interface/navigation/LocationInterface.d.ts +2 -2
  79. package/dist/interface/navigation/MapInterface.d.mts +2 -2
  80. package/dist/interface/navigation/MapInterface.d.ts +2 -2
  81. package/dist/interface/navigation/RoomInterface.d.mts +2 -2
  82. package/dist/interface/navigation/RoomInterface.d.ts +2 -2
  83. package/dist/interface/quest/QuestInterface.d.mts +1 -1
  84. package/dist/interface/quest/QuestInterface.d.ts +1 -1
  85. package/dist/interface/quest/QuestProps.d.mts +1 -1
  86. package/dist/interface/quest/QuestProps.d.ts +1 -1
  87. package/dist/interface/quest/StageInterface.d.mts +1 -1
  88. package/dist/interface/quest/StageInterface.d.ts +1 -1
  89. package/dist/interface/quest/StageProps.d.mts +1 -1
  90. package/dist/interface/quest/StageProps.d.ts +1 -1
  91. package/dist/managers/NavigatorManager.d.mts +2 -2
  92. package/dist/managers/NavigatorManager.d.ts +2 -2
  93. package/dist/managers/QuestManager.d.mts +1 -1
  94. package/dist/managers/QuestManager.d.ts +1 -1
  95. package/dist/managers/RoutineManager.d.mts +2 -2
  96. package/dist/managers/RoutineManager.d.ts +2 -2
  97. package/dist/managers/index.d.mts +3 -3
  98. package/dist/managers/index.d.ts +3 -3
  99. package/dist/types/QuestsRequired.d.mts +1 -1
  100. package/dist/types/QuestsRequired.d.ts +1 -1
  101. package/dist/types/index.d.mts +1 -1
  102. package/dist/types/index.d.ts +1 -1
  103. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts","../../../src/classes/quest/QuestBaseModel.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage","QuestBaseModel","stages"],"mappings":"+CAMA,IAAMA,CAAAA,CAAiB,iBACFC,CAArB,CAAA,cAA8CC,gBAAuD,CACpG,WACCC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,EACH,CAAA,CACD,KAAML,CAAAA,CAAAA,CAAgBG,CAAE,CAAA,CAZP,IAAAC,CAAAA,OAAAA,CAAAA,CAAAA,CAajB,IAAK,CAAA,QAAA,CAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC3B,CAEA,IAAI,MAAA,EAA2B,CAC9B,OAAO,IAAA,CAAK,OACb,CAEA,IAAI,iBAAA,EAAwC,CAC3C,OAAO,IAAA,CAAK,kBAA2B,CAAA,mBAAmB,CAC3D,CACA,IAAY,iBAAA,CAAkBC,CAA2B,CAAA,CACxD,IAAK,CAAA,kBAAA,CAAmB,mBAAqBA,CAAAA,CAAK,EACnD,CAEA,IAAI,YAA2C,EAAA,CAC9C,IAAIC,CAAAA,CAAQ,KAAK,iBACjB,CAAA,GAAI,EAAAA,CAAAA,GAAU,SAAaA,EAAAA,CAAAA,EAAS,KAAK,MAAO,CAAA,MAAA,CAAA,CAGhD,OAAO,IAAA,CAAK,MAAOA,CAAAA,CAAK,CACzB,CAEA,IAAI,OAAA,EAAmB,CACtB,OAAO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ASA,CAAM,CAAA,KAAA,CACpB,IAAK,CAAA,cAAA,CAAiBA,EAAM,aAAiB,EAAA,MAC9C,CAEQ,KAAA,CAIR,IAAI,IAAA,EAAe,CAClB,OAAO,IAAK,CAAA,KACb,CAEQ,YAAA,CAIR,IAAI,WAAA,EAAsB,CACzB,OAAO,IAAA,CAAK,YACb,CAEQ,KAIR,CAAA,IAAI,IAA2B,EAAA,CAC9B,OAAO,IAAA,CAAK,KACb,CAEQ,MAIR,CAAA,IAAI,OAA4B,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,cAAA,CAIR,IAAI,aAAA,EAAyB,CAC5B,OAAO,IAAK,CAAA,cACb,CACD","file":"QuestBaseModel.mjs","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n","import { QuestProps, StageInterface } from \"../../interface\";\r\nimport QuestStoredClass from \"./QuestStoredClass\";\r\n\r\nexport default class QuestBaseModel extends QuestStoredClass {\r\n\tconstructor(id: string, stages: StageInterface[], props: QuestProps) {\r\n\t\tsuper(id, stages, { onStart: props.onStart, onNextStage: props.onNextStage });\r\n\t\tthis._name = props.name || \"\";\r\n\t\tthis._description = props.description || \"\";\r\n\t\tthis._icon = props.icon;\r\n\t\tthis._image = props.image;\r\n\t\tthis._inDevelopment = props.inDevelopment || false;\r\n\t}\r\n\r\n\tprivate _name: string;\r\n\t/**\r\n\t * The name of the quest.\r\n\t */\r\n\tget name(): string {\r\n\t\treturn this._name;\r\n\t}\r\n\r\n\tprivate _description: string;\r\n\t/**\r\n\t * The description of the quest.\r\n\t */\r\n\tget description(): string {\r\n\t\treturn this._description;\r\n\t}\r\n\r\n\tprivate _icon?: string;\r\n\t/**\r\n\t * Icon of the quest.\r\n\t */\r\n\tget icon(): string | undefined {\r\n\t\treturn this._icon;\r\n\t}\r\n\r\n\tprivate _image?: string;\r\n\t/**\r\n\t * Image of the quest.\r\n\t */\r\n\tget image(): string | undefined {\r\n\t\treturn this._image;\r\n\t}\r\n\r\n\tprivate _inDevelopment: boolean;\r\n\t/**\r\n\t * If the quest is in development.\r\n\t */\r\n\tget inDevelopment(): boolean {\r\n\t\treturn this._inDevelopment;\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts","../../../src/classes/quest/QuestBaseModel.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage","QuestBaseModel","stages"],"mappings":"+CAMA,I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Content":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this as any as QuestInterface, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as any as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n","import { QuestProps, StageInterface } from \"../../interface\";\r\nimport QuestStoredClass from \"./QuestStoredClass\";\r\n\r\nexport default class QuestBaseModel extends QuestStoredClass {\r\n\tconstructor(id: string, stages: StageInterface[], props: QuestProps) {\r\n\t\tsuper(id, stages, { onStart: props.onStart, onNextStage: props.onNextStage });\r\n\t\tthis._name = props.name || \"\";\r\n\t\tthis._description = props.description || \"\";\r\n\t\tthis._icon = props.icon;\r\n\t\tthis._image = props.image;\r\n\t\tthis._inDevelopment = props.inDevelopment || false;\r\n\t}\r\n\r\n\tprivate _name: string;\r\n\t/**\r\n\t * The name of the quest.\r\n\t */\r\n\tget name(): string {\r\n\t\treturn this._name;\r\n\t}\r\n\r\n\tprivate _description: string;\r\n\t/**\r\n\t * The description of the quest.\r\n\t */\r\n\tget description(): string {\r\n\t\treturn this._description;\r\n\t}\r\n\r\n\tprivate _icon?: string;\r\n\t/**\r\n\t * Icon of the quest.\r\n\t */\r\n\tget icon(): string | undefined {\r\n\t\treturn this._icon;\r\n\t}\r\n\r\n\tprivate _image?: string;\r\n\t/**\r\n\t * Image of the quest.\r\n\t */\r\n\tget image(): string | undefined {\r\n\t\treturn this._image;\r\n\t}\r\n\r\n\tprivate _inDevelopment: boolean;\r\n\t/**\r\n\t * If the quest is in development.\r\n\t */\r\n\tget inDevelopment(): boolean {\r\n\t\treturn this._inDevelopment;\r\n\t}\r\n}\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import { OnStartEndStageQuest } from '@drincs/nqtr/dist/override';
2
2
  import { StoredClassModel } from '@drincs/pixi-vn';
3
- import { b as QuestBaseInternalInterface, S as StageBaseInterface, Q as QuestBaseInterface } from '../../StageInterface-DgeEtkqv.mjs';
3
+ import { b as QuestBaseInternalInterface, S as StageBaseInterface, Q as QuestBaseInterface } from '../../StageInterface-DmLgfrk4.mjs';
4
4
 
5
5
  declare class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {
6
6
  private readonly _stages;
@@ -1,6 +1,6 @@
1
1
  import { OnStartEndStageQuest } from '@drincs/nqtr/dist/override';
2
2
  import { StoredClassModel } from '@drincs/pixi-vn';
3
- import { b as QuestBaseInternalInterface, S as StageBaseInterface, Q as QuestBaseInterface } from '../../StageInterface-DgeEtkqv.js';
3
+ import { b as QuestBaseInternalInterface, S as StageBaseInterface, Q as QuestBaseInterface } from '../../StageInterface-DmLgfrk4.js';
4
4
 
5
5
  declare class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {
6
6
  private readonly _stages;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage"],"mappings":"uDAMMA,CAAiB,CAAA,gBAAA,CACFC,EAArB,cAA8CC,uBAAuD,CACpG,WACCC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,GACH,CACD,KAAA,CAAML,EAAgBG,CAAE,CAAA,CAZP,aAAAC,CAajB,CAAA,IAAA,CAAK,SAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC3B,CAEA,IAAI,QAA2B,CAC9B,OAAO,KAAK,OACb,CAEA,IAAI,iBAAwC,EAAA,CAC3C,OAAO,IAAK,CAAA,kBAAA,CAA2B,mBAAmB,CAC3D,CACA,IAAY,iBAAkBC,CAAAA,CAAAA,CAA2B,CACxD,IAAK,CAAA,kBAAA,CAAmB,oBAAqBA,CAAK,EACnD,CAEA,IAAI,YAAA,EAA2C,CAC9C,IAAIC,CAAAA,CAAQ,KAAK,iBACjB,CAAA,GAAI,EAAAA,CAAU,GAAA,SAAA,EAAaA,GAAS,IAAK,CAAA,MAAA,CAAO,QAGhD,OAAO,IAAA,CAAK,OAAOA,CAAK,CACzB,CAEA,IAAI,OAAA,EAAmB,CACtB,OAAO,IAAA,CAAK,oBAAsB,SACnC,CAEA,IAAI,SAAqB,EAAA,CACxB,OAAI,IAAK,CAAA,iBAAA,GAAsB,UACvB,KAED,CAAA,IAAA,CAAK,kBAAoB,IAAK,CAAA,MAAA,CAAO,OAAS,CACtD,CAEA,IAAI,MAAkB,EAAA,CACrB,OAAO,IAAK,CAAA,kBAAA,CAA4B,QAAQ,CAAK,EAAA,KACtD,CACA,IAAI,MAAA,CAAOD,EAAgB,CAC1B,IAAA,CAAK,mBAAmB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MAAMP,CAAK,CAAA,CAE3B,QAAQ,IAAK,CAAA,CAAA,aAAA,EAAgB,KAAK,EAAE,CAAA,8BAAA,CAAgC,EAEtE,CACD","file":"QuestStoredClass.js","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage"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AAA,eAAA,CAAiB,EAC9C,KAER,CAAA,GAAI,KAAK,SACR,CAAA,OAAA,OAAA,CAAQ,KAAK,CAAgB,aAAA,EAAA,IAAA,CAAK,EAAE,CAAuB,qBAAA,CAAA,CAAA,CACpD,MAER,IAAII,CAAAA,CAAY,KAAK,YACjBC,CAAAA,CAAAA,CAAoB,KAAK,iBAC7B,CAAA,GAAI,CAACD,CAAaC,EAAAA,CAAAA,GAAsB,UACvC,OAAQ,OAAA,CAAA,KAAA,CAAM,gBAAgB,IAAK,CAAA,EAAE,uBAAuB,CACrD,CAAA,KAAA,CAER,KAAK,iBAAoBA,CAAAA,CAAAA,CAAoB,EAC7C,IAAK,CAAA,WAAA,EAAe,KAAK,WAAY,CAAA,IAAA,CAA+BL,CAAK,CACrEI,CAAAA,CAAAA,EAAaA,EAAU,KAC1BA,EAAAA,CAAAA,CAAU,MAAMA,CAAWJ,CAAAA,CAAK,EAEjC,IAAIM,CAAAA,CAAmB,KAAK,YAC5B,CAAA,OAAIA,IACFA,CAA6C,CAAA,UAAA,GAC1C,IAAK,CAAA,qBAAA,EACR,KAAK,iBAAkBN,CAAAA,CAAK,GAIvB,IACR,CAEA,IAAI,qBAAiC,EAAA,CACpC,IAAIG,CAAe,CAAA,IAAA,CAAK,aACxB,OAAKA,CAAAA,CAGE,CAACA,CAAa,CAAA,OAAA,EAAWA,EAAa,QAAY,EAAA,CAACA,EAAa,SAF/D,CAAA,KAGT,CAEA,iBAAkBH,CAAAA,CAAAA,CAAmC,CACpD,IAAIO,CAAAA,CAAkB,KAAK,YACvBA,CAAAA,CAAAA,EAAmB,KAAK,qBAC3BA,CAAAA,CAAAA,CAAgB,MAAMP,CAAK,CAAA,CAE3B,QAAQ,IAAK,CAAA,CAAA,aAAA,EAAgB,KAAK,EAAE,CAAA,8BAAA,CAAgC,EAEtE,CACD","file":"QuestStoredClass.js","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this as any as QuestInterface, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as any as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage"],"mappings":"mDAMMA,CAAiB,CAAA,gBAAA,CACFC,EAArB,cAA8CC,gBAAuD,CACpG,WACCC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,GACH,CACD,KAAA,CAAML,EAAgBG,CAAE,CAAA,CAZP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AAA,CAAY,KAAK,YACjBC,CAAAA,CAAAA,CAAoB,KAAK,iBAC7B,CAAA,GAAI,CAACD,CAAaC,EAAAA,CAAAA,GAAsB,UACvC,OAAQ,OAAA,CAAA,KAAA,CAAM,gBAAgB,IAAK,CAAA,EAAE,uBAAuB,CACrD,CAAA,KAAA,CAER,KAAK,iBAAoBA,CAAAA,CAAAA,CAAoB,EAC7C,IAAK,CAAA,WAAA,EAAe,KAAK,WAAY,CAAA,IAAA,CAAML,CAAK,CAC5CI,CAAAA,CAAAA,EAAaA,EAAU,KAC1BA,EAAAA,CAAAA,CAAU,MAAMA,CAAWJ,CAAAA,CAAK,EAEjC,IAAIM,CAAAA,CAAmB,KAAK,YAC5B,CAAA,OAAIA,IACFA,CAAsC,CAAA,UAAA,GACnC,IAAK,CAAA,qBAAA,EACR,KAAK,iBAAkBN,CAAAA,CAAK,GAIvB,IACR,CAEA,IAAI,qBAAiC,EAAA,CACpC,IAAIG,CAAe,CAAA,IAAA,CAAK,aACxB,OAAKA,CAAAA,CAGE,CAACA,CAAa,CAAA,OAAA,EAAWA,EAAa,QAAY,EAAA,CAACA,EAAa,SAF/D,CAAA,KAGT,CAEA,iBAAkBH,CAAAA,CAAAA,CAAmC,CACpD,IAAIO,CAAAA,CAAkB,KAAK,YACvBA,CAAAA,CAAAA,EAAmB,KAAK,qBAC3BA,CAAAA,CAAAA,CAAgB,MAAMP,CAAK,CAAA,CAE3B,QAAQ,IAAK,CAAA,CAAA,aAAA,EAAgB,KAAK,EAAE,CAAA,8BAAA,CAAgC,EAEtE,CACD","file":"QuestStoredClass.mjs","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage"],"mappings":"mDAMMA,CAAiB,CAAA,gBAAA,CACFC,EAArB,cAA8CC,gBAAuD,CACpG,WACCC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,GACH,CACD,KAAA,CAAML,EAAgBG,CAAE,CAAA,CAZP,aAAAC,CAajB,CAAA,IAAA,CAAK,SAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC3B,CAEA,IAAI,QAA2B,CAC9B,OAAO,KAAK,OACb,CAEA,IAAI,iBAAwC,EAAA,CAC3C,OAAO,IAAK,CAAA,kBAA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KAAK,iBAAoBA,CAAAA,CAAAA,CAAoB,EAC7C,IAAK,CAAA,WAAA,EAAe,KAAK,WAAY,CAAA,IAAA,CAA+BL,CAAK,CACrEI,CAAAA,CAAAA,EAAaA,EAAU,KAC1BA,EAAAA,CAAAA,CAAU,MAAMA,CAAWJ,CAAAA,CAAK,EAEjC,IAAIM,CAAAA,CAAmB,KAAK,YAC5B,CAAA,OAAIA,IACFA,CAA6C,CAAA,UAAA,GAC1C,IAAK,CAAA,qBAAA,EACR,KAAK,iBAAkBN,CAAAA,CAAK,GAIvB,IACR,CAEA,IAAI,qBAAiC,EAAA,CACpC,IAAIG,CAAe,CAAA,IAAA,CAAK,aACxB,OAAKA,CAAAA,CAGE,CAACA,CAAa,CAAA,OAAA,EAAWA,EAAa,QAAY,EAAA,CAACA,EAAa,SAF/D,CAAA,KAGT,CAEA,iBAAkBH,CAAAA,CAAAA,CAAmC,CACpD,IAAIO,CAAAA,CAAkB,KAAK,YACvBA,CAAAA,CAAAA,EAAmB,KAAK,qBAC3BA,CAAAA,CAAAA,CAAgB,MAAMP,CAAK,CAAA,CAE3B,QAAQ,IAAK,CAAA,CAAA,aAAA,EAAgB,KAAK,EAAE,CAAA,8BAAA,CAAgC,EAEtE,CACD","file":"QuestStoredClass.mjs","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this as any as QuestInterface, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as any as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n"]}
@@ -2,7 +2,7 @@ import StageProps from '../../interface/quest/StageProps.mjs';
2
2
  import StageFlags from '../../interface/quest/StageFlags.mjs';
3
3
  import StageStoredClass from './StageStoredClass.mjs';
4
4
  import '@drincs/nqtr/dist/override';
5
- import '../../StageInterface-DgeEtkqv.mjs';
5
+ import '../../StageInterface-DmLgfrk4.mjs';
6
6
  import '@drincs/pixi-vn';
7
7
 
8
8
  declare class StageBaseModel extends StageStoredClass {
@@ -2,7 +2,7 @@ import StageProps from '../../interface/quest/StageProps.js';
2
2
  import StageFlags from '../../interface/quest/StageFlags.js';
3
3
  import StageStoredClass from './StageStoredClass.js';
4
4
  import '@drincs/nqtr/dist/override';
5
- import '../../StageInterface-DgeEtkqv.js';
5
+ import '../../StageInterface-DmLgfrk4.js';
6
6
  import '@drincs/pixi-vn';
7
7
 
8
8
  declare class StageBaseModel extends StageStoredClass {
@@ -1,2 +1,2 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var s="___nqtr-time_manager_data___";var n=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var f=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:a=1,timeSlots:C=[],weekLength:m=7,weekendStartDay:D=m-1,weekDaysNames:v=[]}=e;n.minDayHours=t,n.maxDayHours=r,n.defaultTimeSpent=a,n.timeSlots=C,n.weekLength=m,D>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${m}, so will be ignored`):n.weekendStartDay=D,v.length!==m?console.warn(`[NQTR] Week days names should be equal to week length ${m}, so will be ignored`):n.weekDaysNames=v;}get minDayHours(){return n.minDayHours}get maxDayHours(){return n.maxDayHours}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get weekDaysNames(){return n.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(s)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(s)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(s,t);}get currentDay(){let e=pixiVn.storage.getVariable(s)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(s)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(s,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var _=new f;var k="__nqtr-stage__",g=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(k,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>_.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=_.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var I=class extends g{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>pixiVn.getFlag(e.flag))?false:super.canStart}};module.exports=I;//# sourceMappingURL=StageBaseModel.js.map
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var s="___nqtr-time_manager_data___";var n=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var f=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:C=[],weekLength:m=7,weekendStartDay:D=m-1,weekDaysNames:v=[]}=e;n.minDayHours=t,n.maxDayHours=r,n.defaultTimeSpent=i,n.timeSlots=C,n.weekLength=m,D>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${m}, so will be ignored`):n.weekendStartDay=D,v.length!==m?console.warn(`[NQTR] Week days names should be equal to week length ${m}, so will be ignored`):n.weekDaysNames=v;}get minDayHours(){return n.minDayHours}get maxDayHours(){return n.maxDayHours}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get weekDaysNames(){return n.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(s)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(s)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(s,t);}get currentDay(){let e=pixiVn.storage.getVariable(s)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(s)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(s,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var _=new f;var k="__nqtr-stage__",g=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(k,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>_.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=_.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var I=class extends g{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>pixiVn.getFlag(e.flag))?false:super.canStart}};module.exports=I;//# sourceMappingURL=StageBaseModel.js.map
2
2
  //# sourceMappingURL=StageBaseModel.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/constants.ts","../../../src/managers/TimeManagerSettings.ts","../../../src/managers/TimeManager.ts","../../../src/managers/index.ts","../../../src/classes/quest/StageStoredClass.ts","../../../src/classes/quest/StageBaseModel.ts"],"names":["TIME_DATA_KEY","TimeManagerSettings","TimeManager","settings","minDayHours","maxDayHours","defaultTimeSpent","timeSlots","weekLength","weekendStartDay","weekDaysNames","data","storage","value","weekDayNumber","index","slot","timeSpent","newHour","newDayHour","days","newDay","fromHour","toHour","currentHour","timeTracker","navigator","STAGE_CATEGORY","StageStoredClass","StoredClassModel","id","options","prevStageEndDay","daysRequired","q","props","StageBaseModel","flag","getFlag"],"mappings":"mDACO,IAAMA,EAAgB,8BCC7B,CAAA,IAAqBC,EAArB,KAAiE,CAC7D,OAAO,WAAsB,CAAA,CAAA,CAC7B,OAAO,WAAsB,CAAA,EAAA,CAC7B,OAAO,gBAA2B,CAAA,CAAA,CAClC,OAAO,SAAA,CAA0B,EAAC,CAClC,OAAO,UAAqB,CAAA,CAAA,CAC5B,OAAO,eAA0B,CAAA,IAAA,CAAK,WAAa,CACnD,CAAA,OAAO,cAA0B,EACrC,ECJA,IAAqBC,CAAAA,CAArB,KAAiC,CAC7B,UAAA,CAAWC,EAAwB,CAC/B,GAAM,CACF,WAAA,CAAAC,CAAc,CAAA,CAAA,CACd,YAAAC,CAAc,CAAA,EAAA,CACd,iBAAAC,CAAmB,CAAA,CAAA,CACnB,UAAAC,CAAY,CAAA,GACZ,UAAAC,CAAAA,CAAAA,CAAa,EACb,eAAAC,CAAAA,CAAAA,CAAkBD,EAAa,CAC/B,CAAA,aAAA,CAAAE,EAAgB,EACpB,CAAIP,CAAAA,CAAAA,CACJF,CAAoB,CAAA,WAAA,CAAcG,EAClCH,CAAoB,CAAA,WAAA,CAAcI,EAClCJ,CAAoB,CAAA,gBAAA,CAAmBK,EACvCL,CA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B,EACrD,CAAA,IAAA,CAAK,OAASA,CAAM,CAAA,KAAA,CACpB,KAAK,qBAAwBA,CAAAA,CAAAA,CAAM,sBAAwB,EAAC,CAC5D,KAAK,0BAA6BA,CAAAA,CAAAA,CAAM,2BAA6B,GACtE,CAEQ,MAIR,IAAI,IAAA,EAAe,CAClB,OAAO,IAAA,CAAK,KACb,CAEQ,YAIR,CAAA,IAAI,aAAsB,CACzB,OAAO,KAAK,YACb,CAEQ,mBAIR,IAAI,iBAAA,EAA4B,CAC/B,OAAO,IAAA,CAAK,kBACb,CAEQ,MAAA,CAIR,IAAI,KAA4B,EAAA,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,MAIR,CAAA,IAAI,OAAsB,CACzB,OAAO,KAAK,MACb,CAEQ,sBAIR,IAAI,oBAAA,EAAqC,CACxC,OAAO,IAAA,CAAK,qBACb,CAEQ,0BAAA,CAIR,IAAI,yBAAoC,EAAA,CACvC,OAAO,IAAK,CAAA,0BACb,CAEA,IAAa,SAAqB,EAAA,CACjC,OAAI,KAAM,CAAA,SAAA,CACF,KAEJ,IAAK,CAAA,KAAA,CAAM,OAAS,CAClB,CAAA,CAAA,CAAA,IAAA,CAAK,MAAM,KAAOE,CAAAA,CAAAA,EAASC,eAAQD,CAAK,CAAA,IAAI,CAAC,CAK5C,CAAA,KACR,CACA,IAAa,SAAA,CAAUxB,CAAgB,CAAA,CACtC,KAAM,CAAA,SAAA,CAAYA,EACnB,CACA,IAAa,UAAoB,CAChC,OAAI,KAAK,oBAAqB,CAAA,MAAA,CAAS,GAAK,CAAC,IAAA,CAAK,qBAAqB,KAAOwB,CAAAA,CAAAA,EAASC,eAAQD,CAAK,CAAA,IAAI,CAAC,CACjG,CAAA,KAAA,CAED,KAAM,CAAA,QACd,CACD","file":"StageBaseModel.js","sourcesContent":["export const TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nexport const TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\n","import { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nexport default class TimeManagerSettings implements TimeSettings {\n static minDayHours: number = 0\n static maxDayHours: number = 24\n static defaultTimeSpent: number = 1\n static timeSlots: ITimeStlot[] = []\n static weekLength: number = 7\n static weekendStartDay: number = this.weekLength - 1\n static weekDaysNames: string[] = []\n}\n","import { storage } from \"@drincs/pixi-vn\";\nimport { TIME_DATA_KEY } from \"../constants\";\nimport TimeDataType from \"../types/TimeDataType\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\nimport TimeManagerSettings from \"./TimeManagerSettings\";\n\nexport default class TimeManager {\n initialize(settings: TimeSettings) {\n const {\n minDayHours = 0,\n maxDayHours = 24,\n defaultTimeSpent = 1,\n timeSlots = [],\n weekLength = 7,\n weekendStartDay = weekLength - 1,\n weekDaysNames = [],\n } = settings\n TimeManagerSettings.minDayHours = minDayHours\n TimeManagerSettings.maxDayHours = maxDayHours\n TimeManagerSettings.defaultTimeSpent = defaultTimeSpent\n TimeManagerSettings.timeSlots = timeSlots\n TimeManagerSettings.weekLength = weekLength\n if (weekendStartDay >= TimeManagerSettings.weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekendStartDay = weekendStartDay\n }\n if (weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekDaysNames = weekDaysNames\n }\n }\n get minDayHours(): number {\n return TimeManagerSettings.minDayHours\n }\n get maxDayHours(): number {\n return TimeManagerSettings.maxDayHours\n }\n get defaultTimeSpent(): number {\n return TimeManagerSettings.defaultTimeSpent\n }\n get timeSlots(): ITimeStlot[] {\n return TimeManagerSettings.timeSlots\n }\n get weekLength(): number {\n return TimeManagerSettings.weekLength\n }\n get weekendStartDay(): number {\n return TimeManagerSettings.weekendStartDay\n }\n get weekDaysNames(): string[] {\n return TimeManagerSettings.weekDaysNames\n }\n\n /**\n * Get the current hour\n */\n get currentHour(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return this.minDayHours\n }\n set currentHour(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n get currentDay(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n set currentDay(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n get isWeekend(): boolean {\n return this.currentWeekDayNumber >= this.weekendStartDay\n }\n /**\n * Get the current week day number (1 - {@link weekLength}).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n get currentWeekDayNumber(): number {\n let result = this.currentDay % this.weekLength\n return result + 1\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.\n * @default \"\"\n */\n get currentDayName(): string {\n let weekDayNumber = this.currentWeekDayNumber - 1\n if (weekDayNumber >= this.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, this.weekDaysNames)\n return \"\"\n }\n return this.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current {@link timeSlots} index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```tsx\n * import { weekLength } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />\n * )\n * }\n */\n get currentTimeSlot(): number {\n if (this.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < this.timeSlots.length; index++) {\n let slot = this.timeSlots[index]\n if (this.timeSlots.length > index + 1) {\n if (this.nowIsBetween(slot.startHour, this.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return this.timeSlots.length - 1\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: {@link defaultTimeSpent})\n * @returns currentTimeSlot.currentHour\n */\n increaseHour(timeSpent: number = this.defaultTimeSpent): number {\n let newHour = this.currentHour + timeSpent\n if (newHour >= this.maxDayHours) {\n this.increaseDay()\n newHour = this.minDayHours + (newHour - this.maxDayHours)\n }\n this.currentHour = newHour\n return this.currentHour\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: {@link minDayHours})\n * @param days is the number of days to increase (default: 1)\n * @returns timeTracker.currentDay\n */\n increaseDay(newDayHour: number = this.minDayHours, days: number = 1): number {\n let newDay = this.currentDay + days\n this.currentDay = newDay\n this.currentHour = newDayHour\n return this.currentDay\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the {@link currentHour} is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n nowIsBetween(fromHour: number | undefined, toHour: number | undefined): boolean {\n if (fromHour === undefined) {\n fromHour = this.minDayHours\n }\n if (toHour === undefined) {\n toHour = this.maxDayHours\n }\n let currentHour = this.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n","import NavigatorManager from \"./NavigatorManager\";\nimport QuestManager from \"./QuestManager\";\nimport RoutineManager from \"./RoutineManager\";\nimport { default as TimeManager } from \"./TimeManager\";\n\nconst timeTracker = new TimeManager();\nconst navigator = new NavigatorManager();\nconst routine = new RoutineManager();\nconst questsNotebook = new QuestManager();\n\nexport { navigator, questsNotebook, routine, timeTracker };\n","import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { StageInterface } from \"../../interface\";\nimport { StageBaseInternalInterface } from \"../../interface/quest/StageInterface\";\nimport { timeTracker } from \"../../managers\";\nimport { QuestsRequiredType } from \"../../types\";\n\nconst STAGE_CATEGORY = \"__nqtr-stage__\";\nexport default class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\toptions: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage starts.\n\t\t\t */\n\t\t\tonStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage ends.\n\t\t\t */\n\t\t\tonEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The day required to start the stage.\n\t\t\t * @example If the value is 3, and the previous stage ends on day 1, the stage will start on day 4.\n\t\t\t */\n\t\t\tdaysRequiredToStart?: number;\n\t\t\t/**\n\t\t\t * The quests required to start the stage.\n\t\t\t * @default []\n\t\t\t */\n\t\t\tquestsRequiredToStart?: QuestsRequiredType[];\n\t\t} = {}\n\t) {\n\t\tsuper(STAGE_CATEGORY, id);\n\t\tthis._onStart = options.onStart;\n\t\tthis._onEnd = options.onEnd;\n\t\tthis._daysRequiredToStart = options.daysRequiredToStart;\n\t\tthis._questsRequiredToStart = options.questsRequiredToStart || [];\n\t}\n\n\tprivate _onStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onEnd(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onEnd;\n\t}\n\n\tget completed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"completed\") || false;\n\t}\n\tset completed(value: boolean) {\n\t\tthis.setStorageProperty(\"completed\", value);\n\t}\n\n\tget started(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"started\") || false;\n\t}\n\tset started(value: boolean) {\n\t\tthis.setStorageProperty(\"started\", value);\n\t}\n\n\tprivate get prevStageEndDay(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"prevStageEndDay\");\n\t}\n\tprivate set prevStageEndDay(value: number | undefined) {\n\t\tthis.setStorageProperty(\"prevStageEndDay\", value);\n\t}\n\n\tget startDay(): number | undefined {\n\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\tif (prevStageEndDay === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn prevStageEndDay + this.daysRequiredToStart;\n\t}\n\n\tget canStart(): boolean {\n\t\tlet daysRequired = this.daysRequiredToStart;\n\t\tif (daysRequired > 0) {\n\t\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\t\tif (prevStageEndDay === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (prevStageEndDay + daysRequired > timeTracker.currentDay) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tthis.questsRequiredToStart.length > 0 &&\n\t\t\t!this.questsRequiredToStart.every(\n\t\t\t\t(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tinizialize() {\n\t\tif (this.daysRequiredToStart > 0) {\n\t\t\tthis.prevStageEndDay = timeTracker.currentDay;\n\t\t\tconsole.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);\n\t\t}\n\t}\n\n\tstart(props: OnStartEndStageQuest) {\n\t\tif (this.canStart) {\n\t\t\tthis.started = true;\n\t\t\tif (this.onStart) {\n\t\t\t\tthis.onStart(this, props);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Stage ${this.id} can't start`);\n\t\t}\n\t}\n\n\tprivate _daysRequiredToStart?: number;\n\tget daysRequiredToStart(): number {\n\t\treturn this._daysRequiredToStart || 0;\n\t}\n\n\tprivate _questsRequiredToStart: QuestsRequiredType[];\n\tget questsRequiredToStart(): QuestsRequiredType[] {\n\t\treturn this._questsRequiredToStart || [];\n\t}\n}\n","import { getFlag } from \"@drincs/pixi-vn\";\nimport { StageProps } from \"../../interface\";\nimport StageFlags from \"../../interface/quest/StageFlags\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nexport default class StageBaseModel extends StageStoredClass {\n\tconstructor(id: string, props: StageProps) {\n\t\tsuper(id, {\n\t\t\tonStart: props.onStart,\n\t\t\tonEnd: props.onEnd,\n\t\t\tdaysRequiredToStart: props.daysRequiredToStart,\n\t\t\tquestsRequiredToStart: props.questsRequiredToStart,\n\t\t});\n\t\tthis._name = props.name || \"\";\n\t\tthis._flags = props.flags || [];\n\t\tthis._description = props.description || \"\";\n\t\tthis._adviceDescription = props.adviceDescription || \"\";\n\t\tthis._image = props.image;\n\t\tthis._flagsRequiredToStart = props.flagsRequiredToStart || [];\n\t\tthis._requestDescriptionToStart = props.requestDescriptionToStart || \"\";\n\t}\n\n\tprivate _name: string;\n\t/**\n\t * The name of the stage.\n\t */\n\tget name(): string {\n\t\treturn this._name;\n\t}\n\n\tprivate _description: string;\n\t/**\n\t * The description of the stage.\n\t */\n\tget description(): string {\n\t\treturn this._description;\n\t}\n\n\tprivate _adviceDescription: string;\n\t/**\n\t * The advice description of the stage.\n\t */\n\tget adviceDescription(): string {\n\t\treturn this._adviceDescription;\n\t}\n\n\tprivate _image?: string;\n\t/**\n\t * The image of the stage.\n\t */\n\tget image(): string | undefined {\n\t\treturn this._image;\n\t}\n\n\tprivate _flags: StageFlags[];\n\t/**\n\t * The list of flags that the player must complete to finish the stage.\n\t */\n\tget flags(): StageFlags[] {\n\t\treturn this._flags;\n\t}\n\n\tprivate _flagsRequiredToStart: StageFlags[];\n\t/**\n\t * The list of flags required to start the stage.\n\t */\n\tget flagsRequiredToStart(): StageFlags[] {\n\t\treturn this._flagsRequiredToStart;\n\t}\n\n\tprivate _requestDescriptionToStart: string;\n\t/**\n\t * The description of the request to start the stage.\n\t */\n\tget requestDescriptionToStart(): string {\n\t\treturn this._requestDescriptionToStart;\n\t}\n\n\toverride get completed(): boolean {\n\t\tif (super.completed) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.flags.length > 0) {\n\t\t\tif (!this.flags.every((flag) => getFlag(flag.flag))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\toverride set completed(value: boolean) {\n\t\tsuper.completed = value;\n\t}\n\toverride get canStart(): boolean {\n\t\tif (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.canStart;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/constants.ts","../../../src/managers/TimeManagerSettings.ts","../../../src/managers/TimeManager.ts","../../../src/managers/index.ts","../../../src/classes/quest/StageStoredClass.ts","../../../src/classes/quest/StageBaseModel.ts"],"names":["TIME_DATA_KEY","TimeManagerSettings","TimeManager","settings","minDayHours","maxDayHours","defaultTimeSpent","timeSlots","weekLength","weekendStartDay","weekDaysNames","data","storage","value","weekDayNumber","index","slot","timeSpent","newHour","newDayHour","days","newDay","fromHour","toHour","currentHour","timeTracker","navigator","STAGE_CATEGORY","StageStoredClass","StoredClassModel","id","options","prevStageEndDay","daysRequired","q","props","StageBaseModel","flag","getFlag"],"mappings":"mDACO,IAAMA,EAAgB,8BCC7B,CAAA,IAAqBC,EAArB,KAAiE,CAC7D,OAAO,WAAsB,CAAA,CAAA,CAC7B,OAAO,WAAsB,CAAA,EA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CAEA,IAAa,SAAqB,EAAA,CACjC,OAAI,KAAM,CAAA,SAAA,CACF,KAEJ,IAAK,CAAA,KAAA,CAAM,OAAS,CAClB,CAAA,CAAA,CAAA,IAAA,CAAK,MAAM,KAAOE,CAAAA,CAAAA,EAASC,eAAQD,CAAK,CAAA,IAAI,CAAC,CAK5C,CAAA,KACR,CACA,IAAa,SAAA,CAAUxB,CAAgB,CAAA,CACtC,KAAM,CAAA,SAAA,CAAYA,EACnB,CACA,IAAa,UAAoB,CAChC,OAAI,KAAK,oBAAqB,CAAA,MAAA,CAAS,GAAK,CAAC,IAAA,CAAK,qBAAqB,KAAOwB,CAAAA,CAAAA,EAASC,eAAQD,CAAK,CAAA,IAAI,CAAC,CACjG,CAAA,KAAA,CAED,KAAM,CAAA,QACd,CACD","file":"StageBaseModel.js","sourcesContent":["export const TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nexport const TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\n","import { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nexport default class TimeManagerSettings implements TimeSettings {\n static minDayHours: number = 0\n static maxDayHours: number = 24\n static defaultTimeSpent: number = 1\n static timeSlots: ITimeStlot[] = []\n static weekLength: number = 7\n static weekendStartDay: number = this.weekLength - 1\n static weekDaysNames: string[] = []\n}\n","import { storage } from \"@drincs/pixi-vn\";\nimport { TIME_DATA_KEY } from \"../constants\";\nimport TimeDataType from \"../types/TimeDataType\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\nimport TimeManagerSettings from \"./TimeManagerSettings\";\n\nexport default class TimeManager {\n initialize(settings: TimeSettings) {\n const {\n minDayHours = 0,\n maxDayHours = 24,\n defaultTimeSpent = 1,\n timeSlots = [],\n weekLength = 7,\n weekendStartDay = weekLength - 1,\n weekDaysNames = [],\n } = settings\n TimeManagerSettings.minDayHours = minDayHours\n TimeManagerSettings.maxDayHours = maxDayHours\n TimeManagerSettings.defaultTimeSpent = defaultTimeSpent\n TimeManagerSettings.timeSlots = timeSlots\n TimeManagerSettings.weekLength = weekLength\n if (weekendStartDay >= TimeManagerSettings.weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekendStartDay = weekendStartDay\n }\n if (weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekDaysNames = weekDaysNames\n }\n }\n get minDayHours(): number {\n return TimeManagerSettings.minDayHours\n }\n get maxDayHours(): number {\n return TimeManagerSettings.maxDayHours\n }\n get defaultTimeSpent(): number {\n return TimeManagerSettings.defaultTimeSpent\n }\n get timeSlots(): ITimeStlot[] {\n return TimeManagerSettings.timeSlots\n }\n get weekLength(): number {\n return TimeManagerSettings.weekLength\n }\n get weekendStartDay(): number {\n return TimeManagerSettings.weekendStartDay\n }\n get weekDaysNames(): string[] {\n return TimeManagerSettings.weekDaysNames\n }\n\n /**\n * Get the current hour\n */\n get currentHour(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return this.minDayHours\n }\n set currentHour(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n get currentDay(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n set currentDay(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n get isWeekend(): boolean {\n return this.currentWeekDayNumber >= this.weekendStartDay\n }\n /**\n * Get the current week day number (1 - {@link weekLength}).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n get currentWeekDayNumber(): number {\n let result = this.currentDay % this.weekLength\n return result + 1\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.\n * @default \"\"\n */\n get currentDayName(): string {\n let weekDayNumber = this.currentWeekDayNumber - 1\n if (weekDayNumber >= this.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, this.weekDaysNames)\n return \"\"\n }\n return this.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current {@link timeSlots} index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```tsx\n * import { weekLength } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />\n * )\n * }\n */\n get currentTimeSlot(): number {\n if (this.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < this.timeSlots.length; index++) {\n let slot = this.timeSlots[index]\n if (this.timeSlots.length > index + 1) {\n if (this.nowIsBetween(slot.startHour, this.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return this.timeSlots.length - 1\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: {@link defaultTimeSpent})\n * @returns currentTimeSlot.currentHour\n */\n increaseHour(timeSpent: number = this.defaultTimeSpent): number {\n let newHour = this.currentHour + timeSpent\n if (newHour >= this.maxDayHours) {\n this.increaseDay()\n newHour = this.minDayHours + (newHour - this.maxDayHours)\n }\n this.currentHour = newHour\n return this.currentHour\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: {@link minDayHours})\n * @param days is the number of days to increase (default: 1)\n * @returns timeTracker.currentDay\n */\n increaseDay(newDayHour: number = this.minDayHours, days: number = 1): number {\n let newDay = this.currentDay + days\n this.currentDay = newDay\n this.currentHour = newDayHour\n return this.currentDay\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the {@link currentHour} is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n nowIsBetween(fromHour: number | undefined, toHour: number | undefined): boolean {\n if (fromHour === undefined) {\n fromHour = this.minDayHours\n }\n if (toHour === undefined) {\n toHour = this.maxDayHours\n }\n let currentHour = this.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n","import NavigatorManager from \"./NavigatorManager\";\nimport QuestManager from \"./QuestManager\";\nimport RoutineManager from \"./RoutineManager\";\nimport { default as TimeManager } from \"./TimeManager\";\n\nconst timeTracker = new TimeManager();\nconst navigator = new NavigatorManager();\nconst routine = new RoutineManager();\nconst questsNotebook = new QuestManager();\n\nexport { navigator, questsNotebook, routine, timeTracker };\n","import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { StageInterface } from \"../../interface\";\nimport { StageBaseInternalInterface } from \"../../interface/quest/StageInterface\";\nimport { timeTracker } from \"../../managers\";\nimport { QuestsRequiredType } from \"../../types\";\n\nconst STAGE_CATEGORY = \"__nqtr-stage__\";\nexport default class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\toptions: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage starts.\n\t\t\t */\n\t\t\tonStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage ends.\n\t\t\t */\n\t\t\tonEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The day required to start the stage.\n\t\t\t * @example If the value is 3, and the previous stage ends on day 1, the stage will start on day 4.\n\t\t\t */\n\t\t\tdaysRequiredToStart?: number;\n\t\t\t/**\n\t\t\t * The quests required to start the stage.\n\t\t\t * @default []\n\t\t\t */\n\t\t\tquestsRequiredToStart?: QuestsRequiredType[];\n\t\t} = {}\n\t) {\n\t\tsuper(STAGE_CATEGORY, id);\n\t\tthis._onStart = options.onStart;\n\t\tthis._onEnd = options.onEnd;\n\t\tthis._daysRequiredToStart = options.daysRequiredToStart;\n\t\tthis._questsRequiredToStart = options.questsRequiredToStart || [];\n\t}\n\n\tprivate _onStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onEnd(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onEnd;\n\t}\n\n\tget completed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"completed\") || false;\n\t}\n\tset completed(value: boolean) {\n\t\tthis.setStorageProperty(\"completed\", value);\n\t}\n\n\tget started(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"started\") || false;\n\t}\n\tset started(value: boolean) {\n\t\tthis.setStorageProperty(\"started\", value);\n\t}\n\n\tprivate get prevStageEndDay(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"prevStageEndDay\");\n\t}\n\tprivate set prevStageEndDay(value: number | undefined) {\n\t\tthis.setStorageProperty(\"prevStageEndDay\", value);\n\t}\n\n\tget startDay(): number | undefined {\n\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\tif (prevStageEndDay === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn prevStageEndDay + this.daysRequiredToStart;\n\t}\n\n\tget canStart(): boolean {\n\t\tlet daysRequired = this.daysRequiredToStart;\n\t\tif (daysRequired > 0) {\n\t\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\t\tif (prevStageEndDay === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (prevStageEndDay + daysRequired > timeTracker.currentDay) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tthis.questsRequiredToStart.length > 0 &&\n\t\t\t!this.questsRequiredToStart.every(\n\t\t\t\t(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tinizialize() {\n\t\tif (this.daysRequiredToStart > 0) {\n\t\t\tthis.prevStageEndDay = timeTracker.currentDay;\n\t\t\tconsole.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);\n\t\t}\n\t}\n\n\tstart(props: OnStartEndStageQuest) {\n\t\tif (this.canStart) {\n\t\t\tthis.started = true;\n\t\t\tif (this.onStart) {\n\t\t\t\tthis.onStart(this as any as StageInterface, props);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Stage ${this.id} can't start`);\n\t\t}\n\t}\n\n\tprivate _daysRequiredToStart?: number;\n\tget daysRequiredToStart(): number {\n\t\treturn this._daysRequiredToStart || 0;\n\t}\n\n\tprivate _questsRequiredToStart: QuestsRequiredType[];\n\tget questsRequiredToStart(): QuestsRequiredType[] {\n\t\treturn this._questsRequiredToStart || [];\n\t}\n}\n","import { getFlag } from \"@drincs/pixi-vn\";\nimport { StageProps } from \"../../interface\";\nimport StageFlags from \"../../interface/quest/StageFlags\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nexport default class StageBaseModel extends StageStoredClass {\n\tconstructor(id: string, props: StageProps) {\n\t\tsuper(id, {\n\t\t\tonStart: props.onStart,\n\t\t\tonEnd: props.onEnd,\n\t\t\tdaysRequiredToStart: props.daysRequiredToStart,\n\t\t\tquestsRequiredToStart: props.questsRequiredToStart,\n\t\t});\n\t\tthis._name = props.name || \"\";\n\t\tthis._flags = props.flags || [];\n\t\tthis._description = props.description || \"\";\n\t\tthis._adviceDescription = props.adviceDescription || \"\";\n\t\tthis._image = props.image;\n\t\tthis._flagsRequiredToStart = props.flagsRequiredToStart || [];\n\t\tthis._requestDescriptionToStart = props.requestDescriptionToStart || \"\";\n\t}\n\n\tprivate _name: string;\n\t/**\n\t * The name of the stage.\n\t */\n\tget name(): string {\n\t\treturn this._name;\n\t}\n\n\tprivate _description: string;\n\t/**\n\t * The description of the stage.\n\t */\n\tget description(): string {\n\t\treturn this._description;\n\t}\n\n\tprivate _adviceDescription: string;\n\t/**\n\t * The advice description of the stage.\n\t */\n\tget adviceDescription(): string {\n\t\treturn this._adviceDescription;\n\t}\n\n\tprivate _image?: string;\n\t/**\n\t * The image of the stage.\n\t */\n\tget image(): string | undefined {\n\t\treturn this._image;\n\t}\n\n\tprivate _flags: StageFlags[];\n\t/**\n\t * The list of flags that the player must complete to finish the stage.\n\t */\n\tget flags(): StageFlags[] {\n\t\treturn this._flags;\n\t}\n\n\tprivate _flagsRequiredToStart: StageFlags[];\n\t/**\n\t * The list of flags required to start the stage.\n\t */\n\tget flagsRequiredToStart(): StageFlags[] {\n\t\treturn this._flagsRequiredToStart;\n\t}\n\n\tprivate _requestDescriptionToStart: string;\n\t/**\n\t * The description of the request to start the stage.\n\t */\n\tget requestDescriptionToStart(): string {\n\t\treturn this._requestDescriptionToStart;\n\t}\n\n\toverride get completed(): boolean {\n\t\tif (super.completed) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.flags.length > 0) {\n\t\t\tif (!this.flags.every((flag) => getFlag(flag.flag))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\toverride set completed(value: boolean) {\n\t\tsuper.completed = value;\n\t}\n\toverride get canStart(): boolean {\n\t\tif (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.canStart;\n\t}\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {getFlag,StoredClassModel,storage}from'@drincs/pixi-vn';var s="___nqtr-time_manager_data___";var n=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var f=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:a=1,timeSlots:C=[],weekLength:m=7,weekendStartDay:D=m-1,weekDaysNames:v=[]}=e;n.minDayHours=t,n.maxDayHours=r,n.defaultTimeSpent=a,n.timeSlots=C,n.weekLength=m,D>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${m}, so will be ignored`):n.weekendStartDay=D,v.length!==m?console.warn(`[NQTR] Week days names should be equal to week length ${m}, so will be ignored`):n.weekDaysNames=v;}get minDayHours(){return n.minDayHours}get maxDayHours(){return n.maxDayHours}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get weekDaysNames(){return n.weekDaysNames}get currentHour(){let e=storage.getVariable(s)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(s)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(s,t);}get currentDay(){let e=storage.getVariable(s)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(s)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(s,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var _=new f;var k="__nqtr-stage__",g=class extends StoredClassModel{constructor(e,t={}){super(k,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>_.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=_.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var I=class extends g{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>getFlag(e.flag))?false:super.canStart}};export{I as default};//# sourceMappingURL=StageBaseModel.mjs.map
1
+ import {getFlag,StoredClassModel,storage}from'@drincs/pixi-vn';var s="___nqtr-time_manager_data___";var n=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var f=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:C=[],weekLength:m=7,weekendStartDay:D=m-1,weekDaysNames:v=[]}=e;n.minDayHours=t,n.maxDayHours=r,n.defaultTimeSpent=i,n.timeSlots=C,n.weekLength=m,D>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${m}, so will be ignored`):n.weekendStartDay=D,v.length!==m?console.warn(`[NQTR] Week days names should be equal to week length ${m}, so will be ignored`):n.weekDaysNames=v;}get minDayHours(){return n.minDayHours}get maxDayHours(){return n.maxDayHours}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get weekDaysNames(){return n.weekDaysNames}get currentHour(){let e=storage.getVariable(s)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(s)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(s,t);}get currentDay(){let e=storage.getVariable(s)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(s)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(s,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var _=new f;var k="__nqtr-stage__",g=class extends StoredClassModel{constructor(e,t={}){super(k,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>_.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=_.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var I=class extends g{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>getFlag(e.flag))?false:super.canStart}};export{I as default};//# sourceMappingURL=StageBaseModel.mjs.map
2
2
  //# sourceMappingURL=StageBaseModel.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/constants.ts","../../../src/managers/TimeManagerSettings.ts","../../../src/managers/TimeManager.ts","../../../src/managers/index.ts","../../../src/classes/quest/StageStoredClass.ts","../../../src/classes/quest/StageBaseModel.ts"],"names":["TIME_DATA_KEY","TimeManagerSettings","TimeManager","settings","minDayHours","maxDayHours","defaultTimeSpent","timeSlots","weekLength","weekendStartDay","weekDaysNames","data","storage","value","weekDayNumber","index","slot","timeSpent","newHour","newDayHour","days","newDay","fromHour","toHour","currentHour","timeTracker","navigator","STAGE_CATEGORY","StageStoredClass","StoredClassModel","id","options","prevStageEndDay","daysRequired","q","props","StageBaseModel","flag","getFlag"],"mappings":"+DACO,IAAMA,EAAgB,8BCC7B,CAAA,IAAqBC,EAArB,KAAiE,CAC7D,OAAO,WAAsB,CAAA,CAAA,CAC7B,OAAO,WAAsB,CAAA,EAAA,CAC7B,OAAO,gBAA2B,CAAA,CAAA,CAClC,OAAO,SAAA,CAA0B,EAAC,CAClC,OAAO,UAAqB,CAAA,CAAA,CAC5B,OAAO,eAA0B,CAAA,IAAA,CAAK,WAAa,CACnD,CAAA,OAAO,cAA0B,EACrC,ECJA,IAAqBC,CAAAA,CAArB,KAAiC,CAC7B,UAAA,CAAWC,EAAwB,CAC/B,GAAM,CACF,WAAA,CAAAC,CAAc,CAAA,CAAA,CACd,YAAAC,CAAc,CAAA,EAAA,CACd,iBAAAC,CAAmB,CAAA,CAAA,CACnB,UAAAC,CAAY,CAAA,GACZ,UAAAC,CAAAA,CAAAA,CAAa,EACb,eAAAC,CAAAA,CAAAA,CAAkBD,EAAa,CAC/B,CAAA,aAAA,CAAAE,EAAgB,EACpB,CAA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"StageBaseModel.mjs","sourcesContent":["export const TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nexport const TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\n","import { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nexport default class TimeManagerSettings implements TimeSettings {\n static minDayHours: number = 0\n static maxDayHours: number = 24\n static defaultTimeSpent: number = 1\n static timeSlots: ITimeStlot[] = []\n static weekLength: number = 7\n static weekendStartDay: number = this.weekLength - 1\n static weekDaysNames: string[] = []\n}\n","import { storage } from \"@drincs/pixi-vn\";\nimport { TIME_DATA_KEY } from \"../constants\";\nimport TimeDataType from \"../types/TimeDataType\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\nimport TimeManagerSettings from \"./TimeManagerSettings\";\n\nexport default class TimeManager {\n initialize(settings: TimeSettings) {\n const {\n minDayHours = 0,\n maxDayHours = 24,\n defaultTimeSpent = 1,\n timeSlots = [],\n weekLength = 7,\n weekendStartDay = weekLength - 1,\n weekDaysNames = [],\n } = settings\n TimeManagerSettings.minDayHours = minDayHours\n TimeManagerSettings.maxDayHours = maxDayHours\n TimeManagerSettings.defaultTimeSpent = defaultTimeSpent\n TimeManagerSettings.timeSlots = timeSlots\n TimeManagerSettings.weekLength = weekLength\n if (weekendStartDay >= TimeManagerSettings.weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekendStartDay = weekendStartDay\n }\n if (weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekDaysNames = weekDaysNames\n }\n }\n get minDayHours(): number {\n return TimeManagerSettings.minDayHours\n }\n get maxDayHours(): number {\n return TimeManagerSettings.maxDayHours\n }\n get defaultTimeSpent(): number {\n return TimeManagerSettings.defaultTimeSpent\n }\n get timeSlots(): ITimeStlot[] {\n return TimeManagerSettings.timeSlots\n }\n get weekLength(): number {\n return TimeManagerSettings.weekLength\n }\n get weekendStartDay(): number {\n return TimeManagerSettings.weekendStartDay\n }\n get weekDaysNames(): string[] {\n return TimeManagerSettings.weekDaysNames\n }\n\n /**\n * Get the current hour\n */\n get currentHour(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return this.minDayHours\n }\n set currentHour(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n get currentDay(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n set currentDay(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n get isWeekend(): boolean {\n return this.currentWeekDayNumber >= this.weekendStartDay\n }\n /**\n * Get the current week day number (1 - {@link weekLength}).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n get currentWeekDayNumber(): number {\n let result = this.currentDay % this.weekLength\n return result + 1\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.\n * @default \"\"\n */\n get currentDayName(): string {\n let weekDayNumber = this.currentWeekDayNumber - 1\n if (weekDayNumber >= this.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, this.weekDaysNames)\n return \"\"\n }\n return this.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current {@link timeSlots} index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```tsx\n * import { weekLength } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />\n * )\n * }\n */\n get currentTimeSlot(): number {\n if (this.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < this.timeSlots.length; index++) {\n let slot = this.timeSlots[index]\n if (this.timeSlots.length > index + 1) {\n if (this.nowIsBetween(slot.startHour, this.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return this.timeSlots.length - 1\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: {@link defaultTimeSpent})\n * @returns currentTimeSlot.currentHour\n */\n increaseHour(timeSpent: number = this.defaultTimeSpent): number {\n let newHour = this.currentHour + timeSpent\n if (newHour >= this.maxDayHours) {\n this.increaseDay()\n newHour = this.minDayHours + (newHour - this.maxDayHours)\n }\n this.currentHour = newHour\n return this.currentHour\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: {@link minDayHours})\n * @param days is the number of days to increase (default: 1)\n * @returns timeTracker.currentDay\n */\n increaseDay(newDayHour: number = this.minDayHours, days: number = 1): number {\n let newDay = this.currentDay + days\n this.currentDay = newDay\n this.currentHour = newDayHour\n return this.currentDay\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the {@link currentHour} is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n nowIsBetween(fromHour: number | undefined, toHour: number | undefined): boolean {\n if (fromHour === undefined) {\n fromHour = this.minDayHours\n }\n if (toHour === undefined) {\n toHour = this.maxDayHours\n }\n let currentHour = this.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n","import NavigatorManager from \"./NavigatorManager\";\nimport QuestManager from \"./QuestManager\";\nimport RoutineManager from \"./RoutineManager\";\nimport { default as TimeManager } from \"./TimeManager\";\n\nconst timeTracker = new TimeManager();\nconst navigator = new NavigatorManager();\nconst routine = new RoutineManager();\nconst questsNotebook = new QuestManager();\n\nexport { navigator, questsNotebook, routine, timeTracker };\n","import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { StageInterface } from \"../../interface\";\nimport { StageBaseInternalInterface } from \"../../interface/quest/StageInterface\";\nimport { timeTracker } from \"../../managers\";\nimport { QuestsRequiredType } from \"../../types\";\n\nconst STAGE_CATEGORY = \"__nqtr-stage__\";\nexport default class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\toptions: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage starts.\n\t\t\t */\n\t\t\tonStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage ends.\n\t\t\t */\n\t\t\tonEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The day required to start the stage.\n\t\t\t * @example If the value is 3, and the previous stage ends on day 1, the stage will start on day 4.\n\t\t\t */\n\t\t\tdaysRequiredToStart?: number;\n\t\t\t/**\n\t\t\t * The quests required to start the stage.\n\t\t\t * @default []\n\t\t\t */\n\t\t\tquestsRequiredToStart?: QuestsRequiredType[];\n\t\t} = {}\n\t) {\n\t\tsuper(STAGE_CATEGORY, id);\n\t\tthis._onStart = options.onStart;\n\t\tthis._onEnd = options.onEnd;\n\t\tthis._daysRequiredToStart = options.daysRequiredToStart;\n\t\tthis._questsRequiredToStart = options.questsRequiredToStart || [];\n\t}\n\n\tprivate _onStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onEnd(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onEnd;\n\t}\n\n\tget completed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"completed\") || false;\n\t}\n\tset completed(value: boolean) {\n\t\tthis.setStorageProperty(\"completed\", value);\n\t}\n\n\tget started(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"started\") || false;\n\t}\n\tset started(value: boolean) {\n\t\tthis.setStorageProperty(\"started\", value);\n\t}\n\n\tprivate get prevStageEndDay(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"prevStageEndDay\");\n\t}\n\tprivate set prevStageEndDay(value: number | undefined) {\n\t\tthis.setStorageProperty(\"prevStageEndDay\", value);\n\t}\n\n\tget startDay(): number | undefined {\n\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\tif (prevStageEndDay === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn prevStageEndDay + this.daysRequiredToStart;\n\t}\n\n\tget canStart(): boolean {\n\t\tlet daysRequired = this.daysRequiredToStart;\n\t\tif (daysRequired > 0) {\n\t\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\t\tif (prevStageEndDay === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (prevStageEndDay + daysRequired > timeTracker.currentDay) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tthis.questsRequiredToStart.length > 0 &&\n\t\t\t!this.questsRequiredToStart.every(\n\t\t\t\t(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tinizialize() {\n\t\tif (this.daysRequiredToStart > 0) {\n\t\t\tthis.prevStageEndDay = timeTracker.currentDay;\n\t\t\tconsole.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);\n\t\t}\n\t}\n\n\tstart(props: OnStartEndStageQuest) {\n\t\tif (this.canStart) {\n\t\t\tthis.started = true;\n\t\t\tif (this.onStart) {\n\t\t\t\tthis.onStart(this, props);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Stage ${this.id} can't start`);\n\t\t}\n\t}\n\n\tprivate _daysRequiredToStart?: number;\n\tget daysRequiredToStart(): number {\n\t\treturn this._daysRequiredToStart || 0;\n\t}\n\n\tprivate _questsRequiredToStart: QuestsRequiredType[];\n\tget questsRequiredToStart(): QuestsRequiredType[] {\n\t\treturn this._questsRequiredToStart || [];\n\t}\n}\n","import { getFlag } from \"@drincs/pixi-vn\";\nimport { StageProps } from \"../../interface\";\nimport StageFlags from \"../../interface/quest/StageFlags\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nexport default class StageBaseModel extends StageStoredClass {\n\tconstructor(id: string, props: StageProps) {\n\t\tsuper(id, {\n\t\t\tonStart: props.onStart,\n\t\t\tonEnd: props.onEnd,\n\t\t\tdaysRequiredToStart: props.daysRequiredToStart,\n\t\t\tquestsRequiredToStart: props.questsRequiredToStart,\n\t\t});\n\t\tthis._name = props.name || \"\";\n\t\tthis._flags = props.flags || [];\n\t\tthis._description = props.description || \"\";\n\t\tthis._adviceDescription = props.adviceDescription || \"\";\n\t\tthis._image = props.image;\n\t\tthis._flagsRequiredToStart = props.flagsRequiredToStart || [];\n\t\tthis._requestDescriptionToStart = props.requestDescriptionToStart || \"\";\n\t}\n\n\tprivate _name: string;\n\t/**\n\t * The name of the stage.\n\t */\n\tget name(): string {\n\t\treturn this._name;\n\t}\n\n\tprivate _description: string;\n\t/**\n\t * The description of the stage.\n\t */\n\tget description(): string {\n\t\treturn this._description;\n\t}\n\n\tprivate _adviceDescription: string;\n\t/**\n\t * The advice description of the stage.\n\t */\n\tget adviceDescription(): string {\n\t\treturn this._adviceDescription;\n\t}\n\n\tprivate _image?: string;\n\t/**\n\t * The image of the stage.\n\t */\n\tget image(): string | undefined {\n\t\treturn this._image;\n\t}\n\n\tprivate _flags: StageFlags[];\n\t/**\n\t * The list of flags that the player must complete to finish the stage.\n\t */\n\tget flags(): StageFlags[] {\n\t\treturn this._flags;\n\t}\n\n\tprivate _flagsRequiredToStart: StageFlags[];\n\t/**\n\t * The list of flags required to start the stage.\n\t */\n\tget flagsRequiredToStart(): StageFlags[] {\n\t\treturn this._flagsRequiredToStart;\n\t}\n\n\tprivate _requestDescriptionToStart: string;\n\t/**\n\t * The description of the request to start the stage.\n\t */\n\tget requestDescriptionToStart(): string {\n\t\treturn this._requestDescriptionToStart;\n\t}\n\n\toverride get completed(): boolean {\n\t\tif (super.completed) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.flags.length > 0) {\n\t\t\tif (!this.flags.every((flag) => getFlag(flag.flag))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\toverride set completed(value: boolean) {\n\t\tsuper.completed = value;\n\t}\n\toverride get canStart(): boolean {\n\t\tif (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.canStart;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/constants.ts","../../../src/managers/TimeManagerSettings.ts","../../../src/managers/TimeManager.ts","../../../src/managers/index.ts","../../../src/classes/quest/StageStoredClass.ts","../../../src/classes/quest/StageBaseModel.ts"],"names":["TIME_DATA_KEY","TimeManagerSettings","TimeManager","settings","minDayHours","maxDayHours","defaultTimeSpent","timeSlots","weekLength","weekendStartDay","weekDaysNames","data","storage","value","weekDayNumber","index","slot","timeSpent","newHour","newDayHour","days","newDay","fromHour","toHour","currentHour","timeTracker","navigator","STAGE_CATEGORY","StageStoredClass","StoredClassModel","id","options","prevStageEndDay","daysRequired","q","props","StageBaseModel","flag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EQ,sBAIR,IAAI,oBAAA,EAAqC,CACxC,OAAO,IAAA,CAAK,qBACb,CAEQ,0BAAA,CAIR,IAAI,yBAAoC,EAAA,CACvC,OAAO,IAAK,CAAA,0BACb,CAEA,IAAa,SAAqB,EAAA,CACjC,OAAI,KAAM,CAAA,SAAA,CACF,KAEJ,IAAK,CAAA,KAAA,CAAM,OAAS,CAClB,CAAA,CAAA,CAAA,IAAA,CAAK,MAAM,KAAOE,CAAAA,CAAAA,EAASC,QAAQD,CAAK,CAAA,IAAI,CAAC,CAK5C,CAAA,KACR,CACA,IAAa,SAAA,CAAUxB,CAAgB,CAAA,CACtC,KAAM,CAAA,SAAA,CAAYA,EACnB,CACA,IAAa,UAAoB,CAChC,OAAI,KAAK,oBAAqB,CAAA,MAAA,CAAS,GAAK,CAAC,IAAA,CAAK,qBAAqB,KAAOwB,CAAAA,CAAAA,EAASC,QAAQD,CAAK,CAAA,IAAI,CAAC,CACjG,CAAA,KAAA,CAED,KAAM,CAAA,QACd,CACD","file":"StageBaseModel.mjs","sourcesContent":["export const TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nexport const TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\n","import { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nexport default class TimeManagerSettings implements TimeSettings {\n static minDayHours: number = 0\n static maxDayHours: number = 24\n static defaultTimeSpent: number = 1\n static timeSlots: ITimeStlot[] = []\n static weekLength: number = 7\n static weekendStartDay: number = this.weekLength - 1\n static weekDaysNames: string[] = []\n}\n","import { storage } from \"@drincs/pixi-vn\";\nimport { TIME_DATA_KEY } from \"../constants\";\nimport TimeDataType from \"../types/TimeDataType\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\nimport TimeManagerSettings from \"./TimeManagerSettings\";\n\nexport default class TimeManager {\n initialize(settings: TimeSettings) {\n const {\n minDayHours = 0,\n maxDayHours = 24,\n defaultTimeSpent = 1,\n timeSlots = [],\n weekLength = 7,\n weekendStartDay = weekLength - 1,\n weekDaysNames = [],\n } = settings\n TimeManagerSettings.minDayHours = minDayHours\n TimeManagerSettings.maxDayHours = maxDayHours\n TimeManagerSettings.defaultTimeSpent = defaultTimeSpent\n TimeManagerSettings.timeSlots = timeSlots\n TimeManagerSettings.weekLength = weekLength\n if (weekendStartDay >= TimeManagerSettings.weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekendStartDay = weekendStartDay\n }\n if (weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}, so will be ignored`)\n }\n else {\n TimeManagerSettings.weekDaysNames = weekDaysNames\n }\n }\n get minDayHours(): number {\n return TimeManagerSettings.minDayHours\n }\n get maxDayHours(): number {\n return TimeManagerSettings.maxDayHours\n }\n get defaultTimeSpent(): number {\n return TimeManagerSettings.defaultTimeSpent\n }\n get timeSlots(): ITimeStlot[] {\n return TimeManagerSettings.timeSlots\n }\n get weekLength(): number {\n return TimeManagerSettings.weekLength\n }\n get weekendStartDay(): number {\n return TimeManagerSettings.weekendStartDay\n }\n get weekDaysNames(): string[] {\n return TimeManagerSettings.weekDaysNames\n }\n\n /**\n * Get the current hour\n */\n get currentHour(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return this.minDayHours\n }\n set currentHour(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n get currentDay(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n set currentDay(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n storage.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n get isWeekend(): boolean {\n return this.currentWeekDayNumber >= this.weekendStartDay\n }\n /**\n * Get the current week day number (1 - {@link weekLength}).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n get currentWeekDayNumber(): number {\n let result = this.currentDay % this.weekLength\n return result + 1\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.\n * @default \"\"\n */\n get currentDayName(): string {\n let weekDayNumber = this.currentWeekDayNumber - 1\n if (weekDayNumber >= this.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, this.weekDaysNames)\n return \"\"\n }\n return this.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current {@link timeSlots} index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```tsx\n * import { weekLength } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />\n * )\n * }\n */\n get currentTimeSlot(): number {\n if (this.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < this.timeSlots.length; index++) {\n let slot = this.timeSlots[index]\n if (this.timeSlots.length > index + 1) {\n if (this.nowIsBetween(slot.startHour, this.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return this.timeSlots.length - 1\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: {@link defaultTimeSpent})\n * @returns currentTimeSlot.currentHour\n */\n increaseHour(timeSpent: number = this.defaultTimeSpent): number {\n let newHour = this.currentHour + timeSpent\n if (newHour >= this.maxDayHours) {\n this.increaseDay()\n newHour = this.minDayHours + (newHour - this.maxDayHours)\n }\n this.currentHour = newHour\n return this.currentHour\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: {@link minDayHours})\n * @param days is the number of days to increase (default: 1)\n * @returns timeTracker.currentDay\n */\n increaseDay(newDayHour: number = this.minDayHours, days: number = 1): number {\n let newDay = this.currentDay + days\n this.currentDay = newDay\n this.currentHour = newDayHour\n return this.currentDay\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the {@link currentHour} is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n nowIsBetween(fromHour: number | undefined, toHour: number | undefined): boolean {\n if (fromHour === undefined) {\n fromHour = this.minDayHours\n }\n if (toHour === undefined) {\n toHour = this.maxDayHours\n }\n let currentHour = this.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n","import NavigatorManager from \"./NavigatorManager\";\nimport QuestManager from \"./QuestManager\";\nimport RoutineManager from \"./RoutineManager\";\nimport { default as TimeManager } from \"./TimeManager\";\n\nconst timeTracker = new TimeManager();\nconst navigator = new NavigatorManager();\nconst routine = new RoutineManager();\nconst questsNotebook = new QuestManager();\n\nexport { navigator, questsNotebook, routine, timeTracker };\n","import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { StageInterface } from \"../../interface\";\nimport { StageBaseInternalInterface } from \"../../interface/quest/StageInterface\";\nimport { timeTracker } from \"../../managers\";\nimport { QuestsRequiredType } from \"../../types\";\n\nconst STAGE_CATEGORY = \"__nqtr-stage__\";\nexport default class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\toptions: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage starts.\n\t\t\t */\n\t\t\tonStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when the stage ends.\n\t\t\t */\n\t\t\tonEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The day required to start the stage.\n\t\t\t * @example If the value is 3, and the previous stage ends on day 1, the stage will start on day 4.\n\t\t\t */\n\t\t\tdaysRequiredToStart?: number;\n\t\t\t/**\n\t\t\t * The quests required to start the stage.\n\t\t\t * @default []\n\t\t\t */\n\t\t\tquestsRequiredToStart?: QuestsRequiredType[];\n\t\t} = {}\n\t) {\n\t\tsuper(STAGE_CATEGORY, id);\n\t\tthis._onStart = options.onStart;\n\t\tthis._onEnd = options.onEnd;\n\t\tthis._daysRequiredToStart = options.daysRequiredToStart;\n\t\tthis._questsRequiredToStart = options.questsRequiredToStart || [];\n\t}\n\n\tprivate _onStart?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onEnd?: (stage: StageInterface, props: OnStartEndStageQuest) => void;\n\tget onEnd(): undefined | ((stage: StageInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onEnd;\n\t}\n\n\tget completed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"completed\") || false;\n\t}\n\tset completed(value: boolean) {\n\t\tthis.setStorageProperty(\"completed\", value);\n\t}\n\n\tget started(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"started\") || false;\n\t}\n\tset started(value: boolean) {\n\t\tthis.setStorageProperty(\"started\", value);\n\t}\n\n\tprivate get prevStageEndDay(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"prevStageEndDay\");\n\t}\n\tprivate set prevStageEndDay(value: number | undefined) {\n\t\tthis.setStorageProperty(\"prevStageEndDay\", value);\n\t}\n\n\tget startDay(): number | undefined {\n\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\tif (prevStageEndDay === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn prevStageEndDay + this.daysRequiredToStart;\n\t}\n\n\tget canStart(): boolean {\n\t\tlet daysRequired = this.daysRequiredToStart;\n\t\tif (daysRequired > 0) {\n\t\t\tlet prevStageEndDay = this.prevStageEndDay;\n\t\t\tif (prevStageEndDay === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (prevStageEndDay + daysRequired > timeTracker.currentDay) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tthis.questsRequiredToStart.length > 0 &&\n\t\t\t!this.questsRequiredToStart.every(\n\t\t\t\t(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tinizialize() {\n\t\tif (this.daysRequiredToStart > 0) {\n\t\t\tthis.prevStageEndDay = timeTracker.currentDay;\n\t\t\tconsole.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);\n\t\t}\n\t}\n\n\tstart(props: OnStartEndStageQuest) {\n\t\tif (this.canStart) {\n\t\t\tthis.started = true;\n\t\t\tif (this.onStart) {\n\t\t\t\tthis.onStart(this as any as StageInterface, props);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Stage ${this.id} can't start`);\n\t\t}\n\t}\n\n\tprivate _daysRequiredToStart?: number;\n\tget daysRequiredToStart(): number {\n\t\treturn this._daysRequiredToStart || 0;\n\t}\n\n\tprivate _questsRequiredToStart: QuestsRequiredType[];\n\tget questsRequiredToStart(): QuestsRequiredType[] {\n\t\treturn this._questsRequiredToStart || [];\n\t}\n}\n","import { getFlag } from \"@drincs/pixi-vn\";\nimport { StageProps } from \"../../interface\";\nimport StageFlags from \"../../interface/quest/StageFlags\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nexport default class StageBaseModel extends StageStoredClass {\n\tconstructor(id: string, props: StageProps) {\n\t\tsuper(id, {\n\t\t\tonStart: props.onStart,\n\t\t\tonEnd: props.onEnd,\n\t\t\tdaysRequiredToStart: props.daysRequiredToStart,\n\t\t\tquestsRequiredToStart: props.questsRequiredToStart,\n\t\t});\n\t\tthis._name = props.name || \"\";\n\t\tthis._flags = props.flags || [];\n\t\tthis._description = props.description || \"\";\n\t\tthis._adviceDescription = props.adviceDescription || \"\";\n\t\tthis._image = props.image;\n\t\tthis._flagsRequiredToStart = props.flagsRequiredToStart || [];\n\t\tthis._requestDescriptionToStart = props.requestDescriptionToStart || \"\";\n\t}\n\n\tprivate _name: string;\n\t/**\n\t * The name of the stage.\n\t */\n\tget name(): string {\n\t\treturn this._name;\n\t}\n\n\tprivate _description: string;\n\t/**\n\t * The description of the stage.\n\t */\n\tget description(): string {\n\t\treturn this._description;\n\t}\n\n\tprivate _adviceDescription: string;\n\t/**\n\t * The advice description of the stage.\n\t */\n\tget adviceDescription(): string {\n\t\treturn this._adviceDescription;\n\t}\n\n\tprivate _image?: string;\n\t/**\n\t * The image of the stage.\n\t */\n\tget image(): string | undefined {\n\t\treturn this._image;\n\t}\n\n\tprivate _flags: StageFlags[];\n\t/**\n\t * The list of flags that the player must complete to finish the stage.\n\t */\n\tget flags(): StageFlags[] {\n\t\treturn this._flags;\n\t}\n\n\tprivate _flagsRequiredToStart: StageFlags[];\n\t/**\n\t * The list of flags required to start the stage.\n\t */\n\tget flagsRequiredToStart(): StageFlags[] {\n\t\treturn this._flagsRequiredToStart;\n\t}\n\n\tprivate _requestDescriptionToStart: string;\n\t/**\n\t * The description of the request to start the stage.\n\t */\n\tget requestDescriptionToStart(): string {\n\t\treturn this._requestDescriptionToStart;\n\t}\n\n\toverride get completed(): boolean {\n\t\tif (super.completed) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.flags.length > 0) {\n\t\t\tif (!this.flags.every((flag) => getFlag(flag.flag))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\toverride set completed(value: boolean) {\n\t\tsuper.completed = value;\n\t}\n\toverride get canStart(): boolean {\n\t\tif (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.canStart;\n\t}\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { OnStartEndStageQuest } from '@drincs/nqtr/dist/override';
2
2
  import { StoredClassModel } from '@drincs/pixi-vn';
3
- import { c as StageBaseInternalInterface, S as StageBaseInterface, a as QuestsRequiredType } from '../../StageInterface-DgeEtkqv.mjs';
3
+ import { c as StageBaseInternalInterface, S as StageBaseInterface, a as QuestsRequiredType } from '../../StageInterface-DmLgfrk4.mjs';
4
4
 
5
5
  declare class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {
6
6
  constructor(id: string, options?: {
@@ -1,6 +1,6 @@
1
1
  import { OnStartEndStageQuest } from '@drincs/nqtr/dist/override';
2
2
  import { StoredClassModel } from '@drincs/pixi-vn';
3
- import { c as StageBaseInternalInterface, S as StageBaseInterface, a as QuestsRequiredType } from '../../StageInterface-DgeEtkqv.js';
3
+ import { c as StageBaseInternalInterface, S as StageBaseInterface, a as QuestsRequiredType } from '../../StageInterface-DmLgfrk4.js';
4
4
 
5
5
  declare class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {
6
6
  constructor(id: string, options?: {