@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
package/dist/index.js CHANGED
@@ -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
  }
@@ -1010,18 +884,145 @@ var MapBaseModel = class extends pixiVn.StoredClassModel {
1010
884
  return getLocationsByMap(this);
1011
885
  }
1012
886
  };
887
+ var ActivityModel = class {
888
+ /**
889
+ * @param id The activity id, that must be unique.
890
+ * @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.
891
+ * @param props The activity properties.
892
+ */
893
+ constructor(id, onRun, props) {
894
+ this._id = id;
895
+ this._name = props.name;
896
+ this._fromHour = props.fromHour;
897
+ this._toHour = props.toHour;
898
+ this._fromDay = props.fromDay;
899
+ this._toDay = props.toDay;
900
+ this._disabled = props.disabled || false;
901
+ this._hidden = props.hidden || false;
902
+ this._renderIcon = props.renderIcon;
903
+ this._onRun = onRun;
904
+ }
905
+ /**
906
+ * The activity id, that is unique.
907
+ */
908
+ get id() {
909
+ return this._id;
910
+ }
911
+ /**
912
+ * The name
913
+ */
914
+ get name() {
915
+ return this._name;
916
+ }
917
+ /**
918
+ * The hour when the activity starts. If the activity is not started yet, it will be hidden.
919
+ */
920
+ get fromHour() {
921
+ return this._fromHour;
922
+ }
923
+ /**
924
+ * The hour when the activity ends. If the activity is ended yet, it will be hidden.
925
+ */
926
+ get toHour() {
927
+ return this._toHour;
928
+ }
929
+ /**
930
+ * The day when the activity starts. If the activity is not started yet, it will be hidden.
931
+ */
932
+ get fromDay() {
933
+ return this._fromDay;
934
+ }
935
+ /**
936
+ * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
937
+ */
938
+ get toDay() {
939
+ return this._toDay;
940
+ }
941
+ /**
942
+ * Whether is disabled.
943
+ */
944
+ get disabled() {
945
+ if (typeof this._disabled === "string") {
946
+ return pixiVn.getFlag(this._disabled);
947
+ }
948
+ return this._disabled;
949
+ }
950
+ /**
951
+ * Whether is hidden. If the activity is not started yet, it will be hidden.
952
+ */
953
+ get hidden() {
954
+ if (this.fromDay && this.fromDay > TimeManager.currentDay) {
955
+ return true;
956
+ }
957
+ if (!this.isDeadline) {
958
+ return true;
959
+ }
960
+ if (typeof this._hidden === "string") {
961
+ return pixiVn.getFlag(this._hidden);
962
+ }
963
+ return this._hidden;
964
+ }
965
+ /**
966
+ * The function for rendering the icon of the activity.
967
+ */
968
+ get renderIcon() {
969
+ let render = this._renderIcon;
970
+ if (render === void 0) {
971
+ return void 0;
972
+ }
973
+ if (typeof render === "function") {
974
+ return (props) => {
975
+ return render(this, props);
976
+ };
977
+ }
978
+ return (props) => render;
979
+ }
980
+ get _initialOnRun() {
981
+ return this._onRun;
982
+ }
983
+ /**
984
+ * The function that is called when the activity is runned.
985
+ */
986
+ get run() {
987
+ return (props) => this._onRun(this, props);
988
+ }
989
+ /**
990
+ * Whether the activity is a deadline.
991
+ * @returns Whether the activity is a deadline.
992
+ */
993
+ isDeadline() {
994
+ if (this.toDay && this.toDay <= TimeManager.currentDay) {
995
+ return true;
996
+ }
997
+ return false;
998
+ }
999
+ /**
1000
+ * Export the activity properties.
1001
+ * @returns The activity properties.
1002
+ */
1003
+ export() {
1004
+ return {
1005
+ name: this._name,
1006
+ fromHour: this._fromHour,
1007
+ toHour: this._toHour,
1008
+ fromDay: this._fromDay,
1009
+ toDay: this._toDay,
1010
+ disabled: this._disabled,
1011
+ hidden: this._hidden,
1012
+ renderIcon: this._renderIcon
1013
+ };
1014
+ }
1015
+ };
1013
1016
 
1014
1017
  // src/decorators/ActivityDecorator.ts
