@drincs/nqtr 0.1.18 → 0.1.19

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 (109) hide show
  1. package/dist/{Commitment-DNn_TEgV.d.mts → Commitment-C3Nc2RJH.d.mts} +17 -4
  2. package/dist/{Commitment-GIA4EK_q.d.ts → Commitment-Cc2kZEy0.d.ts} +17 -4
  3. package/dist/classes/Commitment.d.mts +2 -2
  4. package/dist/classes/Commitment.d.ts +2 -2
  5. package/dist/classes/Commitment.js +12 -1
  6. package/dist/classes/Commitment.js.map +1 -1
  7. package/dist/classes/Commitment.mjs +12 -1
  8. package/dist/classes/Commitment.mjs.map +1 -1
  9. package/dist/classes/index.d.mts +2 -2
  10. package/dist/classes/index.d.ts +2 -2
  11. package/dist/classes/index.js +27 -16
  12. package/dist/classes/index.js.map +1 -1
  13. package/dist/classes/index.mjs +27 -16
  14. package/dist/classes/index.mjs.map +1 -1
  15. package/dist/classes/navigation/ActivityRoom.d.mts +2 -2
  16. package/dist/classes/navigation/ActivityRoom.d.ts +2 -2
  17. package/dist/classes/navigation/Location.d.mts +2 -2
  18. package/dist/classes/navigation/Location.d.ts +2 -2
  19. package/dist/classes/navigation/Location.js.map +1 -1
  20. package/dist/classes/navigation/Location.mjs.map +1 -1
  21. package/dist/classes/navigation/Map.d.mts +2 -2
  22. package/dist/classes/navigation/Map.d.ts +2 -2
  23. package/dist/classes/navigation/Map.js.map +1 -1
  24. package/dist/classes/navigation/Map.mjs.map +1 -1
  25. package/dist/classes/navigation/Room.d.mts +2 -2
  26. package/dist/classes/navigation/Room.d.ts +2 -2
  27. package/dist/classes/navigation/Room.js +15 -15
  28. package/dist/classes/navigation/Room.js.map +1 -1
  29. package/dist/classes/navigation/Room.mjs +15 -15
  30. package/dist/classes/navigation/Room.mjs.map +1 -1
  31. package/dist/classes/quest/Stage.d.mts +2 -2
  32. package/dist/classes/quest/Stage.d.ts +2 -2
  33. package/dist/decorators/ActivityDecorator.d.mts +1 -1
  34. package/dist/decorators/ActivityDecorator.d.ts +1 -1
  35. package/dist/decorators/ActivityDecorator.js.map +1 -1
  36. package/dist/decorators/ActivityDecorator.mjs.map +1 -1
  37. package/dist/decorators/CommitmentDecorator.d.mts +32 -6
  38. package/dist/decorators/CommitmentDecorator.d.ts +32 -6
  39. package/dist/decorators/CommitmentDecorator.js +7 -7
  40. package/dist/decorators/CommitmentDecorator.js.map +1 -1
  41. package/dist/decorators/CommitmentDecorator.mjs +5 -5
  42. package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
  43. package/dist/decorators/RoomDecorator.d.mts +3 -3
  44. package/dist/decorators/RoomDecorator.d.ts +3 -3
  45. package/dist/decorators/RoomDecorator.js.map +1 -1
  46. package/dist/decorators/RoomDecorator.mjs.map +1 -1
  47. package/dist/decorators/index.d.mts +3 -3
  48. package/dist/decorators/index.d.ts +3 -3
  49. package/dist/decorators/index.js +5 -18
  50. package/dist/decorators/index.js.map +1 -1
  51. package/dist/decorators/index.mjs +4 -15
  52. package/dist/decorators/index.mjs.map +1 -1
  53. package/dist/functions/ActivityFunctions.d.mts +2 -2
  54. package/dist/functions/ActivityFunctions.d.ts +2 -2
  55. package/dist/functions/ActivityFunctions.js.map +1 -1
  56. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  57. package/dist/functions/NavigationFunctions.d.mts +2 -2
  58. package/dist/functions/NavigationFunctions.d.ts +2 -2
  59. package/dist/functions/NavigationFunctions.js.map +1 -1
  60. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  61. package/dist/functions/RoutineFunctions.d.mts +21 -4
  62. package/dist/functions/RoutineFunctions.d.ts +21 -4
  63. package/dist/functions/RoutineFunctions.js +16 -16
  64. package/dist/functions/RoutineFunctions.js.map +1 -1
  65. package/dist/functions/RoutineFunctions.mjs +16 -16
  66. package/dist/functions/RoutineFunctions.mjs.map +1 -1
  67. package/dist/functions/index.d.mts +3 -3
  68. package/dist/functions/index.d.ts +3 -3
  69. package/dist/functions/index.js +16 -16
  70. package/dist/functions/index.js.map +1 -1
  71. package/dist/functions/index.mjs +16 -16
  72. package/dist/functions/index.mjs.map +1 -1
  73. package/dist/index.d.mts +4 -4
  74. package/dist/index.d.ts +4 -4
  75. package/dist/index.js +34 -35
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +32 -30
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/interface/CommitmentProps.d.mts +2 -2
  80. package/dist/interface/CommitmentProps.d.ts +2 -2
  81. package/dist/interface/RoomProps.d.mts +2 -2
  82. package/dist/interface/RoomProps.d.ts +2 -2
  83. package/dist/interface/index.d.mts +2 -2
  84. package/dist/interface/index.d.ts +2 -2
  85. package/dist/interface/navigation/LocationProps.d.mts +2 -2
  86. package/dist/interface/navigation/LocationProps.d.ts +2 -2
  87. package/dist/interface/navigation/MapProps.d.mts +2 -2
  88. package/dist/interface/navigation/MapProps.d.ts +2 -2
  89. package/dist/types/ExecutionType.d.mts +3 -0
  90. package/dist/types/ExecutionType.d.ts +3 -0
  91. package/dist/types/ExecutionType.js +4 -0
  92. package/dist/types/ExecutionType.js.map +1 -0
  93. package/dist/types/ExecutionType.mjs +3 -0
  94. package/dist/types/ExecutionType.mjs.map +1 -0
  95. package/dist/types/index.d.mts +1 -0
  96. package/dist/types/index.d.ts +1 -0
  97. package/package.json +1 -1
  98. package/dist/enums/ExecutionTypeEnum.d.mts +0 -6
  99. package/dist/enums/ExecutionTypeEnum.d.ts +0 -6
  100. package/dist/enums/ExecutionTypeEnum.js +0 -12
  101. package/dist/enums/ExecutionTypeEnum.js.map +0 -1
  102. package/dist/enums/ExecutionTypeEnum.mjs +0 -10
  103. package/dist/enums/ExecutionTypeEnum.mjs.map +0 -1
  104. package/dist/enums/index.d.mts +0 -1
  105. package/dist/enums/index.d.ts +0 -1
  106. package/dist/enums/index.js +0 -12
  107. package/dist/enums/index.js.map +0 -1
  108. package/dist/enums/index.mjs +0 -10
  109. package/dist/enums/index.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -389,15 +389,6 @@ var ActivityModel = class {
389
389
  };
