@drincs/nqtr 0.1.19 → 0.2.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 (155) hide show
  1. package/dist/{ActivityProps-_79x9-BX.d.ts → ActivityProps-BkHX8xkA.d.ts} +1 -1
  2. package/dist/{ActivityProps-BoJeWa2B.d.mts → ActivityProps-D45DQdcT.d.mts} +1 -1
  3. package/dist/{Commitment-Cc2kZEy0.d.ts → Commitment-BJTIpBQ5.d.ts} +4 -2
  4. package/dist/{Commitment-C3Nc2RJH.d.mts → Commitment-CtNWnNQX.d.mts} +4 -2
  5. package/dist/StageProps-DCZkZHwZ.d.ts +197 -0
  6. package/dist/StageProps-xLLR0rjD.d.mts +197 -0
  7. package/dist/classes/Activity.d.mts +2 -2
  8. package/dist/classes/Activity.d.ts +2 -2
  9. package/dist/classes/Activity.js +1 -1
  10. package/dist/classes/Activity.js.map +1 -1
  11. package/dist/classes/Activity.mjs +1 -1
  12. package/dist/classes/Activity.mjs.map +1 -1
  13. package/dist/classes/ActivityStoredAbstract.d.mts +1 -1
  14. package/dist/classes/ActivityStoredAbstract.d.ts +1 -1
  15. package/dist/classes/ActivityStoredAbstract.js +1 -1
  16. package/dist/classes/ActivityStoredAbstract.js.map +1 -1
  17. package/dist/classes/ActivityStoredAbstract.mjs +1 -1
  18. package/dist/classes/ActivityStoredAbstract.mjs.map +1 -1
  19. package/dist/classes/Commitment.d.mts +2 -2
  20. package/dist/classes/Commitment.d.ts +2 -2
  21. package/dist/classes/Commitment.js +2 -2
  22. package/dist/classes/Commitment.js.map +1 -1
  23. package/dist/classes/Commitment.mjs +2 -2
  24. package/dist/classes/Commitment.mjs.map +1 -1
  25. package/dist/classes/index.d.mts +4 -4
  26. package/dist/classes/index.d.ts +4 -4
  27. package/dist/classes/index.js +290 -322
  28. package/dist/classes/index.js.map +1 -1
  29. package/dist/classes/index.mjs +289 -321
  30. package/dist/classes/index.mjs.map +1 -1
  31. package/dist/classes/navigation/ActivityRoom.d.mts +2 -2
  32. package/dist/classes/navigation/ActivityRoom.d.ts +2 -2
  33. package/dist/classes/navigation/ActivityRoom.js +2 -2
  34. package/dist/classes/navigation/ActivityRoom.js.map +1 -1
  35. package/dist/classes/navigation/ActivityRoom.mjs +2 -2
  36. package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
  37. package/dist/classes/navigation/Location.d.mts +2 -2
  38. package/dist/classes/navigation/Location.d.ts +2 -2
  39. package/dist/classes/navigation/Map.d.mts +2 -2
  40. package/dist/classes/navigation/Map.d.ts +2 -2
  41. package/dist/classes/navigation/Room.d.mts +2 -2
  42. package/dist/classes/navigation/Room.d.ts +2 -2
  43. package/dist/classes/navigation/Room.js +34 -36
  44. package/dist/classes/navigation/Room.js.map +1 -1
  45. package/dist/classes/navigation/Room.mjs +34 -36
  46. package/dist/classes/navigation/Room.mjs.map +1 -1
  47. package/dist/classes/quest/Goal.d.mts +21 -13
  48. package/dist/classes/quest/Goal.d.ts +21 -13
  49. package/dist/classes/quest/Goal.js +50 -15
  50. package/dist/classes/quest/Goal.js.map +1 -1
  51. package/dist/classes/quest/Goal.mjs +47 -15
  52. package/dist/classes/quest/Goal.mjs.map +1 -1
  53. package/dist/classes/quest/Quest.d.mts +3 -2
  54. package/dist/classes/quest/Quest.d.ts +3 -2
  55. package/dist/classes/quest/Quest.js +536 -9
  56. package/dist/classes/quest/Quest.js.map +1 -1
  57. package/dist/classes/quest/Quest.mjs +537 -10
  58. package/dist/classes/quest/Quest.mjs.map +1 -1
  59. package/dist/classes/quest/Stage.d.mts +3 -2
  60. package/dist/classes/quest/Stage.d.ts +3 -2
  61. package/dist/classes/quest/Stage.js +396 -51
  62. package/dist/classes/quest/Stage.js.map +1 -1
  63. package/dist/classes/quest/Stage.mjs +394 -52
  64. package/dist/classes/quest/Stage.mjs.map +1 -1
  65. package/dist/decorators/ActivityDecorator.d.mts +1 -1
  66. package/dist/decorators/ActivityDecorator.d.ts +1 -1
  67. package/dist/decorators/CommitmentDecorator.d.mts +9 -3
  68. package/dist/decorators/CommitmentDecorator.d.ts +9 -3
  69. package/dist/decorators/CommitmentDecorator.js +15 -0
  70. package/dist/decorators/CommitmentDecorator.js.map +1 -1
  71. package/dist/decorators/CommitmentDecorator.mjs +15 -1
  72. package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
  73. package/dist/decorators/QuestDecorator.d.mts +26 -0
  74. package/dist/decorators/QuestDecorator.d.ts +26 -0
  75. package/dist/decorators/QuestDecorator.js +592 -0
  76. package/dist/decorators/QuestDecorator.js.map +1 -0
  77. package/dist/decorators/QuestDecorator.mjs +588 -0
  78. package/dist/decorators/QuestDecorator.mjs.map +1 -0
  79. package/dist/decorators/RoomDecorator.d.mts +2 -2
  80. package/dist/decorators/RoomDecorator.d.ts +2 -2
  81. package/dist/decorators/index.d.mts +8 -3
  82. package/dist/decorators/index.d.ts +8 -3
  83. package/dist/decorators/index.js +598 -0
  84. package/dist/decorators/index.js.map +1 -1
  85. package/dist/decorators/index.mjs +597 -2
  86. package/dist/decorators/index.mjs.map +1 -1
  87. package/dist/functions/ActivityFunctions.d.mts +2 -2
  88. package/dist/functions/ActivityFunctions.d.ts +2 -2
  89. package/dist/functions/ActivityFunctions.js.map +1 -1
  90. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  91. package/dist/functions/NavigationFunctions.d.mts +2 -2
  92. package/dist/functions/NavigationFunctions.d.ts +2 -2
  93. package/dist/functions/NavigationFunctions.js.map +1 -1
  94. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  95. package/dist/functions/RoutineFunctions.d.mts +2 -2
  96. package/dist/functions/RoutineFunctions.d.ts +2 -2
  97. package/dist/functions/RoutineFunctions.js.map +1 -1
  98. package/dist/functions/RoutineFunctions.mjs.map +1 -1
  99. package/dist/functions/index.d.mts +2 -2
  100. package/dist/functions/index.d.ts +2 -2
  101. package/dist/functions/index.js.map +1 -1
  102. package/dist/functions/index.mjs.map +1 -1
  103. package/dist/index.d.mts +6 -5
  104. package/dist/index.d.ts +6 -5
  105. package/dist/index.js +540 -308
  106. package/dist/index.js.map +1 -1
  107. package/dist/index.mjs +536 -307
  108. package/dist/index.mjs.map +1 -1
  109. package/dist/interface/ActivityProps.d.mts +1 -1
  110. package/dist/interface/ActivityProps.d.ts +1 -1
  111. package/dist/interface/CommitmentProps.d.mts +2 -2
  112. package/dist/interface/CommitmentProps.d.ts +2 -2
  113. package/dist/interface/RoomActivityMemory.d.mts +1 -1
  114. package/dist/interface/RoomActivityMemory.d.ts +1 -1
  115. package/dist/interface/RoomProps.d.mts +2 -2
  116. package/dist/interface/RoomProps.d.ts +2 -2
  117. package/dist/interface/index.d.mts +4 -4
  118. package/dist/interface/index.d.ts +4 -4
  119. package/dist/interface/navigation/LocationProps.d.mts +2 -2
  120. package/dist/interface/navigation/LocationProps.d.ts +2 -2
  121. package/dist/interface/navigation/MapProps.d.mts +2 -2
  122. package/dist/interface/navigation/MapProps.d.ts +2 -2
  123. package/dist/interface/quest/GoalProps.d.mts +12 -0
  124. package/dist/interface/quest/GoalProps.d.ts +12 -0
  125. package/dist/interface/quest/QuestProps.d.mts +6 -9
  126. package/dist/interface/quest/QuestProps.d.ts +6 -9
  127. package/dist/interface/quest/StageFlags.d.mts +12 -0
  128. package/dist/interface/quest/StageFlags.d.ts +12 -0
  129. package/dist/interface/quest/StageFlags.js +4 -0
  130. package/dist/interface/quest/StageFlags.js.map +1 -0
  131. package/dist/interface/quest/StageFlags.mjs +3 -0
  132. package/dist/interface/quest/StageFlags.mjs.map +1 -0
  133. package/dist/interface/quest/StageProps.d.mts +3 -2
  134. package/dist/interface/quest/StageProps.d.ts +3 -2
  135. package/dist/override/OnEndStage.d.mts +19 -0
  136. package/dist/override/OnEndStage.d.ts +19 -0
  137. package/dist/override/OnEndStage.js +4 -0
  138. package/dist/override/OnEndStage.js.map +1 -0
  139. package/dist/override/OnEndStage.mjs +3 -0
  140. package/dist/override/OnEndStage.mjs.map +1 -0
  141. package/dist/override/OnStartStage.d.mts +19 -0
  142. package/dist/override/OnStartStage.d.ts +19 -0
  143. package/dist/override/OnStartStage.js +4 -0
  144. package/dist/override/OnStartStage.js.map +1 -0
  145. package/dist/override/OnStartStage.mjs +3 -0
  146. package/dist/override/OnStartStage.mjs.map +1 -0
  147. package/dist/override/index.d.mts +2 -0
  148. package/dist/override/index.d.ts +2 -0
  149. package/dist/types/QuestsRequired.d.mts +3 -2
  150. package/dist/types/QuestsRequired.d.ts +3 -2
  151. package/dist/types/index.d.mts +3 -2
  152. package/dist/types/index.d.ts +3 -2
  153. package/package.json +2 -2
  154. package/dist/Quest-Bdm0R9LA.d.mts +0 -71
  155. package/dist/Quest-CxJcXETG.d.ts +0 -71