1015
1018
  var registeredActivities = {};
1016
- function saveActivity(activity) {
1017
- if (Array.isArray(activity)) {
1018
- activity.forEach((c) => saveActivity(c));
1019
- return;
1020
- }
1021
- if (registeredActivities[activity.id]) {
1022
- console.warn(`[NQTR] Activity id ${activity.id} already exists, it will be overwritten`);
1019
+ function newActivity(id, onRun, props) {
1020
+ if (registeredActivities[id]) {
1021
+ console.warn(`[NQTR] Activity ${id} already exists, it will be overwritten`);
1023
1022
  }
1024
- registeredActivities[activity.id] = activity;
1023
+ let activity = new ActivityModel(id, onRun, props);
1024
+ registeredActivities[id] = activity;
1025
+ return activity;
1025
1026
  }
1026
1027
  function getActivityById(id) {
1027
1028
  try {
@@ -1300,17 +1301,29 @@ var StageQuest = class extends Stage {
1300
1301
  if (storedCompleted) {
1301
1302
  return storedCompleted;
1302
1303
  }
1303
- if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
1304
- return false;
1305
- }
1306
- if (!this.goals.every((goal) => goal.completed)) {
1307
- return false;
1304
+ if (this.flags.length > 0 && this.goals.length > 0) {
1305
+ if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
1306
+ return false;
1307
+ }
1308
+ if (!this.goals.every((goal) => goal.completed)) {
1309
+ return false;
1310
+ }
1311
+ return true;
1308
1312
  }
1309
- return true;
1313
+ return false;
1310
1314
  }
1311
1315
  set completed(value) {
1312
1316
  this.setStorageProperty("completed", value);
1313
1317
  }
1318
+ /**
1319
+ * If the stage is started.
1320
+ */
1321
+ get started() {
1322
+ return this.getStorageProperty("started") || false;
1323
+ }
1324
+ set started(value) {
1325
+ this.setStorageProperty("started", value);
1326
+ }
1314
1327
  /**
1315
1328
  * The list of goals that the player needs to complete to finish the stage.
1316
1329
  */
@@ -1360,13 +1373,26 @@ var StageQuest = class extends Stage {
1360
1373
  return true;
1361
1374
  }
1362
1375
  /**
1363
- * The function that will be called when the stage starts.
1376
+ * Inizialize the stage. **This function should be called only by the Quest class.**
1364
1377
  */
1365
- get onStart() {
1378
+ inizialize() {
1366
1379
  if (this.daysRequiredToStart > 0) {
1367
1380
  this.prevStageEndDay = TimeManager.currentDay;
1381
+ console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
1382
+ }
1383
+ }
1384
+ /**
1385
+ * The function that will be called when the stage starts.
1386
+ */
1387
+ start(props) {
1388
+ if (this.canStart) {
1389
+ this.started = true;
1390
+ if (this.onStart) {
1391
+ this.onStart(props);
1392
+ }
1393
+ } else {
1394
+ console.warn(`[NQTR] Stage ${this.id} can't start`);
1368
1395
  }
1369
- return super.onStart;
1370
1396
  }
1371
1397
  };
1372
1398
 
@@ -1467,7 +1493,10 @@ var Quest = class extends pixiVn.StoredClassModel {
1467
1493
  * If the quest is completed.
1468
1494
  */
1469
1495
  get completed() {
1470
- return this.currentStageIndex === this.stages.length;
1496
+ if (this.currentStageIndex === void 0) {
1497
+ return false;
1498
+ }
1499
+ return this.currentStageIndex > this.stages.length - 1;
1471
1500
  }
1472
1501
  /**
1473
1502
  * Start the quest.
@@ -1485,14 +1514,15 @@ var Quest = class extends pixiVn.StoredClassModel {
1485
1514
  }
1486
1515
  this.currentStageIndex = 0;
1487
1516
  let currentStage = this.currentStage;
1488
- if (currentStage && currentStage.onStart) {
1489
- return currentStage.onStart(props);
1517
+ if (currentStage && currentStage.start) {
1518
+ return currentStage.start(props);
1490
1519
  } else {
1491
1520
  console.error(`[NQTR] Quest ${this.id} has no start stage`);
1492
1521
  }
1493
1522
  }
1494
1523
  /**
1495
- * Try to go to the next stage.
1524
+ * Go to the next stage if the current stage is completed.
1525
+ * If you want to force the change of stage, use goNextStage.
1496
1526
  * @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
1497
1527
  * @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
1498
1528
  * @returns true if the stage was changed, false otherwise.
@@ -1505,25 +1535,88 @@ var Quest = class extends pixiVn.StoredClassModel {
1505
1535
  return false;
1506
1536
  }
1507
1537
  let currentStage = this.currentStage;
1508
- let currentStageIndex = this.currentStageIndex;
1509
- if (!currentStage || currentStageIndex === void 0) {
1538
+ if (!currentStage) {
1510
1539
  console.error(`[NQTR] Quest ${this.id} has no current stage`);
1511
1540
  return false;
1512
1541
  }
1513
1542
  if (currentStage.completed) {
1514
- let nextStageIndex = currentStageIndex + 1;
1515
- currentStageIndex = nextStageIndex;
1516
- let nextStage = this.currentStage;
1517
- if (currentStage && currentStage.onEnd) {
1518
- currentStage.onEnd(endProps);
1519
- }
1520
- if (nextStage && nextStage.onStart) {
1521
- nextStage.onStart(startProps);
1522
- }
1523
- return true;
1543
+ return this.goNextStage(startProps, endProps);
1524
1544
  }
1525
1545
  return false;
1526
1546
  }
1547
+ /**
1548
+ * Complete the current stage and go to the next stage.
1549
+ * If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
1550
+ * @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
1551
+ * @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
1552
+ * @returns true if the stage was changed, false otherwise.
1553
+ */
1554
+ completeCurrentStageAndGoNext(startProps, endProps) {
1555
+ let currentStage = this.currentStage;
1556
+ if (!currentStage) {
1557
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1558
+ return false;
1559
+ }
1560
+ currentStage.completed = true;
1561
+ return this.goNextStage(startProps, endProps);
1562
+ }
1563
+ /**
1564
+ * Go to the next stage without checking if the current stage is completed.
1565
+ * If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
1566
+ * @param startProps
1567
+ * @param endProps
1568
+ * @returns returns true if the stage was changed, false otherwise.
1569
+ */
1570
+ goNextStage(startProps, endProps) {
1571
+ if (!this.started) {
1572
+ console.warn(`[NQTR] Quest ${this.id} is not started`);
1573
+ return false;
1574
+ }
1575
+ if (this.completed) {
1576
+ console.warn(`[NQTR] Quest ${this.id} is already completed`);
1577
+ return false;
1578
+ }
1579
+ let prevStage = this.currentStage;
1580
+ let currentStageIndex = this.currentStageIndex;
1581
+ if (!prevStage || currentStageIndex === void 0) {
1582
+ console.error(`[NQTR] Quest ${this.id} has no current stage`);
1583
+ return false;
1584
+ }
1585
+ this.currentStageIndex = currentStageIndex + 1;
1586
+ if (prevStage && prevStage.onEnd) {
1587
+ prevStage.onEnd(endProps);
1588
+ }
1589
+ let nextCurrentStage = this.currentStage;
1590
+ if (nextCurrentStage) {
1591
+ nextCurrentStage.inizialize();
1592
+ if (this.currentStageMustStart) {
1593
+ this.startCurrentStage(startProps);
1594
+ }
1595
+ }
1596
+ return true;
1597
+ }
1598
+ /**
1599
+ * If the current stage must start. It is true if the current stage is not started, can start and not completed.
1600
+ */
1601
+ get currentStageMustStart() {
1602
+ let currentStage = this.currentStage;
1603
+ if (!currentStage) {
1604
+ return false;
1605
+ }
1606
+ return !currentStage.started && currentStage.canStart && !currentStage.completed;
1607
+ }
1608
+ /**
1609
+ * Start the current stage.
1610
+ * @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
1611
+ */
1612
+ startCurrentStage(props) {
1613
+ let newCurrentStage = this.currentStage;
1614
+ if (newCurrentStage && this.currentStageMustStart) {
1615
+ newCurrentStage.start(props);
1616
+ } else {
1617
+ console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
1618
+ }
1619
+ }
1527
1620
  };
1528
1621
 
1529
1622
  // src/decorators/QuestDecorator.ts
@@ -1549,6 +1642,54 @@ function getQuestById(id) {
1549
1642
  return;
1550
1643
  }
1551
1644
  }
1645
+ function getAllStartedQuests() {
1646
+ return Object.values(registeredQuests).filter((quest) => quest.started);
1647
+ }
1648
+ var CURRENT_ROOM_MEMORY_KEY = "___nqtr-current_room_memory___";
1649
+ function setCurrentRoom(room) {
1650
+ if (room instanceof LocationBaseModel) {
1651
+ let entrance = room.getEntrance();
1652
+ if (!entrance) {
1653
+ console.error(`[NQTR] The location ${room.id} has no entrance room`);
1654
+ return;
1655
+ }
1656
+ room = entrance;
1657
+ } else {
1658
+ let roomRegistrated = getRoomById(room.id);
1659
+ if (!roomRegistrated) {
1660
+ console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);
1661
+ return;
1662
+ }
1663
+ }
1664
+ pixiVn.GameStorageManager.setVariable(CURRENT_ROOM_MEMORY_KEY, room.id);
1665
+ }
1666
+ function getCurrentRoom() {
1667
+ let roomId = pixiVn.GameStorageManager.getVariable(CURRENT_ROOM_MEMORY_KEY);
1668
+ if (!roomId) {
1669
+ console.error(`[NQTR] The current room has not yet been set`);
1670
+ return;
1671
+ }
1672
+ let room = getRoomById(roomId);
1673
+ if (!room) {
1674
+ console.error(`[NQTR] Current room ${roomId} not found`);
1675
+ return;
1676
+ }
1677
+ return room;
1678
+ }
1679
+ function getCurrenrLocation() {
1680
+ let room = getCurrentRoom();
1681
+ if (!room) {
1682
+ return;
1683
+ }
1684
+ return room.location;
1685
+ }
1686
+ function getCurrentMap() {
1687
+ let location = getCurrenrLocation();
1688
+ if (!location) {
1689
+ return;
1690
+ }
1691
+ return location.map;
1692
+ }
1552
1693
 
1553
1694
  // src/functions/RoutineFunctions.ts
1554
1695
  function clearExpiredRoutine() {
@@ -1590,6 +1731,13 @@ function getCurrentRoutine() {
1590
1731
  });
1591
1732
  return Object.values(character_commitments);
1592
1733
  }
