@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
@@ -577,6 +577,199 @@ var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
577
577
  return false;
578
578
  }
579
579
  };
580
+ var ActivityStoredAbstract = class {
581
+ /**
582
+ * @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.
583
+ * @param props The activity properties.
584
+ */
585
+ constructor(onRun, props) {
586
+ this.defaultName = props.name;
587
+ this.defaultFromHour = props.fromHour;
588
+ this.defaultToHour = props.toHour;
589
+ this.defaultFromDay = props.fromDay;
590
+ this.defaultToDay = props.toDay;
591
+ this.defaultDisabled = props.disabled || false;
592
+ this.defaultHidden = props.hidden || false;
593
+ this._renderIcon = props.renderIcon;
594
+ this._onRun = onRun;
595
+ }
596
+ /**
597
+ * The name
598
+ */
599
+ get name() {
600
+ return this.getStorageProperty("name") || this.defaultName || "";
601
+ }
602
+ set name(value) {
603
+ this.setStorageProperty("name", value);
604
+ }
605
+ /**
606
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
607
+ */
608
+ get fromHour() {
609
+ return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
610
+ }
611
+ set fromHour(value) {
612
+ this.setStorageProperty("fromHour", value);
613
+ }
614
+ /**
615
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
616
+ */
617
+ get toHour() {
618
+ return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
619
+ }
620
+ set toHour(value) {
621
+ this.setStorageProperty("toHour", value);
622
+ }
623
+ /**
624
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
625
+ */
626
+ get fromDay() {
627
+ return this.getStorageProperty("fromDay") || this.defaultFromDay;
628
+ }
629
+ set fromDay(value) {
630
+ this.setStorageProperty("fromDay", value);
631
+ }
632
+ /**
633
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
634
+ */
635
+ get toDay() {
636
+ return this.getStorageProperty("toDay") || this.defaultToDay;
637
+ }
638
+ set toDay(value) {
639
+ this.setStorageProperty("toDay", value);
640
+ }
641
+ /**
642
+ * Whether is disabled.
643
+ */
644
+ get disabled() {
645
+ let value = this.getStorageProperty("disabled") || this.defaultDisabled;
646
+ if (typeof value === "string") {
647
+ return pixiVn.getFlag(value);
648
+ }
649
+ return value;
650
+ }
651
+ set disabled(value) {
652
+ this.setStorageProperty("disabled", value);
653
+ }
654
+ /**
655
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
656
+ */
657
+ get hidden() {
658
+ if (this.fromDay && this.fromDay > TimeManager.currentDay) {
659
+ return true;
660
+ }
661
+ if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
662
+ return true;
663
+ }
664
+ if (!this.isExpired) {
665
+ return true;
666
+ }
667
+ let value = this.getStorageProperty("hidden") || this.defaultHidden;
668
+ if (typeof value === "string") {
669
+ return pixiVn.getFlag(value);
670
+ }
671
+ return value;
672
+ }
673
+ set hidden(value) {
674
+ this.setStorageProperty("hidden", value);
675
+ }
676
+ /**
677
+ * The function for rendering the icon of the activity.
678
+ */
679
+ get renderIcon() {
680
+ let render = this._renderIcon;
681
+ if (render === void 0) {
682
+ return void 0;
683
+ }
684
+ if (typeof render === "function") {
685
+ return (props) => {
686
+ return render(this, props);
687
+ };
688
+ }
689
+ return (props) => render;
690
+ }
691
+ /**
692
+ * The function that is called when the activity is runned.
693
+ */
694
+ get onRun() {
695
+ return (props) => {
696
+ return this._onRun(this, props);
697
+ };
698
+ }
699
+ /**
700
+ * Whether the activity is a deadline.
701
+ * @returns Whether the activity is a deadline.
702
+ */
703
+ isExpired() {
704
+ if (this.toDay && this.toDay <= TimeManager.currentDay) {
705
+ return true;
706
+ }
707
+ return false;
708
+ }
709
+ /**
710
+ * Export the activity properties.
711
+ * @returns The activity properties.
712
+ */
713
+ export() {
714
+ return {
715
+ name: this.getStorageProperty("name") || this.defaultName,
716
+ fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
717
+ toHour: this.getStorageProperty("toHour") || this.defaultToHour,
718
+ fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
719
+ toDay: this.getStorageProperty("toDay") || this.defaultToDay,
720
+ disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
721
+ hidden: this.getStorageProperty("hidden") || this.defaultHidden,
722
+ renderIcon: this._renderIcon
723
+ };
724
+ }
725
+ };
726
+
727
+ // src/classes/navigation/ActivityRoom.ts
728
+ var ActivityRoom = class extends ActivityStoredAbstract {
729
+ constructor(id, room, onRun, props) {
730
+ super(onRun, props);
731
+ this._id = id;
732
+ this._room = room;
733
+ }
734
+ setStorageProperty(_, __) {
735
+ this._room.setActivity(this);
736
+ }
737
+ getStorageProperty(propertyName) {
738
+ let activity = this._room.getActivityMemory(this.id);
739
+ if (!activity || !activity.hasOwnProperty(propertyName)) {
740
+ return void 0;
741
+ }
742
+ return activity[propertyName];
743
+ }
744
+ get id() {
745
+ return this._id;
746
+ }
747
+ get room() {
748
+ return this._room;
749
+ }
750
+ export() {
751
+ let result = {};
752
+ if (this.name !== void 0) {
753
+ result["name"] = this.name;
754
+ }
755
+ if (this.fromHour !== void 0) {
756
+ result["fromHour"] = this.fromHour;
757
+ }
758
+ if (this.toHour !== void 0) {
759
+ result["toHour"] = this.toHour;
760
+ }
761
+ if (this.fromDay !== void 0) {
762
+ result["fromDay"] = this.fromDay;
763
+ }
764
+ if (this.toDay !== void 0) {
765
+ result["toDay"] = this.toDay;
766
+ }
767
+ if (this.disabled !== void 0) {
768
+ result["disabled"] = this.disabled;
769
+ }
770
+ return result;
771
+ }
772
+ };
580
773
 
