@drincs/nqtr 0.2.2 → 0.2.3

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 (101) hide show
  1. package/dist/{Commitment-Eox2652k.d.mts → Commitment-BHB-jYOi.d.mts} +2 -2
  2. package/dist/{Commitment-D3LPSbFX.d.ts → Commitment-D-1lsnnU.d.ts} +2 -2
  3. package/dist/{StageProps-D002cyay.d.mts → StageProps-CJSp_a54.d.mts} +8 -1
  4. package/dist/{StageProps-DleWO-vf.d.ts → StageProps-CV4rWD7t.d.ts} +8 -1
  5. package/dist/classes/Commitment.d.mts +1 -1
  6. package/dist/classes/Commitment.d.ts +1 -1
  7. package/dist/classes/index.d.mts +2 -2
  8. package/dist/classes/index.d.ts +2 -2
  9. package/dist/classes/index.js +383 -2
  10. package/dist/classes/index.js.map +1 -1
  11. package/dist/classes/index.mjs +382 -2
  12. package/dist/classes/index.mjs.map +1 -1
  13. package/dist/classes/navigation/ActivityRoom.d.mts +1 -1
  14. package/dist/classes/navigation/ActivityRoom.d.ts +1 -1
  15. package/dist/classes/navigation/ActivityRoom.js +3 -0
  16. package/dist/classes/navigation/ActivityRoom.js.map +1 -1
  17. package/dist/classes/navigation/ActivityRoom.mjs +3 -0
  18. package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
  19. package/dist/classes/navigation/Location.d.mts +1 -1
  20. package/dist/classes/navigation/Location.d.ts +1 -1
  21. package/dist/classes/navigation/Map.d.mts +1 -1
  22. package/dist/classes/navigation/Map.d.ts +1 -1
  23. package/dist/classes/navigation/Room.d.mts +1 -1
  24. package/dist/classes/navigation/Room.d.ts +1 -1
  25. package/dist/classes/navigation/Room.js +37 -34
  26. package/dist/classes/navigation/Room.js.map +1 -1
  27. package/dist/classes/navigation/Room.mjs +37 -34
  28. package/dist/classes/navigation/Room.mjs.map +1 -1
  29. package/dist/classes/quest/Quest.d.mts +1 -1
  30. package/dist/classes/quest/Quest.d.ts +1 -1
  31. package/dist/classes/quest/Quest.js +10 -0
  32. package/dist/classes/quest/Quest.js.map +1 -1
  33. package/dist/classes/quest/Quest.mjs +10 -0
  34. package/dist/classes/quest/Quest.mjs.map +1 -1
  35. package/dist/classes/quest/Stage.d.mts +1 -1
  36. package/dist/classes/quest/Stage.d.ts +1 -1
  37. package/dist/decorators/CommitmentDecorator.d.mts +1 -1
  38. package/dist/decorators/CommitmentDecorator.d.ts +1 -1
  39. package/dist/decorators/QuestDecorator.d.mts +7 -2
  40. package/dist/decorators/QuestDecorator.d.ts +7 -2
  41. package/dist/decorators/QuestDecorator.js +14 -0
  42. package/dist/decorators/QuestDecorator.js.map +1 -1
  43. package/dist/decorators/QuestDecorator.mjs +14 -1
  44. package/dist/decorators/QuestDecorator.mjs.map +1 -1
  45. package/dist/decorators/RoomDecorator.d.mts +1 -1
  46. package/dist/decorators/RoomDecorator.d.ts +1 -1
  47. package/dist/decorators/index.d.mts +3 -3
  48. package/dist/decorators/index.d.ts +3 -3
  49. package/dist/decorators/index.js +14 -0
  50. package/dist/decorators/index.js.map +1 -1
  51. package/dist/decorators/index.mjs +14 -1
  52. package/dist/decorators/index.mjs.map +1 -1
  53. package/dist/functions/ActivityFunctions.d.mts +8 -1
  54. package/dist/functions/ActivityFunctions.d.ts +8 -1
  55. package/dist/functions/ActivityFunctions.js.map +1 -1
  56. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  57. package/dist/functions/NavigationFunctions.d.mts +20 -3
  58. package/dist/functions/NavigationFunctions.d.ts +20 -3
  59. package/dist/functions/NavigationFunctions.js +2 -2
  60. package/dist/functions/NavigationFunctions.js.map +1 -1
  61. package/dist/functions/NavigationFunctions.mjs +2 -2
  62. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  63. package/dist/functions/QuestFunctions.js.map +1 -1
  64. package/dist/functions/QuestFunctions.mjs.map +1 -1
  65. package/dist/functions/RoutineFunctions.d.mts +7 -2
  66. package/dist/functions/RoutineFunctions.d.ts +7 -2
  67. package/dist/functions/RoutineFunctions.js +40 -0
  68. package/dist/functions/RoutineFunctions.js.map +1 -1
  69. package/dist/functions/RoutineFunctions.mjs +40 -1
  70. package/dist/functions/RoutineFunctions.mjs.map +1 -1
  71. package/dist/functions/index.d.mts +3 -3
  72. package/dist/functions/index.d.ts +3 -3
  73. package/dist/functions/index.js +10 -2
  74. package/dist/functions/index.js.map +1 -1
  75. package/dist/functions/index.mjs +9 -2
  76. package/dist/functions/index.mjs.map +1 -1
  77. package/dist/index.d.mts +5 -5
  78. package/dist/index.d.ts +5 -5
  79. package/dist/index.js +74 -48
  80. package/dist/index.js.map +1 -1
  81. package/dist/index.mjs +70 -47
  82. package/dist/index.mjs.map +1 -1
  83. package/dist/interface/CommitmentProps.d.mts +1 -1
  84. package/dist/interface/CommitmentProps.d.ts +1 -1
  85. package/dist/interface/RoomProps.d.mts +1 -1
  86. package/dist/interface/RoomProps.d.ts +1 -1
  87. package/dist/interface/index.d.mts +2 -2
  88. package/dist/interface/index.d.ts +2 -2
  89. package/dist/interface/navigation/LocationProps.d.mts +1 -1
  90. package/dist/interface/navigation/LocationProps.d.ts +1 -1
  91. package/dist/interface/navigation/MapProps.d.mts +1 -1
  92. package/dist/interface/navigation/MapProps.d.ts +1 -1
  93. package/dist/interface/quest/QuestProps.d.mts +1 -1
  94. package/dist/interface/quest/QuestProps.d.ts +1 -1
  95. package/dist/interface/quest/StageProps.d.mts +1 -1
  96. package/dist/interface/quest/StageProps.d.ts +1 -1
  97. package/dist/types/QuestsRequired.d.mts +1 -1
  98. package/dist/types/QuestsRequired.d.ts +1 -1
  99. package/dist/types/index.d.mts +1 -1
  100. package/dist/types/index.d.ts +1 -1
  101. package/package.json +5 -5
