@drincs/nqtr 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/handlers.cjs +1 -1
- package/dist/handlers.d.mts +71 -64
- package/dist/handlers.d.ts +71 -64
- package/dist/handlers.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +98 -90
- package/dist/index.d.ts +98 -90
- package/dist/index.mjs +1 -1
- package/dist/ink.cjs +1 -1
- package/dist/ink.mjs +1 -1
- package/dist/registries.cjs +1 -1
- package/dist/registries.d.mts +45 -41
- package/dist/registries.d.ts +45 -41
- package/dist/registries.mjs +1 -1
- package/package.json +10 -3
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 {
|
|
@@ -178,10 +182,6 @@ interface CommitmentBaseInternalInterface extends ActivityBaseInternalInterface
|
|
|
178
182
|
* The character or characters that are in the commitment and so in the room.
|
|
179
183
|
*/
|
|
180
184
|
readonly characters: CharacterInterface[];
|
|
181
|
-
/**
|
|
182
|
-
* The room where the commitment is.
|
|
183
|
-
*/
|
|
184
|
-
readonly room: RoomInterface;
|
|
185
185
|
/**
|
|
186
186
|
* Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
|
|
187
187
|
* If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
|
|
@@ -194,6 +194,11 @@ interface CommitmentBaseInternalInterface extends ActivityBaseInternalInterface
|
|
|
194
194
|
priority: number;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
interface CommitmentInfo {
|
|
198
|
+
commitment: CommitmentInterface;
|
|
199
|
+
roomId: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
197
202
|
interface CommitmentProps {
|
|
198
203
|
/**
|
|
199
204
|
* The name
|
|
@@ -283,22 +288,13 @@ interface NavigationAbstractInterface extends StoredClassModel {
|
|
|
283
288
|
* @param options
|
|
284
289
|
* @returns
|
|
285
290
|
*/
|
|
286
|
-
addActivity(activity: ActivityInterface, options?:
|
|
287
|
-
/**
|
|
288
|
-
* Time slot in which activity will be active.
|
|
289
|
-
*/
|
|
290
|
-
timeSlot?: TimeSchedulingInterface;
|
|
291
|
-
/**
|
|
292
|
-
* Used to schedule what date it will be added and removed.
|
|
293
|
-
*/
|
|
294
|
-
dateScheduling?: DateSchedulingInterface;
|
|
295
|
-
}): void;
|
|
291
|
+
addActivity(activity: ActivityInterface, options?: ActiveScheduling): void;
|
|
296
292
|
/**
|
|
297
293
|
* Disconnects the activity from the class.
|
|
298
294
|
* @param activity The activity to disconnect from the class.
|
|
299
295
|
* @param options
|
|
300
296
|
*/
|
|
301
|
-
removeActivity(activity: ActivityInterface | string
|
|
297
|
+
removeActivity(activity: ActivityInterface | string): void;
|
|
302
298
|
/**
|
|
303
299
|
* Removes the useless activities.
|
|
304
300
|
*/
|
|
@@ -379,6 +375,11 @@ interface RoomBaseModelProps {
|
|
|
379
375
|
* @default []
|
|
380
376
|
*/
|
|
381
377
|
activities?: ActivityInterface[];
|
|
378
|
+
/**
|
|
379
|
+
* The routine of the room, it is an array of commitments that are executed in the room. You can also add commitments during the game session, but this property is useful to set the initial routine of the room.
|
|
380
|
+
* @default undefined
|
|
381
|
+
*/
|
|
382
|
+
routine?: CommitmentInterface[];
|
|
382
383
|
/**
|
|
383
384
|
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
384
385
|
* @default false
|
|
@@ -407,6 +408,19 @@ interface RoomBaseInternalInterface extends NavigationAbstractInterface {
|
|
|
407
408
|
* The location where the room is.
|
|
408
409
|
*/
|
|
409
410
|
readonly location: LocationInterface;
|
|
411
|
+
/**
|
|
412
|
+
* Connects the commitment to the class.
|
|
413
|
+
* @param commitment The commitment to connect to the class.
|
|
414
|
+
* @param options
|
|
415
|
+
* @returns
|
|
416
|
+
*/
|
|
417
|
+
addCommitment(commitment: CommitmentInterface, options?: ActiveScheduling): void;
|
|
418
|
+
/**
|
|
419
|
+
* Disconnects the commitment from the class.
|
|
420
|
+
* @param commitment The commitment to disconnect from the class.
|
|
421
|
+
* @param options
|
|
422
|
+
*/
|
|
423
|
+
removeCommitment(commitment: CommitmentInterface | string): void;
|
|
410
424
|
/**
|
|
411
425
|
* Get the character commitments of the room.
|
|
412
426
|
*/
|
|
@@ -680,27 +694,19 @@ interface StageProps {
|
|
|
680
694
|
onEnd?: OnRunEvent<StageInterface>;
|
|
681
695
|
}
|
|
682
696
|
|
|
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;
|
|
697
|
+
interface ActivityStoredClassProps extends ActiveScheduling {
|
|
692
698
|
}
|
|
693
699
|
declare class ActivityStoredClass<OnRunEventType = ActivityInterface> extends StoredClassModel implements ActivityBaseInternalInterface {
|
|
694
700
|
private readonly _onRun;
|
|
695
701
|
constructor(id: string, _onRun: OnRunEvent<OnRunEventType>, props: ActivityStoredClassProps, category?: string);
|
|
696
702
|
private _timeSlot?;
|
|
697
|
-
get timeSlot(): TimeSchedulingInterface | undefined;
|
|
703
|
+
get timeSlot(): TimeSchedulingInterface[] | TimeSchedulingInterface | undefined;
|
|
698
704
|
private _dateScheduling?;
|
|
699
705
|
get dateScheduling(): DateSchedulingInterface | undefined;
|
|
700
706
|
protected addTempHistoryItem(): void;
|
|
701
707
|
get run(): OnRunAsyncFunction;
|
|
702
708
|
get expired(): boolean;
|
|
703
|
-
|
|
709
|
+
isActive(options?: ActiveScheduling): boolean;
|
|
704
710
|
}
|
|
705
711
|
|
|
706
712
|
/**
|
|
@@ -782,12 +788,10 @@ interface CommitmentStoredClassProps {
|
|
|
782
788
|
}
|
|
783
789
|
declare class CommitmentStoredClass extends ActivityStoredClass<CommitmentInterface> implements CommitmentBaseInternalInterface {
|
|
784
790
|
private readonly _characters;
|
|
785
|
-
|
|
786
|
-
constructor(id: string, _characters: CharacterInterface[], _room: RoomInterface, onRun: OnRunEvent<CommitmentInterface> | undefined, props: CommitmentStoredClassProps);
|
|
791
|
+
constructor(id: string, _characters: CharacterInterface[], onRun: OnRunEvent<CommitmentInterface> | undefined, props: CommitmentStoredClassProps);
|
|
787
792
|
private readonly defaultExecutionType;
|
|
788
793
|
private readonly defaultPriority?;
|
|
789
794
|
get characters(): CharacterInterface[];
|
|
790
|
-
get room(): RoomInterface;
|
|
791
795
|
get executionType(): ExecutionType;
|
|
792
796
|
set executionType(value: ExecutionType);
|
|
793
797
|
get priority(): number;
|
|
@@ -797,10 +801,10 @@ declare class CommitmentStoredClass extends ActivityStoredClass<CommitmentInterf
|
|
|
797
801
|
|
|
798
802
|
/**
|
|
799
803
|
* The base model of a commitment. I suggest you extend this class to create your own commitment model.
|
|
800
|
-
* You must use the
|
|
804
|
+
* You must use the saveCommitment function to save the commitment in the registered commitments.
|
|
801
805
|
* @example
|
|
802
806
|
* ```ts
|
|
803
|
-
* export const
|
|
807
|
+
* export const miaPlay = new CommitmentBaseModel("mia_play", mia, {
|
|
804
808
|
* name: "Test",
|
|
805
809
|
* image: "https://image.jpg",
|
|
806
810
|
* executionType: ExecutionTypeEnum.INTERACTION,
|
|
@@ -808,17 +812,16 @@ declare class CommitmentStoredClass extends ActivityStoredClass<CommitmentInterf
|
|
|
808
812
|
* // Do something
|
|
809
813
|
* }
|
|
810
814
|
* })
|
|
811
|
-
* saveCommitment(
|
|
815
|
+
* saveCommitment(miaPlay)
|
|
812
816
|
* ```
|
|
813
817
|
*/
|
|
814
818
|
declare class CommitmentBaseModel extends CommitmentStoredClass {
|
|
815
819
|
/**
|
|
816
820
|
* @param id The id of the commitment, it must be unique.
|
|
817
821
|
* @param character The character or characters that are in the commitment and so in the room.
|
|
818
|
-
* @param room The room where the commitment is.
|
|
819
822
|
* @param props The properties of the commitment.
|
|
820
823
|
*/
|
|
821
|
-
constructor(id: string, character: CharacterInterface | CharacterInterface[] | undefined,
|
|
824
|
+
constructor(id: string, character: CharacterInterface | CharacterInterface[] | undefined, props: CommitmentProps);
|
|
822
825
|
private _name;
|
|
823
826
|
/**
|
|
824
827
|
* The name of the commitment.
|
|
@@ -860,11 +863,8 @@ declare abstract class NavigationAbstractClass extends StoredClassModel implemen
|
|
|
860
863
|
private get additionalActivitiesIds();
|
|
861
864
|
private get excludedActivitiesIds();
|
|
862
865
|
get activitiesIds(): string[];
|
|
863
|
-
addActivity(activity: ActivityInterface, options?:
|
|
864
|
-
|
|
865
|
-
dateScheduling?: DateSchedulingInterface;
|
|
866
|
-
}): void;
|
|
867
|
-
removeActivity(activity: ActivityInterface | string, options?: Pick<DateSchedulingInterface, "to">): void;
|
|
866
|
+
addActivity(activity: ActivityInterface, options?: ActiveScheduling): void;
|
|
867
|
+
removeActivity(activity: ActivityInterface | string): void;
|
|
868
868
|
clearExpiredActivities(): void;
|
|
869
869
|
get activities(): ActivityInterface[];
|
|
870
870
|
}
|
|
@@ -970,8 +970,13 @@ declare class RoomStoredClass extends NavigationAbstractClass implements RoomBas
|
|
|
970
970
|
/**
|
|
971
971
|
* The location where the room is.
|
|
972
972
|
*/
|
|
973
|
-
_location: LocationInterface, activities?: ActivityInterface[]
|
|
973
|
+
_location: LocationInterface, activities?: ActivityInterface[] | {
|
|
974
|
+
activities: ActivityInterface[];
|
|
975
|
+
routine: CommitmentInterface[];
|
|
976
|
+
});
|
|
974
977
|
get routine(): CommitmentInterface[];
|
|
978
|
+
addCommitment(commitment: CommitmentInterface, options?: ActiveScheduling): void;
|
|
979
|
+
removeCommitment(commitment: CommitmentInterface | string): void;
|
|
975
980
|
get location(): LocationInterface;
|
|
976
981
|
get characters(): CharacterInterface[];
|
|
977
982
|
get automaticFunctions(): OnRunAsyncFunction[];
|
|
@@ -1240,22 +1245,18 @@ declare class QuestHandler {
|
|
|
1240
1245
|
}
|
|
1241
1246
|
|
|
1242
1247
|
declare class RoutineHandler {
|
|
1243
|
-
get fixedRoutine(): CommitmentInterface[];
|
|
1244
|
-
/**
|
|
1245
|
-
* Set a commitment as fixed, it will be always available. They cannot be deleted or edit during the game session.
|
|
1246
|
-
*/
|
|
1247
|
-
set fixedRoutine(commitments: CommitmentInterface[]);
|
|
1248
1248
|
/**
|
|
1249
1249
|
* Get the temporary commitments by its id.
|
|
1250
1250
|
* @returns The temporary commitments.
|
|
1251
1251
|
*/
|
|
1252
|
-
get temporaryRoutine()
|
|
1253
|
-
get
|
|
1252
|
+
private get temporaryRoutine();
|
|
1253
|
+
get commitmentsIds(): string[];
|
|
1254
1254
|
/**
|
|
1255
1255
|
* This feature adds the commitments during the game session.
|
|
1256
1256
|
* @param commitment The commitment or commitments to add.
|
|
1257
|
+
* @param roomId The id of the room where the commitment is.
|
|
1257
1258
|
*/
|
|
1258
|
-
add(commitment: CommitmentInterface[] | CommitmentInterface): void;
|
|
1259
|
+
add(commitment: CommitmentInterface[] | CommitmentInterface, roomId: string, options?: ActiveScheduling): void;
|
|
1259
1260
|
/**
|
|
1260
1261
|
* Get the commitments added during the game session.
|
|
1261
1262
|
* @param id The id of the commitment.
|
|
@@ -1264,13 +1265,17 @@ declare class RoutineHandler {
|
|
|
1264
1265
|
find(id: string): CommitmentInterface | undefined;
|
|
1265
1266
|
/**
|
|
1266
1267
|
* Remove the commitments added during the game session.
|
|
1267
|
-
* @param commitment The commitment or
|
|
1268
|
+
* @param commitment The commitment or commitment id to remove.
|
|
1269
|
+
* @param roomId The id of the room where the commitment is.
|
|
1268
1270
|
*/
|
|
1269
|
-
remove(commitment: CommitmentInterface
|
|
1271
|
+
remove(commitment: CommitmentInterface | string, roomId?: string): void;
|
|
1270
1272
|
/**
|
|
1271
1273
|
* Clear all the expired commitments.
|
|
1272
1274
|
*/
|
|
1273
1275
|
clearExpiredRoutine(): void;
|
|
1276
|
+
get characterCommitments(): {
|
|
1277
|
+
[character: string]: [CommitmentInterface, string];
|
|
1278
|
+
};
|
|
1274
1279
|
/**
|
|
1275
1280
|
* Get the current commitments. The hidden commitments are not included.
|
|
1276
1281
|
* In case there is a character who has two or more commitments at the same time, will be selected the commitment with the highest priority.
|
|
@@ -1281,6 +1286,9 @@ declare class RoutineHandler {
|
|
|
1281
1286
|
* @returns The current commitments.
|
|
1282
1287
|
*/
|
|
1283
1288
|
get currentRoutine(): CommitmentInterface[];
|
|
1289
|
+
get roomCommitments(): {
|
|
1290
|
+
[roomId: string]: CommitmentInterface[];
|
|
1291
|
+
};
|
|
1284
1292
|
/**
|
|
1285
1293
|
* Get the character commitment.
|
|
1286
1294
|
* @param character The character.
|
|
@@ -1406,4 +1414,4 @@ declare const nqtr: {
|
|
|
1406
1414
|
StageStoredClass: typeof StageStoredClass;
|
|
1407
1415
|
};
|
|
1408
1416
|
|
|
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 };
|
|
1417
|
+
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 {fixedCommitments,RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,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';import {PixiError}from'@drincs/pixi-vn/core';var U=Object.defineProperty;var me=(o,r,e)=>r in o?U(o,r,{enumerable:true,configurable:true,writable:true,value:e}):o[r]=e;var W=(o,r)=>{for(var e in r)U(o,e,{get:r[e],enumerable:true});};var n=(o,r,e)=>me(o,typeof r!="symbol"?r+"":r,e);var F={};W(F,{ActivityBaseModel:()=>b,ActivityStoredClass:()=>g,CommitmentBaseModel:()=>P,CommitmentStoredClass:()=>y,LocationBaseModel:()=>E,LocationStoredClass:()=>S,MapBaseModel:()=>C,MapStoredClass:()=>v,QuestBaseModel:()=>w,QuestStoredClass:()=>_,RoomBaseModel:()=>D,RoomStoredClass:()=>I,StageBaseModel:()=>O,StageStoredClass:()=>x});var ge="__nqtr-activity__",g=class extends StoredClassModel{constructor(e,t,i,a=ge){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 b=class extends g{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 m="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",Y="___nqtr-last_event_memory___";function R(o){storage.set(Y,o);}function J(){return storage.get(Y)}var pe="__nqtr-commitment__",y=class extends g{constructor(e,t,i,a){i=i||(()=>{});super(e,i,a,pe);this._characters=t;n(this,"defaultExecutionType");n(this,"defaultPriority");this.defaultExecutionType=a.executionType||"interaction",this.defaultPriority=a.priority;}get characters(){return this._characters}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(m)||{};storage.set(m,t.prev),super.addTempHistoryItem(),storage.set(m,i);break}}};var P=class extends y{constructor(e,t,i){super(e,t?Array.isArray(t)?t:[t]:[],i.onRun,{executionType:i.executionType,priority:i.priority,timeSlot:i.timeSlot,dateScheduling:i.dateScheduling});n(this,"_name");n(this,"_image");n(this,"_icon");n(this,"defaultDisabled");n(this,"defaultHidden");this._name=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.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 d;(i=>(i.log=(a,...s)=>console.log(`[NQTR] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[NQTR] ${a}`,...s),i.error=(a,...s)=>console.error(`[NQTR] ${a}`,...s),i.info=(a,...s)=>console.info(`[NQTR] ${a}`,...s)))(d||(d={}));var h=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:l=timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=l)throw d.error("The from time must be less than the to time."),new PixiError("invalid_usage","The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw d.error("The from day/date must be less than the to day/date."),new PixiError("invalid_usage","The from day/date must be less than the to day/date.");let s=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(e.id)||s.includes(e.id)?d.info(`Activity with id ${e.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(s.push(e.id),this.setStorageProperty("additionalActivitiesIds",s)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),d.log(`Activity with id ${e.id} was excluded from the ${this.id}, but now it will be added again with the new scheduling options. So it will be removed from the excluded activities list.`)),(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);else if(this.defaultActivitiesIds.includes(t)){let a=this.excludedActivitiesIds;a.push(t),this.setStorageProperty("excludedActivitiesIds",a);}else d.warn(`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(s=>{if(s in e){let{to:c}=e[s].dateScheduling||{};c&&c<timeTracker.currentDate&&(this.removeActivityScheduling(s),i=i.filter(l=>l!==s));}}),a.forEach(s=>{s in t&&t[s]&&(this.removeActivityScheduling(s),a=a.filter(c=>c!==s));});}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 Ie="__nqtr-location__",S=class extends h{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 E=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 xe="__nqtr-map__",v=class extends h{constructor(r,e=[]){super(xe,r,e);}get locations(){return navigator.locations.filter(r=>r.map.id===this.id)}};var C=class extends v{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__",I=class extends h{constructor(e,t,i=[]){var r=(...Nt)=>(super(...Nt),this._location=t,this);Array.isArray(i)?r(ie,e,i):(r(ie,e,i.activities),i.routine.forEach(a=>fixedCommitments.set(a.id,[a,e])));}get routine(){return routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(s=>{let{to:c=timeTracker.dayEndTime+1}=s||{};if(s&&s.from>=c)throw d.error("The from time must be less than the to time."),new PixiError("invalid_usage","The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw d.error("The from day/date must be less than the to day/date."),new PixiError("invalid_usage","The from day/date must be less than the to day/date.");routine.add(e,this.id,{timeSlot:i,dateScheduling:a});}removeCommitment(e){routine.remove(e,this.id);}get location(){return this._location}get characters(){return this.routine.reduce((e,t)=>(e.push(...t.characters),e),[])}get automaticFunctions(){return this.routine.reduce((e,t)=>{if(t.executionType==="automatic"&&t.run){let i=async a=>{await t.run(a);};e.push(i);}return e},[])}};var D=class extends I{constructor(e,t,i={}){super(e,t,{activities:i.activities||[],routine:i.routine||[]});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 Ae="__nqtr-quest__",_=class extends StoredClassModel{constructor(e,t,i={}){super(Ae,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){d.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);d.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:(d.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)):(d.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 d.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 _{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 Ee="__nqtr-stage__",x=class extends StoredClassModel{constructor(e,t={}){super(Ee,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 O=class extends x{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 oe={};var de={};var K={};W(K,{navigator:()=>qe,questsNotebook:()=>Ne,routine:()=>Me,timeTracker:()=>Oe});var q=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){d.error("The current room has not yet been set");return}let e=RegisteredRooms.get(r);if(!e){d.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!RegisteredRooms.get(r)){d.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.get(p);t!==r&&(R({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 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 H="___nqtr-temporary_commitment___",Q=class{get temporaryRoutine(){let r=storage.get(H);if(r){if(Array.isArray(r))throw new PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.")}else return {};return r}get commitmentsIds(){return [...fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(r,e,t={}){Array.isArray(r)||(r=[r]);let i=this.temporaryRoutine;r.forEach(a=>{RegisteredCommitments.get(a.id)&&d.warn(`The commitment ${a.id} is already registered, it will be overwritten`),RegisteredCommitments.add(a),i[a.id]={id:a.id,roomId:e,...t};}),storage.set(H,i);}find(r){return RegisteredCommitments.get(r)}remove(r,e){typeof r!="string"&&(r=r.id);let t=this.temporaryRoutine;t[r]?(!e||t[r].roomId===e)&&delete t[r]:d.warn(`The commitment ${r} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.set(H,t);}clearExpiredRoutine(){RegisteredCommitments.values().forEach(r=>{r.expired&&this.remove(r);});}get characterCommitments(){let r=this.temporaryRoutine;return this.commitmentsIds.reduce((e,t)=>{let i=RegisteredCommitments.get(t),a=r[t],s=a?.roomId||fixedCommitments.get(t)?.[1];return s&&i&&i.isActive(a)&&(i.characters.length>0?i.characters.every(l=>!e[l.id]||i.priority>e[l.id][0].priority)&&i.characters.forEach(l=>{e[l.id]=[i,s];}):d.error(`The commitment ${i.id} has no characters assigned`)),e},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([r])=>r)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((r,e)=>{let t=e[1];return r[t]||(r[t]=[]),r[t].push(e[0]),r},{})}getCommitmentByCharacter(r){return this.currentRoutine.find(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e})}};var f=class f{};n(f,"dayStartTime",0),n(f,"dayEndTime",24),n(f,"defaultTimeSpent",1),n(f,"timeSlots",[]),n(f,"weekLength",7),n(f,"weekendStartDay",f.weekLength-1),n(f,"getDayName");var u=f;var L=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:s=7,weekendStartDay:c=s-1,getDayName:l}=r;u.dayStartTime=e,u.dayEndTime=t,u.defaultTimeSpent=i,u.timeSlots=a,u.weekLength=s,c>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):u.weekendStartDay=c,u.getDayName=l;}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(m)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.get(m)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,R({type:"edittime",prev:e,value:t}),storage.set(m,t);}get currentDate(){let r=storage.get(m)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.get(m)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,R({type:"edittime",prev:e,value:t}),storage.set(m,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 Oe=new L,qe=new q,Me=new Q,Ne=new M;var Le={...F,...oe,...de,handlers:K,registries:Qe},zr=Le;export{b as ActivityBaseModel,g as ActivityStoredClass,P as CommitmentBaseModel,y as CommitmentStoredClass,E as LocationBaseModel,S as LocationStoredClass,C as MapBaseModel,v as MapStoredClass,w as QuestBaseModel,_ as QuestStoredClass,D as RoomBaseModel,I as RoomStoredClass,O as StageBaseModel,x as StageStoredClass,zr as default};
|
package/dist/ink.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var handlers=require('@drincs/nqtr/handlers'),registries=require('@drincs/nqtr/registries');var
|
|
1
|
+
'use strict';var handlers=require('@drincs/nqtr/handlers'),registries=require('@drincs/nqtr/registries'),pixiVnInk=require('@drincs/pixi-vn-ink');var o;(e=>(e.log=(a,...n)=>console.log(`[NQTR] ${a}`,...n),e.warn=(a,...n)=>console.warn(`[NQTR] ${a}`,...n),e.error=(a,...n)=>console.error(`[NQTR] ${a}`,...n),e.info=(a,...n)=>console.info(`[NQTR] ${a}`,...n)))(o||(o={}));function k(i){i||(i={hours:handlers.timeTracker.defaultTimeSpent}),typeof i=="number"&&(i={hours:i});let{hours:u,days:f}=i;f&&handlers.timeTracker.increaseDate(f,handlers.timeTracker.dayStartTime),u&&handlers.timeTracker.increaseTime(u);}var b=(i={})=>{pixiVnInk.VariableGetter.add((e,a)=>{if(e&&typeof e=="object"&&"type"in e&&"key"in e&&"storageOperationType"in e&&"storageType"in e&&e.storageOperationType==="get"&&(e.storageType==="storage"||e.storageType==="tempstorage"||e.storageType==="flagStorage")){let n=e;if(n.key.endsWith("_currentStageIndex")){let t=n.key.replace("_currentStageIndex",""),r=registries.RegisteredQuests.get(t);return r?r.currentStageIndex:(o.warn(`Quest ${t} not found`),a(e))}else if(n.key.endsWith("_started")){let t=n.key.replace("_started",""),r=registries.RegisteredQuests.get(t);return r?r.started:(o.warn(`Quest ${t} not found`),a(e))}else if(n.key.endsWith("_completed")){let t=n.key.replace("_completed",""),r=registries.RegisteredQuests.get(t);return r?r.completed:(o.warn(`Quest ${t} not found`),a(e))}else if(n.key.endsWith("_failed")){let t=n.key.replace("_failed",""),r=registries.RegisteredQuests.get(t);return r?r.failed:(o.warn(`Quest ${t} not found`),a(e))}}return a(e)});let{timeConverter:u=e=>Number(e.replace(":",".")),dateConverter:f=e=>Number(e),wait:l=k}=i;return (e,a,n)=>{switch(e[1]){case "room":switch(e[0]){case "enter":if(e.length>2){let t=registries.RegisteredRooms.get(e[2]);return t?handlers.navigator.currentRoom=t:o.warn(`Room ${e[2]} not found`),true}break}break;case "time":switch(e[0]){case "set":if(e.length>2){let t=u(e[2]);return isNaN(t)?o.warn(`Invalid time format: ${e[2]}`):handlers.timeTracker.currentTime=t,true}break}break;case "date":switch(e[0]){case "set":if(e.length>2){let t=f(e[2]);return isNaN(t)?o.warn(`Invalid date format: ${e[2]}`):handlers.timeTracker.currentDate=t,true}break}break;case "activity":switch(e[0]){case "add":if(e.length==5){let t=registries.RegisteredActivities.get(e[2]);if(!t)return o.warn(`Activity ${e[2]} not found`),true;let{in:r}=n(e.slice(3)),s=registries.RegisteredRooms.get(r);return s?s.addActivity(t):o.warn(`Room ${r} not found`),true}case "remove":if(e.length==5){let t=registries.RegisteredActivities.get(e[2]);if(!t)return o.warn(`Activity ${e[2]} not found`),true;let{from:r}=n(e.slice(3)),s=registries.RegisteredRooms.get(r);return s?s.removeActivity(t):o.warn(`Room ${r} not found`),true}}break;case "routine":switch(e[0]){case "add":if(e.length==5){let t=registries.RegisteredCommitments.get(e[2]);if(!t)return o.warn(`Commitment ${e[2]} not found`),true;let{in:r}=n(e.slice(3)),s=registries.RegisteredRooms.get(r);return s?s.addCommitment(t):o.warn(`Room ${r} not found`),true}case "remove":if(e.length==3){let t=registries.RegisteredCommitments.get(e[2]);return t?(handlers.routine.remove(t),true):(o.warn(`Commitment ${e[2]} not found`),true)}}break;case "quest":switch(e[0]){case "start":if(e.length==3){let t=registries.RegisteredQuests.get(e[2]);return t?(t.start(a),true):(o.warn(`Quest ${e[2]} not found`),true)}case "continue":if(e.length==3){let t=registries.RegisteredQuests.get(e[2]);return t?(t.continue(a),true):(o.warn(`Quest ${e[2]} not found`),true)}}break}switch(e[0]){case "wait":if(e.length==1)return l(),true;if(e.length==2){let t=u(e[1]);return isNaN(t)?o.warn(`Invalid time format: ${e[1]}`):l(t),true}else if(e.length>2){let t=n(e.slice(1));return t.hours!==void 0&&typeof t.hours=="string"&&(t.hours=u(t.hours)),t.days!==void 0&&typeof t.days=="string"&&(t.days=f(t.days)),l(t),true}break}return false}};exports.nqtrHandler=b;
|
package/dist/ink.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {routine,timeTracker,navigator}from'@drincs/nqtr/handlers';import {RegisteredQuests,RegisteredCommitments,RegisteredActivities
|
|
1
|
+
import {routine,timeTracker,navigator}from'@drincs/nqtr/handlers';import {RegisteredQuests,RegisteredCommitments,RegisteredRooms,RegisteredActivities}from'@drincs/nqtr/registries';import {VariableGetter}from'@drincs/pixi-vn-ink';var o;(e=>(e.log=(a,...n)=>console.log(`[NQTR] ${a}`,...n),e.warn=(a,...n)=>console.warn(`[NQTR] ${a}`,...n),e.error=(a,...n)=>console.error(`[NQTR] ${a}`,...n),e.info=(a,...n)=>console.info(`[NQTR] ${a}`,...n)))(o||(o={}));function k(i){i||(i={hours:timeTracker.defaultTimeSpent}),typeof i=="number"&&(i={hours:i});let{hours:u,days:f}=i;f&&timeTracker.increaseDate(f,timeTracker.dayStartTime),u&&timeTracker.increaseTime(u);}var b=(i={})=>{VariableGetter.add((e,a)=>{if(e&&typeof e=="object"&&"type"in e&&"key"in e&&"storageOperationType"in e&&"storageType"in e&&e.storageOperationType==="get"&&(e.storageType==="storage"||e.storageType==="tempstorage"||e.storageType==="flagStorage")){let n=e;if(n.key.endsWith("_currentStageIndex")){let t=n.key.replace("_currentStageIndex",""),r=RegisteredQuests.get(t);return r?r.currentStageIndex:(o.warn(`Quest ${t} not found`),a(e))}else if(n.key.endsWith("_started")){let t=n.key.replace("_started",""),r=RegisteredQuests.get(t);return r?r.started:(o.warn(`Quest ${t} not found`),a(e))}else if(n.key.endsWith("_completed")){let t=n.key.replace("_completed",""),r=RegisteredQuests.get(t);return r?r.completed:(o.warn(`Quest ${t} not found`),a(e))}else if(n.key.endsWith("_failed")){let t=n.key.replace("_failed",""),r=RegisteredQuests.get(t);return r?r.failed:(o.warn(`Quest ${t} not found`),a(e))}}return a(e)});let{timeConverter:u=e=>Number(e.replace(":",".")),dateConverter:f=e=>Number(e),wait:l=k}=i;return (e,a,n)=>{switch(e[1]){case "room":switch(e[0]){case "enter":if(e.length>2){let t=RegisteredRooms.get(e[2]);return t?navigator.currentRoom=t:o.warn(`Room ${e[2]} not found`),true}break}break;case "time":switch(e[0]){case "set":if(e.length>2){let t=u(e[2]);return isNaN(t)?o.warn(`Invalid time format: ${e[2]}`):timeTracker.currentTime=t,true}break}break;case "date":switch(e[0]){case "set":if(e.length>2){let t=f(e[2]);return isNaN(t)?o.warn(`Invalid date format: ${e[2]}`):timeTracker.currentDate=t,true}break}break;case "activity":switch(e[0]){case "add":if(e.length==5){let t=RegisteredActivities.get(e[2]);if(!t)return o.warn(`Activity ${e[2]} not found`),true;let{in:r}=n(e.slice(3)),s=RegisteredRooms.get(r);return s?s.addActivity(t):o.warn(`Room ${r} not found`),true}case "remove":if(e.length==5){let t=RegisteredActivities.get(e[2]);if(!t)return o.warn(`Activity ${e[2]} not found`),true;let{from:r}=n(e.slice(3)),s=RegisteredRooms.get(r);return s?s.removeActivity(t):o.warn(`Room ${r} not found`),true}}break;case "routine":switch(e[0]){case "add":if(e.length==5){let t=RegisteredCommitments.get(e[2]);if(!t)return o.warn(`Commitment ${e[2]} not found`),true;let{in:r}=n(e.slice(3)),s=RegisteredRooms.get(r);return s?s.addCommitment(t):o.warn(`Room ${r} not found`),true}case "remove":if(e.length==3){let t=RegisteredCommitments.get(e[2]);return t?(routine.remove(t),true):(o.warn(`Commitment ${e[2]} not found`),true)}}break;case "quest":switch(e[0]){case "start":if(e.length==3){let t=RegisteredQuests.get(e[2]);return t?(t.start(a),true):(o.warn(`Quest ${e[2]} not found`),true)}case "continue":if(e.length==3){let t=RegisteredQuests.get(e[2]);return t?(t.continue(a),true):(o.warn(`Quest ${e[2]} not found`),true)}}break}switch(e[0]){case "wait":if(e.length==1)return l(),true;if(e.length==2){let t=u(e[1]);return isNaN(t)?o.warn(`Invalid time format: ${e[1]}`):l(t),true}else if(e.length>2){let t=n(e.slice(1));return t.hours!==void 0&&typeof t.hours=="string"&&(t.hours=u(t.hours)),t.days!==void 0&&typeof t.days=="string"&&(t.days=f(t.days)),l(t),true}break}return false}};export{b as nqtrHandler};
|
package/dist/registries.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var pixiVn=require('@drincs/pixi-vn');var t;(n=>(n.log=(e,...r)=>console.log(`[NQTR] ${e}`,...r),n.warn=(e,...r)=>console.warn(`[NQTR] ${e}`,...r),n.error=(e,...r)=>console.error(`[NQTR] ${e}`,...r),n.info=(e,...r)=>console.info(`[NQTR] ${e}`,...r)))(t||(t={}));var s=new pixiVn.CachedMap({cacheSize:20}),
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn');var t;(n=>(n.log=(e,...r)=>console.log(`[NQTR] ${e}`,...r),n.warn=(e,...r)=>console.warn(`[NQTR] ${e}`,...r),n.error=(e,...r)=>console.error(`[NQTR] ${e}`,...r),n.info=(e,...r)=>console.info(`[NQTR] ${e}`,...r)))(t||(t={}));var s=new pixiVn.CachedMap({cacheSize:20}),g;(n=>{function o(e){if(Array.isArray(e)){e.forEach(r=>n.add(r));return}s.set(e.id,e);}n.add=o;function a(e){try{let r=s.get(e);if(!r){console.warn(`[NQTR] Activity ${e} not found, you should register it first`);return}return r}catch(r){t.error(`Error while getting Activity ${e}`,r);return}}n.get=a;function i(){return Array.from(s.values())}n.values=i;function f(e){return s.has(e)}n.has=f;})(g||(g={}));var M=g;var c=new pixiVn.CachedMap({cacheSize:20}),$=new pixiVn.CachedMap({cacheSize:20}),l;(n=>{function o(e){if(Array.isArray(e)){e.forEach(r=>n.add(r));return}c.set(e.id,e);}n.add=o;function a(e){try{let r=c.get(e);if(!r){console.warn(`[NQTR] Commitment ${e} not found, you should register it first`);return}return r}catch(r){t.error(`Error while getting Commitment ${e}`,r);return}}n.get=a;function i(){return Array.from(c.values())}n.values=i;function f(e){return c.has(e)}n.has=f;})(l||(l={}));var E=l;var u=new pixiVn.CachedMap({cacheSize:20}),y;(n=>{function o(e){if(Array.isArray(e)){e.forEach(r=>o(r));return}u.set(e.id,e);}n.add=o;function a(e){try{let r=u.get(e);if(!r){console.warn(`[NQTR] Location ${e} not found, you should register it first`);return}return r}catch(r){t.error(`Error while getting Location ${e}`,r);return}}n.get=a;function i(){return Array.from(u.values())}n.values=i;function f(e){return u.has(e)}n.has=f;})(y||(y={}));var h=y;var m=new pixiVn.CachedMap({cacheSize:20}),x;(n=>{function o(e){if(Array.isArray(e)){e.forEach(r=>o(r));return}m.set(e.id,e);}n.add=o;function a(e){try{let r=m.get(e);if(!r){console.warn(`[NQTR] Map ${e} not found, you should register it first`);return}return r}catch(r){t.error(`Error while getting Map ${e}`,r);return}}n.get=a;function i(){return Array.from(m.values())}n.values=i;function f(e){return m.has(e)}n.has=f;})(x||(x={}));var I=x;var p=new pixiVn.CachedMap({cacheSize:5}),A;(n=>{function o(e){if(Array.isArray(e)){e.forEach(r=>n.add(r));return}p.set(e.id,e);}n.add=o;function a(e){try{let r=p.get(e);if(!r){console.warn(`[NQTR] Quest ${e} not found, you should register it first`);return}return r}catch(r){t.error(`Error while getting Quest ${e}`,r);return}}n.get=a;function i(){return Array.from(p.values())}n.values=i;function f(e){return p.has(e)}n.has=f;})(A||(A={}));var z=A;var d=new pixiVn.CachedMap({cacheSize:20}),w;(n=>{function o(e){if(Array.isArray(e)){e.forEach(C=>o(C));return}d.set(e.id,e);let r=e.location;h.add(r);let R=r?.map;R&&I.add(R);}n.add=o;function a(e){try{let r=d.get(e);if(!r){console.warn(`[NQTR] Room ${e} not found, you should register it first`);return}return r}catch(r){t.error(`Error while getting Room ${e}`,r);return}}n.get=a;function i(){return Array.from(d.values())}n.values=i;function f(e){return d.has(e)}n.has=f;})(w||(w={}));var b=w;exports.RegisteredActivities=M;exports.RegisteredCommitments=E;exports.RegisteredLocations=h;exports.RegisteredMaps=I;exports.RegisteredQuests=z;exports.RegisteredRooms=b;exports.fixedCommitments=$;exports.registeredCommitments=c;
|