@drincs/nqtr 0.2.1 → 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 (115) hide show
  1. package/dist/{Commitment-CtNWnNQX.d.mts → Commitment-BHB-jYOi.d.mts} +4 -4
  2. package/dist/{Commitment-BJTIpBQ5.d.ts → Commitment-D-1lsnnU.d.ts} +4 -4
  3. package/dist/{StageProps-CkXejAbn.d.mts → StageProps-CJSp_a54.d.mts} +38 -3
  4. package/dist/{StageProps-BFsiCaZT.d.ts → StageProps-CV4rWD7t.d.ts} +38 -3
  5. package/dist/classes/Commitment.d.mts +2 -2
  6. package/dist/classes/Commitment.d.ts +2 -2
  7. package/dist/classes/index.d.mts +4 -4
  8. package/dist/classes/index.d.ts +4 -4
  9. package/dist/classes/index.js +384 -133
  10. package/dist/classes/index.js.map +1 -1
  11. package/dist/classes/index.mjs +384 -133
  12. package/dist/classes/index.mjs.map +1 -1
  13. package/dist/classes/navigation/ActivityRoom.d.mts +2 -2
  14. package/dist/classes/navigation/ActivityRoom.d.ts +2 -2
  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 +3 -3
  20. package/dist/classes/navigation/Location.d.ts +3 -3
  21. package/dist/classes/navigation/Map.d.mts +3 -3
  22. package/dist/classes/navigation/Map.d.ts +3 -3
  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 +76 -73
  26. package/dist/classes/navigation/Room.js.map +1 -1
  27. package/dist/classes/navigation/Room.mjs +76 -73
  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 +117 -25
  32. package/dist/classes/quest/Quest.js.map +1 -1
  33. package/dist/classes/quest/Quest.mjs +117 -25
  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/classes/quest/Stage.js +34 -9
  38. package/dist/classes/quest/Stage.js.map +1 -1
  39. package/dist/classes/quest/Stage.mjs +34 -9
  40. package/dist/classes/quest/Stage.mjs.map +1 -1
  41. package/dist/decorators/ActivityDecorator.d.mts +10 -11
  42. package/dist/decorators/ActivityDecorator.d.ts +10 -11
  43. package/dist/decorators/ActivityDecorator.js +384 -9
  44. package/dist/decorators/ActivityDecorator.js.map +1 -1
  45. package/dist/decorators/ActivityDecorator.mjs +384 -9
  46. package/dist/decorators/ActivityDecorator.mjs.map +1 -1
  47. package/dist/decorators/CommitmentDecorator.d.mts +3 -3
  48. package/dist/decorators/CommitmentDecorator.d.ts +3 -3
  49. package/dist/decorators/QuestDecorator.d.mts +10 -4
  50. package/dist/decorators/QuestDecorator.d.ts +10 -4
  51. package/dist/decorators/QuestDecorator.js +121 -25
  52. package/dist/decorators/QuestDecorator.js.map +1 -1
  53. package/dist/decorators/QuestDecorator.mjs +121 -26
  54. package/dist/decorators/QuestDecorator.mjs.map +1 -1
  55. package/dist/decorators/RoomDecorator.d.mts +3 -3
  56. package/dist/decorators/RoomDecorator.d.ts +3 -3
  57. package/dist/decorators/index.d.mts +4 -4
  58. package/dist/decorators/index.d.ts +4 -4
  59. package/dist/decorators/index.js +342 -115
  60. package/dist/decorators/index.js.map +1 -1
  61. package/dist/decorators/index.mjs +342 -116
  62. package/dist/decorators/index.mjs.map +1 -1
  63. package/dist/functions/ActivityFunctions.d.mts +10 -3
  64. package/dist/functions/ActivityFunctions.d.ts +10 -3
  65. package/dist/functions/ActivityFunctions.js.map +1 -1
  66. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  67. package/dist/functions/NavigationFunctions.d.mts +22 -5
  68. package/dist/functions/NavigationFunctions.d.ts +22 -5
  69. package/dist/functions/NavigationFunctions.js +2 -2
  70. package/dist/functions/NavigationFunctions.js.map +1 -1
  71. package/dist/functions/NavigationFunctions.mjs +2 -2
  72. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  73. package/dist/functions/QuestFunctions.d.mts +8 -0
  74. package/dist/functions/QuestFunctions.d.ts +8 -0
  75. package/dist/functions/QuestFunctions.js +21 -0
  76. package/dist/functions/QuestFunctions.js.map +1 -0
  77. package/dist/functions/QuestFunctions.mjs +19 -0
  78. package/dist/functions/QuestFunctions.mjs.map +1 -0
  79. package/dist/functions/RoutineFunctions.d.mts +9 -4
  80. package/dist/functions/RoutineFunctions.d.ts +9 -4
  81. package/dist/functions/RoutineFunctions.js +40 -0
  82. package/dist/functions/RoutineFunctions.js.map +1 -1
  83. package/dist/functions/RoutineFunctions.mjs +40 -1
  84. package/dist/functions/RoutineFunctions.mjs.map +1 -1
  85. package/dist/functions/index.d.mts +6 -5
  86. package/dist/functions/index.d.ts +6 -5
  87. package/dist/functions/index.js +23 -2
  88. package/dist/functions/index.js.map +1 -1
  89. package/dist/functions/index.mjs +21 -2
  90. package/dist/functions/index.mjs.map +1 -1
  91. package/dist/index.d.mts +9 -8
  92. package/dist/index.d.ts +9 -8
  93. package/dist/index.js +328 -213
  94. package/dist/index.js.map +1 -1
  95. package/dist/index.mjs +323 -211
  96. package/dist/index.mjs.map +1 -1
  97. package/dist/interface/CommitmentProps.d.mts +2 -2
  98. package/dist/interface/CommitmentProps.d.ts +2 -2
  99. package/dist/interface/RoomProps.d.mts +2 -2
  100. package/dist/interface/RoomProps.d.ts +2 -2
  101. package/dist/interface/index.d.mts +3 -3
  102. package/dist/interface/index.d.ts +3 -3
  103. package/dist/interface/navigation/LocationProps.d.mts +3 -3
  104. package/dist/interface/navigation/LocationProps.d.ts +3 -3
  105. package/dist/interface/navigation/MapProps.d.mts +3 -3
  106. package/dist/interface/navigation/MapProps.d.ts +3 -3
  107. package/dist/interface/quest/QuestProps.d.mts +1 -1
  108. package/dist/interface/quest/QuestProps.d.ts +1 -1
  109. package/dist/interface/quest/StageProps.d.mts +1 -1
  110. package/dist/interface/quest/StageProps.d.ts +1 -1
  111. package/dist/types/QuestsRequired.d.mts +1 -1
  112. package/dist/types/QuestsRequired.d.ts +1 -1
  113. package/dist/types/index.d.mts +1 -1
  114. package/dist/types/index.d.ts +1 -1
  115. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- import { getFlag, StoredClassModel, GameStorageManager } from '@drincs/pixi-vn';
