@drincs/nqtr 0.1.14 → 0.1.16

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 (217) hide show
  1. package/dist/ActivityProps-B1IaFbGD.d.ts +124 -0
  2. package/dist/ActivityProps-BmIzqtXr.d.mts +124 -0
  3. package/dist/{index-Cu8ZAiqF.d.ts → Commitment-BjkhJtTx.d.ts} +227 -220
  4. package/dist/{index-DhsRZJ3g.d.mts → Commitment-BxUQoZST.d.mts} +227 -220
  5. package/dist/{index-gJ26gdgL.d.mts → Quest-Bdm0R9LA.d.mts} +7 -12
  6. package/dist/{index-BjOzVDyw.d.ts → Quest-CxJcXETG.d.ts} +7 -12
  7. package/dist/classes/Activity.d.mts +41 -127
  8. package/dist/classes/Activity.d.ts +41 -127
  9. package/dist/classes/Activity.js +2 -151
  10. package/dist/classes/Activity.js.map +1 -1
  11. package/dist/classes/Activity.mjs +2 -148
  12. package/dist/classes/Activity.mjs.map +1 -1
  13. package/dist/classes/ActivityStoredAbstract.d.mts +3 -0
  14. package/dist/classes/ActivityStoredAbstract.d.ts +3 -0
  15. package/dist/classes/ActivityStoredAbstract.js +399 -0
  16. package/dist/classes/ActivityStoredAbstract.js.map +1 -0
  17. package/dist/classes/ActivityStoredAbstract.mjs +397 -0
  18. package/dist/classes/ActivityStoredAbstract.mjs.map +1 -0
  19. package/dist/classes/Commitment.d.mts +4 -1
  20. package/dist/classes/Commitment.d.ts +4 -1
  21. package/dist/classes/Commitment.js +5 -4
  22. package/dist/classes/Commitment.js.map +1 -1
  23. package/dist/classes/Commitment.mjs +5 -4
  24. package/dist/classes/Commitment.mjs.map +1 -1
  25. package/dist/classes/index.d.mts +9 -2
  26. package/dist/classes/index.d.ts +9 -2
  27. package/dist/classes/index.js +868 -5
  28. package/dist/classes/index.js.map +1 -1
  29. package/dist/classes/index.mjs +863 -6
  30. package/dist/classes/index.mjs.map +1 -1
  31. package/dist/classes/navigation/ActivityRoom.d.mts +5 -2
  32. package/dist/classes/navigation/ActivityRoom.d.ts +5 -2
  33. package/dist/classes/navigation/ActivityRoom.js +3 -3
  34. package/dist/classes/navigation/ActivityRoom.js.map +1 -1
  35. package/dist/classes/navigation/ActivityRoom.mjs +3 -3
  36. package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
  37. package/dist/classes/navigation/Location.d.mts +5 -2
  38. package/dist/classes/navigation/Location.d.ts +5 -2
  39. package/dist/classes/navigation/Location.js.map +1 -1
  40. package/dist/classes/navigation/Location.mjs.map +1 -1
  41. package/dist/classes/navigation/Map.d.mts +5 -2
  42. package/dist/classes/navigation/Map.d.ts +5 -2
  43. package/dist/classes/navigation/Map.js.map +1 -1
  44. package/dist/classes/navigation/Map.mjs.map +1 -1
  45. package/dist/classes/navigation/Room.d.mts +4 -1
  46. package/dist/classes/navigation/Room.d.ts +4 -1
  47. package/dist/classes/navigation/Room.js +3 -3
  48. package/dist/classes/navigation/Room.js.map +1 -1
  49. package/dist/classes/navigation/Room.mjs +3 -3
  50. package/dist/classes/navigation/Room.mjs.map +1 -1
  51. package/dist/classes/quest/Goal.d.mts +3 -6
  52. package/dist/classes/quest/Goal.d.ts +3 -6
  53. package/dist/classes/quest/Goal.js.map +1 -1
  54. package/dist/classes/quest/Goal.mjs.map +1 -1
  55. package/dist/classes/quest/Quest.d.mts +3 -1
  56. package/dist/classes/quest/Quest.d.ts +3 -1
  57. package/dist/classes/quest/Quest.js.map +1 -1
  58. package/dist/classes/quest/Quest.mjs.map +1 -1
  59. package/dist/classes/quest/Stage.d.mts +3 -1
  60. package/dist/classes/quest/Stage.d.ts +3 -1
  61. package/dist/classes/quest/Stage.js.map +1 -1
  62. package/dist/classes/quest/Stage.mjs.map +1 -1
  63. package/dist/decorators/ActivityDecorator.d.mts +16 -0
  64. package/dist/decorators/ActivityDecorator.d.ts +16 -0
  65. package/dist/decorators/ActivityDecorator.js.map +1 -1
  66. package/dist/decorators/ActivityDecorator.mjs.map +1 -1
  67. package/dist/decorators/CommitmentDecorator.d.mts +5 -2
  68. package/dist/decorators/CommitmentDecorator.d.ts +5 -2
  69. package/dist/decorators/CommitmentDecorator.js +3 -3
  70. package/dist/decorators/CommitmentDecorator.js.map +1 -1
  71. package/dist/decorators/CommitmentDecorator.mjs +3 -3
  72. package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
  73. package/dist/decorators/RoomDecorator.d.mts +9 -2
  74. package/dist/decorators/RoomDecorator.d.ts +9 -2
  75. package/dist/decorators/RoomDecorator.js.map +1 -1
  76. package/dist/decorators/RoomDecorator.mjs.map +1 -1
  77. package/dist/decorators/index.d.mts +4 -1
  78. package/dist/decorators/index.d.ts +4 -1
  79. package/dist/decorators/index.js +3 -3
  80. package/dist/decorators/index.js.map +1 -1
  81. package/dist/decorators/index.mjs +3 -3
  82. package/dist/decorators/index.mjs.map +1 -1
  83. package/dist/functions/ActivityFunctions.d.mts +5 -2
  84. package/dist/functions/ActivityFunctions.d.ts +5 -2
  85. package/dist/functions/ActivityFunctions.js.map +1 -1
  86. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  87. package/dist/functions/NavigationFunctions.d.mts +5 -2
  88. package/dist/functions/NavigationFunctions.d.ts +5 -2
  89. package/dist/functions/NavigationFunctions.js.map +1 -1
  90. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  91. package/dist/functions/RoutineFunctions.d.mts +5 -2
  92. package/dist/functions/RoutineFunctions.d.ts +5 -2
  93. package/dist/functions/RoutineFunctions.js.map +1 -1
  94. package/dist/functions/RoutineFunctions.mjs.map +1 -1
  95. package/dist/functions/index.d.mts +5 -2
  96. package/dist/functions/index.d.ts +5 -2
  97. package/dist/functions/index.js.map +1 -1
  98. package/dist/functions/index.mjs.map +1 -1
  99. package/dist/index.d.mts +9 -4
  100. package/dist/index.d.ts +9 -4
  101. package/dist/index.js +155 -154
  102. package/dist/index.js.map +1 -1
  103. package/dist/index.mjs +155 -154
  104. package/dist/index.mjs.map +1 -1
  105. package/dist/interface/ActivityProps.d.mts +3 -0
  106. package/dist/interface/ActivityProps.d.ts +3 -0
  107. package/dist/{override/GraphicHTMLElement.js → interface/ActivityProps.js} +1 -1
  108. package/dist/interface/ActivityProps.mjs +3 -0
  109. package/dist/interface/CommitmentProps.d.mts +8 -0
  110. package/dist/interface/CommitmentProps.d.ts +8 -0
  111. package/dist/{override/OnRunActivityProps.js → interface/CommitmentProps.js} +1 -1
  112. package/dist/interface/CommitmentProps.mjs +3 -0
  113. package/dist/interface/RoomActivityMemory.d.mts +9 -0
  114. package/dist/interface/RoomActivityMemory.d.ts +9 -0
  115. package/dist/interface/RoomActivityMemory.js +4 -0
  116. package/dist/interface/RoomActivityMemory.js.map +1 -0
  117. package/dist/interface/RoomActivityMemory.mjs +3 -0
  118. package/dist/interface/RoomActivityMemory.mjs.map +1 -0
  119. package/dist/interface/RoomProps.d.mts +8 -0
  120. package/dist/interface/RoomProps.d.ts +8 -0
  121. package/dist/interface/RoomProps.js +4 -0
  122. package/dist/interface/RoomProps.js.map +1 -0
  123. package/dist/interface/RoomProps.mjs +3 -0
  124. package/dist/interface/RoomProps.mjs.map +1 -0
  125. package/dist/interface/index.d.mts +12 -0
  126. package/dist/interface/index.d.ts +12 -0
  127. package/dist/interface/index.js +4 -0
  128. package/dist/interface/index.js.map +1 -0
  129. package/dist/interface/index.mjs +3 -0
  130. package/dist/interface/index.mjs.map +1 -0
  131. package/dist/interface/navigation/LocationProps.d.mts +8 -0
  132. package/dist/interface/navigation/LocationProps.d.ts +8 -0
  133. package/dist/interface/navigation/LocationProps.js +4 -0
  134. package/dist/interface/navigation/LocationProps.js.map +1 -0
  135. package/dist/interface/navigation/LocationProps.mjs +3 -0
  136. package/dist/interface/navigation/LocationProps.mjs.map +1 -0
  137. package/dist/interface/navigation/MapProps.d.mts +8 -0
  138. package/dist/interface/navigation/MapProps.d.ts +8 -0
  139. package/dist/interface/navigation/MapProps.js +4 -0
  140. package/dist/interface/navigation/MapProps.js.map +1 -0
  141. package/dist/interface/navigation/MapProps.mjs +3 -0
  142. package/dist/interface/navigation/MapProps.mjs.map +1 -0
  143. package/dist/interface/quest/GoalProps.d.mts +7 -0
  144. package/dist/interface/quest/GoalProps.d.ts +7 -0
  145. package/dist/interface/quest/GoalProps.js +4 -0
  146. package/dist/interface/quest/GoalProps.js.map +1 -0
  147. package/dist/interface/quest/GoalProps.mjs +3 -0
  148. package/dist/interface/quest/GoalProps.mjs.map +1 -0
  149. package/dist/interface/quest/QuestProps.d.mts +9 -0
  150. package/dist/interface/quest/QuestProps.d.ts +9 -0
  151. package/dist/interface/quest/QuestProps.js +4 -0
  152. package/dist/interface/quest/QuestProps.js.map +1 -0
  153. package/dist/interface/quest/QuestProps.mjs +3 -0
  154. package/dist/interface/quest/QuestProps.mjs.map +1 -0
  155. package/dist/interface/quest/StageProps.d.mts +5 -0
  156. package/dist/interface/quest/StageProps.d.ts +5 -0
  157. package/dist/interface/quest/StageProps.js +4 -0
  158. package/dist/interface/quest/StageProps.js.map +1 -0
  159. package/dist/interface/quest/StageProps.mjs +3 -0
  160. package/dist/interface/quest/StageProps.mjs.map +1 -0
  161. package/dist/managers/TimeManager.d.mts +1 -1
  162. package/dist/managers/TimeManager.d.ts +1 -1
  163. package/dist/managers/TimeManager.js +1 -1
  164. package/dist/managers/TimeManager.js.map +1 -1
  165. package/dist/managers/TimeManager.mjs +1 -1
  166. package/dist/managers/TimeManager.mjs.map +1 -1
  167. package/dist/managers/index.js +1 -1
  168. package/dist/managers/index.js.map +1 -1
  169. package/dist/managers/index.mjs +1 -1
  170. package/dist/managers/index.mjs.map +1 -1
  171. package/dist/override/GraphicItemType.d.mts +3 -4
  172. package/dist/override/GraphicItemType.d.ts +3 -4
  173. package/dist/override/{OnRunActivityProps.d.mts → OnRunProps.d.mts} +3 -3
  174. package/dist/override/{OnRunActivityProps.d.ts → OnRunProps.d.ts} +3 -3
  175. package/dist/override/OnRunProps.js +4 -0
  176. package/dist/override/OnRunProps.js.map +1 -0
  177. package/dist/override/OnRunProps.mjs +3 -0
  178. package/dist/override/OnRunProps.mjs.map +1 -0
  179. package/dist/override/index.d.mts +1 -2
  180. package/dist/override/index.d.ts +1 -2
  181. package/dist/types/OnRunActivityEvent.d.mts +8 -0
  182. package/dist/types/OnRunActivityEvent.d.ts +8 -0
  183. package/dist/types/OnRunActivityEvent.js +4 -0
  184. package/dist/types/OnRunActivityEvent.js.map +1 -0
  185. package/dist/types/OnRunActivityEvent.mjs +3 -0
  186. package/dist/types/OnRunActivityEvent.mjs.map +1 -0
  187. package/dist/types/OnRunCommitmentEvent.d.mts +8 -0
  188. package/dist/types/OnRunCommitmentEvent.d.ts +8 -0
  189. package/dist/types/OnRunCommitmentEvent.js +4 -0
  190. package/dist/types/OnRunCommitmentEvent.js.map +1 -0
  191. package/dist/types/OnRunCommitmentEvent.mjs +3 -0
  192. package/dist/types/OnRunCommitmentEvent.mjs.map +1 -0
  193. package/dist/types/QuestsRequired.d.mts +4 -2
  194. package/dist/types/QuestsRequired.d.ts +4 -2
  195. package/dist/types/index.d.mts +4 -2
  196. package/dist/types/index.d.ts +4 -2
  197. package/package.json +1 -1
  198. package/dist/classes/navigation/index.d.mts +0 -5
  199. package/dist/classes/navigation/index.d.ts +0 -5
  200. package/dist/classes/navigation/index.js +0 -987
  201. package/dist/classes/navigation/index.js.map +0 -1
  202. package/dist/classes/navigation/index.mjs +0 -983
  203. package/dist/classes/navigation/index.mjs.map +0 -1
  204. package/dist/classes/quest/index.d.mts +0 -3
  205. package/dist/classes/quest/index.d.ts +0 -3
  206. package/dist/classes/quest/index.js +0 -133
  207. package/dist/classes/quest/index.js.map +0 -1
  208. package/dist/classes/quest/index.mjs +0 -129
  209. package/dist/classes/quest/index.mjs.map +0 -1
  210. package/dist/override/GraphicHTMLElement.d.mts +0 -7
  211. package/dist/override/GraphicHTMLElement.d.ts +0 -7
  212. package/dist/override/GraphicHTMLElement.mjs +0 -3
  213. package/dist/override/OnRunActivityProps.mjs +0 -3
  214. /package/dist/{override/GraphicHTMLElement.js.map → interface/ActivityProps.js.map} +0 -0
  215. /package/dist/{override/GraphicHTMLElement.mjs.map → interface/ActivityProps.mjs.map} +0 -0
  216. /package/dist/{override/OnRunActivityProps.js.map → interface/CommitmentProps.js.map} +0 -0
  217. /package/dist/{override/OnRunActivityProps.mjs.map → interface/CommitmentProps.mjs.map} +0 -0
