@drincs/nqtr 0.1.19 → 0.1.20

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 (93) hide show
  1. package/dist/Quest-BQ1pwvQ_.d.ts +197 -0
  2. package/dist/Quest-DaNlPBHb.d.mts +197 -0
  3. package/dist/classes/index.d.mts +3 -3
  4. package/dist/classes/index.d.ts +3 -3
  5. package/dist/classes/index.js +488 -298
  6. package/dist/classes/index.js.map +1 -1
  7. package/dist/classes/index.mjs +486 -297
  8. package/dist/classes/index.mjs.map +1 -1
  9. package/dist/classes/navigation/ActivityRoom.d.mts +1 -1
  10. package/dist/classes/navigation/ActivityRoom.d.ts +1 -1
  11. package/dist/classes/navigation/ActivityRoom.js +1 -1
  12. package/dist/classes/navigation/ActivityRoom.js.map +1 -1
  13. package/dist/classes/navigation/ActivityRoom.mjs +1 -1
  14. package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
  15. package/dist/classes/navigation/Room.js.map +1 -1
  16. package/dist/classes/navigation/Room.mjs.map +1 -1
  17. package/dist/classes/quest/Goal.d.mts +21 -13
  18. package/dist/classes/quest/Goal.d.ts +21 -13
  19. package/dist/classes/quest/Goal.js +50 -15
  20. package/dist/classes/quest/Goal.js.map +1 -1
  21. package/dist/classes/quest/Goal.mjs +47 -15
  22. package/dist/classes/quest/Goal.mjs.map +1 -1
  23. package/dist/classes/quest/Quest.d.mts +3 -2
  24. package/dist/classes/quest/Quest.d.ts +3 -2
  25. package/dist/classes/quest/Quest.js +536 -9
  26. package/dist/classes/quest/Quest.js.map +1 -1
  27. package/dist/classes/quest/Quest.mjs +537 -10
  28. package/dist/classes/quest/Quest.mjs.map +1 -1
  29. package/dist/classes/quest/Stage.d.mts +3 -2
  30. package/dist/classes/quest/Stage.d.ts +3 -2
  31. package/dist/classes/quest/Stage.js +396 -51
  32. package/dist/classes/quest/Stage.js.map +1 -1
  33. package/dist/classes/quest/Stage.mjs +394 -52
  34. package/dist/classes/quest/Stage.mjs.map +1 -1
  35. package/dist/decorators/QuestDecorator.d.mts +28 -0
  36. package/dist/decorators/QuestDecorator.d.ts +28 -0
  37. package/dist/decorators/QuestDecorator.js +33 -0
  38. package/dist/decorators/QuestDecorator.js.map +1 -0
  39. package/dist/decorators/QuestDecorator.mjs +29 -0
  40. package/dist/decorators/QuestDecorator.mjs.map +1 -0
  41. package/dist/decorators/index.d.mts +5 -0
  42. package/dist/decorators/index.d.ts +5 -0
  43. package/dist/decorators/index.js +28 -0
  44. package/dist/decorators/index.js.map +1 -1
  45. package/dist/decorators/index.mjs +27 -1
  46. package/dist/decorators/index.mjs.map +1 -1
  47. package/dist/functions/ActivityFunctions.js.map +1 -1
  48. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  49. package/dist/functions/NavigationFunctions.js.map +1 -1
  50. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  51. package/dist/functions/index.js.map +1 -1
  52. package/dist/functions/index.mjs.map +1 -1
  53. package/dist/index.d.mts +4 -3
  54. package/dist/index.d.ts +4 -3
  55. package/dist/index.js +518 -300
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.mjs +514 -299
  58. package/dist/index.mjs.map +1 -1
  59. package/dist/interface/index.d.mts +2 -2
  60. package/dist/interface/index.d.ts +2 -2
  61. package/dist/interface/quest/GoalProps.d.mts +12 -0
  62. package/dist/interface/quest/GoalProps.d.ts +12 -0
  63. package/dist/interface/quest/QuestProps.d.mts +6 -9
  64. package/dist/interface/quest/QuestProps.d.ts +6 -9
  65. package/dist/interface/quest/StageFlags.d.mts +12 -0
  66. package/dist/interface/quest/StageFlags.d.ts +12 -0
  67. package/dist/interface/quest/StageFlags.js +4 -0
  68. package/dist/interface/quest/StageFlags.js.map +1 -0
  69. package/dist/interface/quest/StageFlags.mjs +3 -0
  70. package/dist/interface/quest/StageFlags.mjs.map +1 -0
  71. package/dist/interface/quest/StageProps.d.mts +3 -2
  72. package/dist/interface/quest/StageProps.d.ts +3 -2
  73. package/dist/override/OnEndStage.d.mts +19 -0
  74. package/dist/override/OnEndStage.d.ts +19 -0
  75. package/dist/override/OnEndStage.js +4 -0
  76. package/dist/override/OnEndStage.js.map +1 -0
  77. package/dist/override/OnEndStage.mjs +3 -0
  78. package/dist/override/OnEndStage.mjs.map +1 -0
  79. package/dist/override/OnStartStage.d.mts +19 -0
  80. package/dist/override/OnStartStage.d.ts +19 -0
  81. package/dist/override/OnStartStage.js +4 -0
  82. package/dist/override/OnStartStage.js.map +1 -0
  83. package/dist/override/OnStartStage.mjs +3 -0
  84. package/dist/override/OnStartStage.mjs.map +1 -0
  85. package/dist/override/index.d.mts +2 -0
  86. package/dist/override/index.d.ts +2 -0
  87. package/dist/types/QuestsRequired.d.mts +3 -2
  88. package/dist/types/QuestsRequired.d.ts +3 -2
  89. package/dist/types/index.d.mts +3 -2
  90. package/dist/types/index.d.ts +3 -2
  91. package/package.json +1 -1
  92. package/dist/Quest-Bdm0R9LA.d.mts +0 -71
  93. package/dist/Quest-CxJcXETG.d.ts +0 -71
