@drincs/nqtr 0.2.12 → 0.2.13

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 (281) hide show
  1. package/dist/{ActivityProps-BkHX8xkA.d.ts → ActivityProps-LWY7Zucl.d.ts} +2 -2
  2. package/dist/{ActivityProps-D45DQdcT.d.mts → ActivityProps-WgXDAYbc.d.mts} +2 -2
  3. package/dist/{Commitment-DJD0f8AH.d.mts → Commitment-BujJuTv8.d.mts} +7 -7
  4. package/dist/{Commitment-C_qBgeF9.d.ts → Commitment-DFYAApxl.d.ts} +7 -7
  5. package/dist/{StageProps-CuE_n1Wg.d.mts → StageProps-CqgBUi3e.d.mts} +1 -1
  6. package/dist/{StageProps-CCjGI625.d.ts → StageProps-DghO7WaT.d.ts} +1 -1
  7. package/dist/classes/Activity.d.mts +1 -1
  8. package/dist/classes/Activity.d.ts +1 -1
  9. package/dist/classes/Activity.js +1 -381
  10. package/dist/classes/Activity.js.map +1 -1
  11. package/dist/classes/Activity.mjs +1 -379
  12. package/dist/classes/Activity.mjs.map +1 -1
  13. package/dist/classes/ActivityStoredAbstract.d.mts +1 -1
  14. package/dist/classes/ActivityStoredAbstract.d.ts +1 -1
  15. package/dist/classes/ActivityStoredAbstract.js +1 -398
  16. package/dist/classes/ActivityStoredAbstract.js.map +1 -1
  17. package/dist/classes/ActivityStoredAbstract.mjs +1 -396
  18. package/dist/classes/ActivityStoredAbstract.mjs.map +1 -1
  19. package/dist/classes/Commitment.d.mts +2 -2
  20. package/dist/classes/Commitment.d.ts +2 -2
  21. package/dist/classes/Commitment.js +1 -438
  22. package/dist/classes/Commitment.js.map +1 -1
  23. package/dist/classes/Commitment.mjs +1 -436
  24. package/dist/classes/Commitment.mjs.map +1 -1
  25. package/dist/classes/index.d.mts +3 -3
  26. package/dist/classes/index.d.ts +3 -3
  27. package/dist/classes/index.js +1 -1700
  28. package/dist/classes/index.js.map +1 -1
  29. package/dist/classes/index.mjs +1 -1691
  30. package/dist/classes/index.mjs.map +1 -1
  31. package/dist/classes/navigation/ActivityRoom.d.mts +2 -2
  32. package/dist/classes/navigation/ActivityRoom.d.ts +2 -2
  33. package/dist/classes/navigation/ActivityRoom.js +1 -448
  34. package/dist/classes/navigation/ActivityRoom.js.map +1 -1
  35. package/dist/classes/navigation/ActivityRoom.mjs +1 -446
  36. package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
  37. package/dist/classes/navigation/Location.d.mts +2 -2
  38. package/dist/classes/navigation/Location.d.ts +2 -2
  39. package/dist/classes/navigation/Location.js +1 -118
  40. package/dist/classes/navigation/Location.js.map +1 -1
  41. package/dist/classes/navigation/Location.mjs +1 -116
  42. package/dist/classes/navigation/Location.mjs.map +1 -1
  43. package/dist/classes/navigation/Map.d.mts +2 -2
  44. package/dist/classes/navigation/Map.d.ts +2 -2
  45. package/dist/classes/navigation/Map.js +1 -114
  46. package/dist/classes/navigation/Map.js.map +1 -1
  47. package/dist/classes/navigation/Map.mjs +1 -112
  48. package/dist/classes/navigation/Map.mjs.map +1 -1
  49. package/dist/classes/navigation/Room.d.mts +2 -2
  50. package/dist/classes/navigation/Room.d.ts +2 -2
  51. package/dist/classes/navigation/Room.js +1 -778
  52. package/dist/classes/navigation/Room.js.map +1 -1
  53. package/dist/classes/navigation/Room.mjs +1 -773
  54. package/dist/classes/navigation/Room.mjs.map +1 -1
  55. package/dist/classes/quest/Goal.js +1 -85
  56. package/dist/classes/quest/Goal.js.map +1 -1
  57. package/dist/classes/quest/Goal.mjs +1 -80
  58. package/dist/classes/quest/Goal.mjs.map +1 -1
  59. package/dist/classes/quest/Quest.d.mts +1 -1
  60. package/dist/classes/quest/Quest.d.ts +1 -1
  61. package/dist/classes/quest/Quest.js +1 -769
  62. package/dist/classes/quest/Quest.js.map +1 -1
  63. package/dist/classes/quest/Quest.mjs +1 -767
  64. package/dist/classes/quest/Quest.mjs.map +1 -1
  65. package/dist/classes/quest/Stage.d.mts +1 -1
  66. package/dist/classes/quest/Stage.d.ts +1 -1
  67. package/dist/classes/quest/Stage.js +1 -536
  68. package/dist/classes/quest/Stage.js.map +1 -1
  69. package/dist/classes/quest/Stage.mjs +1 -531
  70. package/dist/classes/quest/Stage.mjs.map +1 -1
  71. package/dist/constants.d.mts +4 -0
  72. package/dist/constants.d.ts +4 -0
  73. package/dist/constants.js +2 -0
  74. package/dist/constants.js.map +1 -0
  75. package/dist/constants.mjs +2 -0
  76. package/dist/constants.mjs.map +1 -0
  77. package/dist/decorators/ActivityDecorator.d.mts +1 -1
  78. package/dist/decorators/ActivityDecorator.d.ts +1 -1
  79. package/dist/decorators/ActivityDecorator.js +1 -407
  80. package/dist/decorators/ActivityDecorator.js.map +1 -1
  81. package/dist/decorators/ActivityDecorator.mjs +1 -403
  82. package/dist/decorators/ActivityDecorator.mjs.map +1 -1
  83. package/dist/decorators/CommitmentDecorator.d.mts +2 -2
  84. package/dist/decorators/CommitmentDecorator.d.ts +2 -2
  85. package/dist/decorators/CommitmentDecorator.js +1 -91
  86. package/dist/decorators/CommitmentDecorator.js.map +1 -1
  87. package/dist/decorators/CommitmentDecorator.mjs +1 -81
  88. package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
  89. package/dist/decorators/QuestDecorator.d.mts +1 -1
  90. package/dist/decorators/QuestDecorator.d.ts +1 -1
  91. package/dist/decorators/QuestDecorator.js +1 -799
  92. package/dist/decorators/QuestDecorator.js.map +1 -1
  93. package/dist/decorators/QuestDecorator.mjs +1 -794
  94. package/dist/decorators/QuestDecorator.mjs.map +1 -1
  95. package/dist/decorators/RoomDecorator.d.mts +2 -2
  96. package/dist/decorators/RoomDecorator.d.ts +2 -2
  97. package/dist/decorators/RoomDecorator.js +1 -56
  98. package/dist/decorators/RoomDecorator.js.map +1 -1
  99. package/dist/decorators/RoomDecorator.mjs +1 -48
  100. package/dist/decorators/RoomDecorator.mjs.map +1 -1
  101. package/dist/decorators/index.d.mts +3 -3
  102. package/dist/decorators/index.d.ts +3 -3
  103. package/dist/decorators/index.js +1 -1068
  104. package/dist/decorators/index.js.map +1 -1
  105. package/dist/decorators/index.mjs +1 -1053
  106. package/dist/decorators/index.mjs.map +1 -1
  107. package/dist/functions/ActivityFunctions.d.mts +2 -2
  108. package/dist/functions/ActivityFunctions.d.ts +2 -2
  109. package/dist/functions/ActivityFunctions.js +1 -53
  110. package/dist/functions/ActivityFunctions.js.map +1 -1
  111. package/dist/functions/ActivityFunctions.mjs +1 -50
  112. package/dist/functions/ActivityFunctions.mjs.map +1 -1
  113. package/dist/functions/NavigationFunctions.d.mts +2 -2
  114. package/dist/functions/NavigationFunctions.d.ts +2 -2
  115. package/dist/functions/NavigationFunctions.js +1 -181
  116. package/dist/functions/NavigationFunctions.js.map +1 -1
  117. package/dist/functions/NavigationFunctions.mjs +1 -176
  118. package/dist/functions/NavigationFunctions.mjs.map +1 -1
  119. package/dist/functions/QuestFunctions.js +1 -20
  120. package/dist/functions/QuestFunctions.js.map +1 -1
  121. package/dist/functions/QuestFunctions.mjs +1 -18
  122. package/dist/functions/QuestFunctions.mjs.map +1 -1
  123. package/dist/functions/RoutineFunctions.d.mts +4 -4
  124. package/dist/functions/RoutineFunctions.d.ts +4 -4
  125. package/dist/functions/RoutineFunctions.js +1 -126
  126. package/dist/functions/RoutineFunctions.js.map +1 -1
  127. package/dist/functions/RoutineFunctions.mjs +1 -121
  128. package/dist/functions/RoutineFunctions.mjs.map +1 -1
  129. package/dist/functions/index.d.mts +2 -2
  130. package/dist/functions/index.d.ts +2 -2
  131. package/dist/functions/index.js +1 -293
  132. package/dist/functions/index.js.map +1 -1
  133. package/dist/functions/index.mjs +1 -281
  134. package/dist/functions/index.mjs.map +1 -1
  135. package/dist/index.d.mts +55 -13
  136. package/dist/index.d.ts +55 -13
  137. package/dist/index.js +1 -2058
  138. package/dist/index.js.map +1 -1
  139. package/dist/index.mjs +1 -2023
  140. package/dist/index.mjs.map +1 -1
  141. package/dist/interface/ActivityProps.d.mts +1 -1
  142. package/dist/interface/ActivityProps.d.ts +1 -1
  143. package/dist/interface/ActivityProps.js +1 -3
  144. package/dist/interface/ActivityProps.js.map +1 -1
  145. package/dist/interface/ActivityProps.mjs +1 -2
  146. package/dist/interface/ActivityProps.mjs.map +1 -1
  147. package/dist/interface/CommitmentProps.d.mts +2 -2
  148. package/dist/interface/CommitmentProps.d.ts +2 -2
  149. package/dist/interface/CommitmentProps.js +1 -3
  150. package/dist/interface/CommitmentProps.js.map +1 -1
  151. package/dist/interface/CommitmentProps.mjs +1 -2
  152. package/dist/interface/CommitmentProps.mjs.map +1 -1
  153. package/dist/interface/RoomActivityMemory.d.mts +1 -1
  154. package/dist/interface/RoomActivityMemory.d.ts +1 -1
  155. package/dist/interface/RoomActivityMemory.js +1 -3
  156. package/dist/interface/RoomActivityMemory.js.map +1 -1
  157. package/dist/interface/RoomActivityMemory.mjs +1 -2
  158. package/dist/interface/RoomActivityMemory.mjs.map +1 -1
  159. package/dist/interface/RoomProps.d.mts +2 -2
  160. package/dist/interface/RoomProps.d.ts +2 -2
  161. package/dist/interface/RoomProps.js +1 -3
  162. package/dist/interface/RoomProps.js.map +1 -1
  163. package/dist/interface/RoomProps.mjs +1 -2
  164. package/dist/interface/RoomProps.mjs.map +1 -1
  165. package/dist/interface/index.d.mts +3 -3
  166. package/dist/interface/index.d.ts +3 -3
  167. package/dist/interface/index.js +1 -3
  168. package/dist/interface/index.js.map +1 -1
  169. package/dist/interface/index.mjs +1 -2
  170. package/dist/interface/index.mjs.map +1 -1
  171. package/dist/interface/navigation/LocationProps.d.mts +2 -2
  172. package/dist/interface/navigation/LocationProps.d.ts +2 -2
  173. package/dist/interface/navigation/LocationProps.js +1 -3
  174. package/dist/interface/navigation/LocationProps.js.map +1 -1
  175. package/dist/interface/navigation/LocationProps.mjs +1 -2
  176. package/dist/interface/navigation/LocationProps.mjs.map +1 -1
  177. package/dist/interface/navigation/MapProps.d.mts +2 -2
  178. package/dist/interface/navigation/MapProps.d.ts +2 -2
  179. package/dist/interface/navigation/MapProps.js +1 -3
  180. package/dist/interface/navigation/MapProps.js.map +1 -1
  181. package/dist/interface/navigation/MapProps.mjs +1 -2
  182. package/dist/interface/navigation/MapProps.mjs.map +1 -1
  183. package/dist/interface/quest/GoalProps.js +1 -3
  184. package/dist/interface/quest/GoalProps.js.map +1 -1
  185. package/dist/interface/quest/GoalProps.mjs +1 -2
  186. package/dist/interface/quest/GoalProps.mjs.map +1 -1
  187. package/dist/interface/quest/QuestProps.d.mts +1 -1
  188. package/dist/interface/quest/QuestProps.d.ts +1 -1
  189. package/dist/interface/quest/QuestProps.js +1 -3
  190. package/dist/interface/quest/QuestProps.js.map +1 -1
  191. package/dist/interface/quest/QuestProps.mjs +1 -2
  192. package/dist/interface/quest/QuestProps.mjs.map +1 -1
  193. package/dist/interface/quest/StageFlags.js +1 -3
  194. package/dist/interface/quest/StageFlags.js.map +1 -1
  195. package/dist/interface/quest/StageFlags.mjs +1 -2
  196. package/dist/interface/quest/StageFlags.mjs.map +1 -1
  197. package/dist/interface/quest/StageProps.d.mts +1 -1
  198. package/dist/interface/quest/StageProps.d.ts +1 -1
  199. package/dist/interface/quest/StageProps.js +1 -3
  200. package/dist/interface/quest/StageProps.js.map +1 -1
  201. package/dist/interface/quest/StageProps.mjs +1 -2
  202. package/dist/interface/quest/StageProps.mjs.map +1 -1
  203. package/dist/managers/TimeManager.d.mts +30 -31
  204. package/dist/managers/TimeManager.d.ts +30 -31
  205. package/dist/managers/TimeManager.js +1 -250
  206. package/dist/managers/TimeManager.js.map +1 -1
  207. package/dist/managers/TimeManager.mjs +1 -248
  208. package/dist/managers/TimeManager.mjs.map +1 -1
  209. package/dist/managers/index.d.mts +5 -1
  210. package/dist/managers/index.d.ts +5 -1
  211. package/dist/managers/index.js +1 -250
  212. package/dist/managers/index.js.map +1 -1
  213. package/dist/managers/index.mjs +1 -248
  214. package/dist/managers/index.mjs.map +1 -1
  215. package/dist/override/GraphicItemInterface.js +1 -3
  216. package/dist/override/GraphicItemInterface.js.map +1 -1
  217. package/dist/override/GraphicItemInterface.mjs +1 -2
  218. package/dist/override/GraphicItemInterface.mjs.map +1 -1
  219. package/dist/override/GraphicItemType.d.mts +2 -2
  220. package/dist/override/GraphicItemType.d.ts +2 -2
  221. package/dist/override/GraphicItemType.js +1 -3
  222. package/dist/override/GraphicItemType.js.map +1 -1
  223. package/dist/override/GraphicItemType.mjs +1 -2
  224. package/dist/override/GraphicItemType.mjs.map +1 -1
  225. package/dist/override/NeighboringMapsInterface.js +1 -3
  226. package/dist/override/NeighboringMapsInterface.js.map +1 -1
  227. package/dist/override/NeighboringMapsInterface.mjs +1 -2
  228. package/dist/override/NeighboringMapsInterface.mjs.map +1 -1
  229. package/dist/override/OnRenderGraphicItemProps.js +1 -3
  230. package/dist/override/OnRenderGraphicItemProps.js.map +1 -1
  231. package/dist/override/OnRenderGraphicItemProps.mjs +1 -2
  232. package/dist/override/OnRenderGraphicItemProps.mjs.map +1 -1
  233. package/dist/override/OnRunProps.js +1 -3
  234. package/dist/override/OnRunProps.js.map +1 -1
  235. package/dist/override/OnRunProps.mjs +1 -2
  236. package/dist/override/OnRunProps.mjs.map +1 -1
  237. package/dist/override/OnStartEndStageQuest.js +1 -3
  238. package/dist/override/OnStartEndStageQuest.js.map +1 -1
  239. package/dist/override/OnStartEndStageQuest.mjs +1 -2
  240. package/dist/override/OnStartEndStageQuest.mjs.map +1 -1
  241. package/dist/override/index.js +1 -3
  242. package/dist/override/index.js.map +1 -1
  243. package/dist/override/index.mjs +1 -2
  244. package/dist/override/index.mjs.map +1 -1
  245. package/dist/types/ExecutionType.js +1 -3
  246. package/dist/types/ExecutionType.js.map +1 -1
  247. package/dist/types/ExecutionType.mjs +1 -2
  248. package/dist/types/ExecutionType.mjs.map +1 -1
  249. package/dist/types/OnRunActivityEvent.js +1 -3
  250. package/dist/types/OnRunActivityEvent.js.map +1 -1
  251. package/dist/types/OnRunActivityEvent.mjs +1 -2
  252. package/dist/types/OnRunActivityEvent.mjs.map +1 -1
  253. package/dist/types/OnRunCommitmentEvent.js +1 -3
  254. package/dist/types/OnRunCommitmentEvent.js.map +1 -1
  255. package/dist/types/OnRunCommitmentEvent.mjs +1 -2
  256. package/dist/types/OnRunCommitmentEvent.mjs.map +1 -1
  257. package/dist/types/QuestsRequired.d.mts +1 -1
  258. package/dist/types/QuestsRequired.d.ts +1 -1
  259. package/dist/types/QuestsRequired.js +1 -3
  260. package/dist/types/QuestsRequired.js.map +1 -1
  261. package/dist/types/QuestsRequired.mjs +1 -2
  262. package/dist/types/QuestsRequired.mjs.map +1 -1
  263. package/dist/types/TimeDataType.d.mts +6 -0
  264. package/dist/types/TimeDataType.d.ts +6 -0
  265. package/dist/types/TimeDataType.js +2 -0
  266. package/dist/types/TimeDataType.js.map +1 -0
  267. package/dist/types/TimeDataType.mjs +2 -0
  268. package/dist/types/TimeDataType.mjs.map +1 -0
  269. package/dist/types/TimeSettings.d.mts +1 -1
  270. package/dist/types/TimeSettings.d.ts +1 -1
  271. package/dist/types/TimeSettings.js +1 -3
  272. package/dist/types/TimeSettings.js.map +1 -1
  273. package/dist/types/TimeSettings.mjs +1 -2
  274. package/dist/types/TimeSettings.mjs.map +1 -1
  275. package/dist/types/index.d.mts +1 -1
  276. package/dist/types/index.d.ts +1 -1
  277. package/dist/types/index.js +1 -3
  278. package/dist/types/index.js.map +1 -1
  279. package/dist/types/index.mjs +1 -2
  280. package/dist/types/index.mjs.map +1 -1
  281. package/package.json +8 -7