1734
+ function getCurrentRoomRoutine() {
1735
+ let room = getCurrentRoom();
1736
+ if (!room) {
1737
+ return [];
1738
+ }
1739
+ return room.getRoutine();
1740
+ }
1593
1741
  function getCommitmentByCharacter(character) {
1594
1742
  getCurrentRoutine().forEach((c) => {
1595
1743
  if (c.characters.map((ch) => ch.id).includes(character.id)) {
@@ -1601,7 +1749,7 @@ function getCommitmentByCharacter(character) {
1601
1749
 
1602
1750
  // src/classes/navigation/Room.ts
1603
1751
  var ROOM_CATEGORY = "__nqtr-room__";
1604
- var RoomBaseModel = class extends pixiVn.StoredClassModel {
1752
+ var RoomBaseModel2 = class extends pixiVn.StoredClassModel {
1605
1753
  /**
1606
1754
  * @param id The id of the room, it must be unique.
1607
1755
  * @param location The location where the room is.
@@ -1835,51 +1983,6 @@ var RoomBaseModel = class extends pixiVn.StoredClassModel {
1835
1983
  return commitments.filter((c) => c.room.id === this.id);
1836
1984
  }
1837
1985
  };
1838
- var CURRENT_ROOM_MEMORY_KEY = "___nqtr-current_room_memory___";
1839
- function setCurrentRoom(room) {
1840
- if (room instanceof LocationBaseModel) {
1841
- let entrance = room.getEntrance();
1842
- if (!entrance) {
1843
- console.error(`[NQTR] The location ${room.id} has no entrance room`);
1844
- return;
1845
- }
1846
- room = entrance;
1847
- } else {
1848
- let roomRegistrated = getRoomById(room.id);
1849
- if (!roomRegistrated) {
1850
- console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);
1851
- return;
1852
- }
1853
- }
1854
- pixiVn.GameStorageManager.setVariable(CURRENT_ROOM_MEMORY_KEY, room.id);
1855
- }
1856
- function getCurrentRoom() {
1857
- let roomId = pixiVn.GameStorageManager.getVariable(CURRENT_ROOM_MEMORY_KEY);
1858
- if (!roomId) {
1859
- console.error(`[NQTR] The current room has not yet been set`);
1860
- return;
1861
- }
1862
- let room = getRoomById(roomId);
1863
- if (!room) {
1864
- console.error(`[NQTR] Current room ${roomId} not found`);
1865
- return;
1866
- }
1867
- return room;
1868
- }
1869
- function getCurrenrLocation() {
1870
- let room = getCurrentRoom();
1871
- if (!room) {
1872
- return;
1873
- }
1874
- return room.location;
1875
- }
1876
- function getCueerntMap() {
1877
- let location = getCurrenrLocation();
1878
- if (!location) {
1879
- return;
1880
- }
1881
- return location.map;
1882
- }
1883
1986
 
1884
1987
  // src/functions/ActivityFunctions.ts
1885
1988
  function clearExpiredActivities() {
@@ -1895,13 +1998,22 @@ function currentActivities() {
1895
1998
  return currentRoom.activities.filter((activity) => !activity.hidden);
1896
1999
  }
1897
2000
 
1898
- exports.ActivityModel = ActivityModel;
2001
+ // src/functions/QuestFunctions.ts
2002
+ function startMustStartStageQuests(props) {
2003
+ Object.entries(registeredQuests).forEach(([_, quest]) => {
2004
+ if (quest.currentStageMustStart) {
2005
+ quest.startCurrentStage(props);
2006
+ }
2007
+ });
2008
+ }
2009
+
1899
2010
  exports.ActivityRoom = ActivityRoom;
1900
2011
  exports.CommitmentBaseModel = CommitmentBaseModel;
1901
2012
  exports.Goal = Goal;
1902
2013
  exports.LocationBaseModel = LocationBaseModel;
1903
2014
  exports.MapBaseModel = MapBaseModel;
1904
- exports.RoomBaseModel = RoomBaseModel;
2015
+ exports.Quest = Quest;
2016
+ exports.RoomBaseModel = RoomBaseModel2;
1905
2017
  exports.Stage = Stage;
1906
2018
  exports.TimeManager = TimeManager;
1907
2019
  exports.addCommitment = addCommitment;
@@ -1911,20 +2023,23 @@ exports.currentActivities = currentActivities;
1911
2023
  exports.getActivityById = getActivityById;
1912
2024
  exports.getAllLocations = getAllLocations;
1913
2025
  exports.getAllMaps = getAllMaps;
2026
+ exports.getAllStartedQuests = getAllStartedQuests;
1914
2027
  exports.getCommitmentByCharacter = getCommitmentByCharacter;
1915
2028
  exports.getCommitmentById = getCommitmentById;
1916
- exports.getCueerntMap = getCueerntMap;
1917
2029
  exports.getCurrenrLocation = getCurrenrLocation;
2030
+ exports.getCurrentMap = getCurrentMap;
1918
2031
  exports.getCurrentRoom = getCurrentRoom;
2032
+ exports.getCurrentRoomRoutine = getCurrentRoomRoutine;
1919
2033
  exports.getCurrentRoutine = getCurrentRoutine;
1920
2034
  exports.getQuestById = getQuestById;
1921
2035
  exports.getRoomById = getRoomById;
2036
+ exports.newActivity = newActivity;
1922
2037
  exports.newQuest = newQuest;
1923
2038
  exports.removeCommitment = removeCommitment;
1924
- exports.saveActivity = saveActivity;
1925
2039
  exports.saveCommitment = saveCommitment;
1926
2040
  exports.saveRoom = saveRoom;
1927
2041
  exports.setCurrentRoom = setCurrentRoom;
1928
2042
  exports.setFixedRoutine = setFixedRoutine;
2043
+ exports.startMustStartStageQuests = startMustStartStageQuests;
1929
2044
  //# sourceMappingURL=out.js.map
1930
2045
  //# sourceMappingURL=index.js.map