1
+ import { StoredClassModel, getFlag, GameStorageManager } from '@drincs/pixi-vn';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -259,136 +259,7 @@ var TimeManager = class _TimeManager {
259
259
  }
260
260
  };
261
261
 
262
- // src/classes/Activity.ts
263
- var ActivityModel = class {
264
- /**
265
- * @param id The activity id, that must be unique.
266
- * @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.
267
- * @param props The activity properties.
268
- */
269
- constructor(id, onRun, props) {
270
- this._id = id;
271
- this._name = props.name;
272
- this._fromHour = props.fromHour;
273
- this._toHour = props.toHour;
274
- this._fromDay = props.fromDay;
275
- this._toDay = props.toDay;
276
- this._disabled = props.disabled || false;
277
- this._hidden = props.hidden || false;
278
- this._renderIcon = props.renderIcon;
279
- this._onRun = onRun;
280
- }
281
- /**
282
- * The activity id, that is unique.
283
- */
284
- get id() {
285
- return this._id;
286
- }
287
- /**
288
- * The name
289
- */
290
- get name() {
291
- return this._name;
292
- }
293
- /**
294
- * The hour when the activity starts. If the activity is not started yet, it will be hidden.
295
- */
296
- get fromHour() {
297
- return this._fromHour;
298
- }
299
- /**
300
- * The hour when the activity ends. If the activity is ended yet, it will be hidden.
301
- */
302
- get toHour() {
303
- return this._toHour;
304
- }
305
- /**
306
- * The day when the activity starts. If the activity is not started yet, it will be hidden.
307
- */
308
- get fromDay() {
309
- return this._fromDay;
310
- }
311
- /**
312
- * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
313
- */
314
- get toDay() {
315
- return this._toDay;
316
- }
317
- /**
318
- * Whether is disabled.
319
- */
320
- get disabled() {
321
- if (typeof this._disabled === "string") {
322
- return getFlag(this._disabled);
323
- }
324
- return this._disabled;
325
- }
326
- /**
327
- * Whether is hidden. If the activity is not started yet, it will be hidden.
328
- */
329
- get hidden() {
330
- if (this.fromDay && this.fromDay > TimeManager.currentDay) {
331
- return true;
332
- }
333
- if (!this.isDeadline) {
334
- return true;
335
- }
336
- if (typeof this._hidden === "string") {
337
- return getFlag(this._hidden);
338
- }
339
- return this._hidden;
340
- }
341
- /**
342
- * The function for rendering the icon of the activity.
343
- */
344
- get renderIcon() {
345
- let render = this._renderIcon;
346
- if (render === void 0) {
347
- return void 0;
348
- }
349
- if (typeof render === "function") {
350
- return (props) => {
351
- return render(this, props);
352
- };
353
- }
354
- return (props) => render;
355
- }
356
- get _initialOnRun() {
357
- return this._onRun;
358
- }
359
- /**
360
- * The function that is called when the activity is runned.
361
- */
362
- get run() {
363
- return (props) => this._onRun(this, props);
364
- }
365
- /**
366
- * Whether the activity is a deadline.
367
- * @returns Whether the activity is a deadline.
368
- */
369
- isDeadline() {
370
- if (this.toDay && this.toDay <= TimeManager.currentDay) {
371
- return true;
372
- }
373
- return false;
374
- }
375
- /**
376
- * Export the activity properties.
377
- * @returns The activity properties.
378
- */
379
- export() {
380
- return {
381
- name: this._name,
382
- fromHour: this._fromHour,
383
- toHour: this._toHour,
384
- fromDay: this._fromDay,
385
- toDay: this._toDay,
386
- disabled: this._disabled,
387
- hidden: this._hidden,
388
- renderIcon: this._renderIcon
389
- };
390
- }
391
- };
262
+ // src/classes/Commitment.ts
392
263
  var COMMITMENT_CATEGORY = "__nqtr-commitment__";