@@ -217,10 +217,10 @@ declare class ActivityRoom<TRoom extends RoomBaseModel = RoomBaseModel> extends
217
217
  getStorageProperty<T>(propertyName: string): T | undefined;
218
218
  private _id;
219
219
  get id(): string;
220
+ private _room;
220
221
  /**
221
222
  * The room where the activity is.
222
223
  */
223
- private _room;
224
224
  get room(): TRoom;
225
225
  export(): object;
226
226
  }
@@ -368,7 +368,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
368
368
  declare const ROOM_CATEGORY = "__nqtr-room__";
369
369
  /**
370
370
  * The base model of a room. I suggest you extend this class to create your own room model.
371
- * You must use the saveRoom function to save the room in the registered rooms.
371
+ * **You must use the {@link saveRoom} function to save the room in the registered rooms.**
372
372
  * @example
373
373
  * ```ts
374
374
  * export const mcRoom = new RoomBaseModel('mc_room', mcHome, {
@@ -217,10 +217,10 @@ declare class ActivityRoom<TRoom extends RoomBaseModel = RoomBaseModel> extends
217
217
  getStorageProperty<T>(propertyName: string): T | undefined;
218
218
  private _id;
219
219
  get id(): string;
220
+ private _room;
220
221
  /**
221
222
  * The room where the activity is.
222
223
  */