@@ -1,774 +1,2 @@
1
- import { StoredClassModel, getFlag, GameStorageManager } from '@drincs/pixi-vn';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var TIME_SETTINGS_KEY = "___nqtr-time_manager_settings___";
20
- var TIME_DATA_KEY = "___nqtr-time_manager_data___";
21
- var TimeManager = class _TimeManager {
22
- constructor() {
23
- }
24
- static editSettings(settings) {
25
- let data = {};
26
- if (typeof settings.minDayHours === "number") {
27
- data["minDayHours"] = settings.minDayHours;
28
- }
29
- if (typeof settings.maxDayHours === "number") {
30
- data["maxDayHours"] = settings.maxDayHours;
31
- }
32
- if (typeof settings.minDayHours === "number") {
33
- data["defaultTimeSpent"] = settings.defaultTimeSpent;
34
- }
35
- if (Array.isArray(settings.timeSlots)) {
36
- data["timeSlots"] = settings.timeSlots;
37
- }
38
- if (typeof settings.weekLength === "number") {
39
- data["weekLength"] = settings.weekLength;
40
- }
41
- if (typeof settings.weekendStartDay === "number") {
42
- let weekLength = settings.weekLength || _TimeManager.weekLength;
43
- if (settings.weekendStartDay >= weekLength) {
44
- console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`);
45
- }
46
- data["weekendStartDay"] = settings.weekendStartDay;
47
- }
48
- if (Array.isArray(settings.weekDaysNames)) {
49
- let weekLength = settings.weekLength || _TimeManager.weekLength;
50
- if (settings.weekDaysNames.length !== weekLength) {
51
- console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`);
52
- }
53
- data["weekDaysNames"] = settings.weekDaysNames;
54
- }
55
- GameStorageManager.setVariable(TIME_SETTINGS_KEY, data);
56
- }
57
- /**
58
- * Get time settings
59
- * @default {}
60
- */
61
- static get settings() {
62
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY) || {};
63
- return settings;
64
- }
65
- /**
66
- * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.
67
- */
68
- static set settings(value) {
69
- _TimeManager.editSettings(value);
70
- }
71
- static get minDayHours() {
72
- let result = 0;
73
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
74
- if (settings && settings.hasOwnProperty("minDayHours")) {
75
- result = settings.minDayHours || 0;
76
- }
77
- return result;
78
- }
79
- static get maxDayHours() {
80
- let result = 24;
81
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
82
- if (settings && settings.hasOwnProperty("maxDayHours")) {
83
- result = settings.maxDayHours || 24;
84
- }
85
- return result;
86
- }
87
- static get defaultTimeSpent() {
88
- let result = 1;
89
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
90
- if (settings && settings.hasOwnProperty("defaultTimeSpent")) {
91
- result = settings.defaultTimeSpent || 1;
92
- }
93
- return result;
94
- }
95
- static get timeSlots() {
96
- let result = [];
97
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
98
- if (settings && settings.hasOwnProperty("timeSlots")) {
99
- result = settings.timeSlots || [];
100
- }
101
- return result;
102
- }
103
- static get weekLength() {
104
- let result = 7;
105
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
106
- if (settings && settings.hasOwnProperty("weekLength")) {
107
- result = settings.weekLength || 7;
108
- }
109
- return result;
110
- }
111
- static get weekendStartDay() {
112
- let result = _TimeManager.weekLength - 1;
113
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
114
- if (settings && settings.hasOwnProperty("weekendStartDay")) {
115
- result = settings.weekendStartDay || _TimeManager.weekLength - 1;
116
- }
117
- return result;
118
- }
119
- static get weekDaysNames() {
120
- let result = [];
121
- let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
122
- if (settings && settings.hasOwnProperty("weekDaysNames")) {
123
- result = settings.weekDaysNames || result;
124
- }
125
- return result;
126
- }
127
- /**
128
- * Get the current hour
129
- */
130
- static get currentHour() {
131
- let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
132
- if (data.hasOwnProperty("currentHour") && typeof data.currentHour === "number") {
133
- return data.currentHour;
134
- }
135
- return _TimeManager.minDayHours;
136
- }
137
- static set currentHour(value) {
138
- let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
139
- if (typeof value === "number") {
140
- data.currentHour = value;
141
- } else {
142
- delete data.currentHour;
143
- }
144
- GameStorageManager.setVariable(TIME_DATA_KEY, data);
145
- }
146
- /**
147
- * Get the current day
148
- */
149
- static get currentDay() {
150
- let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
151
- if (data.hasOwnProperty("currentDay") && typeof data.currentDay === "number") {
152
- return data.currentDay;
153
- }
154
- return 0;
155
- }
156
- static set currentDay(value) {
157
- let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
158
- if (typeof value === "number") {
159
- data.currentDay = value;
160
- } else {
161
- delete data.currentDay;
162
- }
163
- GameStorageManager.setVariable(TIME_DATA_KEY, data);
164
- }
165
- /**
166
- * If the current day is greater than or equal to the weekend start day, then it will return true.
167
- */
168
- static get isWeekend() {
169
- return _TimeManager.currentWeekDayNumber >= _TimeManager.weekendStartDay;
170
- }
171
- /**
172
- * Get the current week day number (1-TimeManager.weekLength).
173
- * For example, if the week length is 7 and the current day is 10, then the result will be 4.
174
- */
175
- static get currentWeekDayNumber() {
176
- let result = _TimeManager.currentDay % _TimeManager.weekLength;
177
- return result + 1;
178
- }
179
- /**
180
- * Get the current week day name. If the week days names are not defined, then it will return undefined.
181
- * For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
182
- * @default ""
183
- */
184
- static get currentDayName() {
185
- let weekDayNumber = _TimeManager.currentWeekDayNumber - 1;
186
- if (weekDayNumber >= _TimeManager.weekDaysNames.length) {
187
- console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, _TimeManager.weekDaysNames);
188
- return "";
189
- }
190
- return _TimeManager.weekDaysNames[weekDayNumber];
191
- }
192
- /**
193
- * Get the current TimeManager.timeSlots index.
194
- * You can use this property to create "Image that changes based on the time period":
195
- * @example
196
- * ```tsx
197
- * import { TimeManager } from '@drincs/nqtr';
198
- *
199
- * function changeBackground() {
200
- * return (
201
- * <img src={`background-${TimeManager.currentTimeSlot}.png`} />
202
- * )
203
- * }
204
- */
205
- static get currentTimeSlot() {
206
- if (_TimeManager.timeSlots.length === 0) {
207
- console.warn("[NQTR] Time slots are not defined");
208
- return 0;
209
- }
210
- for (let index = 0; index < _TimeManager.timeSlots.length; index++) {
211
- let slot = _TimeManager.timeSlots[index];
212
- if (_TimeManager.timeSlots.length > index + 1) {
213
- if (_TimeManager.nowIsBetween(slot.startHour, _TimeManager.timeSlots[index + 1].startHour)) {
214
- return index;
215
- }
216
- }
217
- }
218
- return _TimeManager.timeSlots.length - 1;
219
- }
220
- /**
221
- * This function will increase the current hour by the given time spent.
222
- * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.
223
- * @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)
224
- * @returns TimeManager.currentHour
225
- */
226
- static increaseHour(timeSpent = _TimeManager.defaultTimeSpent) {
227
- let newHour = _TimeManager.currentHour + timeSpent;
228
- if (newHour >= _TimeManager.maxDayHours) {
229
- _TimeManager.increaseDay();
230
- newHour = _TimeManager.minDayHours + (newHour - _TimeManager.maxDayHours);
231
- }
232
- _TimeManager.currentHour = newHour;
233
- return _TimeManager.currentHour;
234
- }
235
- /**
236
- * This function will increase the current day by the given days.
237
- * @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)
238
- * @param days is the number of days to increase (default: 1)
239
- * @returns TimeManager.currentDay
240
- */
241
- static increaseDay(newDayHour = _TimeManager.minDayHours, days = 1) {
242
- let newDay = _TimeManager.currentDay + days;
243
- _TimeManager.currentDay = newDay;
244
- _TimeManager.currentHour = newDayHour;
245
- return _TimeManager.currentDay;
246
- }
247
- /**
248
- * This function will check if the current hour is between the given hours.
249
- * @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.
250
- * @param toHour the ending hour.
251
- * @returns true if the current hour is between the given hours, otherwise false.
252
- */
253
- static nowIsBetween(fromHour, toHour) {
254
- let currentHour = _TimeManager.currentHour;
255
- if (fromHour < toHour) {
256
- return currentHour >= fromHour && currentHour < toHour;
257
- }
258
- return currentHour >= fromHour || currentHour < toHour;
259
- }
260
- };
261
-
262
- // src/decorators/ActivityDecorator.ts
263
- var registeredActivities = {};
264
- function getActivityById(id) {
265
- try {
266
- let activity = registeredActivities[id];
267
- if (!activity) {
268
- console.error(`[NQTR] Activity ${id} not found`);
269
- return;
270
- }
271
- return activity;
272
- } catch (e) {
273
- console.error(`[NQTR] Error while getting Activity ${id}`, e);
274
- return;
275
- }
276
- }
277
- var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
278
- var registeredCommitments = {};
279
- var fixedCommitments = {};
280
- function getCommitmentById(id) {
281
- try {
282
- let commitment = registeredCommitments[id];
283
- if (!commitment) {
284
- console.error(`[NQTR] Commitment ${id} not found`);
285
- return;
286
- }
287
- return commitment;
288
- } catch (e) {
289
- console.error(`[NQTR] Error while getting Commitment ${id}`, e);
290
- return;
291
- }
292
- }
293
- function getFixedRoutine() {
294
- return Object.values(fixedCommitments);
295
- }
296
- function getTemporaryCommitments() {
297
- let commitmentsIds = GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
298
- if (!commitmentsIds) {
299
- return [];
300
- }
301
- let commitments = commitmentsIds.map((id) => getCommitmentById(id)).filter((commitment) => commitment !== void 0);
302
- return commitments;
303
- }
304
- var ActivityStoredAbstract = class {
305
- /**
306
- * @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.
307
- * @param props The activity properties.
308
- */
309
- constructor(onRun, props) {
310
- this.defaultName = props.name;
311
- this.defaultFromHour = props.fromHour;
312
- this.defaultToHour = props.toHour;
313
- this.defaultFromDay = props.fromDay;
314
- this.defaultToDay = props.toDay;
315
- this.defaultDisabled = props.disabled || false;
316
- this.defaultHidden = props.hidden || false;
317
- this._renderIcon = props.renderIcon;
318
- this._onRun = onRun;
319
- }
320
- /**
321
- * The name
322
- */
323
- get name() {
324
- return this.getStorageProperty("name") || this.defaultName || "";
325
- }
326
- set name(value) {
327
- this.setStorageProperty("name", value);
328
- }
329
- /**
330
- * The hour when the activity starts. If the activity is not started yet, it will be hidden.
331
- */
332
- get fromHour() {
333
- return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
334
- }
335
- set fromHour(value) {
336
- this.setStorageProperty("fromHour", value);
337
- }
338
- /**
339
- * The hour when the activity ends. If the activity is ended yet, it will be hidden.
340
- */
341
- get toHour() {
342
- return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
343
- }
344
- set toHour(value) {
345
- this.setStorageProperty("toHour", value);
346
- }
347
- /**
348
- * The day when the activity starts. If the activity is not started yet, it will be hidden.
349
- */
350
- get fromDay() {
351
- return this.getStorageProperty("fromDay") || this.defaultFromDay;
352
- }
353
- set fromDay(value) {
354
- this.setStorageProperty("fromDay", value);
355
- }
356
- /**
357
- * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
358
- */
359
- get toDay() {
360
- return this.getStorageProperty("toDay") || this.defaultToDay;
361
- }
362
- set toDay(value) {
363
- this.setStorageProperty("toDay", value);
364
- }
365
- /**
366
- * Whether is disabled.
367
- */
368
- get disabled() {
369
- let value = this.getStorageProperty("disabled") || this.defaultDisabled;
370
- if (typeof value === "string") {
371
- return getFlag(value);
372
- }
373
- return value;
374
- }
375
- set disabled(value) {
376
- this.setStorageProperty("disabled", value);
377
- }
378
- /**
379
- * Whether is hidden. If the activity is not started yet, it will be hidden.
380
- */
381
- get hidden() {
382
- if (this.fromDay && this.fromDay > TimeManager.currentDay) {
383
- return true;
384
- }
385
- if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
386
- return true;
387
- }
388
- if (!this.isExpired) {
389
- return true;
390
- }
391
- let value = this.getStorageProperty("hidden") || this.defaultHidden;
392
- if (typeof value === "string") {
393
- return getFlag(value);
394
- }
395
- return value;
396
- }
397
- set hidden(value) {
398
- this.setStorageProperty("hidden", value);
399
- }
400
- /**
401
- * The function for rendering the icon of the activity.
402
- */
403
- get renderIcon() {
404
- let render = this._renderIcon;
405
- if (render === void 0) {
406
- return void 0;
407
- }
408
- if (typeof render === "function") {
409
- return (props) => {
410
- return render(this, props);
411
- };
412
- }
413
- return (props) => render;
414
- }
415
- /**
416
- * The function that is called when the activity is runned.
417
- */
418
- get run() {
419
- return (props) => {
420
- return this._onRun(this, props);
421
- };
422
- }
423
- /**
424
- * Whether the activity is a deadline.
425
- * @returns Whether the activity is a deadline.
426
- */
427
- isExpired() {
428
- if (this.toDay && this.toDay <= TimeManager.currentDay) {
429
- return true;
430
- }
431
- return false;
432
- }
433
- /**
434
- * Export the activity properties.
435
- * @returns The activity properties.
436
- */
437
- export() {
438
- return {
439
- name: this.getStorageProperty("name") || this.defaultName,
440
- fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
441
- toHour: this.getStorageProperty("toHour") || this.defaultToHour,
442
- fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
443
- toDay: this.getStorageProperty("toDay") || this.defaultToDay,
444
- disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
445
- hidden: this.getStorageProperty("hidden") || this.defaultHidden,
446
- renderIcon: this._renderIcon
447
- };
448
- }
449
- };
450
-
451
- // src/classes/navigation/ActivityRoom.ts
452
- var ActivityRoom = class extends ActivityStoredAbstract {
453
- constructor(id, room, onRun, props) {
454
- super(onRun, props);
455
- this._id = id;
456
- this._room = room;
457
- }
458
- setStorageProperty(_, __) {
459
- this._room.setActivity(this);
460
- }
461
- getStorageProperty(propertyName) {
462
- let activity = this._room.getActivityMemory(this.id);
463
- if (!activity || !activity.hasOwnProperty(propertyName)) {
464
- return void 0;
465
- }
466
- return activity[propertyName];
467
- }
468
- get id() {
469
- return this._id;
470
- }
471
- /**
472
- * The room where the activity is.
473
- */
474
- get room() {
475
- return this._room;
476
- }
477
- export() {
478
- let result = {};
479
- if (this.name !== void 0) {
480
- result["name"] = this.name;
481
- }
482
- if (this.fromHour !== void 0) {
483
- result["fromHour"] = this.fromHour;
484
- }
485
- if (this.toHour !== void 0) {
486
- result["toHour"] = this.toHour;
487
- }
488
- if (this.fromDay !== void 0) {
489
- result["fromDay"] = this.fromDay;
490
- }
491
- if (this.toDay !== void 0) {
492
- result["toDay"] = this.toDay;
493
- }
494
- if (this.disabled !== void 0) {
495
- result["disabled"] = this.disabled;
496
- }
497
- return result;
498
- }
499
- };
500
-
501
- // src/functions/RoutineFunctions.ts
502
- function getCurrentRoutine() {
503
- let character_commitments = {};
504
- getTemporaryCommitments().reverse().forEach((c) => {
505
- if (!c.hidden) {
506
- if (c.characters.length > 0) {
507
- let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
508
- if (allAvailable) {
509
- c.characters.forEach((ch) => {
510
- character_commitments[ch.id] = c;
511
- });
512
- }
513
- } else {
514
- console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
515
- }
516
- }
517
- });
518
- getFixedRoutine().reverse().forEach((c) => {
519
- if (!c.hidden) {
520
- if (c.characters.length > 0) {
521
- let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
522
- if (allAvailable) {
523
- c.characters.forEach((ch) => {
524
- character_commitments[ch.id] = c;
525
- });
526
- }
527
- } else {
528
- console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
529
- }
530
- }
531
- });
532
- return Object.values(character_commitments);
533
- }
534
-
535
- // src/classes/navigation/Room.ts
536
- var ROOM_CATEGORY = "__nqtr-room__";
537
- var RoomBaseModel = class extends StoredClassModel {
538
- /**
539
- * @param id The id of the room, it must be unique.
540
- * @param location The location where the room is.
541
- * @param props The properties of the room.
542
- */
543
- constructor(id, location, props = {}) {
544
- var _a;
545
- super(ROOM_CATEGORY, id);
546
- this._location = location;
547
- this.defaultName = props.name || "";
548
- this._renderImage = props.renderImage;
549
- this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
550
- this.defaultDisabled = props.disabled || false;
551
- this.defaultHidden = props.hidden || false;
552
- this._renderIcon = props.renderIcon;
553
- this._isEntrance = props.isEntrance;
554
- }
555
- /**
556
- * The location where the room is.
557
- */
558
- get location() {
559
- return this._location;
560
- }
561
- /**
562
- * Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
563
- */
564
- get isEntrance() {
565
- return this._isEntrance || false;
566
- }
567
- /**
568
- * The name.
569
- * If you set undefined, it will return the initial value of name.
570
- */
571
- get name() {
572
- return this.getStorageProperty("name") || this.defaultName;
573
- }
574
- set name(value) {
575
- this.setStorageProperty("name", value);
576
- }
577
- /**
578
- * The function for rendering the image of the room.
579
- */
580
- get renderImage() {
581
- let render = this._renderImage;
582
- if (render === void 0) {
583
- return void 0;
584
- }
585
- if (typeof render === "function") {
586
- return (props) => {
587
- return render(this, props);
588
- };
589
- }
590
- return (props) => render;
591
- }
592
- /**
593
- * The activities that are available in this room.
594
- */
595
- get defaultActivities() {
596
- let roomMemories = this.getStorageProperty("activities_memory") || {};
597
- let activities = this.defaultActivityIds.map((id) => {
598
- let activity = getActivityById(id);
599
- if (!activity) {
600
- console.warn(`[NQTR] Activity with id ${id} not found, so it will be ignored.`);
601
- return void 0;
602
- }
603
- let memory = activity.export();
604
- if (roomMemories && roomMemories[id]) {
605
- memory = __spreadValues(__spreadValues({}, memory), roomMemories[id]);
606
- }
607
- return new ActivityRoom(id, this, activity._initialOnRun, memory);
608
- }).filter((activity) => activity !== void 0);
609
- return activities;
610
- }
611
- get activityIds() {
612
- let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
613
- return this.defaultActivityIds.concat(addedActivityIds);
614
- }
615
- /**
616
- * The activities that are available in this room.
617
- */
618
- get activities() {
619
- let activities = this.activityIds.map((id) => {
620
- return this.getActivity(id);
621
- }).filter((activity) => activity !== void 0 && !activity.hidden);
622
- return activities;
623
- }
624
- /**
625
- * Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.
626
- * @param id The id of the activity.
627
- * @returns The memory of the activity.
628
- */
629
- getActivityMemory(id) {
630
- let roomMemories = this.getStorageProperty("activities_memory") || {};
631
- let roomMemory = roomMemories[id] || {};
632
- return roomMemory;
633
- }
634
- /**
635
- * Get the activity by id.
636
- * @param id The id of the activity.
637
- * @returns The room activity.
638
- */
639
- getActivity(id) {
640
- if (!this.activityIds.includes(id)) {
641
- console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`);
642
- return void 0;
643
- }
644
- let activity = getActivityById(id);
645
- if (!activity) {
646
- console.error(`[NQTR] Activity with id ${id} not found`);
647
- return void 0;
648
- }
649
- let roomMemories = this.getStorageProperty("activities_memory") || {};
650
- let roomMemory = roomMemories[id] || {};
651
- roomMemory = __spreadValues(__spreadValues({}, activity.export()), roomMemory);
652
- return new ActivityRoom(id, this, activity._initialOnRun, roomMemory);
653
- }
654
- /**
655
- * Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.
656
- * @param id The id of the activity.
657
- * @param memory The memory of the activity.
658
- */
659
- setActivity(activity) {
660
- let roomMemories = this.getStorageProperty("activities_memory") || {};
661
- roomMemories[activity.id] = activity.export();
662
- this.setStorageProperty("activities_memory", roomMemories);
663
- }
664
- /**
665
- * Add an activity to the room.
666
- * @param activity The activity to add.
667
- */
668
- addActivity(activity) {
669
- if (this.activityIds.includes(activity.id)) {
670
- let currentActivity = this.getActivity(activity.id);
671
- if (currentActivity && currentActivity.isExpired()) {
672
- this.removeActivity(activity.id);
673
- return;
674
- } else {
675
- console.error(`[NQTR] Activity with id ${activity.id} already exists in room ${this.id}, so it will be ignored.`);
676
- return;
677
- }
678
- }
679
- let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
680
- addedActivityIds.push(activity.id);
681
- this.setStorageProperty("addedActivityIds", addedActivityIds);
682
- }
683
- /**
684
- * Remove an activity from the room.
685
- * @param activity The activity to remove.
686
- */
687
- removeActivity(activity) {
688
- let activityId = typeof activity === "string" ? activity : activity.id;
689
- if (this.defaultActivityIds.includes(activityId)) {
690
- console.warn(`[NQTR] Activity with id ${activityId} is a default activity, so it can't be removed. It will be hidden instead.`);
691
- let activityToEdit = this.getActivity(activityId);
692
- if (!activityToEdit) {
693
- console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be hidden.`);
694
- return;
695
- }
696
- activityToEdit.hidden = true;
697
- return;
698
- }
699
- let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
700
- let index = addedActivityIds.indexOf(activityId);
701
- if (index === -1) {
702
- console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be removed.`);
703
- return;
704
- }
705
- addedActivityIds.splice(index, 1);
706
- this.setStorageProperty("addedActivityIds", addedActivityIds);
707
- let roomMemories = this.getStorageProperty("activities_memory") || {};
708
- delete roomMemories[activityId];
709
- this.setStorageProperty("activities_memory", roomMemories);
710
- }
711
- /**
712
- * Clear all expired activities.
713
- */
714
- clearExpiredActivities() {
715
- this.activities.forEach((activity) => {
716
- if (activity.isExpired()) {
717
- this.removeActivity(activity.id);
718
- }
719
- });
720
- }
721
- /**
722
- * Whether is disabled. If it is a string, it is a Pixi'VN flag name.
723
- */
724
- get disabled() {
725
- let value = this.getStorageProperty("disabled") || this.defaultDisabled;
726
- if (typeof value === "string") {
727
- return getFlag(value);
728
- }
729
- return value;
730
- }
731
- set disabled(value) {
732
- this.setStorageProperty("disabled", value);
733
- }
734
- /**
735
- * Whether is hidden. If it is a string, it is a Pixi'VN flag name.
736
- */
737
- get hidden() {
738
- let value = this.getStorageProperty("hidden") || this.defaultHidden;
739
- if (typeof value === "string") {
740
- return getFlag(value);
741
- }
742
- return value;
743
- }
744
- set hidden(value) {
745
- this.setStorageProperty("hidden", value);
746
- }
747
- /**
748
- * The function for rendering the icon of the room.
749
- */
750
- get renderIcon() {
751
- let render = this._renderIcon;
752
- if (render === void 0) {
753
- return void 0;
754
- }
755
- if (typeof render === "function") {
756
- return (props) => {
757
- return render(this, props);
758
- };
759
- }
760
- return (props) => render;
761
- }
762
- /**
763
- * Get the character commitments of the room.
764
- * @returns The character commitments of the room.
765
- */
766
- getRoutine() {
767
- let commitments = getCurrentRoutine();
768
- return commitments.filter((c) => c.room.id === this.id);
769
- }
770
- };
771
-
772
- export { ROOM_CATEGORY, RoomBaseModel as default };
773
- //# sourceMappingURL=out.js.map
1
+ import {StoredClassModel,getFlag,storage}from'@drincs/pixi-vn';var a="___nqtr-time_manager_settings___",d="___nqtr-time_manager_data___";var l=class{editSettings(e){let t={};if(typeof e.minDayHours=="number"&&(t.minDayHours=e.minDayHours),typeof e.maxDayHours=="number"&&(t.maxDayHours=e.maxDayHours),typeof e.minDayHours=="number"&&(t.defaultTimeSpent=e.defaultTimeSpent),Array.isArray(e.timeSlots)&&(t.timeSlots=e.timeSlots),typeof e.weekLength=="number"&&(t.weekLength=e.weekLength),typeof e.weekendStartDay=="number"){let r=e.weekLength||this.weekLength;e.weekendStartDay>=r&&console.warn(`[NQTR] Weekend start day should be less than week length ${r}`),t.weekendStartDay=e.weekendStartDay;}if(Array.isArray(e.weekDaysNames)){let r=e.weekLength||this.weekLength;e.weekDaysNames.length!==r&&console.warn(`[NQTR] Week days names should be equal to week length ${r}`),t.weekDaysNames=e.weekDaysNames;}storage.setVariable(a,t);}get settings(){return storage.getVariable(a)||{}}set settings(e){this.editSettings(e);}get minDayHours(){let e=0,t=storage.getVariable(a);return t&&t.hasOwnProperty("minDayHours")&&(e=t.minDayHours||0),e}get maxDayHours(){let e=24,t=storage.getVariable(a);return t&&t.hasOwnProperty("maxDayHours")&&(e=t.maxDayHours||24),e}get defaultTimeSpent(){let e=1,t=storage.getVariable(a);return t&&t.hasOwnProperty("defaultTimeSpent")&&(e=t.defaultTimeSpent||1),e}get timeSlots(){let e=[],t=storage.getVariable(a);return t&&t.hasOwnProperty("timeSlots")&&(e=t.timeSlots||[]),e}get weekLength(){let e=7,t=storage.getVariable(a);return t&&t.hasOwnProperty("weekLength")&&(e=t.weekLength||7),e}get weekendStartDay(){let e=this.weekLength-1,t=storage.getVariable(a);return t&&t.hasOwnProperty("weekendStartDay")&&(e=t.weekendStartDay||this.weekLength-1),e}get weekDaysNames(){let e=[],t=storage.getVariable(a);return t&&t.hasOwnProperty("weekDaysNames")&&(e=t.weekDaysNames||e),e}get currentHour(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(d,t);}get currentDay(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var s=new l;var _={};function p(i){try{let e=_[i];if(!e){console.error(`[NQTR] Activity ${i} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${i}`,e);return}}var D="___nqtr-temporary_commitment___",c={},M={};function y(i){try{let e=c[i];if(!e){console.error(`[NQTR] Commitment ${i} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${i}`,e);return}}function T(){return Object.values(M)}function v(){let i=storage.getVariable(D);return i?i.map(t=>y(t)).filter(t=>t!==undefined):[]}var h=class{constructor(e,t){this.defaultName=t.name,this.defaultFromHour=t.fromHour,this.defaultToHour=t.toHour,this.defaultFromDay=t.fromDay,this.defaultToDay=t.toDay,this.defaultDisabled=t.disabled||false,this.defaultHidden=t.hidden||false,this._renderIcon=t.renderIcon,this._onRun=e;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||""}set name(e){this.setStorageProperty("name",e);}defaultFromHour;get fromHour(){return this.getStorageProperty("fromHour")||this.defaultFromHour||s.minDayHours}set fromHour(e){this.setStorageProperty("fromHour",e);}defaultToHour;get toHour(){return this.getStorageProperty("toHour")||this.defaultToHour||s.maxDayHours+1}set toHour(e){this.setStorageProperty("toHour",e);}defaultFromDay;get fromDay(){return this.getStorageProperty("fromDay")||this.defaultFromDay}set fromDay(e){this.setStorageProperty("fromDay",e);}defaultToDay;get toDay(){return this.getStorageProperty("toDay")||this.defaultToDay}set toDay(e){this.setStorageProperty("toDay",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.fromDay&&this.fromDay>s.currentDay||!s.nowIsBetween(this.fromHour,this.toHour)||!this.isExpired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_onRun;get run(){return e=>this._onRun(this,e)}isExpired(){return !!(this.toDay&&this.toDay<=s.currentDay)}export(){return {name:this.getStorageProperty("name")||this.defaultName,fromHour:this.getStorageProperty("fromHour")||this.defaultFromHour,toHour:this.getStorageProperty("toHour")||this.defaultToHour,fromDay:this.getStorageProperty("fromDay")||this.defaultFromDay,toDay:this.getStorageProperty("toDay")||this.defaultToDay,disabled:this.getStorageProperty("disabled")||this.defaultDisabled,hidden:this.getStorageProperty("hidden")||this.defaultHidden,renderIcon:this._renderIcon}}};var u=class extends h{constructor(e,t,r,o){super(r,o),this._id=e,this._room=t;}setStorageProperty(e,t){this._room.setActivity(this);}getStorageProperty(e){let t=this._room.getActivityMemory(this.id);if(!(!t||!t.hasOwnProperty(e)))return t[e]}_id;get id(){return this._id}_room;get room(){return this._room}export(){let e={};return this.name!==undefined&&(e.name=this.name),this.fromHour!==undefined&&(e.fromHour=this.fromHour),this.toHour!==undefined&&(e.toHour=this.toHour),this.fromDay!==undefined&&(e.fromDay=this.fromDay),this.toDay!==undefined&&(e.toDay=this.toDay),this.disabled!==undefined&&(e.disabled=this.disabled),e}};function b(){let i={};return v().reverse().forEach(e=>{e.hidden||(e.characters.length>0?e.characters.every(r=>!i[r.id]||e.priority>i[r.id].priority)&&e.characters.forEach(r=>{i[r.id]=e;}):console.error(`[NQTR] The commitment ${e.id} has no characters assigned`));}),T().reverse().forEach(e=>{e.hidden||(e.characters.length>0?e.characters.every(r=>!i[r.id]||e.priority>i[r.id].priority)&&e.characters.forEach(r=>{i[r.id]=e;}):console.error(`[NQTR] The commitment ${e.id} has no characters assigned`));}),Object.values(i)}var O="__nqtr-room__",g=class extends StoredClassModel{constructor(e,t,r={}){super(O,e),this._location=t,this.defaultName=r.name||"",this._renderImage=r.renderImage,this.defaultActivityIds=r.defaultActivities?.map(o=>o.id)||[],this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._renderIcon=r.renderIcon,this._isEntrance=r.isEntrance;}_location;get location(){return this._location}_isEntrance;get isEntrance(){return this._isEntrance||false}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_renderImage;get renderImage(){let e=this._renderImage;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}defaultActivityIds;get defaultActivities(){let e=this.getStorageProperty("activities_memory")||{};return this.defaultActivityIds.map(r=>{let o=p(r);if(!o){console.warn(`[NQTR] Activity with id ${r} not found, so it will be ignored.`);return}let m=o.export();return e[r]&&(m={...m,...e[r]}),new u(r,this,o._initialOnRun,m)}).filter(r=>r!==undefined)}get activityIds(){let e=this.getStorageProperty("addedActivityIds")||[];return this.defaultActivityIds.concat(e)}get activities(){return this.activityIds.map(t=>this.getActivity(t)).filter(t=>t!==undefined&&!t.hidden)}getActivityMemory(e){return (this.getStorageProperty("activities_memory")||{})[e]||{}}getActivity(e){if(!this.activityIds.includes(e)){console.error(`[NQTR] Activity with id ${e} not found in room ${this.id}`);return}let t=p(e);if(!t){console.error(`[NQTR] Activity with id ${e} not found`);return}let o=(this.getStorageProperty("activities_memory")||{})[e]||{};return o={...t.export(),...o},new u(e,this,t._initialOnRun,o)}setActivity(e){let t=this.getStorageProperty("activities_memory")||{};t[e.id]=e.export(),this.setStorageProperty("activities_memory",t);}addActivity(e){if(this.activityIds.includes(e.id)){let r=this.getActivity(e.id);if(r&&r.isExpired()){this.removeActivity(e.id);return}else {console.error(`[NQTR] Activity with id ${e.id} already exists in room ${this.id}, so it will be ignored.`);return}}let t=this.getStorageProperty("addedActivityIds")||[];t.push(e.id),this.setStorageProperty("addedActivityIds",t);}removeActivity(e){let t=typeof e=="string"?e:e.id;if(this.defaultActivityIds.includes(t)){console.warn(`[NQTR] Activity with id ${t} is a default activity, so it can't be removed. It will be hidden instead.`);let f=this.getActivity(t);if(!f){console.error(`[NQTR] Activity with id ${t} not found, so it can't be hidden.`);return}f.hidden=true;return}let r=this.getStorageProperty("addedActivityIds")||[],o=r.indexOf(t);if(o===-1){console.error(`[NQTR] Activity with id ${t} not found, so it can't be removed.`);return}r.splice(o,1),this.setStorageProperty("addedActivityIds",r);let m=this.getStorageProperty("activities_memory")||{};delete m[t],this.setStorageProperty("activities_memory",m);}clearExpiredActivities(){this.activities.forEach(e=>{e.isExpired()&&this.removeActivity(e.id);});}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}getRoutine(){return b().filter(t=>t.room.id===this.id)}};export{O as ROOM_CATEGORY,g as default};//# sourceMappingURL=Room.mjs.map
774
2
  //# sourceMappingURL=Room.mjs.map