393
264
  var CommitmentBaseModel = class extends StoredClassModel {
394
265
  /**
@@ -742,6 +613,9 @@ var ActivityRoom = class extends ActivityStoredAbstract {
742
613
  get id() {
743
614
  return this._id;
744
615
  }
616
+ /**
617
+ * The room where the activity is.
618
+ */
745
619
  get room() {
746
620
  return this._room;
747
621
  }
@@ -1048,6 +922,53 @@ var Goal = class extends StoredClassModel {
1048
922
  return this._defaultHave;
1049
923
  }
1050
924
  };
925
+ var GoalStage = class extends Goal {
926
+ constructor(id, stageId, props) {
927
+ super(id, props);
928
+ this._stageId = stageId;
929
+ }
930
+ /**
931
+ * The id of the stage that the goal belongs to.
932
+ */
933
+ get stageId() {
934
+ return this._stageId;
935
+ }
936
+ set stageId(value) {
937
+ this._stageId = value;
938
+ }
939
+ /**
940
+ * The number of times the goal has been completed.
941
+ */
942
+ get have() {
943
+ return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
944
+ }
945
+ set have(value) {
946
+ if (!this._stageId) {
947
+ console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
948
+ return;
949
+ }
950
+ this.setStorageProperty("have-" + this._stageId, value);
951
+ }
952
+ /**
953
+ * If the goal is completed.
954
+ */
955
+ get completed() {
956
+ return this.have >= this.need;
957
+ }
958
+ set completed(value) {
959
+ if (value) {
960
+ this.have = this.need;
961
+ } else {
962
+ console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
963
+ }
964
+ }
965
+ /**
966
+ * Find the goal. It will increment the have value.
967
+ */
968
+ find() {
969
+ this.have++;
970
+ }
971
+ };
1051
972
 