223
- private _room;
224
224
  get room(): TRoom;
225
225
  export(): object;
226
226
  }
@@ -368,7 +368,7 @@ declare class LocationBaseModel<TMap extends MapBaseModel = MapBaseModel> extend
368
368
  declare const ROOM_CATEGORY = "__nqtr-room__";
369
369
  /**
370
370
  * The base model of a room. I suggest you extend this class to create your own room model.
371
- * You must use the saveRoom function to save the room in the registered rooms.
371
+ * **You must use the {@link saveRoom} function to save the room in the registered rooms.**
372
372
  * @example
373
373
  * ```ts
374
374
  * export const mcRoom = new RoomBaseModel('mc_room', mcHome, {
@@ -183,7 +183,14 @@ declare class Quest extends StoredClassModel {
183
183
  * @returns returns true if the stage was changed, false otherwise.
184
184
  */
185
185
  goNextStage(startProps: OnStartStage, endProps: OnEndStage): boolean;
186
+ /**
187
+ * If the current stage must start. It is true if the current stage is not started, can start and not completed.
188
+ */
186
189
  get currentStageMustStart(): boolean;
190
+ /**
191
+ * Start the current stage.
192
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
193
+ */
187
194
  startCurrentStage(props: OnStartStage): void;
188
195
  }
189
196
 
@@ -301,4 +308,4 @@ interface StageProps {
301
308
  onEnd?: (props: OnEndStage) => void;
302
309
  }
303
310
 
304
- export { type QuestProps as Q, Stage as S, type StageProps as a, type QuestsRequiredType as b, Quest as c, StageQuest as d };
311
+ export { Quest as Q, Stage as S, type QuestProps as a, type StageProps as b, type QuestsRequiredType as c, StageQuest as d };
@@ -183,7 +183,14 @@ declare class Quest extends StoredClassModel {
183
183
  * @returns returns true if the stage was changed, false otherwise.
184
184
  */
185
185
  goNextStage(startProps: OnStartStage, endProps: OnEndStage): boolean;
186
+ /**
187
+ * If the current stage must start. It is true if the current stage is not started, can start and not completed.
188
+ */
186
189
  get currentStageMustStart(): boolean;
190
+ /**
191
+ * Start the current stage.
192
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
193
+ */
187
194
  startCurrentStage(props: OnStartStage): void;
188
195
  }
189
196
 
@@ -301,4 +308,4 @@ interface StageProps {
301
308
  onEnd?: (props: OnEndStage) => void;
302
309
  }
303
310
 
304
- export { type QuestProps as Q, Stage as S, type StageProps as a, type QuestsRequiredType as b, Quest as c, StageQuest as d };
311
+ export { Quest as Q, Stage as S, type QuestProps as a, type StageProps as b, type QuestsRequiredType as c, StageQuest as d };
@@ -1,6 +1,6 @@
1
1
  import '@drincs/nqtr/dist/override';
2
2
  import '@drincs/pixi-vn';
3
- export { C as default } from '../Commitment-Eox2652k.mjs';
3
+ export { C as default } from '../Commitment-BHB-jYOi.mjs';
4
4
  import '../types/ExecutionType.mjs';
5
5
  import '../ActivityProps-D45DQdcT.mjs';
6
6
  import '../types/OnRunActivityEvent.mjs';
@@ -1,6 +1,6 @@
1
1
  import '@drincs/nqtr/dist/override';
2
2
  import '@drincs/pixi-vn';
3
- export { C as default } from '../Commitment-D3LPSbFX.js';
3
+ export { C as default } from '../Commitment-D-1lsnnU.js';
4
4
  import '../types/ExecutionType.js';
5
5
  import '../ActivityProps-BkHX8xkA.js';
6
6
  import '../types/OnRunActivityEvent.js';
