@drincs/nqtr 0.7.1 → 0.7.2
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/dist/handlers.cjs +1 -1
- package/dist/handlers.d.mts +43 -39
- package/dist/handlers.d.ts +43 -39
- package/dist/handlers.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +54 -56
- package/dist/index.d.ts +54 -56
- package/dist/index.mjs +1 -1
- package/dist/registries.d.mts +29 -25
- package/dist/registries.d.ts +29 -25
- package/package.json +1 -1
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&®istries.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');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&®istries.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;
|
package/dist/handlers.d.mts
CHANGED
|
@@ -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
|
-
|
|
140
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
interface CommitmentInterface extends CommitmentBaseInternalInterface, CommitmentInterface$1 {
|
package/dist/handlers.d.ts
CHANGED
|
@@ -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
|
-
|
|
140
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
interface CommitmentInterface extends CommitmentBaseInternalInterface, CommitmentInterface$1 {
|
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&®isteredCommitments.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,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&®isteredCommitments.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};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var handlers=require('@drincs/nqtr/handlers'),Qe=require('@drincs/nqtr/registries'),storage=require('@drincs/pixi-vn/storage'),narration=require('@drincs/pixi-vn/narration');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Qe__namespace=/*#__PURE__*/_interopNamespace(Qe);var V=Object.defineProperty;var me=(o,r,e)=>r in o?V(o,r,{enumerable:true,configurable:true,writable:true,value:e}):o[r]=e;var j=(o,r)=>{for(var e in r)V(o,e,{get:r[e],enumerable:true});};var a=(o,r,e)=>me(o,typeof r!="symbol"?r+"":r,e);var G={};j(G,{ActivityBaseModel:()=>b,ActivityStoredClass:()=>f,CommitmentBaseModel:()=>P,CommitmentStoredClass:()=>S,LocationBaseModel:()=>D,LocationStoredClass:()=>v,MapBaseModel:()=>C,MapStoredClass:()=>I,QuestBaseModel:()=>q,QuestStoredClass:()=>x,RoomBaseModel:()=>w,RoomStoredClass:()=>_,StageBaseModel:()=>O,StageStoredClass:()=>R});var pe="__nqtr-activity__",f=class extends storage.StoredClassModel{constructor(e,t,i,n=pe){super(n,e);this._onRun=t;a(this,"_timeSlot");a(this,"_dateScheduling");this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}get timeSlot(){return this._timeSlot}get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.narration.addCurrentStepToHistory();}get run(){return async e=>(this.addTempHistoryItem(),await this._onRun(this,e))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=handlers.timeTracker.currentDate)}get isActive(){return !(this.dateScheduling?.from&&this.dateScheduling.from>handlers.timeTracker.currentDate||this.dateScheduling?.to&&this.dateScheduling.to<handlers.timeTracker.currentDate||!handlers.timeTracker.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to))}};var b=class extends f{constructor(e,t,i){super(e,t,{dateScheduling:i.dateScheduling,timeSlot:i.timeSlot});a(this,"defaultName");a(this,"defaultDisabled");a(this,"defaultHidden");a(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.renderIcon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var l="___nqtr-time_manager_data___",h="___nqtr-current_room_memory___",F="___nqtr-last_event_memory___";function A(o){storage.storage.set(F,o);}function Z(){return storage.storage.get(F)}var Se="__nqtr-commitment__",S=class extends f{constructor(e,t,i,n,s){n=n||(()=>{});super(e,n,s,Se);this._characters=t;this._room=i;a(this,"defaultExecutionType");a(this,"defaultPriority");this.defaultExecutionType=s.executionType||"interaction",this.defaultPriority=s.priority;}get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=handlers.navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=Z();switch(t?.type){case "editroom":storage.storage.set(h,t.prev),super.addTempHistoryItem(),storage.storage.set(h,e.id);break;case "edittime":let i=storage.storage.get(l)||{};storage.storage.set(l,t.prev),super.addTempHistoryItem(),storage.storage.set(l,i);break}}};var P=class extends S{constructor(e,t,i,n){super(e,t?Array.isArray(t)?t:[t]:[],i,n.onRun,{executionType:n.executionType,priority:n.priority,timeSlot:n.timeSlot,dateScheduling:n.dateScheduling});a(this,"_name");a(this,"_image");a(this,"_icon");a(this,"defaultDisabled");a(this,"defaultHidden");this._name=n.name||"",this._image=n.image,this.defaultDisabled=n.disabled||false,this.defaultHidden=n.hidden||false,this._icon=n.icon;}get name(){return this._name}get image(){return this._image}get icon(){return this._icon}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){if(this.dateScheduling?.from&&this.dateScheduling.from>handlers.timeTracker.currentDate||!handlers.timeTracker.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var g=class extends storage.StoredClassModel{constructor(e,t,i=[]){super(e,t);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(e=>e.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let i=this.excludedActivitiesScheduling;delete i[e],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.activeActivityScheduling;i[e]=t,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.excludedActivitiesScheduling;i[e]=t,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let{timeSlot:i,dateScheduling:n}=t,{to:s=handlers.timeTracker.dayEndTime+1}=i||{};if(i&&i.from>=s)throw new Error("[NQTR] The from time must be less than the to time.");if(n?.from!==void 0&&n?.to!==void 0&&n?.from>=n?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(e.id)){console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`);return}let d=this.additionalActivitiesIds;d.includes(e.id)?console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`):(d.push(e.id),this.setStorageProperty("additionalActivitiesIds",d)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),console.log(`[NQTR] Activity with id ${e.id} was excluded, so it will be associated with this class again.`)),(i||n)&&this.editActivityScheduling(e.id,{timeSlot:i,dateScheduling:n});}removeActivity(e,t={}){let{to:i}=t,n=typeof e=="string"?e:e.id,s=this.additionalActivitiesIds;if(s.includes(n)){if(i!==void 0){this.editExcludedActivityScheduling(n,{dateScheduling:{to:i}});return}s=s.filter(d=>d!==n),this.setStorageProperty("additionalActivitiesIds",s),this.removeActivityScheduling(n);}else if(this.defaultActivitiesIds.includes(n)){if(i!==void 0){this.editExcludedActivityScheduling(n,{dateScheduling:{to:i}});return}let d=this.excludedActivitiesIds;d.push(n),this.setStorageProperty("excludedActivitiesIds",d);}else console.warn(`[NQTR] Activity with id ${n} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,n=this.excludedActivitiesIds;i.forEach(s=>{if(s in e){let{to:d}=e[s].dateScheduling||{};d&&d<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(s),i=i.filter(p=>p!==s));}}),n.forEach(s=>{if(s in t){let{to:d}=t[s].dateScheduling||{};d&&d<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(s),n=n.filter(p=>p!==s));}});}get activities(){let e=[],t=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(i=>{let n=Qe.RegisteredActivities.get(i),{dateScheduling:s,timeSlot:d}=t[i]||{},{from:p=n?.dateScheduling?.from,to:W=n?.dateScheduling?.to}=s||{},{from:ce=n?.timeSlot?.from,to:le=n?.timeSlot?.to}=d||{};n&&handlers.timeTracker.nowIsBetween(ce,le)&&!(p&&p>handlers.timeTracker.currentDate)&&!(W&&W<handlers.timeTracker.currentDate)&&e.push(n);}),Object.entries(this.excludedActivitiesScheduling).forEach(([i,n])=>{let s=Qe.RegisteredActivities.get(i);s&&s.isActive&&!(n.dateScheduling&&n.dateScheduling.to!==void 0&&n.dateScheduling.to>=handlers.timeTracker.currentDate)&&e.push(s);}),this.defaultActivities.forEach(i=>{i.isActive&&!e.find(n=>n.id===i.id)&&e.push(i);}),e}};var Ie="__nqtr-location__",v=class extends g{constructor(e,t,i=[]){super(Ie,e,i);this._map=t;}get map(){return this._map}get rooms(){return handlers.navigator.rooms.filter(e=>e.location.id===this.id)}};var D=class extends v{constructor(e,t,i={}){super(e,t,i.activities||[]);a(this,"defaultName");a(this,"defaultDisabled");a(this,"defaultHidden");a(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var xe="__nqtr-map__",I=class extends g{constructor(r,e=[]){super(xe,r,e);}get locations(){return handlers.navigator.locations.filter(r=>r.map.id===this.id)}};var C=class extends I{constructor(e,t={}){super(e,t.activities||[]);a(this,"defaultName");a(this,"_image");this.defaultName=t.name||"",this._image=t.image;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}};var Te="__nqtr-room__",_=class extends g{constructor(e,t,i=[]){super(Te,e,i);this._location=t;}get routine(){return handlers.routine.currentRoutine.filter(e=>e.room.id===this.id)}get location(){return this._location}get characters(){let e=[];return this.routine.forEach(t=>{e.push(...t.characters);}),e}get automaticFunctions(){return this.routine.filter(e=>e.executionType==="automatic"&&e.run).map(e=>async i=>{await e.run(i);})}};var w=class extends _{constructor(e,t,i={}){super(e,t,i.activities||[]);a(this,"defaultName");a(this,"_image");a(this,"defaultDisabled");a(this,"defaultHidden");a(this,"_icon");this.defaultName=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var c;(i=>(i.log=(n,...s)=>console.log(`[NQTR] ${n}`,...s),i.warn=(n,...s)=>console.warn(`[NQTR] ${n}`,...s),i.error=(n,...s)=>console.error(`[NQTR] ${n}`,...s),i.info=(n,...s)=>console.info(`[NQTR] ${n}`,...s)))(c||(c={}));var Ae="__nqtr-quest__",x=class extends storage.StoredClassModel{constructor(e,t,i={}){super(Ae,e);this._stages=t;a(this,"_onStart");a(this,"_onNextStage");this._onStart=i.onStart,this._onNextStage=i.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===void 0||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}get onStart(){return this._onStart}get onNextStage(){return this._onNextStage}async start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){c.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&await this.onStart(this,e),await t.start(e);c.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(e){return await this.advanceIfCompleted(e)}async advanceIfCompleted(e){if(!this.inProgress)return false;let t=this.currentStage;return t?t.completed?await this.advanceUnconditionally(e):false:(c.error(`Quest ${this.id} has no current stage`),false)}async goNext(e){return await this.continue(e)}async continue(e){let t=this.currentStage;return t?(t.completed=true,await this.advanceUnconditionally(e)):(c.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(e){return await this.advanceUnconditionally(e)}async advanceUnconditionally(e){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===void 0)return c.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&await this.onNextStage(this,e),t&&t.onEnd&&await t.onEnd(t,e);let n=this.currentStage;return n&&(n.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}async startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?await t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var q=class extends x{constructor(e,t,i){super(e,t,{onStart:i.onStart,onNextStage:i.onNextStage});a(this,"_name");a(this,"_description");a(this,"_icon");a(this,"_image");a(this,"_inDevelopment");this._name=i.name||"",this._description=i.description||"",this._icon=i.icon,this._image=i.image,this._inDevelopment=i.inDevelopment||false;}get name(){return this._name}get description(){return this._description}get icon(){return this._icon}get image(){return this._image}get inDevelopment(){return this._inDevelopment}};var Pe="__nqtr-stage__",R=class extends storage.StoredClassModel{constructor(e,t={}){super(Pe,e);a(this,"_onStart");a(this,"_onEnd");a(this,"_deltaDateRequired");a(this,"_questsRequired");this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}get onStart(){return this._onStart}get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>handlers.timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=handlers.timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}get deltaDateRequired(){return this._deltaDateRequired||0}get questsRequired(){return this._questsRequired||[]}};var O=class extends R{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired});a(this,"_name");a(this,"_description");a(this,"_adviceDescription");a(this,"_image");a(this,"_flags");a(this,"_flagsRequired");a(this,"_requestDescriptionToStart");this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}get name(){return this._name}get description(){return this._description}get adviceDescription(){return this._adviceDescription}get image(){return this._image}get flags(){return this._flags}get flagsRequired(){return this._flagsRequired}get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.storage.getFlag(e.flag))?false:super.canStart}};var oe={};var de={};var U={};j(U,{navigator:()=>Oe,questsNotebook:()=>Me,routine:()=>Ne,timeTracker:()=>qe});var N=class{get rooms(){return Qe.RegisteredRooms.values()}get locations(){return Qe.RegisteredLocations.values()}get maps(){return Qe.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(h)}get currentRoom(){let r=this.currentRoomId;if(!r){c.error("The current room has not yet been set");return}let e=Qe.RegisteredRooms.get(r);if(!e){c.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!Qe.RegisteredRooms.get(r)){c.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.storage.get(h);t!==r&&(A({type:"editroom",prev:t,value:r}),storage.storage.set(h,r));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Qe.RegisteredRooms.values().forEach(r=>{r.clearExpiredActivities();});}};var M=class{get quests(){return Qe.RegisteredQuests.values()}get startedQuests(){return this.quests.filter(r=>r.started)}get inProgressQuests(){return this.quests.filter(r=>r.inProgress)}get completedQuests(){return this.quests.filter(r=>r.completed)}get failedQuests(){return this.quests.filter(r=>r.failed)}get notStartedQuests(){return this.quests.filter(r=>!r.started)}find(r){return Qe.RegisteredQuests.get(r)}async startsStageMustBeStarted(r){let e=this.quests.map(t=>t.currentStageMustStart?t.startCurrentStage(r):Promise.resolve());await Promise.all(e);}};var z="___nqtr-temporary_commitment___",Q=class{get fixedRoutine(){return [...Qe.fixedCommitments.values()]}set fixedRoutine(r){r.forEach(e=>{Qe.fixedCommitments.has(e.id)&&console.warn(`[NQTR] Commitment id ${e.id} already exists, it will be overwritten`),Qe.fixedCommitments.set(e.id,e);});}get temporaryRoutine(){let r=storage.storage.get(z);return r?r.map(t=>Qe.RegisteredCommitments.get(t)).filter(t=>t!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(r){Array.isArray(r)||(r=[r]);let e=r.map(t=>{if(!Qe.RegisteredCommitments.get(t.id)){console.warn(`[NQTR] Commitment ${t.id} not found, it will be ignored`);return}return t.id}).filter(t=>t!==void 0);storage.storage.set(z,e);}find(r){return Qe.RegisteredCommitments.get(r)}remove(r){Array.isArray(r)||(r=[r]);let e=r.map(i=>i.id),t=storage.storage.get(z);t&&(t=t.filter(i=>!e.includes(i)),storage.storage.set(z,t));}clearExpiredRoutine(){Qe.RegisteredCommitments.values().forEach(r=>{r.expired&&Qe.registeredCommitments.delete(r.id);});}get currentRoutine(){let r={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(e=>{e.isActive&&(e.characters.length>0?e.characters.every(i=>!r[i.id]||e.priority>r[i.id].priority)&&e.characters.forEach(i=>{r[i.id]=e;}):c.error(`The commitment ${e.id} has no characters assigned`));}),Object.values(r)}getCommitmentByCharacter(r){this.currentRoutine.forEach(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e});}};var m=class m{};a(m,"dayStartTime",0),a(m,"dayEndTime",24),a(m,"defaultTimeSpent",1),a(m,"timeSlots",[]),a(m,"weekLength",7),a(m,"weekendStartDay",m.weekLength-1),a(m,"getDayName");var u=m;var L=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:n=[],weekLength:s=7,weekendStartDay:d=s-1,getDayName:p}=r;u.dayStartTime=e,u.dayEndTime=t,u.defaultTimeSpent=i,u.timeSlots=n,u.weekLength=s,d>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):u.weekendStartDay=d,u.getDayName=p;}get dayStartTime(){return u.dayStartTime}get dayEndTime(){return u.dayEndTime}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get getDayName(){return u.getDayName}get currentTime(){let r=storage.storage.get(l)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.storage.get(l)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,A({type:"edittime",prev:e,value:t}),storage.storage.set(l,t);}get currentDate(){let r=storage.storage.get(l)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.storage.get(l)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,A({type:"edittime",prev:e,value:t}),storage.storage.set(l,t);}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 r=0;r<this.timeSlots.length;r++){let e=this.timeSlots[r];if(this.timeSlots.length>r+1&&this.nowIsBetween(e.startTime,this.timeSlots[r+1].startTime))return r}return this.timeSlots.length-1}increaseTime(r=this.defaultTimeSpent){let e=this.currentTime+r;return e>=this.dayEndTime&&(this.increaseDate(),e=this.dayStartTime+(e-this.dayEndTime)),this.currentTime=e,this.currentTime}increaseDate(r=1,e=this.dayStartTime){let t=this.currentDate+r;return this.currentDate=t,this.currentTime=e,this.currentDate}nowIsBetween(r,e){r===void 0&&(r=this.dayStartTime-1),e===void 0&&(e=this.dayEndTime+1);let t=this.currentTime;return r<e?t>=r&&t<e:t>=r||t<e}};var qe=new L,Oe=new N,Ne=new Q,Me=new M;var Le={...G,...oe,...de,handlers:U,registries:Qe__namespace},Lr=Le;Object.defineProperty(exports,"RegisteredActivities",{enumerable:true,get:function(){return Qe.RegisteredActivities}});Object.defineProperty(exports,"RegisteredCommitments",{enumerable:true,get:function(){return Qe.RegisteredCommitments}});Object.defineProperty(exports,"RegisteredLocations",{enumerable:true,get:function(){return Qe.RegisteredLocations}});Object.defineProperty(exports,"RegisteredMaps",{enumerable:true,get:function(){return Qe.RegisteredMaps}});Object.defineProperty(exports,"RegisteredQuests",{enumerable:true,get:function(){return Qe.RegisteredQuests}});Object.defineProperty(exports,"RegisteredRooms",{enumerable:true,get:function(){return Qe.RegisteredRooms}});exports.ActivityBaseModel=b;exports.ActivityStoredClass=f;exports.CommitmentBaseModel=P;exports.CommitmentStoredClass=S;exports.LocationBaseModel=D;exports.LocationStoredClass=v;exports.MapBaseModel=C;exports.MapStoredClass=I;exports.QuestBaseModel=q;exports.QuestStoredClass=x;exports.RoomBaseModel=w;exports.RoomStoredClass=_;exports.StageBaseModel=O;exports.StageStoredClass=R;exports.default=Lr;Object.keys(handlers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return handlers[k]}})});
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var handlers=require('@drincs/nqtr/handlers'),qe=require('@drincs/nqtr/registries'),storage=require('@drincs/pixi-vn/storage'),narration=require('@drincs/pixi-vn/narration');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var qe__namespace=/*#__PURE__*/_interopNamespace(qe);var U=Object.defineProperty;var oe=(s,r,e)=>r in s?U(s,r,{enumerable:true,configurable:true,writable:true,value:e}):s[r]=e;var W=(s,r)=>{for(var e in r)U(s,e,{get:r[e],enumerable:true});};var n=(s,r,e)=>oe(s,typeof r!="symbol"?r+"":r,e);var F={};W(F,{ActivityBaseModel:()=>T,ActivityStoredClass:()=>f,CommitmentBaseModel:()=>E,CommitmentStoredClass:()=>h,LocationBaseModel:()=>P,LocationStoredClass:()=>S,MapBaseModel:()=>D,MapStoredClass:()=>y,QuestBaseModel:()=>w,QuestStoredClass:()=>I,RoomBaseModel:()=>C,RoomStoredClass:()=>v,StageBaseModel:()=>q,StageStoredClass:()=>_});var ce="__nqtr-activity__",f=class extends storage.StoredClassModel{constructor(e,t,i,a=ce){super(a,e);this._onRun=t;n(this,"_timeSlot");n(this,"_dateScheduling");this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}get timeSlot(){return this._timeSlot}get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.narration.addCurrentStepToHistory();}get run(){return async e=>(this.addTempHistoryItem(),await this._onRun(this,e))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=handlers.timeTracker.currentDate)}isActive(e={}){let{timeSlot:t=this.timeSlot,dateScheduling:i=this.dateScheduling}=e;if(i?.from!=null&&i.from>handlers.timeTracker.currentDate||i?.to!=null&&i.to<handlers.timeTracker.currentDate)return false;t&&!Array.isArray(t)&&(t=[t]);for(let a of t||[])if(!handlers.timeTracker.nowIsBetween(a?.from,a?.to))return false;return true}};var T=class extends f{constructor(e,t,i){super(e,t,{dateScheduling:i.dateScheduling,timeSlot:i.timeSlot});n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.renderIcon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var l="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",z="___nqtr-last_event_memory___";function b(s){storage.storage.set(z,s);}function J(){return storage.storage.get(z)}var me="__nqtr-commitment__",h=class extends f{constructor(e,t,i,a,o){a=a||(()=>{});super(e,a,o,me);this._characters=t;this._room=i;n(this,"defaultExecutionType");n(this,"defaultPriority");this.defaultExecutionType=o.executionType||"interaction",this.defaultPriority=o.priority;}get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=handlers.navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=J();switch(t?.type){case "editroom":storage.storage.set(p,t.prev),super.addTempHistoryItem(),storage.storage.set(p,e.id);break;case "edittime":let i=storage.storage.get(l)||{};storage.storage.set(l,t.prev),super.addTempHistoryItem(),storage.storage.set(l,i);break}}};var E=class extends h{constructor(e,t,i,a){super(e,t?Array.isArray(t)?t:[t]:[],i,a.onRun,{executionType:a.executionType,priority:a.priority,timeSlot:a.timeSlot,dateScheduling:a.dateScheduling});n(this,"_name");n(this,"_image");n(this,"_icon");n(this,"defaultDisabled");n(this,"defaultHidden");this._name=a.name||"",this._image=a.image,this.defaultDisabled=a.disabled||false,this.defaultHidden=a.hidden||false,this._icon=a.icon;}get name(){return this._name}get image(){return this._image}get icon(){return this._icon}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var g=class extends storage.StoredClassModel{constructor(e,t,i=[]){super(e,t);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(e=>e.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let i=this.excludedActivitiesScheduling;delete i[e],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.activeActivityScheduling;i[e]=t,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.excludedActivitiesScheduling;i[e]=t,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:R=handlers.timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=R)throw new Error("[NQTR] The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(e.id)){console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`);return}let o=this.additionalActivitiesIds;o.includes(e.id)?console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`):(o.push(e.id),this.setStorageProperty("additionalActivitiesIds",o)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),console.log(`[NQTR] Activity with id ${e.id} was excluded, so it will be associated with this class again.`)),(i||a)&&this.editActivityScheduling(e.id,{timeSlot:i,dateScheduling:a});}removeActivity(e){let t=typeof e=="string"?e:e.id,i=this.additionalActivitiesIds;if(i.includes(t))i=i.filter(a=>a!==t),this.setStorageProperty("additionalActivitiesIds",i),this.removeActivityScheduling(t);else if(this.defaultActivitiesIds.includes(t)){let a=this.excludedActivitiesIds;a.push(t),this.setStorageProperty("excludedActivitiesIds",a);}else console.warn(`[NQTR] Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,a=this.excludedActivitiesIds;i.forEach(o=>{if(o in e){let{to:c}=e[o].dateScheduling||{};c&&c<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(o),i=i.filter(R=>R!==o));}}),a.forEach(o=>{o in t&&t[o]&&(this.removeActivityScheduling(o),a=a.filter(c=>c!==o));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let i=qe.RegisteredActivities.get(t);return i&&i.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(i),e},[])}};var he="__nqtr-location__",S=class extends g{constructor(e,t,i=[]){super(he,e,i);this._map=t;}get map(){return this._map}get rooms(){return handlers.navigator.rooms.filter(e=>e.location.id===this.id)}};var P=class extends S{constructor(e,t,i={}){super(e,t,i.activities||[]);n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var ye="__nqtr-map__",y=class extends g{constructor(r,e=[]){super(ye,r,e);}get locations(){return handlers.navigator.locations.filter(r=>r.map.id===this.id)}};var D=class extends y{constructor(e,t={}){super(e,t.activities||[]);n(this,"defaultName");n(this,"_image");this.defaultName=t.name||"",this._image=t.image;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}};var Ie="__nqtr-room__",v=class extends g{constructor(e,t,i=[]){super(Ie,e,i);this._location=t;}get routine(){return handlers.routine.currentRoutine.filter(e=>e.room.id===this.id)}get location(){return this._location}get characters(){let e=[];return this.routine.forEach(t=>{e.push(...t.characters);}),e}get automaticFunctions(){return this.routine.filter(e=>e.executionType==="automatic"&&e.run).map(e=>async i=>{await e.run(i);})}};var C=class extends v{constructor(e,t,i={}){super(e,t,i.activities||[]);n(this,"defaultName");n(this,"_image");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var u;(i=>(i.log=(a,...o)=>console.log(`[NQTR] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[NQTR] ${a}`,...o),i.error=(a,...o)=>console.error(`[NQTR] ${a}`,...o),i.info=(a,...o)=>console.info(`[NQTR] ${a}`,...o)))(u||(u={}));var xe="__nqtr-quest__",I=class extends storage.StoredClassModel{constructor(e,t,i={}){super(xe,e);this._stages=t;n(this,"_onStart");n(this,"_onNextStage");this._onStart=i.onStart,this._onNextStage=i.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===void 0||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}get onStart(){return this._onStart}get onNextStage(){return this._onNextStage}async start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){u.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&await this.onStart(this,e),await t.start(e);u.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(e){return await this.advanceIfCompleted(e)}async advanceIfCompleted(e){if(!this.inProgress)return false;let t=this.currentStage;return t?t.completed?await this.advanceUnconditionally(e):false:(u.error(`Quest ${this.id} has no current stage`),false)}async goNext(e){return await this.continue(e)}async continue(e){let t=this.currentStage;return t?(t.completed=true,await this.advanceUnconditionally(e)):(u.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(e){return await this.advanceUnconditionally(e)}async advanceUnconditionally(e){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===void 0)return u.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&await this.onNextStage(this,e),t&&t.onEnd&&await t.onEnd(t,e);let a=this.currentStage;return a&&(a.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}async startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?await t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var w=class extends I{constructor(e,t,i){super(e,t,{onStart:i.onStart,onNextStage:i.onNextStage});n(this,"_name");n(this,"_description");n(this,"_icon");n(this,"_image");n(this,"_inDevelopment");this._name=i.name||"",this._description=i.description||"",this._icon=i.icon,this._image=i.image,this._inDevelopment=i.inDevelopment||false;}get name(){return this._name}get description(){return this._description}get icon(){return this._icon}get image(){return this._image}get inDevelopment(){return this._inDevelopment}};var Te="__nqtr-stage__",_=class extends storage.StoredClassModel{constructor(e,t={}){super(Te,e);n(this,"_onStart");n(this,"_onEnd");n(this,"_deltaDateRequired");n(this,"_questsRequired");this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}get onStart(){return this._onStart}get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>handlers.timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=handlers.timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}get deltaDateRequired(){return this._deltaDateRequired||0}get questsRequired(){return this._questsRequired||[]}};var q=class extends _{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired});n(this,"_name");n(this,"_description");n(this,"_adviceDescription");n(this,"_image");n(this,"_flags");n(this,"_flagsRequired");n(this,"_requestDescriptionToStart");this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}get name(){return this._name}get description(){return this._description}get adviceDescription(){return this._adviceDescription}get image(){return this._image}get flags(){return this._flags}get flagsRequired(){return this._flagsRequired}get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.storage.getFlag(e.flag))?false:super.canStart}};var ne={};var ae={};var K={};W(K,{navigator:()=>De,questsNotebook:()=>we,routine:()=>Ce,timeTracker:()=>Pe});var O=class{get rooms(){return qe.RegisteredRooms.values()}get locations(){return qe.RegisteredLocations.values()}get maps(){return qe.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(p)}get currentRoom(){let r=this.currentRoomId;if(!r){u.error("The current room has not yet been set");return}let e=qe.RegisteredRooms.get(r);if(!e){u.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!qe.RegisteredRooms.get(r)){u.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.storage.get(p);t!==r&&(b({type:"editroom",prev:t,value:r}),storage.storage.set(p,r));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){qe.RegisteredRooms.values().forEach(r=>{r.clearExpiredActivities();});}};var N=class{get quests(){return qe.RegisteredQuests.values()}get startedQuests(){return this.quests.filter(r=>r.started)}get inProgressQuests(){return this.quests.filter(r=>r.inProgress)}get completedQuests(){return this.quests.filter(r=>r.completed)}get failedQuests(){return this.quests.filter(r=>r.failed)}get notStartedQuests(){return this.quests.filter(r=>!r.started)}find(r){return qe.RegisteredQuests.get(r)}async startsStageMustBeStarted(r){let e=this.quests.map(t=>t.currentStageMustStart?t.startCurrentStage(r):Promise.resolve());await Promise.all(e);}};var $="___nqtr-temporary_commitment___",M=class{get fixedRoutine(){return [...qe.fixedCommitments.values()]}set fixedRoutine(r){r.forEach(e=>{qe.fixedCommitments.has(e.id)&&console.warn(`[NQTR] Commitment id ${e.id} already exists, it will be overwritten`),qe.fixedCommitments.set(e.id,e);});}get temporaryRoutine(){let r=storage.storage.get($);return r?r.map(t=>qe.RegisteredCommitments.get(t)).filter(t=>t!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(r){Array.isArray(r)||(r=[r]);let e=r.map(t=>{if(!qe.RegisteredCommitments.get(t.id)){console.warn(`[NQTR] Commitment ${t.id} not found, it will be ignored`);return}return t.id}).filter(t=>t!==void 0);storage.storage.set($,e);}find(r){return qe.RegisteredCommitments.get(r)}remove(r){Array.isArray(r)||(r=[r]);let e=r.map(i=>i.id),t=storage.storage.get($);t&&(t=t.filter(i=>!e.includes(i)),storage.storage.set($,t));}clearExpiredRoutine(){qe.RegisteredCommitments.values().forEach(r=>{r.expired&&qe.registeredCommitments.delete(r.id);});}get currentRoutine(){let r={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(e=>{e.isActive()&&(e.characters.length>0?e.characters.every(i=>!r[i.id]||e.priority>r[i.id].priority)&&e.characters.forEach(i=>{r[i.id]=e;}):u.error(`The commitment ${e.id} has no characters assigned`));}),Object.values(r)}getCommitmentByCharacter(r){this.currentRoutine.forEach(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e});}};var m=class m{};n(m,"dayStartTime",0),n(m,"dayEndTime",24),n(m,"defaultTimeSpent",1),n(m,"timeSlots",[]),n(m,"weekLength",7),n(m,"weekendStartDay",m.weekLength-1),n(m,"getDayName");var d=m;var Q=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:o=7,weekendStartDay:c=o-1,getDayName:R}=r;d.dayStartTime=e,d.dayEndTime=t,d.defaultTimeSpent=i,d.timeSlots=a,d.weekLength=o,c>=d.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${o}, so will be ignored`):d.weekendStartDay=c,d.getDayName=R;}get dayStartTime(){return d.dayStartTime}get dayEndTime(){return d.dayEndTime}get defaultTimeSpent(){return d.defaultTimeSpent}get timeSlots(){return d.timeSlots}get weekLength(){return d.weekLength}get weekendStartDay(){return d.weekendStartDay}get getDayName(){return d.getDayName}get currentTime(){let r=storage.storage.get(l)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.storage.get(l)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,b({type:"edittime",prev:e,value:t}),storage.storage.set(l,t);}get currentDate(){let r=storage.storage.get(l)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.storage.get(l)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,b({type:"edittime",prev:e,value:t}),storage.storage.set(l,t);}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 r=0;r<this.timeSlots.length;r++){let e=this.timeSlots[r];if(this.timeSlots.length>r+1&&this.nowIsBetween(e.startTime,this.timeSlots[r+1].startTime))return r}return this.timeSlots.length-1}increaseTime(r=this.defaultTimeSpent){let e=this.currentTime+r;return e>=this.dayEndTime&&(this.increaseDate(),e=this.dayStartTime+(e-this.dayEndTime)),this.currentTime=e,this.currentTime}increaseDate(r=1,e=this.dayStartTime){let t=this.currentDate+r;return this.currentDate=t,this.currentTime=e,this.currentDate}nowIsBetween(r,e){r===void 0&&(r=this.dayStartTime-1),e===void 0&&(e=this.dayEndTime+1);let t=this.currentTime;return r<e?t>=r&&t<e:t>=r||t<e}};var Pe=new Q,De=new O,Ce=new M,we=new N;var Oe={...F,...ne,...ae,handlers:K,registries:qe__namespace},qr=Oe;Object.defineProperty(exports,"RegisteredActivities",{enumerable:true,get:function(){return qe.RegisteredActivities}});Object.defineProperty(exports,"RegisteredCommitments",{enumerable:true,get:function(){return qe.RegisteredCommitments}});Object.defineProperty(exports,"RegisteredLocations",{enumerable:true,get:function(){return qe.RegisteredLocations}});Object.defineProperty(exports,"RegisteredMaps",{enumerable:true,get:function(){return qe.RegisteredMaps}});Object.defineProperty(exports,"RegisteredQuests",{enumerable:true,get:function(){return qe.RegisteredQuests}});Object.defineProperty(exports,"RegisteredRooms",{enumerable:true,get:function(){return qe.RegisteredRooms}});exports.ActivityBaseModel=T;exports.ActivityStoredClass=f;exports.CommitmentBaseModel=E;exports.CommitmentStoredClass=h;exports.LocationBaseModel=P;exports.LocationStoredClass=S;exports.MapBaseModel=D;exports.MapStoredClass=y;exports.QuestBaseModel=w;exports.QuestStoredClass=I;exports.RoomBaseModel=C;exports.RoomStoredClass=v;exports.StageBaseModel=q;exports.StageStoredClass=_;exports.default=qr;Object.keys(handlers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return handlers[k]}})});
|
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,45 @@ import { OnRunProps as OnRunProps$1, ActivityInterface as ActivityInterface$1, C
|
|
|
5
5
|
import { StoredClassModel } from '@drincs/pixi-vn/storage';
|
|
6
6
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
7
7
|
|
|
8
|
+
interface DateSchedulingInterface {
|
|
9
|
+
/**
|
|
10
|
+
* The start date. If the item hasn't started yet, it will be hidden.
|
|
11
|
+
* If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
|
|
12
|
+
*/
|
|
13
|
+
from: number;
|
|
14
|
+
/**
|
|
15
|
+
* The date when the item ends. If the item is ended yet, it will be deleted or hidden.
|
|
16
|
+
* 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.
|
|
17
|
+
* @default undefined
|
|
18
|
+
*/
|
|
19
|
+
to?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TimeSchedulingInterface {
|
|
23
|
+
/**
|
|
24
|
+
* The time when the item starts. If the item is not started yet, it will be hidden.
|
|
25
|
+
* If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
|
|
26
|
+
*/
|
|
27
|
+
from: number;
|
|
28
|
+
/**
|
|
29
|
+
* The time when the item ends. If the item is ended yet, it will be hidden.
|
|
30
|
+
* If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
|
|
31
|
+
* @default timeTracker.dayEndTime + 1
|
|
32
|
+
*/
|
|
33
|
+
to?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface ActiveScheduling {
|
|
37
|
+
/**
|
|
38
|
+
* Time slot in which activity/commitment will be active.
|
|
39
|
+
*/
|
|
40
|
+
readonly timeSlot?: TimeSchedulingInterface[] | TimeSchedulingInterface;
|
|
41
|
+
/**
|
|
42
|
+
* Used to schedule what date it will be added and removed.
|
|
43
|
+
*/
|
|
44
|
+
readonly dateScheduling?: DateSchedulingInterface;
|
|
45
|
+
}
|
|
46
|
+
|
|
8
47
|
type ExecutionType = "automatic" | "interaction";
|
|
9
48
|
|
|
10
49
|
type OnRunProps = OnRunProps$1;
|
|
@@ -81,49 +120,13 @@ type TimeSettings = {
|
|
|
81
120
|
getDayName?: (weekDayNumber: number) => string;
|
|
82
121
|
};
|
|
83
122
|
|
|
84
|
-
interface DateSchedulingInterface {
|
|
85
|
-
/**
|
|
86
|
-
* The start date. If the item hasn't started yet, it will be hidden.
|
|
87
|
-
* If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
|
|
88
|
-
*/
|
|
89
|
-
from: number;
|
|
90
|
-
/**
|
|
91
|
-
* The date when the item ends. If the item is ended yet, it will be deleted or hidden.
|
|
92
|
-
* 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.
|
|
93
|
-
* @default undefined
|
|
94
|
-
*/
|
|
95
|
-
to?: number;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
interface TimeSchedulingInterface {
|
|
99
|
-
/**
|
|
100
|
-
* The time when the item starts. If the item is not started yet, it will be hidden.
|
|
101
|
-
* If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
|
|
102
|
-
*/
|
|
103
|
-
from: number;
|
|
104
|
-
/**
|
|
105
|
-
* The time when the item ends. If the item is ended yet, it will be hidden.
|
|
106
|
-
* If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
|
|
107
|
-
* @default timeTracker.dayEndTime + 1
|
|
108
|
-
*/
|
|
109
|
-
to?: number;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
123
|
interface ActivityInterface extends ActivityBaseInternalInterface, ActivityInterface$1 {
|
|
113
124
|
}
|
|
114
|
-
interface ActivityBaseInternalInterface {
|
|
125
|
+
interface ActivityBaseInternalInterface extends ActiveScheduling {
|
|
115
126
|
/**
|
|
116
127
|
* The id of the activity/commitment.
|
|
117
128
|
*/
|
|
118
129
|
readonly id: string;
|
|
119
|
-
/**
|
|
120
|
-
* Time slot in which activity/commitment will be active.
|
|
121
|
-
*/
|
|
122
|
-
readonly timeSlot: TimeSchedulingInterface | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* Used to schedule what date it will be added and removed.
|
|
125
|
-
*/
|
|
126
|
-
readonly dateScheduling: DateSchedulingInterface | undefined;
|
|
127
130
|
/**
|
|
128
131
|
* The function that is called when the activity/commitment is runned.
|
|
129
132
|
*/
|
|
@@ -135,9 +138,10 @@ interface ActivityBaseInternalInterface {
|
|
|
135
138
|
*/
|
|
136
139
|
readonly expired: boolean;
|
|
137
140
|
/**
|
|
138
|
-
* Whether the activity/commitment is active.
|
|
141
|
+
* Whether the activity/commitment is active, so it will be shown in the routine and can be runned.
|
|
142
|
+
* @param options The options to check if the activity/commitment is active.
|
|
139
143
|
*/
|
|
140
|
-
|
|
144
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
interface ActivityProps {
|
|
@@ -194,6 +198,11 @@ interface CommitmentBaseInternalInterface extends ActivityBaseInternalInterface
|
|
|
194
198
|
priority: number;
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
interface CommitmentInfo {
|
|
202
|
+
commitment: CommitmentInterface;
|
|
203
|
+
roomId: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
197
206
|
interface CommitmentProps {
|
|
198
207
|
/**
|
|
199
208
|
* The name
|
|
@@ -680,27 +689,19 @@ interface StageProps {
|
|
|
680
689
|
onEnd?: OnRunEvent<StageInterface>;
|
|
681
690
|
}
|
|
682
691
|
|
|
683
|
-
interface ActivityStoredClassProps {
|
|
684
|
-
/**
|
|
685
|
-
* Time slot in which activity/commitment will be active.
|
|
686
|
-
*/
|
|
687
|
-
timeSlot?: TimeSchedulingInterface;
|
|
688
|
-
/**
|
|
689
|
-
* Used to schedule what date it will be added and removed.
|
|
690
|
-
*/
|
|
691
|
-
dateScheduling?: DateSchedulingInterface;
|
|
692
|
+
interface ActivityStoredClassProps extends ActiveScheduling {
|
|
692
693
|
}
|
|
693
694
|
declare class ActivityStoredClass<OnRunEventType = ActivityInterface> extends StoredClassModel implements ActivityBaseInternalInterface {
|
|
694
695
|
private readonly _onRun;
|
|
695
696
|
constructor(id: string, _onRun: OnRunEvent<OnRunEventType>, props: ActivityStoredClassProps, category?: string);
|
|
696
697
|
private _timeSlot?;
|
|
697
|
-
get timeSlot(): TimeSchedulingInterface | undefined;
|
|
698
|
+
get timeSlot(): TimeSchedulingInterface[] | TimeSchedulingInterface | undefined;
|
|
698
699
|
private _dateScheduling?;
|
|
699
700
|
get dateScheduling(): DateSchedulingInterface | undefined;
|
|
700
701
|
protected addTempHistoryItem(): void;
|
|
701
702
|
get run(): OnRunAsyncFunction;
|
|
702
703
|
get expired(): boolean;
|
|
703
|
-
|
|
704
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
704
705
|
}
|
|
705
706
|
|
|
706
707
|
/**
|
|
@@ -860,11 +861,8 @@ declare abstract class NavigationAbstractClass extends StoredClassModel implemen
|
|
|
860
861
|
private get additionalActivitiesIds();
|
|
861
862
|
private get excludedActivitiesIds();
|
|
862
863
|
get activitiesIds(): string[];
|
|
863
|
-
addActivity(activity: ActivityInterface, options?:
|
|
864
|
-
|
|
865
|
-
dateScheduling?: DateSchedulingInterface;
|
|
866
|
-
}): void;
|
|
867
|
-
removeActivity(activity: ActivityInterface | string, options?: Pick<DateSchedulingInterface, "to">): void;
|
|
864
|
+
addActivity(activity: ActivityInterface, options?: ActiveScheduling): void;
|
|
865
|
+
removeActivity(activity: ActivityInterface | string): void;
|
|
868
866
|
clearExpiredActivities(): void;
|
|
869
867
|
get activities(): ActivityInterface[];
|
|
870
868
|
}
|
|
@@ -1406,4 +1404,4 @@ declare const nqtr: {
|
|
|
1406
1404
|
StageStoredClass: typeof StageStoredClass;
|
|
1407
1405
|
};
|
|
1408
1406
|
|
|
1409
|
-
export { ActivityBaseModel, type ActivityInterface, type ActivityProps, ActivityStoredClass, type ActivityStoredClassProps, CommitmentBaseModel, type CommitmentInterface, type CommitmentProps, CommitmentStoredClass, type CommitmentStoredClassProps, type DateSchedulingInterface, type ExecutionType, type TimeSlotInterface as ITimeStlot, LocationBaseModel, type LocationBaseModelProps, type LocationInterface, LocationStoredClass, MapBaseModel, type MapBaseModelProps, type MapInterface, MapStoredClass, type OnRunAsyncFunction, type OnRunEvent, type OnRunFunction, type OnRunProps, QuestBaseModel, type QuestInterface, type QuestProps, QuestStoredClass, type QuestStoredClassProps, type QuestsRequiredType, RoomBaseModel, type RoomBaseModelProps, type RoomInterface, RoomStoredClass, StageBaseModel, type StageInterface, type StageProps, StageStoredClass, type StageStoredClassProps, type TimeSchedulingInterface, type TimeSettings, nqtr as default };
|
|
1407
|
+
export { type ActiveScheduling, ActivityBaseModel, type ActivityInterface, type ActivityProps, ActivityStoredClass, type ActivityStoredClassProps, CommitmentBaseModel, type CommitmentInfo, type CommitmentInterface, type CommitmentProps, CommitmentStoredClass, type CommitmentStoredClassProps, type DateSchedulingInterface, type ExecutionType, type TimeSlotInterface as ITimeStlot, LocationBaseModel, type LocationBaseModelProps, type LocationInterface, LocationStoredClass, MapBaseModel, type MapBaseModelProps, type MapInterface, MapStoredClass, type OnRunAsyncFunction, type OnRunEvent, type OnRunFunction, type OnRunProps, QuestBaseModel, type QuestInterface, type QuestProps, QuestStoredClass, type QuestStoredClassProps, type QuestsRequiredType, RoomBaseModel, type RoomBaseModelProps, type RoomInterface, RoomStoredClass, StageBaseModel, type StageInterface, type StageProps, StageStoredClass, type StageStoredClassProps, type TimeSchedulingInterface, type TimeSettings, nqtr as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,45 @@ import { OnRunProps as OnRunProps$1, ActivityInterface as ActivityInterface$1, C
|
|
|
5
5
|
import { StoredClassModel } from '@drincs/pixi-vn/storage';
|
|
6
6
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
7
7
|
|
|
8
|
+
interface DateSchedulingInterface {
|
|
9
|
+
/**
|
|
10
|
+
* The start date. If the item hasn't started yet, it will be hidden.
|
|
11
|
+
* If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
|
|
12
|
+
*/
|
|
13
|
+
from: number;
|
|
14
|
+
/**
|
|
15
|
+
* The date when the item ends. If the item is ended yet, it will be deleted or hidden.
|
|
16
|
+
* 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.
|
|
17
|
+
* @default undefined
|
|
18
|
+
*/
|
|
19
|
+
to?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TimeSchedulingInterface {
|
|
23
|
+
/**
|
|
24
|
+
* The time when the item starts. If the item is not started yet, it will be hidden.
|
|
25
|
+
* If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
|
|
26
|
+
*/
|
|
27
|
+
from: number;
|
|
28
|
+
/**
|
|
29
|
+
* The time when the item ends. If the item is ended yet, it will be hidden.
|
|
30
|
+
* If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
|
|
31
|
+
* @default timeTracker.dayEndTime + 1
|
|
32
|
+
*/
|
|
33
|
+
to?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface ActiveScheduling {
|
|
37
|
+
/**
|
|
38
|
+
* Time slot in which activity/commitment will be active.
|
|
39
|
+
*/
|
|
40
|
+
readonly timeSlot?: TimeSchedulingInterface[] | TimeSchedulingInterface;
|
|
41
|
+
/**
|
|
42
|
+
* Used to schedule what date it will be added and removed.
|
|
43
|
+
*/
|
|
44
|
+
readonly dateScheduling?: DateSchedulingInterface;
|
|
45
|
+
}
|
|
46
|
+
|
|
8
47
|
type ExecutionType = "automatic" | "interaction";
|
|
9
48
|
|
|
10
49
|
type OnRunProps = OnRunProps$1;
|
|
@@ -81,49 +120,13 @@ type TimeSettings = {
|
|
|
81
120
|
getDayName?: (weekDayNumber: number) => string;
|
|
82
121
|
};
|
|
83
122
|
|
|
84
|
-
interface DateSchedulingInterface {
|
|
85
|
-
/**
|
|
86
|
-
* The start date. If the item hasn't started yet, it will be hidden.
|
|
87
|
-
* If you set it to 3, the item will be hidden on dates 1 and 2 and will be shown starting on date 3.
|
|
88
|
-
*/
|
|
89
|
-
from: number;
|
|
90
|
-
/**
|
|
91
|
-
* The date when the item ends. If the item is ended yet, it will be deleted or hidden.
|
|
92
|
-
* 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.
|
|
93
|
-
* @default undefined
|
|
94
|
-
*/
|
|
95
|
-
to?: number;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
interface TimeSchedulingInterface {
|
|
99
|
-
/**
|
|
100
|
-
* The time when the item starts. If the item is not started yet, it will be hidden.
|
|
101
|
-
* If you set 3, the item will be hidden into times 1 and 2, and will be shown from time 3.
|
|
102
|
-
*/
|
|
103
|
-
from: number;
|
|
104
|
-
/**
|
|
105
|
-
* The time when the item ends. If the item is ended yet, it will be hidden.
|
|
106
|
-
* If you set 3, the item will be shown into times 1 and 2 and will be hidden from time 3.
|
|
107
|
-
* @default timeTracker.dayEndTime + 1
|
|
108
|
-
*/
|
|
109
|
-
to?: number;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
123
|
interface ActivityInterface extends ActivityBaseInternalInterface, ActivityInterface$1 {
|
|
113
124
|
}
|
|
114
|
-
interface ActivityBaseInternalInterface {
|
|
125
|
+
interface ActivityBaseInternalInterface extends ActiveScheduling {
|
|
115
126
|
/**
|
|
116
127
|
* The id of the activity/commitment.
|
|
117
128
|
*/
|
|
118
129
|
readonly id: string;
|
|
119
|
-
/**
|
|
120
|
-
* Time slot in which activity/commitment will be active.
|
|
121
|
-
*/
|
|
122
|
-
readonly timeSlot: TimeSchedulingInterface | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* Used to schedule what date it will be added and removed.
|
|
125
|
-
*/
|
|
126
|
-
readonly dateScheduling: DateSchedulingInterface | undefined;
|
|
127
130
|
/**
|
|
128
131
|
* The function that is called when the activity/commitment is runned.
|
|
129
132
|
*/
|
|
@@ -135,9 +138,10 @@ interface ActivityBaseInternalInterface {
|
|
|
135
138
|
*/
|
|
136
139
|
readonly expired: boolean;
|
|
137
140
|
/**
|
|
138
|
-
* Whether the activity/commitment is active.
|
|
141
|
+
* Whether the activity/commitment is active, so it will be shown in the routine and can be runned.
|
|
142
|
+
* @param options The options to check if the activity/commitment is active.
|
|
139
143
|
*/
|
|
140
|
-
|
|
144
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
interface ActivityProps {
|
|
@@ -194,6 +198,11 @@ interface CommitmentBaseInternalInterface extends ActivityBaseInternalInterface
|
|
|
194
198
|
priority: number;
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
interface CommitmentInfo {
|
|
202
|
+
commitment: CommitmentInterface;
|
|
203
|
+
roomId: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
197
206
|
interface CommitmentProps {
|
|
198
207
|
/**
|
|
199
208
|
* The name
|
|
@@ -680,27 +689,19 @@ interface StageProps {
|
|
|
680
689
|
onEnd?: OnRunEvent<StageInterface>;
|
|
681
690
|
}
|
|
682
691
|
|
|
683
|
-
interface ActivityStoredClassProps {
|
|
684
|
-
/**
|
|
685
|
-
* Time slot in which activity/commitment will be active.
|
|
686
|
-
*/
|
|
687
|
-
timeSlot?: TimeSchedulingInterface;
|
|
688
|
-
/**
|
|
689
|
-
* Used to schedule what date it will be added and removed.
|
|
690
|
-
*/
|
|
691
|
-
dateScheduling?: DateSchedulingInterface;
|
|
692
|
+
interface ActivityStoredClassProps extends ActiveScheduling {
|
|
692
693
|
}
|
|
693
694
|
declare class ActivityStoredClass<OnRunEventType = ActivityInterface> extends StoredClassModel implements ActivityBaseInternalInterface {
|
|
694
695
|
private readonly _onRun;
|
|
695
696
|
constructor(id: string, _onRun: OnRunEvent<OnRunEventType>, props: ActivityStoredClassProps, category?: string);
|
|
696
697
|
private _timeSlot?;
|
|
697
|
-
get timeSlot(): TimeSchedulingInterface | undefined;
|
|
698
|
+
get timeSlot(): TimeSchedulingInterface[] | TimeSchedulingInterface | undefined;
|
|
698
699
|
private _dateScheduling?;
|
|
699
700
|
get dateScheduling(): DateSchedulingInterface | undefined;
|
|
700
701
|
protected addTempHistoryItem(): void;
|
|
701
702
|
get run(): OnRunAsyncFunction;
|
|
702
703
|
get expired(): boolean;
|
|
703
|
-
|
|
704
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
704
705
|
}
|
|
705
706
|
|
|
706
707
|
/**
|
|
@@ -860,11 +861,8 @@ declare abstract class NavigationAbstractClass extends StoredClassModel implemen
|
|
|
860
861
|
private get additionalActivitiesIds();
|
|
861
862
|
private get excludedActivitiesIds();
|
|
862
863
|
get activitiesIds(): string[];
|
|
863
|
-
addActivity(activity: ActivityInterface, options?:
|
|
864
|
-
|
|
865
|
-
dateScheduling?: DateSchedulingInterface;
|
|
866
|
-
}): void;
|
|
867
|
-
removeActivity(activity: ActivityInterface | string, options?: Pick<DateSchedulingInterface, "to">): void;
|
|
864
|
+
addActivity(activity: ActivityInterface, options?: ActiveScheduling): void;
|
|
865
|
+
removeActivity(activity: ActivityInterface | string): void;
|
|
868
866
|
clearExpiredActivities(): void;
|
|
869
867
|
get activities(): ActivityInterface[];
|
|
870
868
|
}
|
|
@@ -1406,4 +1404,4 @@ declare const nqtr: {
|
|
|
1406
1404
|
StageStoredClass: typeof StageStoredClass;
|
|
1407
1405
|
};
|
|
1408
1406
|
|
|
1409
|
-
export { ActivityBaseModel, type ActivityInterface, type ActivityProps, ActivityStoredClass, type ActivityStoredClassProps, CommitmentBaseModel, type CommitmentInterface, type CommitmentProps, CommitmentStoredClass, type CommitmentStoredClassProps, type DateSchedulingInterface, type ExecutionType, type TimeSlotInterface as ITimeStlot, LocationBaseModel, type LocationBaseModelProps, type LocationInterface, LocationStoredClass, MapBaseModel, type MapBaseModelProps, type MapInterface, MapStoredClass, type OnRunAsyncFunction, type OnRunEvent, type OnRunFunction, type OnRunProps, QuestBaseModel, type QuestInterface, type QuestProps, QuestStoredClass, type QuestStoredClassProps, type QuestsRequiredType, RoomBaseModel, type RoomBaseModelProps, type RoomInterface, RoomStoredClass, StageBaseModel, type StageInterface, type StageProps, StageStoredClass, type StageStoredClassProps, type TimeSchedulingInterface, type TimeSettings, nqtr as default };
|
|
1407
|
+
export { type ActiveScheduling, ActivityBaseModel, type ActivityInterface, type ActivityProps, ActivityStoredClass, type ActivityStoredClassProps, CommitmentBaseModel, type CommitmentInfo, type CommitmentInterface, type CommitmentProps, CommitmentStoredClass, type CommitmentStoredClassProps, type DateSchedulingInterface, type ExecutionType, type TimeSlotInterface as ITimeStlot, LocationBaseModel, type LocationBaseModelProps, type LocationInterface, LocationStoredClass, MapBaseModel, type MapBaseModelProps, type MapInterface, MapStoredClass, type OnRunAsyncFunction, type OnRunEvent, type OnRunFunction, type OnRunProps, QuestBaseModel, type QuestInterface, type QuestProps, QuestStoredClass, type QuestStoredClassProps, type QuestsRequiredType, RoomBaseModel, type RoomBaseModelProps, type RoomInterface, RoomStoredClass, StageBaseModel, type StageInterface, type StageProps, StageStoredClass, type StageStoredClassProps, type TimeSchedulingInterface, type TimeSettings, nqtr as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {timeTracker,navigator,routine}from'@drincs/nqtr/handlers';export*from'@drincs/nqtr/handlers';import*as Qe from'@drincs/nqtr/registries';import {RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,fixedCommitments,RegisteredCommitments,registeredCommitments,RegisteredActivities}from'@drincs/nqtr/registries';export{RegisteredActivities,RegisteredCommitments,RegisteredLocations,RegisteredMaps,RegisteredQuests,RegisteredRooms}from'@drincs/nqtr/registries';import {StoredClassModel,storage}from'@drincs/pixi-vn/storage';import {narration}from'@drincs/pixi-vn/narration';var V=Object.defineProperty;var me=(o,r,e)=>r in o?V(o,r,{enumerable:true,configurable:true,writable:true,value:e}):o[r]=e;var j=(o,r)=>{for(var e in r)V(o,e,{get:r[e],enumerable:true});};var a=(o,r,e)=>me(o,typeof r!="symbol"?r+"":r,e);var G={};j(G,{ActivityBaseModel:()=>b,ActivityStoredClass:()=>f,CommitmentBaseModel:()=>P,CommitmentStoredClass:()=>S,LocationBaseModel:()=>D,LocationStoredClass:()=>v,MapBaseModel:()=>C,MapStoredClass:()=>I,QuestBaseModel:()=>q,QuestStoredClass:()=>x,RoomBaseModel:()=>w,RoomStoredClass:()=>_,StageBaseModel:()=>O,StageStoredClass:()=>R});var pe="__nqtr-activity__",f=class extends StoredClassModel{constructor(e,t,i,n=pe){super(n,e);this._onRun=t;a(this,"_timeSlot");a(this,"_dateScheduling");this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}get timeSlot(){return this._timeSlot}get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.addCurrentStepToHistory();}get run(){return async e=>(this.addTempHistoryItem(),await this._onRun(this,e))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=timeTracker.currentDate)}get isActive(){return !(this.dateScheduling?.from&&this.dateScheduling.from>timeTracker.currentDate||this.dateScheduling?.to&&this.dateScheduling.to<timeTracker.currentDate||!timeTracker.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to))}};var b=class extends f{constructor(e,t,i){super(e,t,{dateScheduling:i.dateScheduling,timeSlot:i.timeSlot});a(this,"defaultName");a(this,"defaultDisabled");a(this,"defaultHidden");a(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.renderIcon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var l="___nqtr-time_manager_data___",h="___nqtr-current_room_memory___",F="___nqtr-last_event_memory___";function A(o){storage.set(F,o);}function Z(){return storage.get(F)}var Se="__nqtr-commitment__",S=class extends f{constructor(e,t,i,n,s){n=n||(()=>{});super(e,n,s,Se);this._characters=t;this._room=i;a(this,"defaultExecutionType");a(this,"defaultPriority");this.defaultExecutionType=s.executionType||"interaction",this.defaultPriority=s.priority;}get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=Z();switch(t?.type){case "editroom":storage.set(h,t.prev),super.addTempHistoryItem(),storage.set(h,e.id);break;case "edittime":let i=storage.get(l)||{};storage.set(l,t.prev),super.addTempHistoryItem(),storage.set(l,i);break}}};var P=class extends S{constructor(e,t,i,n){super(e,t?Array.isArray(t)?t:[t]:[],i,n.onRun,{executionType:n.executionType,priority:n.priority,timeSlot:n.timeSlot,dateScheduling:n.dateScheduling});a(this,"_name");a(this,"_image");a(this,"_icon");a(this,"defaultDisabled");a(this,"defaultHidden");this._name=n.name||"",this._image=n.image,this.defaultDisabled=n.disabled||false,this.defaultHidden=n.hidden||false,this._icon=n.icon;}get name(){return this._name}get image(){return this._image}get icon(){return this._icon}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){if(this.dateScheduling?.from&&this.dateScheduling.from>timeTracker.currentDate||!timeTracker.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var g=class extends StoredClassModel{constructor(e,t,i=[]){super(e,t);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(e=>e.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let i=this.excludedActivitiesScheduling;delete i[e],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.activeActivityScheduling;i[e]=t,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.excludedActivitiesScheduling;i[e]=t,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let{timeSlot:i,dateScheduling:n}=t,{to:s=timeTracker.dayEndTime+1}=i||{};if(i&&i.from>=s)throw new Error("[NQTR] The from time must be less than the to time.");if(n?.from!==void 0&&n?.to!==void 0&&n?.from>=n?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(e.id)){console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`);return}let d=this.additionalActivitiesIds;d.includes(e.id)?console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`):(d.push(e.id),this.setStorageProperty("additionalActivitiesIds",d)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),console.log(`[NQTR] Activity with id ${e.id} was excluded, so it will be associated with this class again.`)),(i||n)&&this.editActivityScheduling(e.id,{timeSlot:i,dateScheduling:n});}removeActivity(e,t={}){let{to:i}=t,n=typeof e=="string"?e:e.id,s=this.additionalActivitiesIds;if(s.includes(n)){if(i!==void 0){this.editExcludedActivityScheduling(n,{dateScheduling:{to:i}});return}s=s.filter(d=>d!==n),this.setStorageProperty("additionalActivitiesIds",s),this.removeActivityScheduling(n);}else if(this.defaultActivitiesIds.includes(n)){if(i!==void 0){this.editExcludedActivityScheduling(n,{dateScheduling:{to:i}});return}let d=this.excludedActivitiesIds;d.push(n),this.setStorageProperty("excludedActivitiesIds",d);}else console.warn(`[NQTR] Activity with id ${n} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,n=this.excludedActivitiesIds;i.forEach(s=>{if(s in e){let{to:d}=e[s].dateScheduling||{};d&&d<timeTracker.currentDate&&(this.removeActivityScheduling(s),i=i.filter(p=>p!==s));}}),n.forEach(s=>{if(s in t){let{to:d}=t[s].dateScheduling||{};d&&d<timeTracker.currentDate&&(this.removeActivityScheduling(s),n=n.filter(p=>p!==s));}});}get activities(){let e=[],t=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(i=>{let n=RegisteredActivities.get(i),{dateScheduling:s,timeSlot:d}=t[i]||{},{from:p=n?.dateScheduling?.from,to:W=n?.dateScheduling?.to}=s||{},{from:ce=n?.timeSlot?.from,to:le=n?.timeSlot?.to}=d||{};n&&timeTracker.nowIsBetween(ce,le)&&!(p&&p>timeTracker.currentDate)&&!(W&&W<timeTracker.currentDate)&&e.push(n);}),Object.entries(this.excludedActivitiesScheduling).forEach(([i,n])=>{let s=RegisteredActivities.get(i);s&&s.isActive&&!(n.dateScheduling&&n.dateScheduling.to!==void 0&&n.dateScheduling.to>=timeTracker.currentDate)&&e.push(s);}),this.defaultActivities.forEach(i=>{i.isActive&&!e.find(n=>n.id===i.id)&&e.push(i);}),e}};var Ie="__nqtr-location__",v=class extends g{constructor(e,t,i=[]){super(Ie,e,i);this._map=t;}get map(){return this._map}get rooms(){return navigator.rooms.filter(e=>e.location.id===this.id)}};var D=class extends v{constructor(e,t,i={}){super(e,t,i.activities||[]);a(this,"defaultName");a(this,"defaultDisabled");a(this,"defaultHidden");a(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var xe="__nqtr-map__",I=class extends g{constructor(r,e=[]){super(xe,r,e);}get locations(){return navigator.locations.filter(r=>r.map.id===this.id)}};var C=class extends I{constructor(e,t={}){super(e,t.activities||[]);a(this,"defaultName");a(this,"_image");this.defaultName=t.name||"",this._image=t.image;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}};var Te="__nqtr-room__",_=class extends g{constructor(e,t,i=[]){super(Te,e,i);this._location=t;}get routine(){return routine.currentRoutine.filter(e=>e.room.id===this.id)}get location(){return this._location}get characters(){let e=[];return this.routine.forEach(t=>{e.push(...t.characters);}),e}get automaticFunctions(){return this.routine.filter(e=>e.executionType==="automatic"&&e.run).map(e=>async i=>{await e.run(i);})}};var w=class extends _{constructor(e,t,i={}){super(e,t,i.activities||[]);a(this,"defaultName");a(this,"_image");a(this,"defaultDisabled");a(this,"defaultHidden");a(this,"_icon");this.defaultName=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var c;(i=>(i.log=(n,...s)=>console.log(`[NQTR] ${n}`,...s),i.warn=(n,...s)=>console.warn(`[NQTR] ${n}`,...s),i.error=(n,...s)=>console.error(`[NQTR] ${n}`,...s),i.info=(n,...s)=>console.info(`[NQTR] ${n}`,...s)))(c||(c={}));var Ae="__nqtr-quest__",x=class extends StoredClassModel{constructor(e,t,i={}){super(Ae,e);this._stages=t;a(this,"_onStart");a(this,"_onNextStage");this._onStart=i.onStart,this._onNextStage=i.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===void 0||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}get onStart(){return this._onStart}get onNextStage(){return this._onNextStage}async start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){c.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&await this.onStart(this,e),await t.start(e);c.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(e){return await this.advanceIfCompleted(e)}async advanceIfCompleted(e){if(!this.inProgress)return false;let t=this.currentStage;return t?t.completed?await this.advanceUnconditionally(e):false:(c.error(`Quest ${this.id} has no current stage`),false)}async goNext(e){return await this.continue(e)}async continue(e){let t=this.currentStage;return t?(t.completed=true,await this.advanceUnconditionally(e)):(c.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(e){return await this.advanceUnconditionally(e)}async advanceUnconditionally(e){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===void 0)return c.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&await this.onNextStage(this,e),t&&t.onEnd&&await t.onEnd(t,e);let n=this.currentStage;return n&&(n.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}async startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?await t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var q=class extends x{constructor(e,t,i){super(e,t,{onStart:i.onStart,onNextStage:i.onNextStage});a(this,"_name");a(this,"_description");a(this,"_icon");a(this,"_image");a(this,"_inDevelopment");this._name=i.name||"",this._description=i.description||"",this._icon=i.icon,this._image=i.image,this._inDevelopment=i.inDevelopment||false;}get name(){return this._name}get description(){return this._description}get icon(){return this._icon}get image(){return this._image}get inDevelopment(){return this._inDevelopment}};var Pe="__nqtr-stage__",R=class extends StoredClassModel{constructor(e,t={}){super(Pe,e);a(this,"_onStart");a(this,"_onEnd");a(this,"_deltaDateRequired");a(this,"_questsRequired");this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}get onStart(){return this._onStart}get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}get deltaDateRequired(){return this._deltaDateRequired||0}get questsRequired(){return this._questsRequired||[]}};var O=class extends R{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired});a(this,"_name");a(this,"_description");a(this,"_adviceDescription");a(this,"_image");a(this,"_flags");a(this,"_flagsRequired");a(this,"_requestDescriptionToStart");this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}get name(){return this._name}get description(){return this._description}get adviceDescription(){return this._adviceDescription}get image(){return this._image}get flags(){return this._flags}get flagsRequired(){return this._flagsRequired}get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.getFlag(e.flag))?false:super.canStart}};var oe={};var de={};var U={};j(U,{navigator:()=>Oe,questsNotebook:()=>Me,routine:()=>Ne,timeTracker:()=>qe});var N=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(h)}get currentRoom(){let r=this.currentRoomId;if(!r){c.error("The current room has not yet been set");return}let e=RegisteredRooms.get(r);if(!e){c.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!RegisteredRooms.get(r)){c.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.get(h);t!==r&&(A({type:"editroom",prev:t,value:r}),storage.set(h,r));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(r=>{r.clearExpiredActivities();});}};var M=class{get quests(){return RegisteredQuests.values()}get startedQuests(){return this.quests.filter(r=>r.started)}get inProgressQuests(){return this.quests.filter(r=>r.inProgress)}get completedQuests(){return this.quests.filter(r=>r.completed)}get failedQuests(){return this.quests.filter(r=>r.failed)}get notStartedQuests(){return this.quests.filter(r=>!r.started)}find(r){return RegisteredQuests.get(r)}async startsStageMustBeStarted(r){let e=this.quests.map(t=>t.currentStageMustStart?t.startCurrentStage(r):Promise.resolve());await Promise.all(e);}};var z="___nqtr-temporary_commitment___",Q=class{get fixedRoutine(){return [...fixedCommitments.values()]}set fixedRoutine(r){r.forEach(e=>{fixedCommitments.has(e.id)&&console.warn(`[NQTR] Commitment id ${e.id} already exists, it will be overwritten`),fixedCommitments.set(e.id,e);});}get temporaryRoutine(){let r=storage.get(z);return r?r.map(t=>RegisteredCommitments.get(t)).filter(t=>t!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(r){Array.isArray(r)||(r=[r]);let e=r.map(t=>{if(!RegisteredCommitments.get(t.id)){console.warn(`[NQTR] Commitment ${t.id} not found, it will be ignored`);return}return t.id}).filter(t=>t!==void 0);storage.set(z,e);}find(r){return RegisteredCommitments.get(r)}remove(r){Array.isArray(r)||(r=[r]);let e=r.map(i=>i.id),t=storage.get(z);t&&(t=t.filter(i=>!e.includes(i)),storage.set(z,t));}clearExpiredRoutine(){RegisteredCommitments.values().forEach(r=>{r.expired&®isteredCommitments.delete(r.id);});}get currentRoutine(){let r={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(e=>{e.isActive&&(e.characters.length>0?e.characters.every(i=>!r[i.id]||e.priority>r[i.id].priority)&&e.characters.forEach(i=>{r[i.id]=e;}):c.error(`The commitment ${e.id} has no characters assigned`));}),Object.values(r)}getCommitmentByCharacter(r){this.currentRoutine.forEach(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e});}};var m=class m{};a(m,"dayStartTime",0),a(m,"dayEndTime",24),a(m,"defaultTimeSpent",1),a(m,"timeSlots",[]),a(m,"weekLength",7),a(m,"weekendStartDay",m.weekLength-1),a(m,"getDayName");var u=m;var L=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:n=[],weekLength:s=7,weekendStartDay:d=s-1,getDayName:p}=r;u.dayStartTime=e,u.dayEndTime=t,u.defaultTimeSpent=i,u.timeSlots=n,u.weekLength=s,d>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):u.weekendStartDay=d,u.getDayName=p;}get dayStartTime(){return u.dayStartTime}get dayEndTime(){return u.dayEndTime}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get getDayName(){return u.getDayName}get currentTime(){let r=storage.get(l)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.get(l)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,A({type:"edittime",prev:e,value:t}),storage.set(l,t);}get currentDate(){let r=storage.get(l)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.get(l)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,A({type:"edittime",prev:e,value:t}),storage.set(l,t);}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 r=0;r<this.timeSlots.length;r++){let e=this.timeSlots[r];if(this.timeSlots.length>r+1&&this.nowIsBetween(e.startTime,this.timeSlots[r+1].startTime))return r}return this.timeSlots.length-1}increaseTime(r=this.defaultTimeSpent){let e=this.currentTime+r;return e>=this.dayEndTime&&(this.increaseDate(),e=this.dayStartTime+(e-this.dayEndTime)),this.currentTime=e,this.currentTime}increaseDate(r=1,e=this.dayStartTime){let t=this.currentDate+r;return this.currentDate=t,this.currentTime=e,this.currentDate}nowIsBetween(r,e){r===void 0&&(r=this.dayStartTime-1),e===void 0&&(e=this.dayEndTime+1);let t=this.currentTime;return r<e?t>=r&&t<e:t>=r||t<e}};var qe=new L,Oe=new N,Ne=new Q,Me=new M;var Le={...G,...oe,...de,handlers:U,registries:Qe},Lr=Le;export{b as ActivityBaseModel,f as ActivityStoredClass,P as CommitmentBaseModel,S as CommitmentStoredClass,D as LocationBaseModel,v as LocationStoredClass,C as MapBaseModel,I as MapStoredClass,q as QuestBaseModel,x as QuestStoredClass,w as RoomBaseModel,_ as RoomStoredClass,O as StageBaseModel,R as StageStoredClass,Lr as default};
|
|
1
|
+
import {timeTracker,navigator,routine}from'@drincs/nqtr/handlers';export*from'@drincs/nqtr/handlers';import*as qe from'@drincs/nqtr/registries';import {RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,fixedCommitments,RegisteredCommitments,registeredCommitments,RegisteredActivities}from'@drincs/nqtr/registries';export{RegisteredActivities,RegisteredCommitments,RegisteredLocations,RegisteredMaps,RegisteredQuests,RegisteredRooms}from'@drincs/nqtr/registries';import {StoredClassModel,storage}from'@drincs/pixi-vn/storage';import {narration}from'@drincs/pixi-vn/narration';var U=Object.defineProperty;var oe=(s,r,e)=>r in s?U(s,r,{enumerable:true,configurable:true,writable:true,value:e}):s[r]=e;var W=(s,r)=>{for(var e in r)U(s,e,{get:r[e],enumerable:true});};var n=(s,r,e)=>oe(s,typeof r!="symbol"?r+"":r,e);var F={};W(F,{ActivityBaseModel:()=>T,ActivityStoredClass:()=>f,CommitmentBaseModel:()=>E,CommitmentStoredClass:()=>h,LocationBaseModel:()=>P,LocationStoredClass:()=>S,MapBaseModel:()=>D,MapStoredClass:()=>y,QuestBaseModel:()=>w,QuestStoredClass:()=>I,RoomBaseModel:()=>C,RoomStoredClass:()=>v,StageBaseModel:()=>q,StageStoredClass:()=>_});var ce="__nqtr-activity__",f=class extends StoredClassModel{constructor(e,t,i,a=ce){super(a,e);this._onRun=t;n(this,"_timeSlot");n(this,"_dateScheduling");this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}get timeSlot(){return this._timeSlot}get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.addCurrentStepToHistory();}get run(){return async e=>(this.addTempHistoryItem(),await this._onRun(this,e))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=timeTracker.currentDate)}isActive(e={}){let{timeSlot:t=this.timeSlot,dateScheduling:i=this.dateScheduling}=e;if(i?.from!=null&&i.from>timeTracker.currentDate||i?.to!=null&&i.to<timeTracker.currentDate)return false;t&&!Array.isArray(t)&&(t=[t]);for(let a of t||[])if(!timeTracker.nowIsBetween(a?.from,a?.to))return false;return true}};var T=class extends f{constructor(e,t,i){super(e,t,{dateScheduling:i.dateScheduling,timeSlot:i.timeSlot});n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.renderIcon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var l="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",z="___nqtr-last_event_memory___";function b(s){storage.set(z,s);}function J(){return storage.get(z)}var me="__nqtr-commitment__",h=class extends f{constructor(e,t,i,a,o){a=a||(()=>{});super(e,a,o,me);this._characters=t;this._room=i;n(this,"defaultExecutionType");n(this,"defaultPriority");this.defaultExecutionType=o.executionType||"interaction",this.defaultPriority=o.priority;}get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=J();switch(t?.type){case "editroom":storage.set(p,t.prev),super.addTempHistoryItem(),storage.set(p,e.id);break;case "edittime":let i=storage.get(l)||{};storage.set(l,t.prev),super.addTempHistoryItem(),storage.set(l,i);break}}};var E=class extends h{constructor(e,t,i,a){super(e,t?Array.isArray(t)?t:[t]:[],i,a.onRun,{executionType:a.executionType,priority:a.priority,timeSlot:a.timeSlot,dateScheduling:a.dateScheduling});n(this,"_name");n(this,"_image");n(this,"_icon");n(this,"defaultDisabled");n(this,"defaultHidden");this._name=a.name||"",this._image=a.image,this.defaultDisabled=a.disabled||false,this.defaultHidden=a.hidden||false,this._icon=a.icon;}get name(){return this._name}get image(){return this._image}get icon(){return this._icon}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var g=class extends StoredClassModel{constructor(e,t,i=[]){super(e,t);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(e=>e.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let i=this.excludedActivitiesScheduling;delete i[e],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.activeActivityScheduling;i[e]=t,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.excludedActivitiesScheduling;i[e]=t,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:R=timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=R)throw new Error("[NQTR] The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(e.id)){console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`);return}let o=this.additionalActivitiesIds;o.includes(e.id)?console.warn(`[NQTR] Activity with id ${e.id} already exists, so it will be ignored.`):(o.push(e.id),this.setStorageProperty("additionalActivitiesIds",o)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),console.log(`[NQTR] Activity with id ${e.id} was excluded, so it will be associated with this class again.`)),(i||a)&&this.editActivityScheduling(e.id,{timeSlot:i,dateScheduling:a});}removeActivity(e){let t=typeof e=="string"?e:e.id,i=this.additionalActivitiesIds;if(i.includes(t))i=i.filter(a=>a!==t),this.setStorageProperty("additionalActivitiesIds",i),this.removeActivityScheduling(t);else if(this.defaultActivitiesIds.includes(t)){let a=this.excludedActivitiesIds;a.push(t),this.setStorageProperty("excludedActivitiesIds",a);}else console.warn(`[NQTR] Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,a=this.excludedActivitiesIds;i.forEach(o=>{if(o in e){let{to:c}=e[o].dateScheduling||{};c&&c<timeTracker.currentDate&&(this.removeActivityScheduling(o),i=i.filter(R=>R!==o));}}),a.forEach(o=>{o in t&&t[o]&&(this.removeActivityScheduling(o),a=a.filter(c=>c!==o));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let i=RegisteredActivities.get(t);return i&&i.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(i),e},[])}};var he="__nqtr-location__",S=class extends g{constructor(e,t,i=[]){super(he,e,i);this._map=t;}get map(){return this._map}get rooms(){return navigator.rooms.filter(e=>e.location.id===this.id)}};var P=class extends S{constructor(e,t,i={}){super(e,t,i.activities||[]);n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var ye="__nqtr-map__",y=class extends g{constructor(r,e=[]){super(ye,r,e);}get locations(){return navigator.locations.filter(r=>r.map.id===this.id)}};var D=class extends y{constructor(e,t={}){super(e,t.activities||[]);n(this,"defaultName");n(this,"_image");this.defaultName=t.name||"",this._image=t.image;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}};var Ie="__nqtr-room__",v=class extends g{constructor(e,t,i=[]){super(Ie,e,i);this._location=t;}get routine(){return routine.currentRoutine.filter(e=>e.room.id===this.id)}get location(){return this._location}get characters(){let e=[];return this.routine.forEach(t=>{e.push(...t.characters);}),e}get automaticFunctions(){return this.routine.filter(e=>e.executionType==="automatic"&&e.run).map(e=>async i=>{await e.run(i);})}};var C=class extends v{constructor(e,t,i={}){super(e,t,i.activities||[]);n(this,"defaultName");n(this,"_image");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var u;(i=>(i.log=(a,...o)=>console.log(`[NQTR] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[NQTR] ${a}`,...o),i.error=(a,...o)=>console.error(`[NQTR] ${a}`,...o),i.info=(a,...o)=>console.info(`[NQTR] ${a}`,...o)))(u||(u={}));var xe="__nqtr-quest__",I=class extends StoredClassModel{constructor(e,t,i={}){super(xe,e);this._stages=t;n(this,"_onStart");n(this,"_onNextStage");this._onStart=i.onStart,this._onNextStage=i.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===void 0||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}get onStart(){return this._onStart}get onNextStage(){return this._onNextStage}async start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){u.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&await this.onStart(this,e),await t.start(e);u.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(e){return await this.advanceIfCompleted(e)}async advanceIfCompleted(e){if(!this.inProgress)return false;let t=this.currentStage;return t?t.completed?await this.advanceUnconditionally(e):false:(u.error(`Quest ${this.id} has no current stage`),false)}async goNext(e){return await this.continue(e)}async continue(e){let t=this.currentStage;return t?(t.completed=true,await this.advanceUnconditionally(e)):(u.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(e){return await this.advanceUnconditionally(e)}async advanceUnconditionally(e){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===void 0)return u.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&await this.onNextStage(this,e),t&&t.onEnd&&await t.onEnd(t,e);let a=this.currentStage;return a&&(a.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}async startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?await t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var w=class extends I{constructor(e,t,i){super(e,t,{onStart:i.onStart,onNextStage:i.onNextStage});n(this,"_name");n(this,"_description");n(this,"_icon");n(this,"_image");n(this,"_inDevelopment");this._name=i.name||"",this._description=i.description||"",this._icon=i.icon,this._image=i.image,this._inDevelopment=i.inDevelopment||false;}get name(){return this._name}get description(){return this._description}get icon(){return this._icon}get image(){return this._image}get inDevelopment(){return this._inDevelopment}};var Te="__nqtr-stage__",_=class extends StoredClassModel{constructor(e,t={}){super(Te,e);n(this,"_onStart");n(this,"_onEnd");n(this,"_deltaDateRequired");n(this,"_questsRequired");this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}get onStart(){return this._onStart}get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}get deltaDateRequired(){return this._deltaDateRequired||0}get questsRequired(){return this._questsRequired||[]}};var q=class extends _{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired});n(this,"_name");n(this,"_description");n(this,"_adviceDescription");n(this,"_image");n(this,"_flags");n(this,"_flagsRequired");n(this,"_requestDescriptionToStart");this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}get name(){return this._name}get description(){return this._description}get adviceDescription(){return this._adviceDescription}get image(){return this._image}get flags(){return this._flags}get flagsRequired(){return this._flagsRequired}get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.getFlag(e.flag))?false:super.canStart}};var ne={};var ae={};var K={};W(K,{navigator:()=>De,questsNotebook:()=>we,routine:()=>Ce,timeTracker:()=>Pe});var O=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(p)}get currentRoom(){let r=this.currentRoomId;if(!r){u.error("The current room has not yet been set");return}let e=RegisteredRooms.get(r);if(!e){u.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!RegisteredRooms.get(r)){u.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.get(p);t!==r&&(b({type:"editroom",prev:t,value:r}),storage.set(p,r));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(r=>{r.clearExpiredActivities();});}};var N=class{get quests(){return RegisteredQuests.values()}get startedQuests(){return this.quests.filter(r=>r.started)}get inProgressQuests(){return this.quests.filter(r=>r.inProgress)}get completedQuests(){return this.quests.filter(r=>r.completed)}get failedQuests(){return this.quests.filter(r=>r.failed)}get notStartedQuests(){return this.quests.filter(r=>!r.started)}find(r){return RegisteredQuests.get(r)}async startsStageMustBeStarted(r){let e=this.quests.map(t=>t.currentStageMustStart?t.startCurrentStage(r):Promise.resolve());await Promise.all(e);}};var $="___nqtr-temporary_commitment___",M=class{get fixedRoutine(){return [...fixedCommitments.values()]}set fixedRoutine(r){r.forEach(e=>{fixedCommitments.has(e.id)&&console.warn(`[NQTR] Commitment id ${e.id} already exists, it will be overwritten`),fixedCommitments.set(e.id,e);});}get temporaryRoutine(){let r=storage.get($);return r?r.map(t=>RegisteredCommitments.get(t)).filter(t=>t!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(r){Array.isArray(r)||(r=[r]);let e=r.map(t=>{if(!RegisteredCommitments.get(t.id)){console.warn(`[NQTR] Commitment ${t.id} not found, it will be ignored`);return}return t.id}).filter(t=>t!==void 0);storage.set($,e);}find(r){return RegisteredCommitments.get(r)}remove(r){Array.isArray(r)||(r=[r]);let e=r.map(i=>i.id),t=storage.get($);t&&(t=t.filter(i=>!e.includes(i)),storage.set($,t));}clearExpiredRoutine(){RegisteredCommitments.values().forEach(r=>{r.expired&®isteredCommitments.delete(r.id);});}get currentRoutine(){let r={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(e=>{e.isActive()&&(e.characters.length>0?e.characters.every(i=>!r[i.id]||e.priority>r[i.id].priority)&&e.characters.forEach(i=>{r[i.id]=e;}):u.error(`The commitment ${e.id} has no characters assigned`));}),Object.values(r)}getCommitmentByCharacter(r){this.currentRoutine.forEach(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e});}};var m=class m{};n(m,"dayStartTime",0),n(m,"dayEndTime",24),n(m,"defaultTimeSpent",1),n(m,"timeSlots",[]),n(m,"weekLength",7),n(m,"weekendStartDay",m.weekLength-1),n(m,"getDayName");var d=m;var Q=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:o=7,weekendStartDay:c=o-1,getDayName:R}=r;d.dayStartTime=e,d.dayEndTime=t,d.defaultTimeSpent=i,d.timeSlots=a,d.weekLength=o,c>=d.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${o}, so will be ignored`):d.weekendStartDay=c,d.getDayName=R;}get dayStartTime(){return d.dayStartTime}get dayEndTime(){return d.dayEndTime}get defaultTimeSpent(){return d.defaultTimeSpent}get timeSlots(){return d.timeSlots}get weekLength(){return d.weekLength}get weekendStartDay(){return d.weekendStartDay}get getDayName(){return d.getDayName}get currentTime(){let r=storage.get(l)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.get(l)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,b({type:"edittime",prev:e,value:t}),storage.set(l,t);}get currentDate(){let r=storage.get(l)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.get(l)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,b({type:"edittime",prev:e,value:t}),storage.set(l,t);}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 r=0;r<this.timeSlots.length;r++){let e=this.timeSlots[r];if(this.timeSlots.length>r+1&&this.nowIsBetween(e.startTime,this.timeSlots[r+1].startTime))return r}return this.timeSlots.length-1}increaseTime(r=this.defaultTimeSpent){let e=this.currentTime+r;return e>=this.dayEndTime&&(this.increaseDate(),e=this.dayStartTime+(e-this.dayEndTime)),this.currentTime=e,this.currentTime}increaseDate(r=1,e=this.dayStartTime){let t=this.currentDate+r;return this.currentDate=t,this.currentTime=e,this.currentDate}nowIsBetween(r,e){r===void 0&&(r=this.dayStartTime-1),e===void 0&&(e=this.dayEndTime+1);let t=this.currentTime;return r<e?t>=r&&t<e:t>=r||t<e}};var Pe=new Q,De=new O,Ce=new M,we=new N;var Oe={...F,...ne,...ae,handlers:K,registries:qe},qr=Oe;export{T as ActivityBaseModel,f as ActivityStoredClass,E as CommitmentBaseModel,h as CommitmentStoredClass,P as LocationBaseModel,S as LocationStoredClass,D as MapBaseModel,y as MapStoredClass,w as QuestBaseModel,I as QuestStoredClass,C as RoomBaseModel,v as RoomStoredClass,q as StageBaseModel,_ as StageStoredClass,qr as default};
|
package/dist/registries.d.mts
CHANGED
|
@@ -2,20 +2,6 @@ import { OnRunProps as OnRunProps$1, ActivityInterface as ActivityInterface$1, C
|
|
|
2
2
|
import { CharacterInterface, CachedMap } from '@drincs/pixi-vn';
|
|
3
3
|
import { StoredClassModel } from '@drincs/pixi-vn/storage';
|
|
4
4
|
|
|
5
|
-
type ExecutionType = "automatic" | "interaction";
|
|
6
|
-
|
|
7
|
-
type OnRunProps = OnRunProps$1;
|
|
8
|
-
/**
|
|
9
|
-
* The function that is called when the class is runned.
|
|
10
|
-
*/
|
|
11
|
-
type OnRunEvent<T> = (item: T, props: OnRunProps) => any | Promise<any>;
|
|
12
|
-
type OnRunAsyncFunction = (props: OnRunProps) => Promise<any>;
|
|
13
|
-
|
|
14
|
-
type QuestsRequiredType = {
|
|
15
|
-
quest: QuestInterface;
|
|
16
|
-
stageNumber: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
5
|
interface DateSchedulingInterface {
|
|
20
6
|
/**
|
|
21
7
|
* The start date. If the item hasn't started yet, it will be hidden.
|
|
@@ -44,21 +30,38 @@ interface TimeSchedulingInterface {
|
|
|
44
30
|
to?: number;
|
|
45
31
|
}
|
|
46
32
|
|
|
47
|
-
interface
|
|
48
|
-
}
|
|
49
|
-
interface ActivityBaseInternalInterface {
|
|
50
|
-
/**
|
|
51
|
-
* The id of the activity/commitment.
|
|
52
|
-
*/
|
|
53
|
-
readonly id: string;
|
|
33
|
+
interface ActiveScheduling {
|
|
54
34
|
/**
|
|
55
35
|
* Time slot in which activity/commitment will be active.
|
|
56
36
|
*/
|
|
57
|
-
readonly timeSlot
|
|
37
|
+
readonly timeSlot?: TimeSchedulingInterface[] | TimeSchedulingInterface;
|
|
58
38
|
/**
|
|
59
39
|
* Used to schedule what date it will be added and removed.
|
|
60
40
|
*/
|
|
61
|
-
readonly dateScheduling
|
|
41
|
+
readonly dateScheduling?: DateSchedulingInterface;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type ExecutionType = "automatic" | "interaction";
|
|
45
|
+
|
|
46
|
+
type OnRunProps = OnRunProps$1;
|
|
47
|
+
/**
|
|
48
|
+
* The function that is called when the class is runned.
|
|
49
|
+
*/
|
|
50
|
+
type OnRunEvent<T> = (item: T, props: OnRunProps) => any | Promise<any>;
|
|
51
|
+
type OnRunAsyncFunction = (props: OnRunProps) => Promise<any>;
|
|
52
|
+
|
|
53
|
+
type QuestsRequiredType = {
|
|
54
|
+
quest: QuestInterface;
|
|
55
|
+
stageNumber: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface ActivityInterface extends ActivityBaseInternalInterface, ActivityInterface$1 {
|
|
59
|
+
}
|
|
60
|
+
interface ActivityBaseInternalInterface extends ActiveScheduling {
|
|
61
|
+
/**
|
|
62
|
+
* The id of the activity/commitment.
|
|
63
|
+
*/
|
|
64
|
+
readonly id: string;
|
|
62
65
|
/**
|
|
63
66
|
* The function that is called when the activity/commitment is runned.
|
|
64
67
|
*/
|
|
@@ -70,9 +73,10 @@ interface ActivityBaseInternalInterface {
|
|
|
70
73
|
*/
|
|
71
74
|
readonly expired: boolean;
|
|
72
75
|
/**
|
|
73
|
-
* Whether the activity/commitment is active.
|
|
76
|
+
* Whether the activity/commitment is active, so it will be shown in the routine and can be runned.
|
|
77
|
+
* @param options The options to check if the activity/commitment is active.
|
|
74
78
|
*/
|
|
75
|
-
|
|
79
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
interface CommitmentInterface extends CommitmentBaseInternalInterface, CommitmentInterface$1 {
|
package/dist/registries.d.ts
CHANGED
|
@@ -2,20 +2,6 @@ import { OnRunProps as OnRunProps$1, ActivityInterface as ActivityInterface$1, C
|
|
|
2
2
|
import { CharacterInterface, CachedMap } from '@drincs/pixi-vn';
|
|
3
3
|
import { StoredClassModel } from '@drincs/pixi-vn/storage';
|
|
4
4
|
|
|
5
|
-
type ExecutionType = "automatic" | "interaction";
|
|
6
|
-
|
|
7
|
-
type OnRunProps = OnRunProps$1;
|
|
8
|
-
/**
|
|
9
|
-
* The function that is called when the class is runned.
|
|
10
|
-
*/
|
|
11
|
-
type OnRunEvent<T> = (item: T, props: OnRunProps) => any | Promise<any>;
|
|
12
|
-
type OnRunAsyncFunction = (props: OnRunProps) => Promise<any>;
|
|
13
|
-
|
|
14
|
-
type QuestsRequiredType = {
|
|
15
|
-
quest: QuestInterface;
|
|
16
|
-
stageNumber: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
5
|
interface DateSchedulingInterface {
|
|
20
6
|
/**
|
|
21
7
|
* The start date. If the item hasn't started yet, it will be hidden.
|
|
@@ -44,21 +30,38 @@ interface TimeSchedulingInterface {
|
|
|
44
30
|
to?: number;
|
|
45
31
|
}
|
|
46
32
|
|
|
47
|
-
interface
|
|
48
|
-
}
|
|
49
|
-
interface ActivityBaseInternalInterface {
|
|
50
|
-
/**
|
|
51
|
-
* The id of the activity/commitment.
|
|
52
|
-
*/
|
|
53
|
-
readonly id: string;
|
|
33
|
+
interface ActiveScheduling {
|
|
54
34
|
/**
|
|
55
35
|
* Time slot in which activity/commitment will be active.
|
|
56
36
|
*/
|
|
57
|
-
readonly timeSlot
|
|
37
|
+
readonly timeSlot?: TimeSchedulingInterface[] | TimeSchedulingInterface;
|
|
58
38
|
/**
|
|
59
39
|
* Used to schedule what date it will be added and removed.
|
|
60
40
|
*/
|
|
61
|
-
readonly dateScheduling
|
|
41
|
+
readonly dateScheduling?: DateSchedulingInterface;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type ExecutionType = "automatic" | "interaction";
|
|
45
|
+
|
|
46
|
+
type OnRunProps = OnRunProps$1;
|
|
47
|
+
/**
|
|
48
|
+
* The function that is called when the class is runned.
|
|
49
|
+
*/
|
|
50
|
+
type OnRunEvent<T> = (item: T, props: OnRunProps) => any | Promise<any>;
|
|
51
|
+
type OnRunAsyncFunction = (props: OnRunProps) => Promise<any>;
|
|
52
|
+
|
|
53
|
+
type QuestsRequiredType = {
|
|
54
|
+
quest: QuestInterface;
|
|
55
|
+
stageNumber: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface ActivityInterface extends ActivityBaseInternalInterface, ActivityInterface$1 {
|
|
59
|
+
}
|
|
60
|
+
interface ActivityBaseInternalInterface extends ActiveScheduling {
|
|
61
|
+
/**
|
|
62
|
+
* The id of the activity/commitment.
|
|
63
|
+
*/
|
|
64
|
+
readonly id: string;
|
|
62
65
|
/**
|
|
63
66
|
* The function that is called when the activity/commitment is runned.
|
|
64
67
|
*/
|
|
@@ -70,9 +73,10 @@ interface ActivityBaseInternalInterface {
|
|
|
70
73
|
*/
|
|
71
74
|
readonly expired: boolean;
|
|
72
75
|
/**
|
|
73
|
-
* Whether the activity/commitment is active.
|
|
76
|
+
* Whether the activity/commitment is active, so it will be shown in the routine and can be runned.
|
|
77
|
+
* @param options The options to check if the activity/commitment is active.
|
|
74
78
|
*/
|
|
75
|
-
|
|
79
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
interface CommitmentInterface extends CommitmentBaseInternalInterface, CommitmentInterface$1 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/nqtr",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "A complete system introducing the concepts of location, time and event, producing the framework of a not-quite-point-and-click adventure game.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|