1052
973
  // src/classes/quest/Stage.ts
1053
974
  var STAGE_CATEGORY = "__nqtr-stage__";
@@ -1150,6 +1071,336 @@ var Stage = class extends StoredClassModel {
1150
1071
  return this._onEnd;
1151
1072
  }
1152
1073
  };
1074
+ var StageQuest = class extends Stage {
1075
+ constructor(id, props) {
1076
+ super(id, props);
1077
+ }
1078
+ /**
1079
+ * Check if the flag and goals are completed.
1080
+ * You can force the completion of the stage by setting the completed property to true.
1081
+ */
1082
+ get completed() {
1083
+ let storedCompleted = this.getStorageProperty("completed");
1084
+ if (storedCompleted) {
1085
+ return storedCompleted;
1086
+ }
1087
+ if (this.flags.length > 0 && this.goals.length > 0) {
1088
+ if (!this.flags.every((flag) => getFlag(flag.flag))) {
1089
+ return false;
1090
+ }
1091
+ if (!this.goals.every((goal) => goal.completed)) {
1092
+ return false;
1093
+ }
1094
+ return true;
1095
+ }
1096
+ return false;
1097
+ }
1098
+ set completed(value) {
1099
+ this.setStorageProperty("completed", value);
1100
+ }
1101
+ /**
1102
+ * If the stage is started.
1103
+ */
1104
+ get started() {
1105
+ return this.getStorageProperty("started") || false;
1106
+ }
1107
+ set started(value) {
1108
+ this.setStorageProperty("started", value);
1109
+ }
1110
+ /**
1111
+ * The list of goals that the player needs to complete to finish the stage.
1112
+ */
1113
+ get goals() {
1114
+ return this.defaultGoals.map((goal) => {
1115
+ return new GoalStage(goal.id, this.id, goal);
1116
+ });
1117
+ }
1118
+ get prevStageEndDay() {
1119
+ return this.getStorageProperty("prevStageEndDay");
1120
+ }
1121
+ set prevStageEndDay(value) {
1122
+ this.setStorageProperty("prevStageEndDay", value);
1123
+ }
1124
+ /**
1125
+ * The day when the stage starts.
1126
+ */
1127
+ get startDay() {
1128
+ let prevStageEndDay = this.prevStageEndDay;
1129
+ if (prevStageEndDay === void 0) {
1130
+ return void 0;
1131
+ }
1132
+ return prevStageEndDay + this.daysRequiredToStart;
1133
+ }
1134
+ /**
1135
+ * Check if the stage can start.
1136
+ */
1137
+ get canStart() {
1138
+ let daysRequired = this.daysRequiredToStart;
1139
+ if (daysRequired > 0) {
1140
+ let prevStageEndDay = this.prevStageEndDay;
1141
+ if (prevStageEndDay === void 0) {
1142
+ return false;
1143
+ }
1144
+ if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
1145
+ return false;
1146
+ }
1147
+ }
1148
+ if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {
1149
+ return false;
1150
+ }
1151
+ if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
1152
+ (q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
1153
+ )) {
1154
+ return false;
1155
+ }
1156
+ return true;
1157
+ }
1158
+ /**
1159
+ * Inizialize the stage. **This function should be called only by the Quest class.**
1160
+ */
1161
+ inizialize() {
1162
+ if (this.daysRequiredToStart > 0) {
1163
+ this.prevStageEndDay = TimeManager.currentDay;
1164
+ console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
1165
+ }
1166
+ }
1167
+ /**
1168
+ * The function that will be called when the stage starts.
1169
+ */
1170
+ start(props) {
1171
+ if (this.canStart) {
1172
+ this.started = true;
1173
+ if (this.onStart) {
1174
+ this.onStart(props);
1175
+ }
1176
+ } else {
1177
+ console.warn(`[NQTR] Stage ${this.id} can't start`);
1178
+ }
1179
+ }
1180
+ };
1181
+
1182
+ // src/classes/quest/Quest.ts
1183
+ var QUEST_CATEGORY = "__nqtr-quest__";
1184
+ var Quest = class extends StoredClassModel {
1185
+ constructor(id, stages, props) {
1186
+ super(QUEST_CATEGORY, id);
1187
+ this._stages = stages;
1188
+ this._name = props.name || "";
1189
+ this._description = props.description || "";
1190
+ this._renderIcon = props.renderIcon;
1191
+ this._renderImage = props.renderImage;
1192
+ this._isInDevelopment = props.isInDevelopment || false;
1193
+ }
1194
+ /**
1195
+ * The stages of the quest.
1196
+ */
1197
+ get stages() {
1198
+ return this._stages.map((stage, index) => {
1199
+ return new StageQuest(stage.id, stage);
1200
+ });
1201
+ }
1202
+ /**
1203
+ * The name of the quest.
1204
+ */
1205
+ get name() {
1206
+ return this._name;
1207
+ }
1208
+ /**
1209
+ * The description of the quest.
1210
+ */
1211
+ get description() {
1212
+ return this._description;
1213
+ }
1214
+ /**
1215
+ * The function for rendering the icon of the quest.
1216
+ */
1217
+ get renderIcon() {
1218
+ let render = this._renderIcon;
1219
+ if (render === void 0) {
1220
+ return void 0;
1221
+ }
1222
+ if (typeof render === "function") {
1223
+ return (props) => {
1224
+ return render(this, props);
1225
+ };
1226
+ }
1227
+ return (props) => render;
1228
+ }
1229
+ /**
1230
+ * The function for rendering the image of the quest.
1231
+ */
1232
+ get renderImage() {
1233
+ let render = this._renderImage;
1234
+ if (render === void 0) {
1235
+ return void 0;
1236
+ }
1237
+ if (typeof render === "function") {
1238
+ return (props) => {
1239
+ return render(this, props);
1240
+ };
1241
+ }
1242
+ return (props) => render;
1243
+ }
1244
+ /**
1245
+ * If the quest is in development.
1246
+ */
1247
+ get isInDevelopment() {
1248
+ return this._isInDevelopment;
1249
+ }
1250
+ /**
1251
+ * The index of the current stage.
1252
+ */
1253
+ get currentStageIndex() {
1254
+ return this.getStorageProperty("currentStageIndex");
1255
+ }
1256
+ set currentStageIndex(value) {
1257
+ this.setStorageProperty("currentStageIndex", value);
1258
+ }
1259
+ /**
1260
+ * The current stage.
1261
+ */
1262
+ get currentStage() {
1263
+ let index = this.currentStageIndex;
1264
+ if (index === void 0 || index >= this.stages.length) {
1265
+ return void 0;
1266
+ }
1267
+ return this.stages[index];
1268
+ }
1269
+ /**
1270
+ * If the quest is started.
1271
+ */
1272
+ get started() {
1273
+ return this.currentStageIndex !== void 0;
1274
+ }
1275
+ /**
1276
+ * If the quest is completed.
1277
+ */
1278
+ get completed() {
1279
+ if (this.currentStageIndex === void 0) {
1280
+ return false;
1281
+ }
1282
+ return this.currentStageIndex > this.stages.length - 1;
1283
+ }
1284
+ /**
1285
+ * Start the quest.
1286
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
1287
+ * @returns
1288
+ */
1289
+ start(props) {
1290
+ if (this.started) {
1291
+ console.warn(`[NQTR] Quest ${this.id} is already started`);
1292
+ return;
1293
+ }
1294
+ if (this.stages.length === 0) {
1295
+ console.error(`[NQTR] Quest ${this.id} has no stages`);
1296
+ return;
1297
+ }
1298
+ this.currentStageIndex = 0;
1299
+ let currentStage = this.currentStage;
1300
+ if (currentStage && currentStage.start) {
1301
+ return currentStage.start(props);
1302
+ } else {
1303
+ console.error(`[NQTR] Quest ${this.id} has no start stage`);
1304
+ }
1305
+ }
1306
+ /**
1307
+ * Go to the next stage if the current stage is completed.
1308
+ * If you want to force the change of stage, use goNextStage.
1309
+ * @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
1310
+ * @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
1311
+ * @returns true if the stage was changed, false otherwise.
1312
+ */
1313
+ tryToGoNextStage(startProps, endProps) {
1314
+ if (!this.started) {
1315
+ return false;
1316
+ }
1317
+ if (this.completed) {
1318
+ return false;
1319
+ }
1320
+ let currentStage = this.currentStage;
1321
+ if (!currentStage) {
1322
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1323
+ return false;
1324
+ }
1325
+ if (currentStage.completed) {
1326
+ return this.goNextStage(startProps, endProps);
1327
+ }
1328
+ return false;
1329
+ }
1330
+ /**
1331
+ * Complete the current stage and go to the next stage.
1332
+ * If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
1333
+ * @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
1334
+ * @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
1335
+ * @returns true if the stage was changed, false otherwise.
1336
+ */
1337
+ completeCurrentStageAndGoNext(startProps, endProps) {
1338
+ let currentStage = this.currentStage;
1339
+ if (!currentStage) {
1340
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1341
+ return false;
1342
+ }
1343
+ currentStage.completed = true;
1344
+ return this.goNextStage(startProps, endProps);
1345
+ }
1346
+ /**
1347
+ * Go to the next stage without checking if the current stage is completed.
1348
+ * If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
1349
+ * @param startProps
1350
+ * @param endProps
1351
+ * @returns returns true if the stage was changed, false otherwise.
1352
+ */
1353
+ goNextStage(startProps, endProps) {
1354
+ if (!this.started) {
1355
+ console.warn(`[NQTR] Quest ${this.id} is not started`);
1356
+ return false;
1357
+ }
1358
+ if (this.completed) {
1359
+ console.warn(`[NQTR] Quest ${this.id} is already completed`);
1360
+ return false;
1361
+ }
1362
+ let prevStage = this.currentStage;
1363
+ let currentStageIndex = this.currentStageIndex;
1364
+ if (!prevStage || currentStageIndex === void 0) {
1365
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1366
+ return false;
1367
+ }
1368
+ this.currentStageIndex = currentStageIndex + 1;
1369
+ if (prevStage && prevStage.onEnd) {
1370
+ prevStage.onEnd(endProps);
1371
+ }
1372
+ let nextCurrentStage = this.currentStage;
1373
+ if (nextCurrentStage) {
1374
+ nextCurrentStage.inizialize();
1375
+ if (this.currentStageMustStart) {
1376
+ this.startCurrentStage(startProps);
1377
+ }
1378
+ }
1379
+ return true;
1380
+ }
1381
+ /**
1382
+ * If the current stage must start. It is true if the current stage is not started, can start and not completed.
1383
+ */
1384
+ get currentStageMustStart() {
1385
+ let currentStage = this.currentStage;
1386
+ if (!currentStage) {
1387
+ return false;
1388
+ }
1389
+ return !currentStage.started && currentStage.canStart && !currentStage.completed;
1390
+ }
1391
+ /**
1392
+ * Start the current stage.
1393
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
1394
+ */
1395
+ startCurrentStage(props) {
1396
+ let newCurrentStage = this.currentStage;
1397
+ if (newCurrentStage && this.currentStageMustStart) {
1398
+ newCurrentStage.start(props);
1399
+ } else {
1400
+ console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
1401
+ }
1402
+ }
1403
+ };
1153
1404
 
1154
1405
  // src/functions/RoutineFunctions.ts
1155
1406
  function getCurrentRoutine() {
@@ -1187,7 +1438,7 @@ function getCurrentRoutine() {
1187
1438
 
1188
1439
  // src/classes/navigation/Room.ts
1189
1440
  var ROOM_CATEGORY = "__nqtr-room__";
1190
- var RoomBaseModel = class extends StoredClassModel {
1441
+ var RoomBaseModel2 = class extends StoredClassModel {
1191
1442
  /**
1192
1443
  * @param id The id of the room, it must be unique.
1193
1444
  * @param location The location where the room is.
@@ -1422,6 +1673,6 @@ var RoomBaseModel = class extends StoredClassModel {
1422
1673
  }
1423
1674
  };
1424
1675
 
1425
- export { ActivityModel, ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, RoomBaseModel, Stage };
1676
+ export { ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, Quest, RoomBaseModel2 as RoomBaseModel, Stage };
1426
1677
  //# sourceMappingURL=out.js.map
1427
1678
  //# sourceMappingURL=index.mjs.map