@@ -1,6 +1,6 @@
1
- export { A as ActivityRoom, C as CommitmentBaseModel, L as LocationBaseModel, M as MapBaseModel, R as RoomBaseModel } from '../Commitment-Eox2652k.mjs';
1
+ export { A as ActivityRoom, C as CommitmentBaseModel, L as LocationBaseModel, M as MapBaseModel, R as RoomBaseModel } from '../Commitment-BHB-jYOi.mjs';
2
2
  export { default as Goal } from './quest/Goal.mjs';
3
- export { S as Stage } from '../StageProps-D002cyay.mjs';
3
+ export { Q as Quest, S as Stage } from '../StageProps-CJSp_a54.mjs';
4
4
  import '@drincs/nqtr/dist/override';
5
5
  import '@drincs/pixi-vn';
6
6
  import '../ActivityProps-D45DQdcT.mjs';
@@ -1,6 +1,6 @@
1
- export { A as ActivityRoom, C as CommitmentBaseModel, L as LocationBaseModel, M as MapBaseModel, R as RoomBaseModel } from '../Commitment-D3LPSbFX.js';
1
+ export { A as ActivityRoom, C as CommitmentBaseModel, L as LocationBaseModel, M as MapBaseModel, R as RoomBaseModel } from '../Commitment-D-1lsnnU.js';
2
2
  export { default as Goal } from './quest/Goal.js';
3
- export { S as Stage } from '../StageProps-DleWO-vf.js';
3
+ export { Q as Quest, S as Stage } from '../StageProps-CV4rWD7t.js';
4
4
  import '@drincs/nqtr/dist/override';
5
5
  import '@drincs/pixi-vn';
6
6
  import '../ActivityProps-BkHX8xkA.js';
@@ -615,6 +615,9 @@ var ActivityRoom = class extends ActivityStoredAbstract {
615
615
  get id() {
616
616
  return this._id;
617
617
  }
618
+ /**
619
+ * The room where the activity is.
620
+ */
618
621
  get room() {
619
622
  return this._room;
620
623
  }
@@ -921,6 +924,53 @@ var Goal = class extends pixiVn.StoredClassModel {
921
924
  return this._defaultHave;
922
925
  }
923
926
  };
927
+ var GoalStage = class extends Goal {
928
+ constructor(id, stageId, props) {
929
+ super(id, props);
930
+ this._stageId = stageId;
931
+ }
932
+ /**
933
+ * The id of the stage that the goal belongs to.
934
+ */
935
+ get stageId() {
936
+ return this._stageId;
937
+ }
938
+ set stageId(value) {
939
+ this._stageId = value;
940
+ }
941
+ /**
942
+ * The number of times the goal has been completed.
943
+ */
944
+ get have() {
945
+ return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
946
+ }
947
+ set have(value) {
948
+ if (!this._stageId) {
949
+ console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
950
+ return;
951
+ }
952
+ this.setStorageProperty("have-" + this._stageId, value);
953
+ }
954
+ /**
955
+ * If the goal is completed.
956
+ */
957
+ get completed() {
958
+ return this.have >= this.need;
959
+ }
960
+ set completed(value) {
961
+ if (value) {
962
+ this.have = this.need;
963
+ } else {
964
+ console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
965
+ }
966
+ }
967
+ /**
968
+ * Find the goal. It will increment the have value.
969
+ */
970
+ find() {
971
+ this.have++;
972
+ }
973
+ };
924
974
 
925
975
  // src/classes/quest/Stage.ts
926
976
  var STAGE_CATEGORY = "__nqtr-stage__";
@@ -1023,6 +1073,336 @@ var Stage = class extends pixiVn.StoredClassModel {
1023
1073
  return this._onEnd;
1024
1074
  }
1025
1075
  };