@@ -1,6 +1,21 @@
1
1
  import { getFlag, StoredClassModel, GameStorageManager } from '@drincs/pixi-vn';
2
2
 
3
- // src/classes/Activity.ts
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
4
19
  var TIME_SETTINGS_KEY = "___nqtr-time_manager_settings___";
5
20
  var TIME_DATA_KEY = "___nqtr-time_manager_data___";
6
21
  var TimeManager = class _TimeManager {
@@ -178,7 +193,7 @@ var TimeManager = class _TimeManager {
178
193
  * Get the current TimeManager.timeSlots index.
179
194
  * You can use this property to create "Image that changes based on the time period":
180
195
  * @example
181
- * ```ts
196
+ * ```tsx
182
197
  * import { TimeManager } from '@drincs/nqtr';
183
198
  *
184
199
  * function changeBackground() {
@@ -480,11 +495,12 @@ var CommitmentBaseModel = class extends StoredClassModel {
480
495
  * Is a function that is called when the player interacts with the character.
481
496
  */
482
497
  onRun() {
483
- if (!this._onRun) {
498
+ let onRun = this._onRun;
499
+ if (!onRun) {
484
500
  console.warn("[NQTR] onRun() is not defined for commitmen, so it will not run.", this);
485
- } else {
486
- this._onRun(this);
501
+ return;
487
502
  }
503
+ return (props) => onRun(this, props);
488
504
  }
489
505
  /**
490
506
  * Whether is disabled. You can also pass a Pixi'VN flag name.
@@ -533,6 +549,847 @@ var CommitmentBaseModel = class extends StoredClassModel {
533
549
  }
534
550
  };
535
551
 
536
- export { ActivityModel, CommitmentBaseModel };
552
+ // src/decorators/RoomDecorator.ts
553
+ var registeredRooms = {};
554
+ function getRoomsByLocation(location) {
555
+ return Object.values(registeredRooms).filter((room) => room.location.id === location.id);
556
+ }
557
+ function getAllLocations() {
558
+ let result = {};
559
+ Object.values(registeredRooms).forEach((room) => {
560
+ result[room.location.id] = room.location;
561
+ });
562
+ return Object.values(result);
563
+ }
564
+ function getLocationsByMap(map) {
565
+ return getAllLocations().filter((location) => location.map.id === map.id);
566
+ }
567
+
568
+ // src/classes/navigation/Location.ts
569
+ var LOCATION_CATEGORY = "__nqtr-location__";
570
+ var LocationBaseModel = class extends StoredClassModel {
571
+ /**
572
+ * @param id The id of the location, it must be unique.
573
+ * @param map The map where the location is.
574
+ * @param props The properties of the location.
575
+ */
576
+ constructor(id, map, props = {}) {
577
+ super(LOCATION_CATEGORY, id);
578
+ this.defaultName = props.name || "";
579
+ this.defaultDisabled = props.disabled || false;
580
+ this.defaultHidden = props.hidden || false;
581
+ this._renderIcon = props.renderIcon;
582
+ this._map = map;
583
+ }
584
+ /**
585
+ * The name of the location.
586
+ * If you set undefined, it will return the initial value of name.
587
+ */
588
+ get name() {
589
+ return this.getStorageProperty("name") || this.defaultName;
590
+ }
591
+ set name(value) {
592
+ this.setStorageProperty("name", value);
593
+ }
594
+ /**
595
+ * Whether is disabled. If it is a string, it is a Pixi'VN flag name.
596
+ */
597
+ get disabled() {
598
+ let value = this.getStorageProperty("disabled") || this.defaultDisabled;
599
+ if (typeof value === "string") {
600
+ return getFlag(value);
601
+ }
602
+ return value;
603
+ }
604
+ set disabled(value) {
605
+ this.setStorageProperty("disabled", value);
606
+ }
607
+ /**
608
+ * Whether is hidden. If it is a string, it is a Pixi'VN flag name.
609
+ */
610
+ get hidden() {
611
+ let value = this.getStorageProperty("hidden") || this.defaultHidden;
612
+ if (typeof value === "string") {
613
+ return getFlag(value);
614
+ }
615
+ return value;
616
+ }
617
+ set hidden(value) {
618
+ this.setStorageProperty("hidden", value);
619
+ }
620
+ /**
621
+ * The function for rendering the icon of the location.
622
+ */
623
+ get renderIcon() {
624
+ let render = this._renderIcon;
625
+ if (render === void 0) {
626
+ return void 0;
627
+ }
628
+ if (typeof render === "function") {
629
+ return (props) => {
630
+ return render(this, props);
631
+ };
632
+ }
633
+ return (props) => render;
634
+ }
635
+ /**
636
+ * The map where the location is.
637
+ */
638
+ get map() {
639
+ return this._map;
640
+ }
641
+ /**
642
+ * Get the entrance room of the location.
643
+ * You can cast the room to a specific type that extends RoomBaseModel.
644
+ * @returns The entrance room or the first room if there is no entrance.
645
+ * @example
646
+ * ```typescript
647
+ * const entranceHome = new RoomBaseModel("entrance-home", home, { isEntrance: true })
648
+ * saveRoom(entranceHome)
649
+ * const home = new LocationBaseModel("home", map, { name: "Home" })
650
+ *
651
+ * const entrance = home.getEntrance() // entrance === entranceHome
652
+ * ```
653
+ */
654
+ getEntrance() {
655
+ let rooms = this.getRooms();
656
+ if (rooms.length === 0) {
657
+ console.error(`[NQTR] The location ${this.id} has no rooms`);
658
+ return;
659
+ }
660
+ return rooms.find((room) => room.isEntrance) || rooms[0];
661
+ }
662
+ /**
663
+ * Get all rooms in the location.
664
+ * You can cast the rooms to a specific type that extends RoomBaseModel.
665
+ * @returns The rooms in the location.
666
+ */
667
+ getRooms() {
668
+ return getRoomsByLocation(this);
669
+ }
670
+ };
671
+ var MAP_CATEGORY = "__nqtr-map__";
672
+ var MapBaseModel = class extends StoredClassModel {
673
+ /**
674
+ * @param id The id of the map, it must be unique.
675
+ * @param props The properties of the map.
676
+ */
677
+ constructor(id, props = {}) {
678
+ super(MAP_CATEGORY, id);
679
+ this.defaultName = props.name || "";
680
+ this._renderImage = props.renderImage;
681
+ this.defaultDisabled = props.disabled || false;
682
+ this.defaultHidden = props.hidden || false;
683
+ }
684
+ /**
685
+ * The name of the map.
686
+ * If you set undefined, it will return the initial value of name.
687
+ */
688
+ get name() {
689
+ return this.getStorageProperty("name") || this.defaultName;
690
+ }
691
+ set name(value) {
692
+ this.setStorageProperty("name", value);
693
+ }
694
+ /**
695
+ * The function for rendering the image of the map.
696
+ */
697
+ get renderImage() {
698
+ let render = this._renderImage;
699
+ if (render === void 0) {
700
+ return void 0;
701
+ }
702
+ if (typeof render === "function") {
703
+ return (props) => {
704
+ return render(this, props);
705
+ };
706
+ }
707
+ return (props) => render;
708
+ }
709
+ /**
710
+ * Whether is disabled. If it is a string, it is a Pixi'VN flag name.
711
+ */
712
+ get disabled() {
713
+ let value = this.getStorageProperty("disabled") || this.defaultDisabled;
714
+ if (typeof value === "string") {
715
+ return getFlag(value);
716
+ }
717
+ return value;
718
+ }
719
+ set disabled(value) {
720
+ this.setStorageProperty("disabled", value);
721
+ }
722
+ /**
723
+ * Whether is hidden. If it is a string, it is a Pixi'VN flag name.
724
+ */
725
+ get hidden() {
726
+ let value = this.getStorageProperty("hidden") || this.defaultHidden;
727
+ if (typeof value === "string") {
728
+ return getFlag(value);
729
+ }
730
+ return value;
731
+ }
732
+ set hidden(value) {
733
+ this.setStorageProperty("hidden", value);
734
+ }
735
+ /**
736
+ * The neighboring maps that are available in this map.
737
+ * @example
738
+ * ```ts
739
+ * {
740
+ * "north": "atlanta_map_id",
741
+ * "south": "miami_map_id",
742
+ * "east": "new_york_map_id",
743
+ * "west": "los_angeles_map_id"
744
+ * }
745
+ * ```
746
+ */
747
+ get neighboringMaps() {
748
+ return this._neighboringMaps || {};
749
+ }
750
+ set neighboringMaps(value) {
751
+ this._neighboringMaps = value;
752
+ }
753
+ /**
754
+ * Get all locations in the map.
755
+ * @returns The locations in the map.
756
+ */
757
+ getLocations() {
758
+ return getLocationsByMap(this);
759
+ }
760
+ };
761
+
762
+ // src/decorators/ActivityDecorator.ts
763
+ var registeredActivities = {};
764
+ function getActivityById(id) {
765
+ try {
766
+ let activity = registeredActivities[id];
767
+ if (!activity) {
768
+ console.error(`[NQTR] Activity ${id} not found`);
769
+ return;
770
+ }
771
+ return activity;
772
+ } catch (e) {
773
+ console.error(`[NQTR] Error while getting Activity ${id}`, e);
774
+ return;
775
+ }
776
+ }
777
+ var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
778
+ var registeredCommitments = {};
779
+ var fixedCommitments = {};
780
+ function getCommitmentById(id) {
781
+ try {
782
+ let commitment = registeredCommitments[id];
783
+ if (!commitment) {
784
+ console.error(`[NQTR] Commitment ${id} not found`);
785
+ return;
786
+ }
787
+ return commitment;
788
+ } catch (e) {
789
+ console.error(`[NQTR] Error while getting Commitment ${id}`, e);
790
+ return;
791
+ }
792
+ }
793
+ function getFixedCommitments() {
794
+ return Object.values(fixedCommitments);
795
+ }
796
+ function getTemporaryCommitments() {
797
+ let commitmentsIds = GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
798
+ if (!commitmentsIds) {
799
+ return [];
800
+ }
801
+ let commitments = commitmentsIds.map((id) => getCommitmentById(id)).filter((commitment) => commitment !== void 0);
802
+ return commitments;
803
+ }
804
+
805
+ // src/functions/RoutineFunctions.ts
806
+ function getCurrentCommitments() {
807
+ let character_commitments = {};
808
+ let oltherCommitments = [];
809
+ getTemporaryCommitments().reverse().forEach((c) => {
810
+ if (!c.hidden) {
811
+ if (c.characters.length > 1) {
812
+ let allAvailable = c.characters.every((ch) => !character_commitments[ch.id]);
813
+ if (allAvailable) {
814
+ c.characters.forEach((ch) => {
815
+ character_commitments[ch.id] = c;
816
+ });
817
+ }
818
+ } else {
819
+ oltherCommitments.push(c);
820
+ }
821
+ }
822
+ });
823
+ getFixedCommitments().reverse().forEach((c) => {
824
+ if (!c.hidden) {
825
+ if (c.characters.length > 1) {
826
+ c.characters.forEach((ch) => {
827
+ if (!character_commitments[ch.id]) {
828
+ character_commitments[ch.id] = c;
829
+ }
830
+ });
831
+ } else {
832
+ oltherCommitments.push(c);
833
+ }
834
+ }
835
+ });
836
+ return Object.values(character_commitments).concat(oltherCommitments);
837
+ }
838
+ var ActivityStoredAbstract = class {
839
+ /**
840
+ * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
841
+ * @param props The activity properties.
842
+ */
843
+ constructor(onRun, props) {
844
+ this.defaultName = props.name;
845
+ this.defaultFromHour = props.fromHour;
846
+ this.defaultToHour = props.toHour;
847
+ this.defaultFromDay = props.fromDay;
848
+ this.defaultToDay = props.toDay;
849
+ this.defaultDisabled = props.disabled || false;
850
+ this.defaultHidden = props.hidden || false;
851
+ this._renderIcon = props.renderIcon;
852
+ this._onRun = onRun;
853
+ }
854
+ /**
855
+ * The name
856
+ */
857
+ get name() {
858
+ return this.getStorageProperty("name") || this.defaultName || "";
859
+ }
860
+ set name(value) {
861
+ this.setStorageProperty("name", value);
862
+ }
863
+ /**
864
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
865
+ */
866
+ get fromHour() {
867
+ return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
868
+ }
869
+ set fromHour(value) {
870
+ this.setStorageProperty("fromHour", value);
871
+ }
872
+ /**
873
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
874
+ */
875
+ get toHour() {
876
+ return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
877
+ }
878
+ set toHour(value) {
879
+ this.setStorageProperty("toHour", value);
880
+ }
881
+ /**
882
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
883
+ */
884
+ get fromDay() {
885
+ return this.getStorageProperty("fromDay") || this.defaultFromDay;
886
+ }
887
+ set fromDay(value) {
888
+ this.setStorageProperty("fromDay", value);
889
+ }
890
+ /**
891
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
892
+ */
893
+ get toDay() {
894
+ return this.getStorageProperty("toDay") || this.defaultToDay;
895
+ }
896
+ set toDay(value) {
897
+ this.setStorageProperty("toDay", value);
898
+ }
899
+ /**
900
+ * Whether is disabled.
901
+ */
902
+ get disabled() {
903
+ let value = this.getStorageProperty("disabled") || this.defaultDisabled;
904
+ if (typeof value === "string") {
905
+ return getFlag(value);
906
+ }
907
+ return value;
908
+ }
909
+ set disabled(value) {
910
+ this.setStorageProperty("disabled", value);
911
+ }
912
+ /**
913
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
914
+ */
915
+ get hidden() {
916
+ if (this.fromDay && this.fromDay > TimeManager.currentDay) {
917
+ return true;
918
+ }
919
+ if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
920
+ return true;
921
+ }
922
+ if (!this.isExpired) {
923
+ return true;
924
+ }
925
+ let value = this.getStorageProperty("hidden") || this.defaultHidden;
926
+ if (typeof value === "string") {
927
+ return getFlag(value);
928
+ }
929
+ return value;
930
+ }
931
+ set hidden(value) {
932
+ this.setStorageProperty("hidden", value);
933
+ }
934
+ /**
935
+ * The function for rendering the icon of the activity.
936
+ */
937
+ get renderIcon() {
938
+ let render = this._renderIcon;
939
+ if (render === void 0) {
940
+ return void 0;
941
+ }
942
+ if (typeof render === "function") {
943
+ return (props) => {
944
+ return render(this, props);
945
+ };
946
+ }
947
+ return (props) => render;
948
+ }
949
+ /**
950
+ * The function that is called when the activity is runned.
951
+ */
952
+ get onRun() {
953
+ return (props) => {
954
+ return this._onRun(this, props);
955
+ };
956
+ }
957
+ /**
958
+ * Whether the activity is a deadline.
959
+ * @returns Whether the activity is a deadline.
960
+ */
961
+ isExpired() {
962
+ if (this.toDay && this.toDay <= TimeManager.currentDay) {
963
+ return true;
964
+ }
965
+ return false;
966
+ }
967
+ /**
968
+ * Export the activity properties.
969
+ * @returns The activity properties.
970
+ */
971
+ export() {
972
+ return {
973
+ name: this.getStorageProperty("name") || this.defaultName,
974
+ fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
975
+ toHour: this.getStorageProperty("toHour") || this.defaultToHour,
976
+ fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
977
+ toDay: this.getStorageProperty("toDay") || this.defaultToDay,
978
+ disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
979
+ hidden: this.getStorageProperty("hidden") || this.defaultHidden,
980
+ renderIcon: this._renderIcon
981
+ };
982
+ }
983
+ };
984
+
985
+ // src/classes/navigation/ActivityRoom.ts
986
+ var ActivityRoom = class extends ActivityStoredAbstract {
987
+ constructor(id, room, onRun, props) {
988
+ super(onRun, props);
989
+ this._id = id;
990
+ this._room = room;
991
+ }
992
+ setStorageProperty(_, __) {
993
+ this._room.setActivity(this);
994
+ }
995
+ getStorageProperty(propertyName) {
996
+ let activity = this._room.getActivityMemory(this.id);
997
+ if (!activity || !activity.hasOwnProperty(propertyName)) {
998
+ return void 0;
999
+ }
1000
+ return activity[propertyName];
1001
+ }
1002
+ get id() {
1003
+ return this._id;
1004
+ }
1005
+ get room() {
1006
+ return this._room;
1007
+ }
1008
+ export() {
1009
+ let result = {};
1010
+ if (this.name !== void 0) {
1011
+ result["name"] = this.name;
1012
+ }
1013
+ if (this.fromHour !== void 0) {
1014
+ result["fromHour"] = this.fromHour;
1015
+ }
1016
+ if (this.toHour !== void 0) {
1017
+ result["toHour"] = this.toHour;
1018
+ }
1019
+ if (this.fromDay !== void 0) {
1020
+ result["fromDay"] = this.fromDay;
1021
+ }
1022
+ if (this.toDay !== void 0) {
1023
+ result["toDay"] = this.toDay;
1024
+ }
1025
+ if (this.disabled !== void 0) {
1026
+ result["disabled"] = this.disabled;
1027
+ }
1028
+ return result;
1029
+ }
1030
+ };
1031
+
1032
+ // src/classes/navigation/Room.ts
1033
+ var ROOM_CATEGORY = "__nqtr-room__";
1034
+ var RoomBaseModel = class extends StoredClassModel {
1035
+ /**
1036
+ * @param id The id of the room, it must be unique.
1037
+ * @param location The location where the room is.
1038
+ * @param props The properties of the room.
1039
+ */
1040
+ constructor(id, location, props = {}) {
1041
+ var _a;
1042
+ super(ROOM_CATEGORY, id);
1043
+ this._location = location;
1044
+ this.defaultName = props.name || "";
1045
+ this._renderImage = props.renderImage;
1046
+ this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
1047
+ this.defaultDisabled = props.disabled || false;
1048
+ this.defaultHidden = props.hidden || false;
1049
+ this._renderIcon = props.renderIcon;
1050
+ this._isEntrance = props.isEntrance;
1051
+ }
1052
+ /**
1053
+ * The location where the room is.
1054
+ */
1055
+ get location() {
1056
+ return this._location;
1057
+ }
1058
+ /**
1059
+ * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
1060
+ */
1061
+ get isEntrance() {
1062
+ return this._isEntrance || false;
1063
+ }
1064
+ /**
1065
+ * The name.
1066
+ * If you set undefined, it will return the initial value of name.
1067
+ */
1068
+ get name() {
1069
+ return this.getStorageProperty("name") || this.defaultName;
1070
+ }
1071
+ set name(value) {
1072
+ this.setStorageProperty("name", value);
1073
+ }
1074
+ /**
1075
+ * The function for rendering the image of the room.
1076
+ */
1077
+ get renderImage() {
1078
+ let render = this._renderImage;
1079
+ if (render === void 0) {
1080
+ return void 0;
1081
+ }
1082
+ if (typeof render === "function") {
1083
+ return (props) => {
1084
+ return render(this, props);
1085
+ };
1086
+ }
1087
+ return (props) => render;
1088
+ }
1089
+ /**
1090
+ * The activities that are available in this room.
1091
+ */
1092
+ get defaultActivities() {
1093
+ let roomMemories = this.getStorageProperty("activities_memory") || {};
1094
+ let activities = this.defaultActivityIds.map((id) => {
1095
+ let activity = getActivityById(id);
1096
+ if (!activity) {
1097
+ console.warn(`[NQTR] Activity with id ${id} not found, so it will be ignored.`);
1098
+ return void 0;
1099
+ }
1100
+ let memory = activity.export();
1101
+ if (roomMemories && roomMemories[id]) {
1102
+ memory = __spreadValues(__spreadValues({}, memory), roomMemories[id]);
1103
+ }
1104
+ return new ActivityRoom(id, this, activity._initialOnRun, memory);
1105
+ }).filter((activity) => activity !== void 0);
1106
+ return activities;
1107
+ }
1108
+ get activityIds() {
1109
+ let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
1110
+ return this.defaultActivityIds.concat(addedActivityIds);
1111
+ }
1112
+ /**
1113
+ * The activities that are available in this room.
1114
+ */
1115
+ get activities() {
1116
+ let activities = this.activityIds.map((id) => {
1117
+ return this.getActivity(id);
1118
+ }).filter((activity) => activity !== void 0 && !activity.hidden);
1119
+ return activities;
1120
+ }
1121
+ /**
1122
+ * Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.
1123
+ * @param id The id of the activity.
1124
+ * @returns The memory of the activity.
1125
+ */
1126
+ getActivityMemory(id) {
1127
+ let roomMemories = this.getStorageProperty("activities_memory") || {};
1128
+ let roomMemory = roomMemories[id] || {};
1129
+ return roomMemory;
1130
+ }
1131
+ /**
1132
+ * Get the activity by id.
1133
+ * @param id The id of the activity.
1134
+ * @returns The room activity.
1135
+ */
1136
+ getActivity(id) {
1137
+ if (!this.activityIds.includes(id)) {
1138
+ console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`);
1139
+ return void 0;
1140
+ }
1141
+ let activity = getActivityById(id);
1142
+ if (!activity) {
1143
+ console.error(`[NQTR] Activity with id ${id} not found`);
1144
+ return void 0;
1145
+ }
1146
+ let roomMemories = this.getStorageProperty("activities_memory") || {};
1147
+ let roomMemory = roomMemories[id] || {};
1148
+ roomMemory = __spreadValues(__spreadValues({}, activity.export()), roomMemory);
1149
+ return new ActivityRoom(id, this, activity._initialOnRun, roomMemory);
1150
+ }
1151
+ /**
1152
+ * Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.
1153
+ * @param id The id of the activity.
1154
+ * @param memory The memory of the activity.
1155
+ */
1156
+ setActivity(activity) {
1157
+ let roomMemories = this.getStorageProperty("activities_memory") || {};
1158
+ roomMemories[activity.id] = activity.export();
1159
+ this.setStorageProperty("activities_memory", roomMemories);
1160
+ }
1161
+ /**
1162
+ * Add an activity to the room.
1163
+ * @param activity The activity to add.
1164
+ */
1165
+ addActivity(activity) {
1166
+ if (this.activityIds.includes(activity.id)) {
1167
+ let currentActivity = this.getActivity(activity.id);
1168
+ if (currentActivity && currentActivity.isExpired()) {
1169
+ this.removeActivity(activity.id);
1170
+ return;
1171
+ } else {
1172
+ console.error(`[NQTR] Activity with id ${activity.id} already exists in room ${this.id}, so it will be ignored.`);
1173
+ return;
1174
+ }
1175
+ }
1176
+ let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
1177
+ addedActivityIds.push(activity.id);
1178
+ this.setStorageProperty("addedActivityIds", addedActivityIds);
1179
+ }
1180
+ /**
1181
+ * Remove an activity from the room.
1182
+ * @param activity The activity to remove.
1183
+ */
1184
+ removeActivity(activity) {
1185
+ let activityId = typeof activity === "string" ? activity : activity.id;
1186
+ if (this.defaultActivityIds.includes(activityId)) {
1187
+ console.warn(`[NQTR] Activity with id ${activityId} is a default activity, so it can't be removed. It will be hidden instead.`);
1188
+ let activityToEdit = this.getActivity(activityId);
1189
+ if (!activityToEdit) {
1190
+ console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be hidden.`);
1191
+ return;
1192
+ }
1193
+ activityToEdit.hidden = true;
1194
+ return;
1195
+ }
1196
+ let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
1197
+ let index = addedActivityIds.indexOf(activityId);
1198
+ if (index === -1) {
1199
+ console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be removed.`);
1200
+ return;
1201
+ }
1202
+ addedActivityIds.splice(index, 1);
1203
+ this.setStorageProperty("addedActivityIds", addedActivityIds);
1204
+ let roomMemories = this.getStorageProperty("activities_memory") || {};
1205
+ delete roomMemories[activityId];
1206
+ this.setStorageProperty("activities_memory", roomMemories);
1207
+ }
1208
+ /**
1209
+ * Clear all expired activities.
1210
+ */
1211
+ clearExpiredActivities() {
1212
+ this.activities.forEach((activity) => {
1213
+ if (activity.isExpired()) {
1214
+ this.removeActivity(activity.id);
1215
+ }
1216
+ });
1217
+ }
1218
+ /**
1219
+ * Whether is disabled. If it is a string, it is a Pixi'VN flag name.
1220
+ */
1221
+ get disabled() {
1222
+ let value = this.getStorageProperty("disabled") || this.defaultDisabled;
1223
+ if (typeof value === "string") {
1224
+ return getFlag(value);
1225
+ }
1226
+ return value;
1227
+ }
1228
+ set disabled(value) {
1229
+ this.setStorageProperty("disabled", value);
1230
+ }
1231
+ /**
1232
+ * Whether is hidden. If it is a string, it is a Pixi'VN flag name.
1233
+ */
1234
+ get hidden() {
1235
+ let value = this.getStorageProperty("hidden") || this.defaultHidden;
1236
+ if (typeof value === "string") {
1237
+ return getFlag(value);
1238
+ }
1239
+ return value;
1240
+ }
1241
+ set hidden(value) {
1242
+ this.setStorageProperty("hidden", value);
1243
+ }
1244
+ /**
1245
+ * The function for rendering the icon of the room.
1246
+ */
1247
+ get renderIcon() {
1248
+ let render = this._renderIcon;
1249
+ if (render === void 0) {
1250
+ return void 0;
1251
+ }
1252
+ if (typeof render === "function") {
1253
+ return (props) => {
1254
+ return render(this, props);
1255
+ };
1256
+ }
1257
+ return (props) => render;
1258
+ }
1259
+ /**
1260
+ * Get the character commitments of the room.
1261
+ * @returns The character commitments of the room.
1262
+ */
1263
+ getRoutine() {
1264
+ let commitments = getCurrentCommitments();
1265
+ return commitments.filter((c) => c.room.id === this.id);
1266
+ }
1267
+ };
1268
+
1269
+ // src/classes/quest/Goal.ts
1270
+ var Goal = class {
1271
+ constructor(props) {
1272
+ this._description = props.description;
1273
+ this.need = props.need || 1;
1274
+ this.have = props.have || 0;
1275
+ }
1276
+ get description() {
1277
+ return this._description;
1278
+ }
1279
+ get isComplete() {
1280
+ return this.have >= this.need;
1281
+ }
1282
+ setComplete() {
1283
+ this.have = this.need;
1284
+ }
1285
+ find() {
1286
+ this.have++;
1287
+ }
1288
+ get export() {
1289
+ return {
1290
+ description: this.description,
1291
+ need: this.need,
1292
+ have: this.have
1293
+ };
1294
+ }
1295
+ };
1296
+ var QUEST_CATEGORY = "__nqtr-quest__";
1297
+ var QuestBaseModel = class extends StoredClassModel {
1298
+ constructor(id, stages, props) {
1299
+ super(QUEST_CATEGORY, id);
1300
+ this._stages = stages;
1301
+ this._name = props.name || "";
1302
+ this._description = props.description || "";
1303
+ this._icon = props.icon || "";
1304
+ this._image = props.image || "";
1305
+ this._isInDevelopment = props.isInDevelopment || false;
1306
+ }
1307
+ get stages() {
1308
+ return this._stages;
1309
+ }
1310
+ get name() {
1311
+ return this._name;
1312
+ }
1313
+ get description() {
1314
+ return this._description;
1315
+ }
1316
+ get icon() {
1317
+ return this._icon;
1318
+ }
1319
+ get image() {
1320
+ return this._image;
1321
+ }
1322
+ get isInDevelopment() {
1323
+ return this._isInDevelopment;
1324
+ }
1325
+ };
1326
+ var STAGE_CATEGORY = "__nqtr-stage__";
1327
+ var StageBaseModel = class extends StoredClassModel {
1328
+ constructor(id, props) {
1329
+ super(STAGE_CATEGORY, id);
1330
+ this._completed = false;
1331
+ this._active = false;
1332
+ this.defaultGoals = [];
1333
+ this._name = props.name || "";
1334
+ this._description = props.description || "";
1335
+ this._adviceDescription = props.adviceDescription || "";
1336
+ this._image = props.image || "";
1337
+ this._daysRequiredToStart = props.daysRequiredToStart;
1338
+ this._flagsRequired = props.flagsRequired;
1339
+ this._questsRequired = props.questsRequired;
1340
+ this._requestDescription = props.requestDescription || "";
1341
+ this._onStart = props.onStart;
1342
+ this._onEnd = props.onEnd;
1343
+ }
1344
+ get completed() {
1345
+ return this._completed;
1346
+ }
1347
+ get active() {
1348
+ return this._active;
1349
+ }
1350
+ get goals() {
1351
+ let list = this.getStorageProperty("goals");
1352
+ if (!list) {
1353
+ return this.defaultGoals;
1354
+ }
1355
+ return list.map((goal) => new Goal(goal));
1356
+ }
1357
+ set goals(value) {
1358
+ let list = value.map((goal) => goal.export);
1359
+ this.setStorageProperty("goals", list);
1360
+ }
1361
+ get name() {
1362
+ return this._name;
1363
+ }
1364
+ get description() {
1365
+ return this._description;
1366
+ }
1367
+ get adviceDescription() {
1368
+ return this._adviceDescription;
1369
+ }
1370
+ get image() {
1371
+ return this._image;
1372
+ }
1373
+ get daysRequiredToStart() {
1374
+ return this._daysRequiredToStart;
1375
+ }
1376
+ get flagsRequired() {
1377
+ return this._flagsRequired;
1378
+ }
1379
+ get questsRequired() {
1380
+ return this._questsRequired;
1381
+ }
1382
+ get requestDescription() {
1383
+ return this._requestDescription;
1384
+ }
1385
+ get onStart() {
1386
+ return this._onStart;
1387
+ }
1388
+ get onEnd() {
1389
+ return this._onEnd;
1390
+ }
1391
+ };
1392
+
1393
+ export { ActivityModel, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, QuestBaseModel, RoomBaseModel, StageBaseModel };
537
1394
  //# sourceMappingURL=out.js.map
538
1395
  //# sourceMappingURL=index.mjs.map