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