1076
+ var StageQuest = class extends Stage {
1077
+ constructor(id, props) {
1078
+ super(id, props);
1079
+ }
1080
+ /**
1081
+ * Check if the flag and goals are completed.
1082
+ * You can force the completion of the stage by setting the completed property to true.
1083
+ */
1084
+ get completed() {
1085
+ let storedCompleted = this.getStorageProperty("completed");
1086
+ if (storedCompleted) {
1087
+ return storedCompleted;
1088
+ }
1089
+ if (this.flags.length > 0 && this.goals.length > 0) {
1090
+ if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
1091
+ return false;
1092
+ }
1093
+ if (!this.goals.every((goal) => goal.completed)) {
1094
+ return false;
1095
+ }
1096
+ return true;
1097
+ }
1098
+ return false;
1099
+ }
1100
+ set completed(value) {
1101
+ this.setStorageProperty("completed", value);
1102
+ }
1103
+ /**
1104
+ * If the stage is started.
1105
+ */
1106
+ get started() {
1107
+ return this.getStorageProperty("started") || false;
1108
+ }
1109
+ set started(value) {
1110
+ this.setStorageProperty("started", value);
1111
+ }
1112
+ /**
1113
+ * The list of goals that the player needs to complete to finish the stage.
1114
+ */
1115
+ get goals() {
1116
+ return this.defaultGoals.map((goal) => {
1117
+ return new GoalStage(goal.id, this.id, goal);
1118
+ });
1119
+ }
1120
+ get prevStageEndDay() {
1121
+ return this.getStorageProperty("prevStageEndDay");
1122
+ }
1123
+ set prevStageEndDay(value) {
1124
+ this.setStorageProperty("prevStageEndDay", value);
1125
+ }
1126
+ /**
1127
+ * The day when the stage starts.
1128
+ */
1129
+ get startDay() {
1130
+ let prevStageEndDay = this.prevStageEndDay;
1131
+ if (prevStageEndDay === void 0) {
1132
+ return void 0;
1133
+ }
1134
+ return prevStageEndDay + this.daysRequiredToStart;
1135
+ }
1136
+ /**
1137
+ * Check if the stage can start.
1138
+ */
1139
+ get canStart() {
1140
+ let daysRequired = this.daysRequiredToStart;
1141
+ if (daysRequired > 0) {
1142
+ let prevStageEndDay = this.prevStageEndDay;
1143
+ if (prevStageEndDay === void 0) {
1144
+ return false;
1145
+ }
1146
+ if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
1147
+ return false;
1148
+ }
1149
+ }
1150
+ if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => pixiVn.getFlag(flag.flag))) {
1151
+ return false;
1152
+ }
1153
+ if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
1154
+ (q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
1155
+ )) {
1156
+ return false;
1157
+ }
1158
+ return true;
1159
+ }
1160
+ /**
1161
+ * Inizialize the stage. **This function should be called only by the Quest class.**
1162
+ */
1163
+ inizialize() {
1164
+ if (this.daysRequiredToStart > 0) {
1165
+ this.prevStageEndDay = TimeManager.currentDay;
1166
+ console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
1167
+ }
1168
+ }
1169
+ /**
1170
+ * The function that will be called when the stage starts.
1171
+ */
1172
+ start(props) {
1173
+ if (this.canStart) {
1174
+ this.started = true;
1175
+ if (this.onStart) {
1176
+ this.onStart(props);
1177
+ }
1178
+ } else {
1179
+ console.warn(`[NQTR] Stage ${this.id} can't start`);
1180
+ }
1181
+ }
1182
+ };
1183
+
1184
+ // src/classes/quest/Quest.ts
1185
+ var QUEST_CATEGORY = "__nqtr-quest__";
1186
+ var Quest = class extends pixiVn.StoredClassModel {
1187
+ constructor(id, stages, props) {
1188
+ super(QUEST_CATEGORY, id);
1189
+ this._stages = stages;
1190
+ this._name = props.name || "";
1191
+ this._description = props.description || "";
1192
+ this._renderIcon = props.renderIcon;
1193
+ this._renderImage = props.renderImage;
1194
+ this._isInDevelopment = props.isInDevelopment || false;
1195
+ }
1196
+ /**
1197
+ * The stages of the quest.
1198
+ */
1199
+ get stages() {
1200
+ return this._stages.map((stage, index) => {
1201
+ return new StageQuest(stage.id, stage);
1202
+ });
1203
+ }
1204
+ /**
1205
+ * The name of the quest.
1206
+ */
1207
+ get name() {
1208
+ return this._name;
1209
+ }
1210
+ /**
1211
+ * The description of the quest.
1212
+ */
1213
+ get description() {
1214
+ return this._description;
1215
+ }
1216
+ /**
1217
+ * The function for rendering the icon of the quest.
1218
+ */
1219
+ get renderIcon() {
1220
+ let render = this._renderIcon;
1221
+ if (render === void 0) {
1222
+ return void 0;
1223
+ }
1224
+ if (typeof render === "function") {
1225
+ return (props) => {
1226
+ return render(this, props);
1227
+ };
1228
+ }
1229
+ return (props) => render;
1230
+ }
1231
+ /**
1232
+ * The function for rendering the image of the quest.
1233
+ */
1234
+ get renderImage() {
1235
+ let render = this._renderImage;
1236
+ if (render === void 0) {
1237
+ return void 0;
1238
+ }
1239
+ if (typeof render === "function") {
1240
+ return (props) => {
1241
+ return render(this, props);
1242
+ };
1243
+ }
1244
+ return (props) => render;
1245
+ }
1246
+ /**
1247
+ * If the quest is in development.
1248
+ */
1249
+ get isInDevelopment() {
1250
+ return this._isInDevelopment;
1251
+ }
1252
+ /**
1253
+ * The index of the current stage.
1254
+ */
1255
+ get currentStageIndex() {
1256
+ return this.getStorageProperty("currentStageIndex");
1257
+ }
1258
+ set currentStageIndex(value) {
1259
+ this.setStorageProperty("currentStageIndex", value);
1260
+ }
1261
+ /**
1262
+ * The current stage.
1263
+ */
1264
+ get currentStage() {
1265
+ let index = this.currentStageIndex;
1266
+ if (index === void 0 || index >= this.stages.length) {
1267
+ return void 0;
1268
+ }
1269
+ return this.stages[index];
1270
+ }
1271
+ /**
1272
+ * If the quest is started.
1273
+ */
1274
+ get started() {
1275
+ return this.currentStageIndex !== void 0;
1276
+ }
1277
+ /**
1278
+ * If the quest is completed.
1279
+ */
1280
+ get completed() {
1281
+ if (this.currentStageIndex === void 0) {
1282
+ return false;
1283
+ }
1284
+ return this.currentStageIndex > this.stages.length - 1;
1285
+ }
1286
+ /**
1287
+ * Start the quest.
1288
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
1289
+ * @returns
1290
+ */
1291
+ start(props) {
1292
+ if (this.started) {
1293
+ console.warn(`[NQTR] Quest ${this.id} is already started`);
1294
+ return;
1295
+ }
1296
+ if (this.stages.length === 0) {
1297
+ console.error(`[NQTR] Quest ${this.id} has no stages`);
1298
+ return;
1299
+ }
1300
+ this.currentStageIndex = 0;
1301
+ let currentStage = this.currentStage;
1302
+ if (currentStage && currentStage.start) {
1303
+ return currentStage.start(props);
1304
+ } else {
1305
+ console.error(`[NQTR] Quest ${this.id} has no start stage`);
1306
+ }
1307
+ }
1308
+ /**
1309
+ * Go to the next stage if the current stage is completed.
1310
+ * If you want to force the change of stage, use goNextStage.
1311
+ * @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
1312
+ * @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
1313
+ * @returns true if the stage was changed, false otherwise.
1314
+ */
1315
+ tryToGoNextStage(startProps, endProps) {
1316
+ if (!this.started) {
1317
+ return false;
1318
+ }
1319
+ if (this.completed) {
1320
+ return false;
1321
+ }
1322
+ let currentStage = this.currentStage;
1323
+ if (!currentStage) {
1324
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1325
+ return false;
1326
+ }
1327
+ if (currentStage.completed) {
1328
+ return this.goNextStage(startProps, endProps);
1329
+ }
1330
+ return false;
1331
+ }
1332
+ /**
1333
+ * Complete the current stage and go to the next stage.
1334
+ * If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
1335
+ * @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
1336
+ * @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
1337
+ * @returns true if the stage was changed, false otherwise.
1338
+ */
1339
+ completeCurrentStageAndGoNext(startProps, endProps) {
1340
+ let currentStage = this.currentStage;
1341
+ if (!currentStage) {
1342
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1343
+ return false;
1344
+ }
1345
+ currentStage.completed = true;
1346
+ return this.goNextStage(startProps, endProps);
1347
+ }
1348
+ /**
1349
+ * Go to the next stage without checking if the current stage is completed.
1350
+ * If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
1351
+ * @param startProps
1352
+ * @param endProps
1353
+ * @returns returns true if the stage was changed, false otherwise.
1354
+ */
1355
+ goNextStage(startProps, endProps) {
1356
+ if (!this.started) {
1357
+ console.warn(`[NQTR] Quest ${this.id} is not started`);
1358
+ return false;
1359
+ }
1360
+ if (this.completed) {
1361
+ console.warn(`[NQTR] Quest ${this.id} is already completed`);
1362
+ return false;
1363
+ }
1364
+ let prevStage = this.currentStage;
1365
+ let currentStageIndex = this.currentStageIndex;
1366
+ if (!prevStage || currentStageIndex === void 0) {
1367
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1368
+ return false;
1369
+ }
1370
+ this.currentStageIndex = currentStageIndex + 1;
1371
+ if (prevStage && prevStage.onEnd) {
1372
+ prevStage.onEnd(endProps);
1373
+ }
1374
+ let nextCurrentStage = this.currentStage;
1375
+ if (nextCurrentStage) {
1376
+ nextCurrentStage.inizialize();
1377
+ if (this.currentStageMustStart) {
1378
+ this.startCurrentStage(startProps);
1379
+ }
1380
+ }
1381
+ return true;
1382
+ }
1383
+ /**
1384
+ * If the current stage must start. It is true if the current stage is not started, can start and not completed.
1385
+ */
1386
+ get currentStageMustStart() {
1387
+ let currentStage = this.currentStage;
1388
+ if (!currentStage) {
1389
+ return false;
1390
+ }
1391
+ return !currentStage.started && currentStage.canStart && !currentStage.completed;
1392
+ }
1393
+ /**
1394
+ * Start the current stage.
1395
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
1396
+ */
1397
+ startCurrentStage(props) {
1398
+ let newCurrentStage = this.currentStage;
1399
+ if (newCurrentStage && this.currentStageMustStart) {
1400
+ newCurrentStage.start(props);
1401
+ } else {
1402
+ console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
1403
+ }
1404
+ }
1405
+ };
1026
1406
 
