@drincs/nqtr 0.7.1 → 0.8.0

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.
package/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Navigation Quest Time Routine (NQTR)
2
2
 
3
+ ![cover](https://github.com/user-attachments/assets/9b514c5c-8243-4cdd-9129-ca5e45caec62)
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@drincs/nqtr" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/@drincs/nqtr?label=version" alt="npm version"></a>
7
+ <a href="https://www.npmjs.com/package/@drincs/nqtr" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/@drincs/nqtr" alt="npm downloads per month"></a>
8
+ <a target="_blank" href="https://www.jsdelivr.com/package/npm/@drincs/nqtr" rel="noopener noreferrer nofollow"><img alt="jsDelivr hits (npm)" src="https://img.shields.io/jsdelivr/npm/hm/@drincs/nqtr?logo=jsdeliver"></a>
9
+ <a href="https://www.npmjs.com/package/@drincs/nqtr" rel="noopener noreferrer nofollow"><img alt="NPM License" src="https://img.shields.io/npm/l/@drincs/nqtr"></a>
10
+ <a target="_blank" href="https://discord.gg/E95FZWakzp" rel="noopener noreferrer nofollow"><img alt="Discord" src="https://img.shields.io/discord/1263071210011496501?color=7289da&label=discord"></a>
11
+ </p>
12
+
3
13
  **What is NQTR?** NQTR (Navigation Quest Time Routine) is an extension for Pixi'VN that adds advanced systems for navigation, quests, time management, and game state handling. It is fully customizable and extensible, enabling developers to implement complex game mechanics with ease.
4
14
 
5
15
  ## Installation
package/dist/handlers.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var registries=require('@drincs/nqtr/registries'),storage=require('@drincs/pixi-vn/storage');var C=Object.defineProperty;var N=(a,e,t)=>e in a?C(a,e,{enumerable:true,configurable:true,writable:true,value:t}):a[e]=t;var u=(a,e,t)=>N(a,typeof e!="symbol"?e+"":e,t);var f="___nqtr-time_manager_data___",T="___nqtr-current_room_memory___",D="___nqtr-last_event_memory___";function l(a){storage.storage.set(D,a);}var c;(i=>(i.log=(m,...s)=>console.log(`[NQTR] ${m}`,...s),i.warn=(m,...s)=>console.warn(`[NQTR] ${m}`,...s),i.error=(m,...s)=>console.error(`[NQTR] ${m}`,...s),i.info=(m,...s)=>console.info(`[NQTR] ${m}`,...s)))(c||(c={}));var p=class{get rooms(){return registries.RegisteredRooms.values()}get locations(){return registries.RegisteredLocations.values()}get maps(){return registries.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(T)}get currentRoom(){let e=this.currentRoomId;if(!e){c.error("The current room has not yet been set");return}let t=registries.RegisteredRooms.get(e);if(!t){c.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!registries.RegisteredRooms.get(e)){c.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.storage.get(T);r!==e&&(l({type:"editroom",prev:r,value:e}),storage.storage.set(T,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){registries.RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var g=class{get quests(){return registries.RegisteredQuests.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return registries.RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var I="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return [...registries.fixedCommitments.values()]}set fixedRoutine(e){e.forEach(t=>{registries.fixedCommitments.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),registries.fixedCommitments.set(t.id,t);});}get temporaryRoutine(){let e=storage.storage.get(I);return e?e.map(r=>registries.RegisteredCommitments.get(r)).filter(r=>r!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!registries.RegisteredCommitments.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);storage.storage.set(I,t);}find(e){return registries.RegisteredCommitments.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=storage.storage.get(I);r&&(r=r.filter(i=>!t.includes(i)),storage.storage.set(I,r));}clearExpiredRoutine(){registries.RegisteredCommitments.values().forEach(e=>{e.expired&&registries.registeredCommitments.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):c.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var o=class o{};u(o,"dayStartTime",0),u(o,"dayEndTime",24),u(o,"defaultTimeSpent",1),u(o,"timeSlots",[]),u(o,"weekLength",7),u(o,"weekendStartDay",o.weekLength-1),u(o,"getDayName");var n=o;var h=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:m=[],weekLength:s=7,weekendStartDay:w=s-1,getDayName:x}=e;n.dayStartTime=t,n.dayEndTime=r,n.defaultTimeSpent=i,n.timeSlots=m,n.weekLength=s,w>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):n.weekendStartDay=w,n.getDayName=x;}get dayStartTime(){return n.dayStartTime}get dayEndTime(){return n.dayEndTime}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get getDayName(){return n.getDayName}get currentTime(){let e=storage.storage.get(f)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.storage.get(f)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,l({type:"edittime",prev:t,value:r}),storage.storage.set(f,r);}get currentDate(){let e=storage.storage.get(f)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.storage.get(f)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,l({type:"edittime",prev:t,value:r}),storage.storage.set(f,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}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.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var ce=new h,fe=new p,de=new y,le=new g;exports.navigator=fe;exports.questsNotebook=le;exports.routine=de;exports.timeTracker=ce;
1
+ 'use strict';var registries=require('@drincs/nqtr/registries'),storage=require('@drincs/pixi-vn/storage'),core=require('@drincs/pixi-vn/core');var N=Object.defineProperty;var k=(o,e,t)=>e in o?N(o,e,{enumerable:true,configurable:true,writable:true,value:t}):o[e]=t;var c=(o,e,t)=>k(o,typeof e!="symbol"?e+"":e,t);var d="___nqtr-time_manager_data___",I="___nqtr-current_room_memory___",v="___nqtr-last_event_memory___";function p(o){storage.storage.set(v,o);}var m;(i=>(i.log=(a,...s)=>console.log(`[NQTR] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[NQTR] ${a}`,...s),i.error=(a,...s)=>console.error(`[NQTR] ${a}`,...s),i.info=(a,...s)=>console.info(`[NQTR] ${a}`,...s)))(m||(m={}));var g=class{get rooms(){return registries.RegisteredRooms.values()}get locations(){return registries.RegisteredLocations.values()}get maps(){return registries.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(I)}get currentRoom(){let e=this.currentRoomId;if(!e){m.error("The current room has not yet been set");return}let t=registries.RegisteredRooms.get(e);if(!t){m.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!registries.RegisteredRooms.get(e)){m.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.storage.get(I);r!==e&&(p({type:"editroom",prev:r,value:e}),storage.storage.set(I,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){registries.RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var y=class{get quests(){return registries.RegisteredQuests.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return registries.RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var w="___nqtr-temporary_commitment___",T=class{get temporaryRoutine(){let e=storage.storage.get(w);if(e){if(Array.isArray(e))throw new core.PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.")}else return {};return e}get commitmentsIds(){return [...registries.fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let i=this.temporaryRoutine;e.forEach(a=>{registries.RegisteredCommitments.get(a.id)&&m.warn(`The commitment ${a.id} is already registered, it will be overwritten`),registries.RegisteredCommitments.add(a),i[a.id]={id:a.id,roomId:t,...r};}),storage.storage.set(w,i);}find(e){return registries.RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:m.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.storage.set(w,r);}clearExpiredRoutine(){registries.RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let i=registries.RegisteredCommitments.get(r),a=e[r],s=a?.roomId||registries.fixedCommitments.get(r)?.[1];return s&&i&&i.isActive(a)&&(i.characters.length>0?i.characters.every(f=>!t[f.id]||i.priority>t[f.id][0].priority)&&i.characters.forEach(f=>{t[f.id]=[i,s];}):m.error(`The commitment ${i.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){return this.currentRoutine.find(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t})}};var u=class u{};c(u,"dayStartTime",0),c(u,"dayEndTime",24),c(u,"defaultTimeSpent",1),c(u,"timeSlots",[]),c(u,"weekLength",7),c(u,"weekendStartDay",u.weekLength-1),c(u,"getDayName");var n=u;var _=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:s=7,weekendStartDay:E=s-1,getDayName:f}=e;n.dayStartTime=t,n.dayEndTime=r,n.defaultTimeSpent=i,n.timeSlots=a,n.weekLength=s,E>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):n.weekendStartDay=E,n.getDayName=f;}get dayStartTime(){return n.dayStartTime}get dayEndTime(){return n.dayEndTime}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get getDayName(){return n.getDayName}get currentTime(){let e=storage.storage.get(d)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.storage.get(d)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,p({type:"edittime",prev:t,value:r}),storage.storage.set(d,r);}get currentDate(){let e=storage.storage.get(d)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.storage.get(d)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,p({type:"edittime",prev:t,value:r}),storage.storage.set(d,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}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.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var de=new _,fe=new g,le=new T,pe=new y;exports.navigator=fe;exports.questsNotebook=pe;exports.routine=le;exports.timeTracker=de;
@@ -2,6 +2,45 @@ import { OnRunProps as OnRunProps$1, ActivityInterface as ActivityInterface$1, C
2
2
  import { StoredClassModel } from '@drincs/pixi-vn/storage';
3
3
  import { CharacterInterface } from '@drincs/pixi-vn';
4
4
 
5
+ interface DateSchedulingInterface {
6
+ /**
7
+ * The start date. If the item hasn't started yet, it will be hidden.
8
+ * If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
9
+ */
10
+ from: number;
11
+ /**
12
+ * The date when the item ends. If the item is ended yet, it will be deleted or hidden.
13
+ * If you set { from: 0, to: 3 }, the item will be shown into dates 1 and 2 and will be deleted or hidden from date 3.
14
+ * @default undefined
15
+ */
16
+ to?: number;
17
+ }
18
+
19
+ interface TimeSchedulingInterface {
20
+ /**
21
+ * The time when the item starts. If the item is not started yet, it will be hidden.
22
+ * If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
23
+ */
24
+ from: number;
25
+ /**
26
+ * The time when the item ends. If the item is ended yet, it will be hidden.
27
+ * If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
28
+ * @default timeTracker.dayEndTime + 1
29
+ */
30
+ to?: number;
31
+ }
32
+
33
+ interface ActiveScheduling {
34
+ /**
35
+ * Time slot in which activity/commitment will be active.
36
+ */
37
+ readonly timeSlot?: TimeSchedulingInterface[] | TimeSchedulingInterface;
38
+ /**
39
+ * Used to schedule what date it will be added and removed.
40
+ */
41
+ readonly dateScheduling?: DateSchedulingInterface;
42
+ }
43
+
5
44
  type ExecutionType = "automatic" | "interaction";
6
45
 
7
46
  type OnRunProps = OnRunProps$1;
@@ -77,49 +116,13 @@ type TimeSettings = {
77
116
  getDayName?: (weekDayNumber: number) => string;
78
117
  };
79
118
 
80
- interface DateSchedulingInterface {
81
- /**
82
- * The start date. If the item hasn't started yet, it will be hidden.
83
- * If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
84
- */
85
- from: number;
86
- /**
87
- * The date when the item ends. If the item is ended yet, it will be deleted or hidden.
88
- * If you set { from: 0, to: 3 }, the item will be shown into dates 1 and 2 and will be deleted or hidden from date 3.
89
- * @default undefined
90
- */
91
- to?: number;
92
- }
93
-
94
- interface TimeSchedulingInterface {
95
- /**
96
- * The time when the item starts. If the item is not started yet, it will be hidden.
97
- * If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
98
- */
99
- from: number;
100
- /**
101
- * The time when the item ends. If the item is ended yet, it will be hidden.
102
- * If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
103
- * @default timeTracker.dayEndTime + 1
104
- */
105
- to?: number;
106
- }
107
-
108
119
  interface ActivityInterface extends ActivityBaseInternalInterface, ActivityInterface$1 {
109
120
  }
110
- interface ActivityBaseInternalInterface {
121
+ interface ActivityBaseInternalInterface extends ActiveScheduling {
111
122
  /**
112
123
  * The id of the activity/commitment.
113
124
  */
114
125
  readonly id: string;
115
- /**
116
- * Time slot in which activity/commitment will be active.
117
- */
118
- readonly timeSlot: TimeSchedulingInterface | undefined;
119
- /**
120
- * Used to schedule what date it will be added and removed.
121
- */
122
- readonly dateScheduling: DateSchedulingInterface | undefined;
123
126
  /**
124
127
  * The function that is called when the activity/commitment is runned.
125
128
  */
@@ -131,9 +134,10 @@ interface ActivityBaseInternalInterface {
131
134
  */
132
135
  readonly expired: boolean;
133
136
  /**
134
- * Whether the activity/commitment is active.
137
+ * Whether the activity/commitment is active, so it will be shown in the routine and can be runned.
138
+ * @param options The options to check if the activity/commitment is active.
135
139
  */
136
- readonly isActive: boolean;
140
+ isActive(options?: ActiveScheduling): boolean;
137
141
  }
138
142
 
139
143
  interface CommitmentInterface extends CommitmentBaseInternalInterface, CommitmentInterface$1 {
@@ -143,10 +147,6 @@ interface CommitmentBaseInternalInterface extends ActivityBaseInternalInterface
143
147
  * The character or characters that are in the commitment and so in the room.
144
148
  */
145
149
  readonly characters: CharacterInterface[];
146
- /**
147
- * The room where the commitment is.
148
- */
149
- readonly room: RoomInterface;
150
150
  /**
151
151
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
152
152
  * If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
@@ -166,22 +166,13 @@ interface NavigationAbstractInterface extends StoredClassModel {
166
166
  * @param options
167
167
  * @returns
168
168
  */
169
- addActivity(activity: ActivityInterface, options?: {
170
- /**
171
- * Time slot in which activity will be active.
172
- */
173
- timeSlot?: TimeSchedulingInterface;
174
- /**
175
- * Used to schedule what date it will be added and removed.
176
- */
177
- dateScheduling?: DateSchedulingInterface;
178
- }): void;
169
+ addActivity(activity: ActivityInterface, options?: ActiveScheduling): void;
179
170
  /**
180
171
  * Disconnects the activity from the class.
181
172
  * @param activity The activity to disconnect from the class.
182
173
  * @param options
183
174
  */
184
- removeActivity(activity: ActivityInterface | string, options?: Pick<DateSchedulingInterface, "to">): void;
175
+ removeActivity(activity: ActivityInterface | string): void;
185
176
  /**
186
177
  * Removes the useless activities.
187
178
  */
@@ -239,6 +230,19 @@ interface RoomBaseInternalInterface extends NavigationAbstractInterface {
239
230
  * The location where the room is.
240
231
  */
241
232
  readonly location: LocationInterface;
233
+ /**
234
+ * Connects the commitment to the class.
235
+ * @param commitment The commitment to connect to the class.
236
+ * @param options
237
+ * @returns
238
+ */
239
+ addCommitment(commitment: CommitmentInterface, options?: ActiveScheduling): void;
240
+ /**
241
+ * Disconnects the commitment from the class.
242
+ * @param commitment The commitment to disconnect from the class.
243
+ * @param options
244
+ */
245
+ removeCommitment(commitment: CommitmentInterface | string): void;
242
246
  /**
243
247
  * Get the character commitments of the room.
244
248
  */
@@ -464,22 +468,18 @@ declare class QuestHandler {
464
468
  }
465
469
 
466
470
  declare class RoutineHandler {
467
- get fixedRoutine(): CommitmentInterface[];
468
- /**
469
- * Set a commitment as fixed, it will be always available. They cannot be deleted or edit during the game session.
470
- */
471
- set fixedRoutine(commitments: CommitmentInterface[]);
472
471
  /**
473
472
  * Get the temporary commitments by its id.
474
473
  * @returns The temporary commitments.
475
474
  */
476
- get temporaryRoutine(): CommitmentInterface[];
477
- get allRoutine(): CommitmentInterface[];
475
+ private get temporaryRoutine();
476
+ get commitmentsIds(): string[];
478
477
  /**
479
478
  * This feature adds the commitments during the game session.
480
479
  * @param commitment The commitment or commitments to add.
480
+ * @param roomId The id of the room where the commitment is.
481
481
  */
482
- add(commitment: CommitmentInterface[] | CommitmentInterface): void;
482
+ add(commitment: CommitmentInterface[] | CommitmentInterface, roomId: string, options?: ActiveScheduling): void;
483
483
  /**
484
484
  * Get the commitments added during the game session.
485
485
  * @param id The id of the commitment.
@@ -488,13 +488,17 @@ declare class RoutineHandler {
488
488
  find(id: string): CommitmentInterface | undefined;
489
489
  /**
490
490
  * Remove the commitments added during the game session.
491
- * @param commitment The commitment or commitments to remove.
491
+ * @param commitment The commitment or commitment id to remove.
492
+ * @param roomId The id of the room where the commitment is.
492
493
  */
493
- remove(commitment: CommitmentInterface[] | CommitmentInterface): void;
494
+ remove(commitment: CommitmentInterface | string, roomId?: string): void;
494
495
  /**
495
496
  * Clear all the expired commitments.
496
497
  */
497
498
  clearExpiredRoutine(): void;
499
+ get characterCommitments(): {
500
+ [character: string]: [CommitmentInterface, string];
501
+ };
498
502
  /**
499
503
  * Get the current commitments. The hidden commitments are not included.
500
504
  * In case there is a character who has two or more commitments at the same time, will be selected the commitment with the highest priority.
@@ -505,6 +509,9 @@ declare class RoutineHandler {
505
509
  * @returns The current commitments.
506
510
  */
507
511
  get currentRoutine(): CommitmentInterface[];
512
+ get roomCommitments(): {
513
+ [roomId: string]: CommitmentInterface[];
514
+ };
508
515
  /**
509
516
  * Get the character commitment.
510
517
  * @param character The character.
@@ -2,6 +2,45 @@ import { OnRunProps as OnRunProps$1, ActivityInterface as ActivityInterface$1, C
2
2
  import { StoredClassModel } from '@drincs/pixi-vn/storage';
3
3
  import { CharacterInterface } from '@drincs/pixi-vn';
4
4
 
5
+ interface DateSchedulingInterface {
6
+ /**
7
+ * The start date. If the item hasn't started yet, it will be hidden.
8
+ * If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
9
+ */
10
+ from: number;
11
+ /**
12
+ * The date when the item ends. If the item is ended yet, it will be deleted or hidden.
13
+ * If you set { from: 0, to: 3 }, the item will be shown into dates 1 and 2 and will be deleted or hidden from date 3.
14
+ * @default undefined
15
+ */
16
+ to?: number;
17
+ }
18
+
19
+ interface TimeSchedulingInterface {
20
+ /**
21
+ * The time when the item starts. If the item is not started yet, it will be hidden.
22
+ * If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
23
+ */
24
+ from: number;
25
+ /**
26
+ * The time when the item ends. If the item is ended yet, it will be hidden.
27
+ * If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
28
+ * @default timeTracker.dayEndTime + 1
29
+ */
30
+ to?: number;
31
+ }
32
+
33
+ interface ActiveScheduling {
34
+ /**
35
+ * Time slot in which activity/commitment will be active.
36
+ */
37
+ readonly timeSlot?: TimeSchedulingInterface[] | TimeSchedulingInterface;
38
+ /**
39
+ * Used to schedule what date it will be added and removed.
40
+ */
41
+ readonly dateScheduling?: DateSchedulingInterface;
42
+ }
43
+
5
44
  type ExecutionType = "automatic" | "interaction";
6
45
 
7
46
  type OnRunProps = OnRunProps$1;
@@ -77,49 +116,13 @@ type TimeSettings = {
77
116
  getDayName?: (weekDayNumber: number) => string;
78
117
  };
79
118
 
80
- interface DateSchedulingInterface {
81
- /**
82
- * The start date. If the item hasn't started yet, it will be hidden.
83
- * If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
84
- */
85
- from: number;
86
- /**
87
- * The date when the item ends. If the item is ended yet, it will be deleted or hidden.
88
- * If you set { from: 0, to: 3 }, the item will be shown into dates 1 and 2 and will be deleted or hidden from date 3.
89
- * @default undefined
90
- */
91
- to?: number;
92
- }
93
-
94
- interface TimeSchedulingInterface {
95
- /**
96
- * The time when the item starts. If the item is not started yet, it will be hidden.
97
- * If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
98
- */
99
- from: number;
100
- /**
101
- * The time when the item ends. If the item is ended yet, it will be hidden.
102
- * If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
103
- * @default timeTracker.dayEndTime + 1
104
- */
105
- to?: number;
106
- }
107
-
108
119
  interface ActivityInterface extends ActivityBaseInternalInterface, ActivityInterface$1 {
109
120
  }
110
- interface ActivityBaseInternalInterface {
121
+ interface ActivityBaseInternalInterface extends ActiveScheduling {
111
122
  /**
112
123
  * The id of the activity/commitment.
113
124
  */
114
125
  readonly id: string;
115
- /**
116
- * Time slot in which activity/commitment will be active.
117
- */
118
- readonly timeSlot: TimeSchedulingInterface | undefined;
119
- /**
120
- * Used to schedule what date it will be added and removed.
121
- */
122
- readonly dateScheduling: DateSchedulingInterface | undefined;
123
126
  /**
124
127
  * The function that is called when the activity/commitment is runned.
125
128
  */
@@ -131,9 +134,10 @@ interface ActivityBaseInternalInterface {
131
134
  */
132
135
  readonly expired: boolean;
133
136
  /**
134
- * Whether the activity/commitment is active.
137
+ * Whether the activity/commitment is active, so it will be shown in the routine and can be runned.
138
+ * @param options The options to check if the activity/commitment is active.
135
139
  */
136
- readonly isActive: boolean;
140
+ isActive(options?: ActiveScheduling): boolean;
137
141
  }
138
142
 
139
143
  interface CommitmentInterface extends CommitmentBaseInternalInterface, CommitmentInterface$1 {
@@ -143,10 +147,6 @@ interface CommitmentBaseInternalInterface extends ActivityBaseInternalInterface
143
147
  * The character or characters that are in the commitment and so in the room.
144
148
  */
145
149
  readonly characters: CharacterInterface[];
146
- /**
147
- * The room where the commitment is.
148
- */
149
- readonly room: RoomInterface;
150
150
  /**
151
151
  * Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
152
152
  * If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
@@ -166,22 +166,13 @@ interface NavigationAbstractInterface extends StoredClassModel {
166
166
  * @param options
167
167
  * @returns
168
168
  */
169
- addActivity(activity: ActivityInterface, options?: {
170
- /**
171
- * Time slot in which activity will be active.
172
- */
173
- timeSlot?: TimeSchedulingInterface;
174
- /**
175
- * Used to schedule what date it will be added and removed.
176
- */
177
- dateScheduling?: DateSchedulingInterface;
178
- }): void;
169
+ addActivity(activity: ActivityInterface, options?: ActiveScheduling): void;
179
170
  /**
180
171
  * Disconnects the activity from the class.
181
172
  * @param activity The activity to disconnect from the class.
182
173
  * @param options
183
174
  */
184
- removeActivity(activity: ActivityInterface | string, options?: Pick<DateSchedulingInterface, "to">): void;
175
+ removeActivity(activity: ActivityInterface | string): void;
185
176
  /**
186
177
  * Removes the useless activities.
187
178
  */
@@ -239,6 +230,19 @@ interface RoomBaseInternalInterface extends NavigationAbstractInterface {
239
230
  * The location where the room is.
240
231
  */
241
232
  readonly location: LocationInterface;
233
+ /**
234
+ * Connects the commitment to the class.
235
+ * @param commitment The commitment to connect to the class.
236
+ * @param options
237
+ * @returns
238
+ */
239
+ addCommitment(commitment: CommitmentInterface, options?: ActiveScheduling): void;
240
+ /**
241
+ * Disconnects the commitment from the class.
242
+ * @param commitment The commitment to disconnect from the class.
243
+ * @param options
244
+ */
245
+ removeCommitment(commitment: CommitmentInterface | string): void;
242
246
  /**
243
247
  * Get the character commitments of the room.
244
248
  */
@@ -464,22 +468,18 @@ declare class QuestHandler {
464
468
  }
465
469
 
466
470
  declare class RoutineHandler {
467
- get fixedRoutine(): CommitmentInterface[];
468
- /**
469
- * Set a commitment as fixed, it will be always available. They cannot be deleted or edit during the game session.
470
- */
471
- set fixedRoutine(commitments: CommitmentInterface[]);
472
471
  /**
473
472
  * Get the temporary commitments by its id.
474
473
  * @returns The temporary commitments.
475
474
  */
476
- get temporaryRoutine(): CommitmentInterface[];
477
- get allRoutine(): CommitmentInterface[];
475
+ private get temporaryRoutine();
476
+ get commitmentsIds(): string[];
478
477
  /**
479
478
  * This feature adds the commitments during the game session.
480
479
  * @param commitment The commitment or commitments to add.
480
+ * @param roomId The id of the room where the commitment is.
481
481
  */
482
- add(commitment: CommitmentInterface[] | CommitmentInterface): void;
482
+ add(commitment: CommitmentInterface[] | CommitmentInterface, roomId: string, options?: ActiveScheduling): void;
483
483
  /**
484
484
  * Get the commitments added during the game session.
485
485
  * @param id The id of the commitment.
@@ -488,13 +488,17 @@ declare class RoutineHandler {
488
488
  find(id: string): CommitmentInterface | undefined;
489
489
  /**
490
490
  * Remove the commitments added during the game session.
491
- * @param commitment The commitment or commitments to remove.
491
+ * @param commitment The commitment or commitment id to remove.
492
+ * @param roomId The id of the room where the commitment is.
492
493
  */
493
- remove(commitment: CommitmentInterface[] | CommitmentInterface): void;
494
+ remove(commitment: CommitmentInterface | string, roomId?: string): void;
494
495
  /**
495
496
  * Clear all the expired commitments.
496
497
  */
497
498
  clearExpiredRoutine(): void;
499
+ get characterCommitments(): {
500
+ [character: string]: [CommitmentInterface, string];
501
+ };
498
502
  /**
499
503
  * Get the current commitments. The hidden commitments are not included.
500
504
  * In case there is a character who has two or more commitments at the same time, will be selected the commitment with the highest priority.
@@ -505,6 +509,9 @@ declare class RoutineHandler {
505
509
  * @returns The current commitments.
506
510
  */
507
511
  get currentRoutine(): CommitmentInterface[];
512
+ get roomCommitments(): {
513
+ [roomId: string]: CommitmentInterface[];
514
+ };
508
515
  /**
509
516
  * Get the character commitment.
510
517
  * @param character The character.
package/dist/handlers.mjs CHANGED
@@ -1 +1 @@
1
- import {RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,fixedCommitments,RegisteredCommitments,registeredCommitments}from'@drincs/nqtr/registries';import {storage}from'@drincs/pixi-vn/storage';var C=Object.defineProperty;var N=(a,e,t)=>e in a?C(a,e,{enumerable:true,configurable:true,writable:true,value:t}):a[e]=t;var u=(a,e,t)=>N(a,typeof e!="symbol"?e+"":e,t);var f="___nqtr-time_manager_data___",T="___nqtr-current_room_memory___",D="___nqtr-last_event_memory___";function l(a){storage.set(D,a);}var c;(i=>(i.log=(m,...s)=>console.log(`[NQTR] ${m}`,...s),i.warn=(m,...s)=>console.warn(`[NQTR] ${m}`,...s),i.error=(m,...s)=>console.error(`[NQTR] ${m}`,...s),i.info=(m,...s)=>console.info(`[NQTR] ${m}`,...s)))(c||(c={}));var p=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(T)}get currentRoom(){let e=this.currentRoomId;if(!e){c.error("The current room has not yet been set");return}let t=RegisteredRooms.get(e);if(!t){c.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!RegisteredRooms.get(e)){c.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.get(T);r!==e&&(l({type:"editroom",prev:r,value:e}),storage.set(T,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var g=class{get quests(){return RegisteredQuests.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var I="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return [...fixedCommitments.values()]}set fixedRoutine(e){e.forEach(t=>{fixedCommitments.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),fixedCommitments.set(t.id,t);});}get temporaryRoutine(){let e=storage.get(I);return e?e.map(r=>RegisteredCommitments.get(r)).filter(r=>r!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!RegisteredCommitments.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);storage.set(I,t);}find(e){return RegisteredCommitments.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=storage.get(I);r&&(r=r.filter(i=>!t.includes(i)),storage.set(I,r));}clearExpiredRoutine(){RegisteredCommitments.values().forEach(e=>{e.expired&&registeredCommitments.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):c.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var o=class o{};u(o,"dayStartTime",0),u(o,"dayEndTime",24),u(o,"defaultTimeSpent",1),u(o,"timeSlots",[]),u(o,"weekLength",7),u(o,"weekendStartDay",o.weekLength-1),u(o,"getDayName");var n=o;var h=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:m=[],weekLength:s=7,weekendStartDay:w=s-1,getDayName:x}=e;n.dayStartTime=t,n.dayEndTime=r,n.defaultTimeSpent=i,n.timeSlots=m,n.weekLength=s,w>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):n.weekendStartDay=w,n.getDayName=x;}get dayStartTime(){return n.dayStartTime}get dayEndTime(){return n.dayEndTime}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get getDayName(){return n.getDayName}get currentTime(){let e=storage.get(f)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.get(f)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,l({type:"edittime",prev:t,value:r}),storage.set(f,r);}get currentDate(){let e=storage.get(f)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.get(f)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,l({type:"edittime",prev:t,value:r}),storage.set(f,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}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.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var ce=new h,fe=new p,de=new y,le=new g;export{fe as navigator,le as questsNotebook,de as routine,ce as timeTracker};
1
+ import {RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,fixedCommitments,RegisteredCommitments}from'@drincs/nqtr/registries';import {storage}from'@drincs/pixi-vn/storage';import {PixiError}from'@drincs/pixi-vn/core';var N=Object.defineProperty;var k=(o,e,t)=>e in o?N(o,e,{enumerable:true,configurable:true,writable:true,value:t}):o[e]=t;var c=(o,e,t)=>k(o,typeof e!="symbol"?e+"":e,t);var d="___nqtr-time_manager_data___",I="___nqtr-current_room_memory___",v="___nqtr-last_event_memory___";function p(o){storage.set(v,o);}var m;(i=>(i.log=(a,...s)=>console.log(`[NQTR] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[NQTR] ${a}`,...s),i.error=(a,...s)=>console.error(`[NQTR] ${a}`,...s),i.info=(a,...s)=>console.info(`[NQTR] ${a}`,...s)))(m||(m={}));var g=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(I)}get currentRoom(){let e=this.currentRoomId;if(!e){m.error("The current room has not yet been set");return}let t=RegisteredRooms.get(e);if(!t){m.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!RegisteredRooms.get(e)){m.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.get(I);r!==e&&(p({type:"editroom",prev:r,value:e}),storage.set(I,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var y=class{get quests(){return RegisteredQuests.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var w="___nqtr-temporary_commitment___",T=class{get temporaryRoutine(){let e=storage.get(w);if(e){if(Array.isArray(e))throw new PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.")}else return {};return e}get commitmentsIds(){return [...fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let i=this.temporaryRoutine;e.forEach(a=>{RegisteredCommitments.get(a.id)&&m.warn(`The commitment ${a.id} is already registered, it will be overwritten`),RegisteredCommitments.add(a),i[a.id]={id:a.id,roomId:t,...r};}),storage.set(w,i);}find(e){return RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:m.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.set(w,r);}clearExpiredRoutine(){RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let i=RegisteredCommitments.get(r),a=e[r],s=a?.roomId||fixedCommitments.get(r)?.[1];return s&&i&&i.isActive(a)&&(i.characters.length>0?i.characters.every(f=>!t[f.id]||i.priority>t[f.id][0].priority)&&i.characters.forEach(f=>{t[f.id]=[i,s];}):m.error(`The commitment ${i.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){return this.currentRoutine.find(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t})}};var u=class u{};c(u,"dayStartTime",0),c(u,"dayEndTime",24),c(u,"defaultTimeSpent",1),c(u,"timeSlots",[]),c(u,"weekLength",7),c(u,"weekendStartDay",u.weekLength-1),c(u,"getDayName");var n=u;var _=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:s=7,weekendStartDay:E=s-1,getDayName:f}=e;n.dayStartTime=t,n.dayEndTime=r,n.defaultTimeSpent=i,n.timeSlots=a,n.weekLength=s,E>=n.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):n.weekendStartDay=E,n.getDayName=f;}get dayStartTime(){return n.dayStartTime}get dayEndTime(){return n.dayEndTime}get defaultTimeSpent(){return n.defaultTimeSpent}get timeSlots(){return n.timeSlots}get weekLength(){return n.weekLength}get weekendStartDay(){return n.weekendStartDay}get getDayName(){return n.getDayName}get currentTime(){let e=storage.get(d)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.get(d)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,p({type:"edittime",prev:t,value:r}),storage.set(d,r);}get currentDate(){let e=storage.get(d)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.get(d)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,p({type:"edittime",prev:t,value:r}),storage.set(d,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}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.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var de=new _,fe=new g,le=new T,pe=new y;export{fe as navigator,pe as questsNotebook,le as routine,de as timeTracker};