@@ -359,7 +359,7 @@ var ActivityModel = class {
359
359
  /**
360
360
  * The function that is called when the activity is runned.
361
361
  */
362
- get onRun() {
362
+ get run() {
363
363
  return (props) => this._onRun(this, props);
364
364
  }
365
365
  /**
@@ -489,6 +489,7 @@ var CommitmentBaseModel = class extends StoredClassModel {
489
489
  }
490
490
  /**
491
491
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
492
+ * If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
492
493
  */
493
494
  get executionType() {
494
495
  return this._executionType;
@@ -511,10 +512,9 @@ var CommitmentBaseModel = class extends StoredClassModel {
511
512
  /**
512
513
  * Is a function that is called when the player interacts with the character.
513
514
  */
514
- get onRun() {
515
+ get run() {
515
516
  let onRun = this._onRun;
516
517
  if (!onRun) {
517
- console.warn("[NQTR] onRun() is not defined for commitmen, so it will not run.", this);
518
518
  return;
519
519
  }
520
520
  return (props) => onRun(this, props);
@@ -575,6 +575,199 @@ var CommitmentBaseModel = class extends StoredClassModel {
575
575
  return false;
576
576
  }
577
577
  };
578
+ var ActivityStoredAbstract = class {
579
+ /**
580
+ * @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.
581
+ * @param props The activity properties.
582
+ */
583
+ constructor(onRun, props) {
584
+ this.defaultName = props.name;
585
+ this.defaultFromHour = props.fromHour;
586
+ this.defaultToHour = props.toHour;
587
+ this.defaultFromDay = props.fromDay;
588
+ this.defaultToDay = props.toDay;
589
+ this.defaultDisabled = props.disabled || false;
590
+ this.defaultHidden = props.hidden || false;
591
+ this._renderIcon = props.renderIcon;
592
+ this._onRun = onRun;
593
+ }
594
+ /**
595
+ * The name
596
+ */
597
+ get name() {
598
+ return this.getStorageProperty("name") || this.defaultName || "";
599
+ }
600
+ set name(value) {
601
+ this.setStorageProperty("name", value);
602
+ }
603
+ /**
604
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
605
+ */
606
+ get fromHour() {
607
+ return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
608
+ }
609
+ set fromHour(value) {
610
+ this.setStorageProperty("fromHour", value);
611
+ }
612
+ /**
613
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
614
+ */
615
+ get toHour() {
616
+ return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
617
+ }
618
+ set toHour(value) {
619
+ this.setStorageProperty("toHour", value);
620
+ }
621
+ /**
622
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
623
+ */
624
+ get fromDay() {
625
+ return this.getStorageProperty("fromDay") || this.defaultFromDay;
626
+ }
627
+ set fromDay(value) {
628
+ this.setStorageProperty("fromDay", value);
629
+ }
630
+ /**
631
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
632
+ */
633
+ get toDay() {
634
+ return this.getStorageProperty("toDay") || this.defaultToDay;
635
+ }
636
+ set toDay(value) {
637
+ this.setStorageProperty("toDay", value);
638
+ }
639
+ /**
640
+ * Whether is disabled.
641
+ */
642
+ get disabled() {
643
+ let value = this.getStorageProperty("disabled") || this.defaultDisabled;
644
+ if (typeof value === "string") {
645
+ return getFlag(value);
646
+ }
647
+ return value;
648
+ }
649
+ set disabled(value) {
650
+ this.setStorageProperty("disabled", value);
651
+ }
652
+ /**
653
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
654
+ */
655
+ get hidden() {
656
+ if (this.fromDay && this.fromDay > TimeManager.currentDay) {
657
+ return true;
658
+ }
659
+ if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
660
+ return true;
661
+ }
662
+ if (!this.isExpired) {
663
+ return true;
664
+ }
665
+ let value = this.getStorageProperty("hidden") || this.defaultHidden;
666
+ if (typeof value === "string") {
667
+ return getFlag(value);
668
+ }
669
+ return value;
670
+ }
671
+ set hidden(value) {
672
+ this.setStorageProperty("hidden", value);
673
+ }
674
+ /**
675
+ * The function for rendering the icon of the activity.
676
+ */
677
+ get renderIcon() {
678
+ let render = this._renderIcon;
679
+ if (render === void 0) {
680
+ return void 0;
681
+ }
682
+ if (typeof render === "function") {
683
+ return (props) => {
684
+ return render(this, props);
685
+ };
686
+ }
687
+ return (props) => render;
688
+ }
689
+ /**
690
+ * The function that is called when the activity is runned.
691
+ */
692
+ get run() {
693
+ return (props) => {
694
+ return this._onRun(this, props);
695
+ };
696
+ }
697
+ /**
698
+ * Whether the activity is a deadline.
699
+ * @returns Whether the activity is a deadline.
700
+ */
701
+ isExpired() {
702
+ if (this.toDay && this.toDay <= TimeManager.currentDay) {
703
+ return true;
704
+ }
705
+ return false;
706
+ }
707
+ /**
708
+ * Export the activity properties.
709
+ * @returns The activity properties.
710
+ */
711
+ export() {
712
+ return {
713
+ name: this.getStorageProperty("name") || this.defaultName,
714
+ fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
715
+ toHour: this.getStorageProperty("toHour") || this.defaultToHour,
716
+ fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
717
+ toDay: this.getStorageProperty("toDay") || this.defaultToDay,
718
+ disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
719
+ hidden: this.getStorageProperty("hidden") || this.defaultHidden,
720
+ renderIcon: this._renderIcon
721
+ };
722
+ }
723
+ };
724
+
725
+ // src/classes/navigation/ActivityRoom.ts
726
+ var ActivityRoom = class extends ActivityStoredAbstract {
727
+ constructor(id, room, onRun, props) {
728
+ super(onRun, props);
729
+ this._id = id;
730
+ this._room = room;
731
+ }
732
+ setStorageProperty(_, __) {
733
+ this._room.setActivity(this);
734
+ }
735
+ getStorageProperty(propertyName) {
736
+ let activity = this._room.getActivityMemory(this.id);
737
+ if (!activity || !activity.hasOwnProperty(propertyName)) {
738
+ return void 0;
739
+ }
740
+ return activity[propertyName];
741
+ }
742
+ get id() {
743
+ return this._id;
744
+ }
745
+ get room() {
746
+ return this._room;
747
+ }
748
+ export() {
749
+ let result = {};
750
+ if (this.name !== void 0) {
751
+ result["name"] = this.name;
752
+ }
753
+ if (this.fromHour !== void 0) {
754
+ result["fromHour"] = this.fromHour;
755
+ }
756
+ if (this.toHour !== void 0) {
757
+ result["toHour"] = this.toHour;
758
+ }
759
+ if (this.fromDay !== void 0) {
760
+ result["fromDay"] = this.fromDay;
761
+ }
762
+ if (this.toDay !== void 0) {
763
+ result["toDay"] = this.toDay;
764
+ }
765
+ if (this.disabled !== void 0) {
766
+ result["disabled"] = this.disabled;
767
+ }
768
+ return result;
769
+ }
770
+ };
578
771
 
579
772
  // src/decorators/RoomDecorator.ts
580
773
  var registeredRooms = {};
@@ -828,141 +1021,60 @@ function getTemporaryCommitments() {
828
1021
  let commitments = commitmentsIds.map((id) => getCommitmentById(id)).filter((commitment) => commitment !== void 0);
829
1022
  return commitments;
830
1023
  }
831
-
832
- // src/functions/RoutineFunctions.ts
833
- function getCurrentRoutine() {
834
- let character_commitments = {};
835
- getTemporaryCommitments().reverse().forEach((c) => {
836
- if (!c.hidden) {
837
- if (c.characters.length > 0) {
838
- let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
839
- if (allAvailable) {
840
- c.characters.forEach((ch) => {
841
- character_commitments[ch.id] = c;
842
- });
843
- }
844
- } else {
845
- console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
846
- }
847
- }
848
- });
849
- getFixedRoutine().reverse().forEach((c) => {
850
- if (!c.hidden) {
851
- if (c.characters.length > 0) {
852
- let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
853
- if (allAvailable) {
854
- c.characters.forEach((ch) => {
855
- character_commitments[ch.id] = c;
856
- });
857
- }
858
- } else {
859
- console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
860
- }
861
- }
862
- });
863
- return Object.values(character_commitments);
864
- }
865
- var ActivityStoredAbstract = class {
866
- /**
867
- * @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.
868
- * @param props The activity properties.
869
- */
870
- constructor(onRun, props) {
871
- this.defaultName = props.name;
872
- this.defaultFromHour = props.fromHour;
873
- this.defaultToHour = props.toHour;
874
- this.defaultFromDay = props.fromDay;
875
- this.defaultToDay = props.toDay;
876
- this.defaultDisabled = props.disabled || false;
877
- this.defaultHidden = props.hidden || false;
878
- this._renderIcon = props.renderIcon;
879
- this._onRun = onRun;
880
- }
881
- /**
882
- * The name
883
- */
884
- get name() {
885
- return this.getStorageProperty("name") || this.defaultName || "";
886
- }
887
- set name(value) {
888
- this.setStorageProperty("name", value);
889
- }
890
- /**
891
- * The hour when the activity starts. If the activity is not started yet, it will be hidden.
892
- */
893
- get fromHour() {
894
- return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
895
- }
896
- set fromHour(value) {
897
- this.setStorageProperty("fromHour", value);
898
- }
899
- /**
900
- * The hour when the activity ends. If the activity is ended yet, it will be hidden.
901
- */
902
- get toHour() {
903
- return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
904
- }
905
- set toHour(value) {
906
- this.setStorageProperty("toHour", value);
1024
+ var GOAL_CATEGORY = "__nqtr-goal__";
1025
+ var Goal = class extends StoredClassModel {
1026
+ constructor(id, props) {
1027
+ super(GOAL_CATEGORY, id);
1028
+ this._description = props.description;
1029
+ this._need = props.need || 1;
1030
+ this._defaultHave = props.have || 0;
907
1031
  }
908
1032
  /**
909
- * The day when the activity starts. If the activity is not started yet, it will be hidden.
1033
+ * The description of the goal.
910
1034
  */
911
- get fromDay() {
912
- return this.getStorageProperty("fromDay") || this.defaultFromDay;
913
- }
914
- set fromDay(value) {
915
- this.setStorageProperty("fromDay", value);
1035
+ get description() {
1036
+ return this._description;
916
1037
  }
917
- /**
918
- * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
919
- */
920
- get toDay() {
921
- return this.getStorageProperty("toDay") || this.defaultToDay;
1038
+ get need() {
1039
+ return this._need;
922
1040
  }
923
- set toDay(value) {
924
- this.setStorageProperty("toDay", value);
1041
+ get defaultHave() {
1042
+ return this._defaultHave;
925
1043
  }
926
- /**
927
- * Whether is disabled.
928
- */
929
- get disabled() {
930
- let value = this.getStorageProperty("disabled") || this.defaultDisabled;
931
- if (typeof value === "string") {
932
- return getFlag(value);
933
- }
934
- return value;
1044
+ };
1045
+
1046
+ // src/classes/quest/Stage.ts
1047
+ var STAGE_CATEGORY = "__nqtr-stage__";
1048
+ var Stage = class extends StoredClassModel {
1049
+ constructor(id, props) {
1050
+ super(STAGE_CATEGORY, id);
1051
+ this._name = props.name || "";
1052
+ this._defaultGoals = props.goals || [];
1053
+ this._flags = props.flags || [];
1054
+ this._description = props.description || "";
1055
+ this._adviceDescription = props.adviceDescription || "";
1056
+ this._renderImage = props.renderImage;
1057
+ this._daysRequiredToStart = props.daysRequiredToStart;
1058
+ this._flagsRequiredToStart = props.flagsRequired || [];
1059
+ this._questsRequiredToStart = props.questsRequired || [];
1060
+ this._requestDescriptionToStart = props.requestDescription || "";
1061
+ this._onStart = props.onStart;
1062
+ this._onEnd = props.onEnd;
935
1063
  }
936
- set disabled(value) {
937
- this.setStorageProperty("disabled", value);
1064
+ get name() {
1065
+ return this._name;
938
1066
  }
939
- /**
940
- * Whether is hidden. If the activity is not started yet, it will be hidden.
941
- */
942
- get hidden() {
943
- if (this.fromDay && this.fromDay > TimeManager.currentDay) {
944
- return true;
945
- }
946
- if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
947
- return true;
948
- }
949
- if (!this.isExpired) {
950
- return true;
951
- }
952
- let value = this.getStorageProperty("hidden") || this.defaultHidden;
953
- if (typeof value === "string") {
954
- return getFlag(value);
955
- }
956
- return value;
1067
+ get description() {
1068
+ return this._description;
957
1069
  }
958
- set hidden(value) {
959
- this.setStorageProperty("hidden", value);
1070
+ get adviceDescription() {
1071
+ return this._adviceDescription;
960
1072
  }
961
1073
  /**
962
- * The function for rendering the icon of the activity.
1074
+ * The function for rendering the image of the stage.
963
1075
  */
964
- get renderIcon() {
965
- let render = this._renderIcon;
1076
+ get renderImage() {
1077
+ let render = this._renderImage;
966
1078
  if (render === void 0) {
967
1079
  return void 0;
968
1080
  }
@@ -973,88 +1085,68 @@ var ActivityStoredAbstract = class {
973
1085
  }
974
1086
  return (props) => render;
975
1087
  }
976
- /**
977
- * The function that is called when the activity is runned.
978
- */
979
- get onRun() {
980
- return (props) => {
981
- return this._onRun(this, props);
982
- };
1088
+ get defaultGoals() {
1089
+ return this._defaultGoals;
983
1090
  }
984
1091
  /**
985
- * Whether the activity is a deadline.
986
- * @returns Whether the activity is a deadline.
1092
+ * The list of flags that the player must complete to finish the stage.
987
1093
  */
988
- isExpired() {
989
- if (this.toDay && this.toDay <= TimeManager.currentDay) {
990
- return true;
991
- }
992
- return false;
1094
+ get flags() {
1095
+ return this._flags;
993
1096
  }
994
- /**
995
- * Export the activity properties.
996
- * @returns The activity properties.
997
- */
998
- export() {
999
- return {
1000
- name: this.getStorageProperty("name") || this.defaultName,
1001
- fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
1002
- toHour: this.getStorageProperty("toHour") || this.defaultToHour,
1003
- fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
1004
- toDay: this.getStorageProperty("toDay") || this.defaultToDay,
1005
- disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
1006
- hidden: this.getStorageProperty("hidden") || this.defaultHidden,
1007
- renderIcon: this._renderIcon
1008
- };
1097
+ get daysRequiredToStart() {
1098
+ return this._daysRequiredToStart || 0;
1009
1099
  }
1010
- };
1011
-
1012
- // src/classes/navigation/ActivityRoom.ts
1013
- var ActivityRoom = class extends ActivityStoredAbstract {
1014
- constructor(id, room, onRun, props) {
1015
- super(onRun, props);
1016
- this._id = id;
1017
- this._room = room;
1100
+ get flagsRequiredToStart() {
1101
+ return this._flagsRequiredToStart;
1018
1102
  }
1019
- setStorageProperty(_, __) {
1020
- this._room.setActivity(this);
1103
+ get questsRequiredToStart() {
1104
+ return this._questsRequiredToStart || [];
1021
1105
  }
1022
- getStorageProperty(propertyName) {
1023
- let activity = this._room.getActivityMemory(this.id);
1024
- if (!activity || !activity.hasOwnProperty(propertyName)) {
1025
- return void 0;
1026
- }
1027
- return activity[propertyName];
1106
+ get requestDescriptionToStart() {
1107
+ return this._requestDescriptionToStart;
1028
1108
  }
1029
- get id() {
1030
- return this._id;
1109
+ get onStart() {
1110
+ return this._onStart;
1031
1111
  }
1032
- get room() {
1033
- return this._room;
1112
+ get onEnd() {
1113
+ return this._onEnd;
1034
1114
  }
1035
- export() {
1036
- let result = {};
1037
- if (this.name !== void 0) {
1038
- result["name"] = this.name;
1039
- }
1040
- if (this.fromHour !== void 0) {
1041
- result["fromHour"] = this.fromHour;
1042
- }
1043
- if (this.toHour !== void 0) {
1044
- result["toHour"] = this.toHour;
1045
- }
1046
- if (this.fromDay !== void 0) {
1047
- result["fromDay"] = this.fromDay;
1048
- }
1049
- if (this.toDay !== void 0) {
1050
- result["toDay"] = this.toDay;
1115
+ };
1116
+
1117
+ // src/functions/RoutineFunctions.ts
1118
+ function getCurrentRoutine() {
1119
+ let character_commitments = {};
1120
+ getTemporaryCommitments().reverse().forEach((c) => {
1121
+ if (!c.hidden) {
1122
+ if (c.characters.length > 0) {
1123
+ let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
1124
+ if (allAvailable) {
1125
+ c.characters.forEach((ch) => {
1126
+ character_commitments[ch.id] = c;
1127
+ });
1128
+ }
1129
+ } else {
1130
+ console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
1131
+ }
1051
1132
  }
1052
- if (this.disabled !== void 0) {
1053
- result["disabled"] = this.disabled;
1133
+ });
1134
+ getFixedRoutine().reverse().forEach((c) => {
1135
+ if (!c.hidden) {
1136
+ if (c.characters.length > 0) {
1137
+ let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
1138
+ if (allAvailable) {
1139
+ c.characters.forEach((ch) => {
1140
+ character_commitments[ch.id] = c;
1141
+ });
1142
+ }
1143
+ } else {
1144
+ console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
1145
+ }
1054
1146
  }
1055
- return result;
1056
- }
1057
- };
1147
+ });
1148
+ return Object.values(character_commitments);
1149
+ }
1058
1150
 
1059
1151
  // src/classes/navigation/Room.ts
1060
1152
  var ROOM_CATEGORY = "__nqtr-room__";
@@ -1293,130 +1385,6 @@ var RoomBaseModel = class extends StoredClassModel {
1293
1385
  }
1294
1386
  };
1295
1387
 
1296
- // src/classes/quest/Goal.ts
1297
- var Goal = class {
1298
- constructor(props) {
1299
- this._description = props.description;
1300
- this.need = props.need || 1;
1301
- this.have = props.have || 0;
1302
- }
1303
- get description() {
1304
- return this._description;
1305
- }
1306
- get isComplete() {
1307
- return this.have >= this.need;
1308
- }
1309
- setComplete() {
1310
- this.have = this.need;
1311
- }
1312
- find() {
1313
- this.have++;
1314
- }
1315
- get export() {
1316
- return {
1317
- description: this.description,
1318
- need: this.need,
1319
- have: this.have
1320
- };
1321
- }
1322
- };
1323
- var QUEST_CATEGORY = "__nqtr-quest__";
1324
- var QuestBaseModel = class extends StoredClassModel {
1325
- constructor(id, stages, props) {
1326
- super(QUEST_CATEGORY, id);
1327
- this._stages = stages;
1328
- this._name = props.name || "";
1329
- this._description = props.description || "";
1330
- this._icon = props.icon || "";
1331
- this._image = props.image || "";
1332
- this._isInDevelopment = props.isInDevelopment || false;
1333
- }
1334
- get stages() {
1335
- return this._stages;
1336
- }
1337
- get name() {
1338
- return this._name;
1339
- }
1340
- get description() {
1341
- return this._description;
1342
- }
1343
- get icon() {
1344
- return this._icon;
1345
- }
1346
- get image() {
1347
- return this._image;
1348
- }
1349
- get isInDevelopment() {
1350
- return this._isInDevelopment;
1351
- }
1352
- };
1353
- var STAGE_CATEGORY = "__nqtr-stage__";
1354
- var StageBaseModel = class extends StoredClassModel {
1355
- constructor(id, props) {
1356
- super(STAGE_CATEGORY, id);
1357
- this._completed = false;
1358
- this._active = false;
1359
- this.defaultGoals = [];
1360
- this._name = props.name || "";
1361
- this._description = props.description || "";
1362
- this._adviceDescription = props.adviceDescription || "";
1363
- this._image = props.image || "";
1364
- this._daysRequiredToStart = props.daysRequiredToStart;
1365
- this._flagsRequired = props.flagsRequired;
1366
- this._questsRequired = props.questsRequired;
1367
- this._requestDescription = props.requestDescription || "";
1368
- this._onStart = props.onStart;
1369
- this._onEnd = props.onEnd;
1370
- }
1371
- get completed() {
1372
- return this._completed;
1373
- }
1374
- get active() {
1375
- return this._active;
1376
- }
1377
- get goals() {
1378
- let list = this.getStorageProperty("goals");
1379
- if (!list) {
1380
- return this.defaultGoals;
1381
- }
1382
- return list.map((goal) => new Goal(goal));
1383
- }
1384
- set goals(value) {
1385
- let list = value.map((goal) => goal.export);
1386
- this.setStorageProperty("goals", list);
1387
- }
1388
- get name() {
1389
- return this._name;
1390
- }
1391
- get description() {
1392
- return this._description;
1393
- }
1394
- get adviceDescription() {
1395
- return this._adviceDescription;
1396
- }
1397
- get image() {
1398
- return this._image;
1399
- }
1400
- get daysRequiredToStart() {
1401
- return this._daysRequiredToStart;
1402
- }
1403
- get flagsRequired() {
1404
- return this._flagsRequired;
1405
- }
1406
- get questsRequired() {
1407
- return this._questsRequired;
1408
- }
1409
- get requestDescription() {
1410
- return this._requestDescription;
1411
- }
1412
- get onStart() {
1413
- return this._onStart;
1414
- }
1415
- get onEnd() {
1416
- return this._onEnd;
1417
- }
1418
- };
1419
-
1420
- export { ActivityModel, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, QuestBaseModel, RoomBaseModel, StageBaseModel };
1388
+ export { ActivityModel, ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, RoomBaseModel, Stage };
1421
1389
  //# sourceMappingURL=out.js.map
1422
1390
  //# sourceMappingURL=index.mjs.map