390
390
  }
391
391
  };
392
-
393
- // src/enums/ExecutionTypeEnum.ts
394
- var ExecutionTypeEnum = /* @__PURE__ */ ((ExecutionTypeEnum2) => {
395
- ExecutionTypeEnum2["AUTOMATIC"] = "automatic";
396
- ExecutionTypeEnum2["INTERACTION"] = "interaction";
397
- return ExecutionTypeEnum2;
398
- })(ExecutionTypeEnum || {});
399
-
400
- // src/classes/Commitment.ts
401
392
  var COMMITMENT_CATEGORY = "__nqtr-commitment__";
402
393
  var CommitmentBaseModel = class extends StoredClassModel {
403
394
  /**
@@ -416,11 +407,12 @@ var CommitmentBaseModel = class extends StoredClassModel {
416
407
  this.defaultFromDay = props.fromDay;
417
408
  this.defaultToDay = props.toDay;
418
409
  this._renderImage = props.renderImage;
419
- this._executionType = props.executionType || "interaction" /* INTERACTION */;
410
+ this._executionType = props.executionType || "interaction";
420
411
  this._onRun = props.onRun;
421
412
  this.defaultDisabled = props.disabled || false;
422
413
  this.defaultHidden = props.hidden || false;
423
414
  this._renderIcon = props.renderIcon;
415
+ this.defaultPriority = props.priority || 0;
424
416
  }
