@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
@@ -261,136 +261,7 @@ var TimeManager = class _TimeManager {
261
261
  }
262
262
  };
263
263
 
264
- // src/classes/Activity.ts
265
- var ActivityModel = class {
266
- /**
267
- * @param id The activity id, that must be unique.
268
- * @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.
269
- * @param props The activity properties.
270
- */
271
- constructor(id, onRun, props) {
272
- this._id = id;
273
- this._name = props.name;
274
- this._fromHour = props.fromHour;
275
- this._toHour = props.toHour;
276
- this._fromDay = props.fromDay;
277
- this._toDay = props.toDay;
278
- this._disabled = props.disabled || false;
279
- this._hidden = props.hidden || false;
280
- this._renderIcon = props.renderIcon;
281
- this._onRun = onRun;
282
- }
283
- /**
284
- * The activity id, that is unique.
285
- */
286
- get id() {
287
- return this._id;
288
- }
289
- /**
290
- * The name
291
- */
292
- get name() {
293
- return this._name;
294
- }
295
- /**
296
- * The hour when the activity starts. If the activity is not started yet, it will be hidden.
297
- */
298
- get fromHour() {
299
- return this._fromHour;
300
- }
301
- /**
302
- * The hour when the activity ends. If the activity is ended yet, it will be hidden.
303
- */
304
- get toHour() {
305
- return this._toHour;
306
- }
307
- /**
308
- * The day when the activity starts. If the activity is not started yet, it will be hidden.
309
- */
310
- get fromDay() {
311
- return this._fromDay;
312
- }
313
- /**
314
- * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
315
- */
316
- get toDay() {
317
- return this._toDay;
318
- }
319
- /**
320
- * Whether is disabled.
321
- */
322
- get disabled() {
323
- if (typeof this._disabled === "string") {
324
- return pixiVn.getFlag(this._disabled);
325
- }
326
- return this._disabled;
327
- }
328
- /**
329
- * Whether is hidden. If the activity is not started yet, it will be hidden.
330
- */
331
- get hidden() {
332
- if (this.fromDay && this.fromDay > TimeManager.currentDay) {
333
- return true;
334
- }
335
- if (!this.isDeadline) {
336
- return true;
337
- }
338
- if (typeof this._hidden === "string") {
339
- return pixiVn.getFlag(this._hidden);
340
- }
341
- return this._hidden;
342
- }
343
- /**
344
- * The function for rendering the icon of the activity.
345
- */
346
- get renderIcon() {
347
- let render = this._renderIcon;
348
- if (render === void 0) {
349
- return void 0;
350
- }
351
- if (typeof render === "function") {
352
- return (props) => {
353
- return render(this, props);
354
- };
355
- }
356
- return (props) => render;
357
- }
358
- get _initialOnRun() {
359
- return this._onRun;
360
- }
361
- /**
362
- * The function that is called when the activity is runned.
363
- */
364
- get run() {
365
- return (props) => this._onRun(this, props);
366
- }
367
- /**
368
- * Whether the activity is a deadline.
369
- * @returns Whether the activity is a deadline.
370
- */
371
- isDeadline() {
372
- if (this.toDay && this.toDay <= TimeManager.currentDay) {
373
- return true;
374
- }
375
- return false;
376
- }
377
- /**
378
- * Export the activity properties.
379
- * @returns The activity properties.
380
- */
381
- export() {
382
- return {
383
- name: this._name,
384
- fromHour: this._fromHour,
385
- toHour: this._toHour,
386
- fromDay: this._fromDay,
387
- toDay: this._toDay,
388
- disabled: this._disabled,
389
- hidden: this._hidden,
390
- renderIcon: this._renderIcon
391
- };
392
- }
393
- };
264
+ // src/classes/Commitment.ts
394
265
  var COMMITMENT_CATEGORY = "__nqtr-commitment__";
395
266
  var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
396
267
  /**
@@ -744,6 +615,9 @@ var ActivityRoom = class extends ActivityStoredAbstract {
744
615
  get id() {
745
616
  return this._id;
746
617
  }
618
+ /**
619
+ * The room where the activity is.
620
+ */
747
621
  get room() {
748
622
  return this._room;
749
623
  }
@@ -1050,6 +924,53 @@ var Goal = class extends pixiVn.StoredClassModel {
1050
924
  return this._defaultHave;
1051
925
  }
1052
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
+ };
1053
974
 
1054
975
  // src/classes/quest/Stage.ts
1055
976
  var STAGE_CATEGORY = "__nqtr-stage__";
@@ -1152,6 +1073,336 @@ var Stage = class extends pixiVn.StoredClassModel {
1152
1073
  return this._onEnd;
1153
1074
  }
1154
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
+ };
1155
1406
 
1156
1407
  // src/functions/RoutineFunctions.ts
1157
1408
  function getCurrentRoutine() {
@@ -1189,7 +1440,7 @@ function getCurrentRoutine() {
1189
1440
 
1190
1441
  // src/classes/navigation/Room.ts
1191
1442
  var ROOM_CATEGORY = "__nqtr-room__";
1192
- var RoomBaseModel = class extends pixiVn.StoredClassModel {
1443
+ var RoomBaseModel2 = class extends pixiVn.StoredClassModel {
1193
1444
  /**
1194
1445
  * @param id The id of the room, it must be unique.
1195
1446
  * @param location The location where the room is.
@@ -1424,13 +1675,13 @@ var RoomBaseModel = class extends pixiVn.StoredClassModel {
1424
1675
  }
1425
1676
  };
1426
1677
 
1427
- exports.ActivityModel = ActivityModel;
1428
1678
  exports.ActivityRoom = ActivityRoom;
1429
1679
  exports.CommitmentBaseModel = CommitmentBaseModel;
1430
1680
  exports.Goal = Goal;
1431
1681
  exports.LocationBaseModel = LocationBaseModel;
1432
1682
  exports.MapBaseModel = MapBaseModel;
1433
- exports.RoomBaseModel = RoomBaseModel;
1683
+ exports.Quest = Quest;
1684
+ exports.RoomBaseModel = RoomBaseModel2;
1434
1685
  exports.Stage = Stage;
1435
1686
  //# sourceMappingURL=out.js.map
1436
1687
  //# sourceMappingURL=index.js.map