581
774
  // src/decorators/RoomDecorator.ts
582
775
  var registeredRooms = {};
@@ -864,244 +1057,51 @@ function getCurrentRoutine() {
864
1057
  });
865
1058
  return Object.values(character_commitments);
866
1059
  }
867
- var ActivityStoredAbstract = class {
1060
+
1061
+ // src/classes/navigation/Room.ts
1062
+ var ROOM_CATEGORY = "__nqtr-room__";
1063
+ var RoomBaseModel = class extends pixiVn.StoredClassModel {
868
1064
  /**
869
- * @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.
870
- * @param props The activity properties.
1065
+ * @param id The id of the room, it must be unique.
1066
+ * @param location The location where the room is.
1067
+ * @param props The properties of the room.
871
1068
  */
872
- constructor(onRun, props) {
873
- this.defaultName = props.name;
874
- this.defaultFromHour = props.fromHour;
875
- this.defaultToHour = props.toHour;
876
- this.defaultFromDay = props.fromDay;
877
- this.defaultToDay = props.toDay;
1069
+ constructor(id, location, props = {}) {
1070
+ var _a;
1071
+ super(ROOM_CATEGORY, id);
1072
+ this._location = location;
1073
+ this.defaultName = props.name || "";
1074
+ this._renderImage = props.renderImage;
1075
+ this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
878
1076
  this.defaultDisabled = props.disabled || false;
879
1077
  this.defaultHidden = props.hidden || false;
880
1078
  this._renderIcon = props.renderIcon;
881
- this._onRun = onRun;
1079
+ this._isEntrance = props.isEntrance;
882
1080
  }
883
1081
  /**
884
- * The name
1082
+ * The location where the room is.
885
1083
  */
886
- get name() {
887
- return this.getStorageProperty("name") || this.defaultName || "";
888
- }
889
- set name(value) {
890
- this.setStorageProperty("name", value);
1084
+ get location() {
1085
+ return this._location;
891
1086
  }
892
1087
  /**
893
- * The hour when the activity starts. If the activity is not started yet, it will be hidden.
1088
+ * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
894
1089
  */
895
- get fromHour() {
896
- return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
897
- }
898
- set fromHour(value) {
899
- this.setStorageProperty("fromHour", value);
1090
+ get isEntrance() {
1091
+ return this._isEntrance || false;
900
1092
  }
901
1093
  /**
902
- * The hour when the activity ends. If the activity is ended yet, it will be hidden.
1094
+ * The name.
1095
+ * If you set undefined, it will return the initial value of name.
903
1096
  */
904
- get toHour() {
905
- return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
1097
+ get name() {
1098
+ return this.getStorageProperty("name") || this.defaultName;
906
1099
  }
907
- set toHour(value) {
908
- this.setStorageProperty("toHour", value);
1100
+ set name(value) {
1101
+ this.setStorageProperty("name", value);
909
1102
  }
910
1103
  /**
911
- * The day when the activity starts. If the activity is not started yet, it will be hidden.
912
- */
913
- get fromDay() {
914
- return this.getStorageProperty("fromDay") || this.defaultFromDay;
915
- }
916
- set fromDay(value) {
917
- this.setStorageProperty("fromDay", value);
918
- }
919
- /**
920
- * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
921
- */
922
- get toDay() {
923
- return this.getStorageProperty("toDay") || this.defaultToDay;
924
- }
925
- set toDay(value) {
926
- this.setStorageProperty("toDay", value);
927
- }
928
- /**
929
- * Whether is disabled.
930
- */
931
- get disabled() {
932
- let value = this.getStorageProperty("disabled") || this.defaultDisabled;
933
- if (typeof value === "string") {
934
- return pixiVn.getFlag(value);
935
- }
936
- return value;
937
- }
938
- set disabled(value) {
939
- this.setStorageProperty("disabled", value);
940
- }
941
- /**
942
- * Whether is hidden. If the activity is not started yet, it will be hidden.
943
- */
944
- get hidden() {
945
- if (this.fromDay && this.fromDay > TimeManager.currentDay) {
946
- return true;
947
- }
948
- if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
949
- return true;
950
- }
951
- if (!this.isExpired) {
952
- return true;
953
- }
954
- let value = this.getStorageProperty("hidden") || this.defaultHidden;
955
- if (typeof value === "string") {
956
- return pixiVn.getFlag(value);
957
- }
958
- return value;
959
- }
960
- set hidden(value) {
961
- this.setStorageProperty("hidden", value);
962
- }
963
- /**
964
- * The function for rendering the icon of the activity.
965
- */
966
- get renderIcon() {
967
- let render = this._renderIcon;
968
- if (render === void 0) {
969
- return void 0;
970
- }
971
- if (typeof render === "function") {
972
- return (props) => {
973
- return render(this, props);
974
- };
975
- }
976
- return (props) => render;
977
- }
978
- /**
979
- * The function that is called when the activity is runned.
980
- */
981
- get onRun() {
982
- return (props) => {
983
- return this._onRun(this, props);
984
- };
985
- }
986
- /**
987
- * Whether the activity is a deadline.
988
- * @returns Whether the activity is a deadline.
989
- */
990
- isExpired() {
991
- if (this.toDay && this.toDay <= TimeManager.currentDay) {
992
- return true;
993
- }
994
- return false;
995
- }
996
- /**
997
- * Export the activity properties.
998
- * @returns The activity properties.
999
- */
1000
- export() {
1001
- return {
1002
- name: this.getStorageProperty("name") || this.defaultName,
1003
- fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
1004
- toHour: this.getStorageProperty("toHour") || this.defaultToHour,
1005
- fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
1006
- toDay: this.getStorageProperty("toDay") || this.defaultToDay,
1007
- disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
1008
- hidden: this.getStorageProperty("hidden") || this.defaultHidden,
1009
- renderIcon: this._renderIcon
1010
- };
1011
- }
1012
- };
1013
-
1014
- // src/classes/navigation/ActivityRoom.ts
1015
- var ActivityRoom = class extends ActivityStoredAbstract {
1016
- constructor(id, room, onRun, props) {
1017
- super(onRun, props);
1018
- this._id = id;
1019
- this._room = room;
1020
- }
1021
- setStorageProperty(_, __) {
1022
- this._room.setActivity(this);
1023
- }
1024
- getStorageProperty(propertyName) {
1025
- let activity = this._room.getActivityMemory(this.id);
1026
- if (!activity || !activity.hasOwnProperty(propertyName)) {
1027
- return void 0;
1028
- }
1029
- return activity[propertyName];
1030
- }
1031
- get id() {
1032
- return this._id;
1033
- }
1034
- get room() {
1035
- return this._room;
1036
- }
1037
- export() {
1038
- let result = {};
1039
- if (this.name !== void 0) {
1040
- result["name"] = this.name;
1041
- }
1042
- if (this.fromHour !== void 0) {
1043
- result["fromHour"] = this.fromHour;
1044
- }
1045
- if (this.toHour !== void 0) {
1046
- result["toHour"] = this.toHour;
1047
- }
1048
- if (this.fromDay !== void 0) {
1049
- result["fromDay"] = this.fromDay;
1050
- }
1051
- if (this.toDay !== void 0) {
1052
- result["toDay"] = this.toDay;
1053
- }
1054
- if (this.disabled !== void 0) {
1055
- result["disabled"] = this.disabled;
1056
- }
1057
- return result;
1058
- }
1059
- };
1060
-
1061
- // src/classes/navigation/Room.ts
1062
- var ROOM_CATEGORY = "__nqtr-room__";
1063
- var RoomBaseModel = class extends pixiVn.StoredClassModel {
1064
- /**
1065
- * @param id The id of the room, it must be unique.
1066
- * @param location The location where the room is.
1067
- * @param props The properties of the room.
1068
- */
1069
- constructor(id, location, props = {}) {
1070
- var _a;
1071
- super(ROOM_CATEGORY, id);
1072
- this._location = location;
1073
- this.defaultName = props.name || "";
1074
- this._renderImage = props.renderImage;
1075
- this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
1076
- this.defaultDisabled = props.disabled || false;
1077
- this.defaultHidden = props.hidden || false;
1078
- this._renderIcon = props.renderIcon;
1079
- this._isEntrance = props.isEntrance;
1080
- }
1081
- /**
1082
- * The location where the room is.
1083
- */
1084
- get location() {
1085
- return this._location;
1086
- }
1087
- /**
1088
- * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
1089
- */
1090
- get isEntrance() {
1091
- return this._isEntrance || false;
1092
- }
1093
- /**
1094
- * The name.
1095
- * If you set undefined, it will return the initial value of name.
1096
- */
1097
- get name() {
1098
- return this.getStorageProperty("name") || this.defaultName;
1099
- }
1100
- set name(value) {
1101
- this.setStorageProperty("name", value);
1102
- }
1103
- /**
1104
- * The function for rendering the image of the room.
1104
+ * The function for rendering the image of the room.
1105
1105
  */
1106
1106
  get renderImage() {
1107
1107
  let render = this._renderImage;
@@ -1294,47 +1294,78 @@ var RoomBaseModel = class extends pixiVn.StoredClassModel {
1294
1294
  return commitments.filter((c) => c.room.id === this.id);
1295
1295
  }
1296
1296
  };
1297
-
1298
- // src/classes/quest/Goal.ts
1299
- var Goal = class {
1300
- constructor(props) {
1297
+ var GOAL_CATEGORY = "__nqtr-goal__";
1298
+ var Goal = class extends pixiVn.StoredClassModel {
1299
+ constructor(id, props) {
1300
+ super(GOAL_CATEGORY, id);
1301
1301
  this._description = props.description;
1302
- this.need = props.need || 1;
1303
- this.have = props.have || 0;
1302
+ this._need = props.need || 1;
1303
+ this._defaultHave = props.have || 0;
1304
1304
  }
1305
+ /**
1306
+ * The description of the goal.
1307
+ */
1305
1308
  get description() {
1306
1309
  return this._description;
1307
1310
  }
1308
- get isComplete() {
1311
+ get need() {
1312
+ return this._need;
1313
+ }
1314
+ get defaultHave() {
1315
+ return this._defaultHave;
1316
+ }
1317
+ };
1318
+ var GoalStage = class extends Goal {
1319
+ constructor(id, stageId, props) {
1320
+ super(id, props);
1321
+ this._stageId = stageId;
1322
+ }
1323
+ get stageId() {
1324
+ return this._stageId;
1325
+ }
1326
+ set stageId(value) {
1327
+ this._stageId = value;
1328
+ }
1329
+ get have() {
1330
+ return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
1331
+ }
1332
+ set have(value) {
1333
+ if (!this._stageId) {
1334
+ console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
1335
+ return;
1336
+ }
1337
+ this.setStorageProperty("have-" + this._stageId, value);
1338
+ }
1339
+ get completed() {
1309
1340
  return this.have >= this.need;
1310
1341
  }
1311
- setComplete() {
1312
- this.have = this.need;
1342
+ set completed(value) {
1343
+ if (value) {
1344
+ this.have = this.need;
1345
+ } else {
1346
+ console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
1347
+ }
1313
1348
  }
1314
1349
  find() {
1315
1350
  this.have++;
1316
1351
  }
1317
- get export() {
1318
- return {
1319
- description: this.description,
1320
- need: this.need,
1321
- have: this.have
1322
- };
1323
- }
1324
1352
  };
1325
- var QUEST_CATEGORY = "__nqtr-quest__";
1326
- var QuestBaseModel = class extends pixiVn.StoredClassModel {
1327
- constructor(id, stages, props) {
1328
- super(QUEST_CATEGORY, id);
1329
- this._stages = stages;
1353
+ var STAGE_CATEGORY = "__nqtr-stage__";
1354
+ var Stage = class extends pixiVn.StoredClassModel {
1355
+ constructor(id, props) {
1356
+ super(STAGE_CATEGORY, id);
1330
1357
  this._name = props.name || "";
1358
+ this._defaultGoals = props.goals || [];
1359
+ this._flags = props.flags || [];
1331
1360
  this._description = props.description || "";
1332
- this._icon = props.icon || "";
1333
- this._image = props.image || "";
1334
- this._isInDevelopment = props.isInDevelopment || false;
1335
- }
1336
- get stages() {
1337
- return this._stages;
1361
+ this._adviceDescription = props.adviceDescription || "";
1362
+ this._renderImage = props.renderImage;
1363
+ this._daysRequiredToStart = props.daysRequiredToStart;
1364
+ this._flagsRequiredToStart = props.flagsRequired || [];
1365
+ this._questsRequiredToStart = props.questsRequired || [];
1366
+ this._requestDescriptionToStart = props.requestDescription || "";
1367
+ this._onStart = props.onStart;
1368
+ this._onEnd = props.onEnd;
1338
1369
  }
1339
1370
  get name() {
1340
1371
  return this._name;
@@ -1342,50 +1373,138 @@ var QuestBaseModel = class extends pixiVn.StoredClassModel {
1342
1373
  get description() {
1343
1374
  return this._description;
1344
1375
  }
1345
- get icon() {
1346
- return this._icon;
1376
+ get adviceDescription() {
1377
+ return this._adviceDescription;
1347
1378
  }
1348
- get image() {
1349
- return this._image;
1379
+ /**
1380
+ * The function for rendering the image of the stage.
1381
+ */
1382
+ get renderImage() {
1383
+ let render = this._renderImage;
1384
+ if (render === void 0) {
1385
+ return void 0;
1386
+ }
1387
+ if (typeof render === "function") {
1388
+ return (props) => {
1389
+ return render(this, props);
1390
+ };
1391
+ }
1392
+ return (props) => render;
1350
1393
  }
1351
- get isInDevelopment() {
1352
- return this._isInDevelopment;
1394
+ get defaultGoals() {
1395
+ return this._defaultGoals;
1396
+ }
1397
+ /**
1398
+ * The list of flags that the player must complete to finish the stage.
1399
+ */
1400
+ get flags() {
1401
+ return this._flags;
1402
+ }
1403
+ get daysRequiredToStart() {
1404
+ return this._daysRequiredToStart || 0;
1405
+ }
1406
+ get flagsRequiredToStart() {
1407
+ return this._flagsRequiredToStart;
1408
+ }
1409
+ get questsRequiredToStart() {
1410
+ return this._questsRequiredToStart || [];
1411
+ }
1412
+ get requestDescriptionToStart() {
1413
+ return this._requestDescriptionToStart;
1414
+ }
1415
+ get onStart() {
1416
+ return this._onStart;
1417
+ }
1418
+ get onEnd() {
1419
+ return this._onEnd;
1353
1420
  }
1354
1421
  };
1355
- var STAGE_CATEGORY = "__nqtr-stage__";
1356
- var StageBaseModel = class extends pixiVn.StoredClassModel {
1422
+ var StageQuest = class extends Stage {
1357
1423
  constructor(id, props) {
1358
- super(STAGE_CATEGORY, id);
1359
- this._completed = false;
1360
- this._active = false;
1361
- this.defaultGoals = [];
1362
- this._name = props.name || "";
1363
- this._description = props.description || "";
1364
- this._adviceDescription = props.adviceDescription || "";
1365
- this._image = props.image || "";
1366
- this._daysRequiredToStart = props.daysRequiredToStart;
1367
- this._flagsRequired = props.flagsRequired;
1368
- this._questsRequired = props.questsRequired;
1369
- this._requestDescription = props.requestDescription || "";
1370
- this._onStart = props.onStart;
1371
- this._onEnd = props.onEnd;
1424
+ super(id, props);
1372
1425
  }
1373
1426
  get completed() {
1374
- return this._completed;
1427
+ let storedCompleted = this.getStorageProperty("completed");
1428
+ if (storedCompleted) {
1429
+ return storedCompleted;
1430
+ }
1431
+ if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
1432
+ return false;
1433
+ }
1434
+ if (!this.goals.every((goal) => goal.completed)) {
1435
+ return false;
1436
+ }
1437
+ return true;
1375
1438
  }
1376
- get active() {
1377
- return this._active;
1439
+ set completed(value) {
1440
+ this.setStorageProperty("completed", value);
1378
1441
  }
1442
+ /**
1443
+ * The list of goals that the player needs to complete to finish the stage.
1444
+ */
1379
1445
  get goals() {
1380
- let list = this.getStorageProperty("goals");
1381
- if (!list) {
1382
- return this.defaultGoals;
1446
+ return this.defaultGoals.map((goal) => {
1447
+ return new GoalStage(goal.id, this.id, goal);
1448
+ });
1449
+ }
1450
+ get prevStageEndDay() {
1451
+ return this.getStorageProperty("prevStageEndDay");
1452
+ }
1453
+ set prevStageEndDay(value) {
1454
+ this.setStorageProperty("prevStageEndDay", value);
1455
+ }
1456
+ get startDay() {
1457
+ let prevStageEndDay = this.prevStageEndDay;
1458
+ if (prevStageEndDay === void 0) {
1459
+ return void 0;
1460
+ }
1461
+ return prevStageEndDay + this.daysRequiredToStart;
1462
+ }
1463
+ get canStart() {
1464
+ let daysRequired = this.daysRequiredToStart;
1465
+ if (daysRequired > 0) {
1466
+ let prevStageEndDay = this.prevStageEndDay;
1467
+ if (prevStageEndDay === void 0) {
1468
+ return false;
1469
+ }
1470
+ if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
1471
+ return false;
1472
+ }
1473
+ }
1474
+ if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => pixiVn.getFlag(flag.flag))) {
1475
+ return false;
1383
1476
  }
1384
- return list.map((goal) => new Goal(goal));
1477
+ if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
1478
+ (q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
1479
+ )) {
1480
+ return false;
1481
+ }
1482
+ return true;
1483
+ }
1484
+ get onStart() {
1485
+ if (this.daysRequiredToStart > 0) {
1486
+ this.prevStageEndDay = TimeManager.currentDay;
1487
+ }
1488
+ return super.onStart;
1489
+ }
1490
+ };
1491
+
1492
+ // src/classes/quest/Quest.ts
1493
+ var QUEST_CATEGORY = "__nqtr-quest__";
1494
+ var Quest = class extends pixiVn.StoredClassModel {
1495
+ constructor(id, stages, props) {
1496
+ super(QUEST_CATEGORY, id);
1497
+ this._stages = stages;
1498
+ this._name = props.name || "";
1499
+ this._description = props.description || "";
1500
+ this._renderIcon = props.renderIcon;
1501
+ this._renderImage = props.renderImage;
1502
+ this._isInDevelopment = props.isInDevelopment || false;
1385
1503
  }
1386
- set goals(value) {
1387
- let list = value.map((goal) => goal.export);
1388
- this.setStorageProperty("goals", list);
1504
+ get stages() {
1505
+ return this._stages.map((stage, index) => {
1506
+ return new StageQuest(stage.id, stage);
1507
+ });
1389
1508
  }
1390
1509
  get name() {
1391
1510
  return this._name;
@@ -1393,39 +1512,110 @@ var StageBaseModel = class extends pixiVn.StoredClassModel {
1393
1512
  get description() {
1394
1513
  return this._description;
1395
1514
  }
1396
- get adviceDescription() {
1397
- return this._adviceDescription;
1515
+ /**
1516
+ * The function for rendering the icon of the quest.
1517
+ */
1518
+ get renderIcon() {
1519
+ let render = this._renderIcon;
1520
+ if (render === void 0) {
1521
+ return void 0;
1522
+ }
1523
+ if (typeof render === "function") {
1524
+ return (props) => {
1525
+ return render(this, props);
1526
+ };
1527
+ }
1528
+ return (props) => render;
1398
1529
  }
1399
- get image() {
1400
- return this._image;
1530
+ /**
1531
+ * The function for rendering the image of the quest.
1532
+ */
1533
+ get renderImage() {
1534
+ let render = this._renderImage;
1535
+ if (render === void 0) {
1536
+ return void 0;
1537
+ }
1538
+ if (typeof render === "function") {
1539
+ return (props) => {
1540
+ return render(this, props);
1541
+ };
1542
+ }
1543
+ return (props) => render;
1401
1544
  }
1402
- get daysRequiredToStart() {
1403
- return this._daysRequiredToStart;
1545
+ get isInDevelopment() {
1546
+ return this._isInDevelopment;
1404
1547
  }
1405
- get flagsRequired() {
1406
- return this._flagsRequired;
1548
+ get currentStageIndex() {
1549
+ return this.getStorageProperty("currentStageIndex");
1407
1550
  }
1408
- get questsRequired() {
1409
- return this._questsRequired;
1551
+ set currentStageIndex(value) {
1552
+ this.setStorageProperty("currentStageIndex", value);
1410
1553
  }
1411
- get requestDescription() {
1412
- return this._requestDescription;
1554
+ get currentStage() {
1555
+ let index = this.currentStageIndex;
1556
+ if (index === void 0 || index >= this.stages.length) {
1557
+ return void 0;
1558
+ }
1559
+ return this.stages[index];
1413
1560
  }
1414
- get onStart() {
1415
- return this._onStart;
1561
+ get started() {
1562
+ return this.currentStageIndex !== void 0;
1416
1563
  }
1417
- get onEnd() {
1418
- return this._onEnd;
1564
+ get completed() {
1565
+ return this.currentStageIndex === this.stages.length;
1566
+ }
1567
+ start() {
1568
+ if (this.started) {
1569
+ console.warn(`[NQTR] Quest ${this.id} is already started`);
1570
+ return;
1571
+ }
1572
+ if (this.stages.length === 0) {
1573
+ console.error(`[NQTR] Quest ${this.id} has no stages`);
1574
+ return;
1575
+ }
1576
+ this.currentStageIndex = 0;
1577
+ let currentStage = this.currentStage;
1578
+ if (currentStage && currentStage.onStart) {
1579
+ return currentStage.onStart();
1580
+ } else {
1581
+ console.error(`[NQTR] Quest ${this.id} has no start stage`);
1582
+ }
1583
+ }
1584
+ tryToGoNextStage() {
1585
+ if (!this.started) {
1586
+ return;
1587
+ }
1588
+ if (this.completed) {
1589
+ return;
1590
+ }
1591
+ let currentStage = this.currentStage;
1592
+ let currentStageIndex = this.currentStageIndex;
1593
+ if (!currentStage || currentStageIndex === void 0) {
1594
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1595
+ return;
1596
+ }
1597
+ if (currentStage.completed) {
1598
+ let nextStageIndex = currentStageIndex + 1;
1599
+ currentStageIndex = nextStageIndex;
1600
+ let nextStage = this.currentStage;
1601
+ if (currentStage && currentStage.onEnd) {
1602
+ currentStage.onEnd();
1603
+ }
1604
+ if (nextStage && nextStage.onStart) {
1605
+ return nextStage.onStart();
1606
+ }
1607
+ }
1419
1608
  }
1420
1609
  };
1421
1610
 
1422
1611
  exports.ActivityModel = ActivityModel;
1612
+ exports.ActivityRoom = ActivityRoom;
1423
1613
  exports.CommitmentBaseModel = CommitmentBaseModel;
1424
1614
  exports.Goal = Goal;
1425
1615
  exports.LocationBaseModel = LocationBaseModel;
1426
1616
  exports.MapBaseModel = MapBaseModel;
1427
- exports.QuestBaseModel = QuestBaseModel;
1617
+ exports.Quest = Quest;
1428
1618
  exports.RoomBaseModel = RoomBaseModel;
1429
- exports.StageBaseModel = StageBaseModel;
1619
+ exports.Stage = Stage;
1430
1620
  //# sourceMappingURL=out.js.map
1431
1621
  //# sourceMappingURL=index.js.map