425
417
  /**
426
418
  * The character or characters that are in the commitment and so in the room.
@@ -562,6 +554,16 @@ var CommitmentBaseModel = class extends StoredClassModel {
562
554
  set hidden(value) {
563
555
  this.setStorageProperty("hidden", value);
564
556
  }
557
+ /**
558
+ * The priority. The higher the number, the higher the priority.
559
+ * To ensure that a character is not in 2 places at the same time, if there are 2 or more valid commits at the same time and with the same character, the one with the highest priority will be chosen.
560
+ */
561
+ get priority() {
562
+ return this.getStorageProperty("priority") || this.defaultPriority || 0;
563
+ }
564
+ set priority(value) {
565
+ this.setStorageProperty("priority", value);
566
+ }
565
567
  /**
566
568
  * Whether the commitment is expired.
567
569
  * @returns Whether the commitment is expired.
@@ -865,9 +867,9 @@ function getCommitmentById(id) {
865
867
  return;
866
868
  }
867
869
  }
868
- function setFixedCommitments(commitments) {
870
+ function setFixedRoutine(commitments) {
869
871
  if (Array.isArray(commitments)) {
870
- commitments.forEach((c) => setFixedCommitments(c));
872
+ commitments.forEach((c) => setFixedRoutine(c));
871
873
  return;
872
874
  }
873
875
  if (fixedCommitments[commitments.id]) {
@@ -875,7 +877,7 @@ function setFixedCommitments(commitments) {
875
877
  }
876
878
  fixedCommitments[commitments.id] = commitments;
877
879
  }
878
- function addTemporaryCommitment(commitment) {
880
+ function addCommitment(commitment) {
879
881
  if (!Array.isArray(commitment)) {
880
882
  commitment = [commitment];
881
883
  }
@@ -889,7 +891,7 @@ function addTemporaryCommitment(commitment) {
889
891
  }).filter((id) => id !== void 0);
890
892
  GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, [commitmentsIds]);
891
893
  }
892
- function getFixedCommitments() {
894
+ function getFixedRoutine() {
893
895
  return Object.values(fixedCommitments);
894
896
  }
895
897
  function getTemporaryCommitments() {
@@ -909,40 +911,40 @@ function clearExpiredRoutine() {
909
911
  }
910
912
  });
911
913
  }
912
- function getCurrentCommitments() {
914
+ function getCurrentRoutine() {
913
915
  let character_commitments = {};
914
- let oltherCommitments = [];
915
916
  getTemporaryCommitments().reverse().forEach((c) => {
916
917
  if (!c.hidden) {
917
- if (c.characters.length > 1) {
918
- let allAvailable = c.characters.every((ch) => !character_commitments[ch.id]);
918
+ if (c.characters.length > 0) {
919
+ let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
919
920
  if (allAvailable) {
920
921
  c.characters.forEach((ch) => {
921
922
  character_commitments[ch.id] = c;
922
923
  });
923
924
  }
924
925
  } else {
925
- oltherCommitments.push(c);
926
+ console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
926
927
  }
927
928
  }
928
929
  });
929
- getFixedCommitments().reverse().forEach((c) => {
930
+ getFixedRoutine().reverse().forEach((c) => {
930
931
  if (!c.hidden) {
931
- if (c.characters.length > 1) {
932
- c.characters.forEach((ch) => {
933
- if (!character_commitments[ch.id]) {
932
+ if (c.characters.length > 0) {
933
+ let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
934
+ if (allAvailable) {
935
+ c.characters.forEach((ch) => {
934
936
  character_commitments[ch.id] = c;
935
- }
936
- });
937
+ });
938
+ }
937
939
  } else {
938
- oltherCommitments.push(c);
940
+ console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
939
941
  }
940
942
  }
941
943
  });
942
- return Object.values(character_commitments).concat(oltherCommitments);
944
+ return Object.values(character_commitments);
943
945
  }
944
946
  function getCommitmentByCharacter(character) {
945
- getCurrentCommitments().forEach((c) => {
947
+ getCurrentRoutine().forEach((c) => {
946
948
  if (c.characters.map((ch) => ch.id).includes(character.id)) {
947
949
  return c;
948
950
  }
@@ -1375,7 +1377,7 @@ var RoomBaseModel = class extends StoredClassModel {
1375
1377
  * @returns The character commitments of the room.
1376
1378
  */
1377
1379
  getRoutine() {
1378
- let commitments = getCurrentCommitments();
1380
+ let commitments = getCurrentRoutine();
1379
1381
  return commitments.filter((c) => c.room.id === this.id);
1380
1382
  }
1381
1383
  };
@@ -1563,6 +1565,6 @@ function currentActivities() {
1563
1565
  return currentRoom.activities.filter((activity) => !activity.hidden);
1564
1566
  }
1565
1567
 
1566
- export { ActivityModel, CommitmentBaseModel, ExecutionTypeEnum, Goal, LocationBaseModel, MapBaseModel, QuestBaseModel, RoomBaseModel, StageBaseModel, TimeManager, addTemporaryCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getAllLocations, getAllMaps, getCommitmentByCharacter, getCommitmentById, getCueerntMap, getCurrenrLocation, getCurrentCommitments, getCurrentRoom, getFixedCommitments, getRoomById, getTemporaryCommitments, saveActivity, saveCommitment, saveRoom, setCurrentRoom, setFixedCommitments };
1568
+ export { ActivityModel, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, QuestBaseModel, RoomBaseModel, StageBaseModel, TimeManager, addCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getAllLocations, getAllMaps, getCommitmentByCharacter, getCommitmentById, getCueerntMap, getCurrenrLocation, getCurrentRoom, getCurrentRoutine, getRoomById, saveActivity, saveCommitment, saveRoom, setCurrentRoom, setFixedRoutine };
1567
1569
  //# sourceMappingURL=out.js.map
1568
1570
  //# sourceMappingURL=index.mjs.map