1027
1407
  // src/functions/RoutineFunctions.ts
1028
1408
  function getCurrentRoutine() {
@@ -1060,7 +1440,7 @@ function getCurrentRoutine() {
1060
1440
 
1061
1441
  // src/classes/navigation/Room.ts
1062
1442
  var ROOM_CATEGORY = "__nqtr-room__";
1063
- var RoomBaseModel = class extends pixiVn.StoredClassModel {
1443
+ var RoomBaseModel2 = class extends pixiVn.StoredClassModel {
1064
1444
  /**
1065
1445
  * @param id The id of the room, it must be unique.
1066
1446
  * @param location The location where the room is.
@@ -1300,7 +1680,8 @@ exports.CommitmentBaseModel = CommitmentBaseModel;
1300
1680
  exports.Goal = Goal;
1301
1681
  exports.LocationBaseModel = LocationBaseModel;
1302
1682
  exports.MapBaseModel = MapBaseModel;
1303
- exports.RoomBaseModel = RoomBaseModel;
1683
+ exports.Quest = Quest;
1684
+ exports.RoomBaseModel = RoomBaseModel2;
1304
1685
  exports.Stage = Stage;
1305
1686
  //# sourceMappingURL=out.js.map
1306
1687
  //# sourceMappingURL=index.js.map