@@ -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 onRun() {
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 = {};
@@ -862,244 +1055,51 @@ function getCurrentRoutine() {
862
1055
  });
863
1056
  return Object.values(character_commitments);
864
1057
  }
865
- var ActivityStoredAbstract = class {
1058
+
1059
+ // src/classes/navigation/Room.ts
1060
+ var ROOM_CATEGORY = "__nqtr-room__";
1061
+ var RoomBaseModel = class extends StoredClassModel {
866
1062
  /**
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.
1063
+ * @param id The id of the room, it must be unique.
1064
+ * @param location The location where the room is.
1065
+ * @param props The properties of the room.
869
1066
  */
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;
1067
+ constructor(id, location, props = {}) {
1068
+ var _a;
1069
+ super(ROOM_CATEGORY, id);
1070
+ this._location = location;
1071
+ this.defaultName = props.name || "";
1072
+ this._renderImage = props.renderImage;
1073
+ this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
876
1074
  this.defaultDisabled = props.disabled || false;
877
1075
  this.defaultHidden = props.hidden || false;
878
1076
  this._renderIcon = props.renderIcon;
879
- this._onRun = onRun;
1077
+ this._isEntrance = props.isEntrance;
880
1078
  }
881
1079
  /**
882
- * The name
1080
+ * The location where the room is.
883
1081
  */
884
- get name() {
885
- return this.getStorageProperty("name") || this.defaultName || "";
886
- }
887
- set name(value) {
888
- this.setStorageProperty("name", value);
1082
+ get location() {
1083
+ return this._location;
889
1084
  }
890
1085
  /**
891
- * The hour when the activity starts. If the activity is not started yet, it will be hidden.
1086
+ * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
892
1087
  */
893
- get fromHour() {
894
- return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
895
- }
896
- set fromHour(value) {
897
- this.setStorageProperty("fromHour", value);
1088
+ get isEntrance() {
1089
+ return this._isEntrance || false;
898
1090
  }
899
1091
  /**
900
- * The hour when the activity ends. If the activity is ended yet, it will be hidden.
1092
+ * The name.
1093
+ * If you set undefined, it will return the initial value of name.
901
1094
  */
902
- get toHour() {
903
- return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
1095
+ get name() {
1096
+ return this.getStorageProperty("name") || this.defaultName;
904
1097
  }
905
- set toHour(value) {
906
- this.setStorageProperty("toHour", value);
1098
+ set name(value) {
1099
+ this.setStorageProperty("name", value);
907
1100
  }
908
1101
  /**
909
- * The day when the activity starts. If the activity is not started yet, it will be hidden.
910
- */
911
- get fromDay() {
912
- return this.getStorageProperty("fromDay") || this.defaultFromDay;
913
- }
914
- set fromDay(value) {
915
- this.setStorageProperty("fromDay", value);
916
- }
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;
922
- }
923
- set toDay(value) {
924
- this.setStorageProperty("toDay", value);
925
- }
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;
935
- }
936
- set disabled(value) {
937
- this.setStorageProperty("disabled", value);
938
- }
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;
957
- }
958
- set hidden(value) {
959
- this.setStorageProperty("hidden", value);
960
- }
961
- /**
962
- * The function for rendering the icon of the activity.
963
- */
964
- get renderIcon() {
965
- let render = this._renderIcon;
966
- if (render === void 0) {
967
- return void 0;
968
- }
969
- if (typeof render === "function") {
970
- return (props) => {
971
- return render(this, props);
972
- };
973
- }
974
- return (props) => render;
975
- }
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
- };
983
- }
984
- /**
985
- * Whether the activity is a deadline.
986
- * @returns Whether the activity is a deadline.
987
- */
988
- isExpired() {
989
- if (this.toDay && this.toDay <= TimeManager.currentDay) {
990
- return true;
991
- }
992
- return false;
993
- }
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
- };
1009
- }
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;
1018
- }
1019
- setStorageProperty(_, __) {
1020
- this._room.setActivity(this);
1021
- }
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];
1028
- }
1029
- get id() {
1030
- return this._id;
1031
- }
1032
- get room() {
1033
- return this._room;
1034
- }
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;
1051
- }
1052
- if (this.disabled !== void 0) {
1053
- result["disabled"] = this.disabled;
1054
- }
1055
- return result;
1056
- }
1057
- };
1058
-
1059
- // src/classes/navigation/Room.ts
1060
- var ROOM_CATEGORY = "__nqtr-room__";
1061
- var RoomBaseModel = class extends StoredClassModel {
1062
- /**
1063
- * @param id The id of the room, it must be unique.
1064
- * @param location The location where the room is.
1065
- * @param props The properties of the room.
1066
- */
1067
- constructor(id, location, props = {}) {
1068
- var _a;
1069
- super(ROOM_CATEGORY, id);
1070
- this._location = location;
1071
- this.defaultName = props.name || "";
1072
- this._renderImage = props.renderImage;
1073
- this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
1074
- this.defaultDisabled = props.disabled || false;
1075
- this.defaultHidden = props.hidden || false;
1076
- this._renderIcon = props.renderIcon;
1077
- this._isEntrance = props.isEntrance;
1078
- }
1079
- /**
1080
- * The location where the room is.
1081
- */
1082
- get location() {
1083
- return this._location;
1084
- }
1085
- /**
1086
- * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
1087
- */
1088
- get isEntrance() {
1089
- return this._isEntrance || false;
1090
- }
1091
- /**
1092
- * The name.
1093
- * If you set undefined, it will return the initial value of name.
1094
- */
1095
- get name() {
1096
- return this.getStorageProperty("name") || this.defaultName;
1097
- }
1098
- set name(value) {
1099
- this.setStorageProperty("name", value);
1100
- }
1101
- /**
1102
- * The function for rendering the image of the room.
1102
+ * The function for rendering the image of the room.
1103
1103
  */
1104
1104
  get renderImage() {
1105
1105
  let render = this._renderImage;
@@ -1292,47 +1292,78 @@ var RoomBaseModel = class extends StoredClassModel {
1292
1292
  return commitments.filter((c) => c.room.id === this.id);
1293
1293
  }
1294
1294
  };
1295
-
1296
- // src/classes/quest/Goal.ts
1297
- var Goal = class {
1298
- constructor(props) {
1295
+ var GOAL_CATEGORY = "__nqtr-goal__";
1296
+ var Goal = class extends StoredClassModel {
1297
+ constructor(id, props) {
1298
+ super(GOAL_CATEGORY, id);
1299
1299
  this._description = props.description;
1300
- this.need = props.need || 1;
1301
- this.have = props.have || 0;
1300
+ this._need = props.need || 1;
1301
+ this._defaultHave = props.have || 0;
1302
1302
  }
1303
+ /**
1304
+ * The description of the goal.
1305
+ */
1303
1306
  get description() {
1304
1307
  return this._description;
1305
1308
  }
1306
- get isComplete() {
1309
+ get need() {
1310
+ return this._need;
1311
+ }
1312
+ get defaultHave() {
1313
+ return this._defaultHave;
1314
+ }
1315
+ };
1316
+ var GoalStage = class extends Goal {
1317
+ constructor(id, stageId, props) {
1318
+ super(id, props);
1319
+ this._stageId = stageId;
1320
+ }
1321
+ get stageId() {
1322
+ return this._stageId;
1323
+ }
1324
+ set stageId(value) {
1325
+ this._stageId = value;
1326
+ }
1327
+ get have() {
1328
+ return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
1329
+ }
1330
+ set have(value) {
1331
+ if (!this._stageId) {
1332
+ console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
1333
+ return;
1334
+ }
1335
+ this.setStorageProperty("have-" + this._stageId, value);
1336
+ }
1337
+ get completed() {
1307
1338
  return this.have >= this.need;
1308
1339
  }
1309
- setComplete() {
1310
- this.have = this.need;
1340
+ set completed(value) {
1341
+ if (value) {
1342
+ this.have = this.need;
1343
+ } else {
1344
+ console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
1345
+ }
1311
1346
  }
1312
1347
  find() {
1313
1348
  this.have++;
1314
1349
  }
1315
- get export() {
1316
- return {
1317
- description: this.description,
1318
- need: this.need,
1319
- have: this.have
1320
- };
1321
- }
1322
1350
  };
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;
1351
+ var STAGE_CATEGORY = "__nqtr-stage__";
1352
+ var Stage = class extends StoredClassModel {
1353
+ constructor(id, props) {
1354
+ super(STAGE_CATEGORY, id);
1328
1355
  this._name = props.name || "";
1356
+ this._defaultGoals = props.goals || [];
1357
+ this._flags = props.flags || [];
1329
1358
  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;
1359
+ this._adviceDescription = props.adviceDescription || "";
1360
+ this._renderImage = props.renderImage;
1361
+ this._daysRequiredToStart = props.daysRequiredToStart;
1362
+ this._flagsRequiredToStart = props.flagsRequired || [];
1363
+ this._questsRequiredToStart = props.questsRequired || [];
1364
+ this._requestDescriptionToStart = props.requestDescription || "";
1365
+ this._onStart = props.onStart;
1366
+ this._onEnd = props.onEnd;
1336
1367
  }
1337
1368
  get name() {
1338
1369
  return this._name;
@@ -1340,50 +1371,138 @@ var QuestBaseModel = class extends StoredClassModel {
1340
1371
  get description() {
1341
1372
  return this._description;
1342
1373
  }
1343
- get icon() {
1344
- return this._icon;
1374
+ get adviceDescription() {
1375
+ return this._adviceDescription;
1345
1376
  }
1346
- get image() {
1347
- return this._image;
1377
+ /**
1378
+ * The function for rendering the image of the stage.
1379
+ */
1380
+ get renderImage() {
1381
+ let render = this._renderImage;
1382
+ if (render === void 0) {
1383
+ return void 0;
1384
+ }
1385
+ if (typeof render === "function") {
1386
+ return (props) => {
1387
+ return render(this, props);
1388
+ };
1389
+ }
1390
+ return (props) => render;
1348
1391
  }
1349
- get isInDevelopment() {
1350
- return this._isInDevelopment;
1392
+ get defaultGoals() {
1393
+ return this._defaultGoals;
1394
+ }
1395
+ /**
1396
+ * The list of flags that the player must complete to finish the stage.
1397
+ */
1398
+ get flags() {
1399
+ return this._flags;
1400
+ }
1401
+ get daysRequiredToStart() {
1402
+ return this._daysRequiredToStart || 0;
1403
+ }
1404
+ get flagsRequiredToStart() {
1405
+ return this._flagsRequiredToStart;
1406
+ }
1407
+ get questsRequiredToStart() {
1408
+ return this._questsRequiredToStart || [];
1409
+ }
1410
+ get requestDescriptionToStart() {
1411
+ return this._requestDescriptionToStart;
1412
+ }
1413
+ get onStart() {
1414
+ return this._onStart;
1415
+ }
1416
+ get onEnd() {
1417
+ return this._onEnd;
1351
1418
  }
1352
1419
  };
1353
- var STAGE_CATEGORY = "__nqtr-stage__";
1354
- var StageBaseModel = class extends StoredClassModel {
1420
+ var StageQuest = class extends Stage {
1355
1421
  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;
1422
+ super(id, props);
1370
1423
  }
1371
1424
  get completed() {
1372
- return this._completed;
1425
+ let storedCompleted = this.getStorageProperty("completed");
1426
+ if (storedCompleted) {
1427
+ return storedCompleted;
1428
+ }
1429
+ if (!this.flags.every((flag) => getFlag(flag.flag))) {
1430
+ return false;
1431
+ }
1432
+ if (!this.goals.every((goal) => goal.completed)) {
1433
+ return false;
1434
+ }
1435
+ return true;
1373
1436
  }
1374
- get active() {
1375
- return this._active;
1437
+ set completed(value) {
1438
+ this.setStorageProperty("completed", value);
1376
1439
  }
1440
+ /**
1441
+ * The list of goals that the player needs to complete to finish the stage.
1442
+ */
1377
1443
  get goals() {
1378
- let list = this.getStorageProperty("goals");
1379
- if (!list) {
1380
- return this.defaultGoals;
1444
+ return this.defaultGoals.map((goal) => {
1445
+ return new GoalStage(goal.id, this.id, goal);
1446
+ });
1447
+ }
1448
+ get prevStageEndDay() {
1449
+ return this.getStorageProperty("prevStageEndDay");
1450
+ }
1451
+ set prevStageEndDay(value) {
1452
+ this.setStorageProperty("prevStageEndDay", value);
1453
+ }
1454
+ get startDay() {
1455
+ let prevStageEndDay = this.prevStageEndDay;
1456
+ if (prevStageEndDay === void 0) {
1457
+ return void 0;
1458
+ }
1459
+ return prevStageEndDay + this.daysRequiredToStart;
1460
+ }
1461
+ get canStart() {
1462
+ let daysRequired = this.daysRequiredToStart;
1463
+ if (daysRequired > 0) {
1464
+ let prevStageEndDay = this.prevStageEndDay;
1465
+ if (prevStageEndDay === void 0) {
1466
+ return false;
1467
+ }
1468
+ if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
1469
+ return false;
1470
+ }
1471
+ }
1472
+ if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {
1473
+ return false;
1381
1474
  }
1382
- return list.map((goal) => new Goal(goal));
1475
+ if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
1476
+ (q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
1477
+ )) {
1478
+ return false;
1479
+ }
1480
+ return true;
1481
+ }
1482
+ get onStart() {
1483
+ if (this.daysRequiredToStart > 0) {
1484
+ this.prevStageEndDay = TimeManager.currentDay;
1485
+ }
1486
+ return super.onStart;
1487
+ }
1488
+ };
1489
+
1490
+ // src/classes/quest/Quest.ts
1491
+ var QUEST_CATEGORY = "__nqtr-quest__";
1492
+ var Quest = class extends StoredClassModel {
1493
+ constructor(id, stages, props) {
1494
+ super(QUEST_CATEGORY, id);
1495
+ this._stages = stages;
1496
+ this._name = props.name || "";
1497
+ this._description = props.description || "";
1498
+ this._renderIcon = props.renderIcon;
1499
+ this._renderImage = props.renderImage;
1500
+ this._isInDevelopment = props.isInDevelopment || false;
1383
1501
  }
1384
- set goals(value) {
1385
- let list = value.map((goal) => goal.export);
1386
- this.setStorageProperty("goals", list);
1502
+ get stages() {
1503
+ return this._stages.map((stage, index) => {
1504
+ return new StageQuest(stage.id, stage);
1505
+ });
1387
1506
  }
1388
1507
  get name() {
1389
1508
  return this._name;
@@ -1391,32 +1510,102 @@ var StageBaseModel = class extends StoredClassModel {
1391
1510
  get description() {
1392
1511
  return this._description;
1393
1512
  }
1394
- get adviceDescription() {
1395
- return this._adviceDescription;
1513
+ /**
1514
+ * The function for rendering the icon of the quest.
1515
+ */
1516
+ get renderIcon() {
1517
+ let render = this._renderIcon;
1518
+ if (render === void 0) {
1519
+ return void 0;
1520
+ }
1521
+ if (typeof render === "function") {
1522
+ return (props) => {
1523
+ return render(this, props);
1524
+ };
1525
+ }
1526
+ return (props) => render;
1396
1527
  }
1397
- get image() {
1398
- return this._image;
1528
+ /**
1529
+ * The function for rendering the image of the quest.
1530
+ */
1531
+ get renderImage() {
1532
+ let render = this._renderImage;
1533
+ if (render === void 0) {
1534
+ return void 0;
1535
+ }
1536
+ if (typeof render === "function") {
1537
+ return (props) => {
1538
+ return render(this, props);
1539
+ };
1540
+ }
1541
+ return (props) => render;
1399
1542
  }
1400
- get daysRequiredToStart() {
1401
- return this._daysRequiredToStart;
1543
+ get isInDevelopment() {
1544
+ return this._isInDevelopment;
1402
1545
  }
1403
- get flagsRequired() {
1404
- return this._flagsRequired;
1546
+ get currentStageIndex() {
1547
+ return this.getStorageProperty("currentStageIndex");
1405
1548
  }
1406
- get questsRequired() {
1407
- return this._questsRequired;
1549
+ set currentStageIndex(value) {
1550
+ this.setStorageProperty("currentStageIndex", value);
1408
1551
  }
1409
- get requestDescription() {
1410
- return this._requestDescription;
1552
+ get currentStage() {
1553
+ let index = this.currentStageIndex;
1554
+ if (index === void 0 || index >= this.stages.length) {
1555
+ return void 0;
1556
+ }
1557
+ return this.stages[index];
1411
1558
  }
1412
- get onStart() {
1413
- return this._onStart;
1559
+ get started() {
1560
+ return this.currentStageIndex !== void 0;
1414
1561
  }
1415
- get onEnd() {
1416
- return this._onEnd;
1562
+ get completed() {
1563
+ return this.currentStageIndex === this.stages.length;
1564
+ }
1565
+ start() {
1566
+ if (this.started) {
1567
+ console.warn(`[NQTR] Quest ${this.id} is already started`);
1568
+ return;
1569
+ }
1570
+ if (this.stages.length === 0) {
1571
+ console.error(`[NQTR] Quest ${this.id} has no stages`);
1572
+ return;
1573
+ }
1574
+ this.currentStageIndex = 0;
1575
+ let currentStage = this.currentStage;
1576
+ if (currentStage && currentStage.onStart) {
1577
+ return currentStage.onStart();
1578
+ } else {
1579
+ console.error(`[NQTR] Quest ${this.id} has no start stage`);
1580
+ }
1581
+ }
1582
+ tryToGoNextStage() {
1583
+ if (!this.started) {
1584
+ return;
1585
+ }
1586
+ if (this.completed) {
1587
+ return;
1588
+ }
1589
+ let currentStage = this.currentStage;
1590
+ let currentStageIndex = this.currentStageIndex;
1591
+ if (!currentStage || currentStageIndex === void 0) {
1592
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1593
+ return;
1594
+ }
1595
+ if (currentStage.completed) {
1596
+ let nextStageIndex = currentStageIndex + 1;
1597
+ currentStageIndex = nextStageIndex;
1598
+ let nextStage = this.currentStage;
1599
+ if (currentStage && currentStage.onEnd) {
1600
+ currentStage.onEnd();
1601
+ }
1602
+ if (nextStage && nextStage.onStart) {
1603
+ return nextStage.onStart();
1604
+ }
1605
+ }
1417
1606
  }
1418
1607
  };
1419
1608
 
1420
- export { ActivityModel, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, QuestBaseModel, RoomBaseModel, StageBaseModel };
1609
+ export { ActivityModel, ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, Quest, RoomBaseModel, Stage };
1421
1610
  //# sourceMappingURL=out.js.map
1422
1611
  //# sourceMappingURL=index.mjs.map