@drincs/nqtr 0.4.2 → 0.5.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/dist/{RoomInterface-Cwm08AzD.d.ts → RoomInterface--jctVS2T.d.mts} +42 -36
- package/dist/{RoomInterface-BRA386zn.d.mts → RoomInterface-BfsHYFLJ.d.ts} +42 -36
- package/dist/{StageInterface-LDgQToad.d.mts → StageInterface-C1Zfcpk3.d.mts} +6 -6
- package/dist/{StageInterface-LDgQToad.d.ts → StageInterface-C1Zfcpk3.d.ts} +6 -6
- package/dist/classes/index.cjs +1 -1
- package/dist/classes/index.cjs.map +1 -1
- package/dist/classes/index.d.mts +30 -58
- package/dist/classes/index.d.ts +30 -58
- package/dist/classes/index.mjs +1 -1
- package/dist/classes/index.mjs.map +1 -1
- package/dist/decorators/index.d.mts +2 -2
- package/dist/decorators/index.d.ts +2 -2
- package/dist/{index-B-x-OmU2.d.ts → index-B-NIWPf6.d.ts} +43 -29
- package/dist/{index-Cq_kqDbo.d.ts → index-C5ZHpLb6.d.mts} +15 -47
- package/dist/{index-k8ho_YWr.d.mts → index-CRjIjzWa.d.mts} +43 -29
- package/dist/{index-CJubtUni.d.mts → index-k8thY0Hu.d.ts} +15 -47
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interface/index.d.mts +3 -3
- package/dist/interface/index.d.ts +3 -3
- package/dist/managers/index.cjs +1 -1
- package/dist/managers/index.cjs.map +1 -1
- package/dist/managers/index.d.mts +3 -3
- package/dist/managers/index.d.ts +3 -3
- package/dist/managers/index.mjs +1 -1
- package/dist/managers/index.mjs.map +1 -1
- package/dist/types/index.d.mts +21 -17
- package/dist/types/index.d.ts +21 -17
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface
|
|
2
|
-
import { Q as QuestInterface } from '../StageInterface-
|
|
1
|
+
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface--jctVS2T.mjs';
|
|
2
|
+
import { Q as QuestInterface } from '../StageInterface-C1Zfcpk3.mjs';
|
|
3
3
|
import '@drincs/nqtr';
|
|
4
4
|
import '@drincs/pixi-vn';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface-
|
|
2
|
-
import { Q as QuestInterface } from '../StageInterface-
|
|
1
|
+
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface-BfsHYFLJ.js';
|
|
2
|
+
import { Q as QuestInterface } from '../StageInterface-C1Zfcpk3.js';
|
|
3
3
|
import '@drincs/nqtr';
|
|
4
4
|
import '@drincs/pixi-vn';
|
|
5
5
|
|
|
@@ -1,34 +1,48 @@
|
|
|
1
|
-
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface-
|
|
1
|
+
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface-BfsHYFLJ.js';
|
|
2
2
|
import { OnRunProps } from '@drincs/nqtr';
|
|
3
|
-
import { Q as QuestInterface } from './StageInterface-
|
|
3
|
+
import { Q as QuestInterface } from './StageInterface-C1Zfcpk3.js';
|
|
4
4
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
5
|
-
import { TimeSettings, ITimeStlot } from './types/index.js';
|
|
5
|
+
import { TimeSettings, ITimeStlot as TimeSlotInterface } from './types/index.js';
|
|
6
6
|
|
|
7
7
|
declare class TimeManager {
|
|
8
8
|
initialize(settings: TimeSettings): void;
|
|
9
|
-
get
|
|
10
|
-
get
|
|
9
|
+
get dayStartTime(): number;
|
|
10
|
+
get dayEndTime(): number;
|
|
11
11
|
get defaultTimeSpent(): number;
|
|
12
|
-
get timeSlots():
|
|
12
|
+
get timeSlots(): TimeSlotInterface[];
|
|
13
13
|
get weekLength(): number;
|
|
14
14
|
get weekendStartDay(): number;
|
|
15
|
-
get weekDaysNames(): string[];
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* Week days name
|
|
17
|
+
* @param weekDayNumber The current week day number (from: 1 - to: {@link weekLength}).
|
|
18
|
+
* @returns The name of the week day.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* (weekDayNumber: Date) => {
|
|
22
|
+
* const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
23
|
+
* return weekDaysNames[currentWeekDayNumber - 1];
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
get getDayName(): ((weekDayNumber: number) => string) | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get the current time. Time is a numeric variable used to determine and manage time during a day/date.
|
|
30
|
+
* It's recommended to use currentTime as if it were the current time. If you also want to manage minutes, you can use a float value.
|
|
18
31
|
*/
|
|
19
|
-
get
|
|
20
|
-
set
|
|
32
|
+
get currentTime(): number;
|
|
33
|
+
set currentTime(value: number | undefined);
|
|
21
34
|
/**
|
|
22
|
-
* Get the current
|
|
35
|
+
* Get the current date. Date is a numeric variable used to determine and manage the number of days passed.
|
|
36
|
+
* It's recommended to use currentDate as if it were the current day.
|
|
23
37
|
*/
|
|
24
|
-
get
|
|
25
|
-
set
|
|
38
|
+
get currentDate(): number;
|
|
39
|
+
set currentDate(value: number | undefined);
|
|
26
40
|
/**
|
|
27
41
|
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
28
42
|
*/
|
|
29
43
|
get isWeekend(): boolean;
|
|
30
44
|
/**
|
|
31
|
-
* Get the current week day number (1 - {@link weekLength}).
|
|
45
|
+
* Get the current week day number (from: 1 - to: {@link weekLength}).
|
|
32
46
|
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
33
47
|
*/
|
|
34
48
|
get currentWeekDayNumber(): number;
|
|
@@ -53,26 +67,26 @@ declare class TimeManager {
|
|
|
53
67
|
*/
|
|
54
68
|
get currentTimeSlot(): number;
|
|
55
69
|
/**
|
|
56
|
-
* This function will increase the current
|
|
57
|
-
* If the new
|
|
58
|
-
* @param
|
|
59
|
-
* @returns currentTimeSlot.
|
|
70
|
+
* This function will increase the current time by the given time spent.
|
|
71
|
+
* If the new time is greater than or equal to the max day times, then it will increase the day and set the new time.
|
|
72
|
+
* @param delta is the time spent in times (default: {@link defaultTimeSpent})
|
|
73
|
+
* @returns currentTimeSlot.currentTime
|
|
60
74
|
*/
|
|
61
|
-
|
|
75
|
+
increaseTime(delta?: number): number;
|
|
62
76
|
/**
|
|
63
|
-
* This function will increase the current
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @returns timeTracker.
|
|
77
|
+
* This function will increase the current date by the given delta.
|
|
78
|
+
* @param time is the time of the new day (default: {@link dayStartTime})
|
|
79
|
+
* @param delta is the number of days to increase (default: 1)
|
|
80
|
+
* @returns timeTracker.currentDate
|
|
67
81
|
*/
|
|
68
|
-
|
|
82
|
+
increaseDate(time?: number, delta?: number): number;
|
|
69
83
|
/**
|
|
70
|
-
* This function will check if the current
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @returns true if the current
|
|
84
|
+
* This function will check if the current time is between the given times.
|
|
85
|
+
* @param fromTime the starting time. If the {@link currentTime} is equal to this time, the function will return true.
|
|
86
|
+
* @param toTime the ending time.
|
|
87
|
+
* @returns true if the current time is between the given times, otherwise false.
|
|
74
88
|
*/
|
|
75
|
-
nowIsBetween(
|
|
89
|
+
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
declare class RoutineManager {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CommitmentInterface, A as ActivityInterface } from './RoomInterface
|
|
2
|
-
import { E as ExecutionType, a as OnRunEvent, Q as QuestInterface, d as QuestsRequiredType, S as StageInterface } from './StageInterface-
|
|
1
|
+
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, A as ActivityInterface } from './RoomInterface--jctVS2T.mjs';
|
|
2
|
+
import { E as ExecutionType, a as OnRunEvent, Q as QuestInterface, d as QuestsRequiredType, S as StageInterface } from './StageInterface-C1Zfcpk3.mjs';
|
|
3
3
|
|
|
4
4
|
interface ActivityProps {
|
|
5
5
|
/**
|
|
@@ -8,29 +8,13 @@ interface ActivityProps {
|
|
|
8
8
|
*/
|
|
9
9
|
name?: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.
|
|
13
|
-
* @default timeTracker.minDayHours
|
|
11
|
+
* Time slot in which activity/commitment will be active.
|
|
14
12
|
*/
|
|
15
|
-
|
|
13
|
+
timeSlot?: TimeSchedulingInterface;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
* If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.
|
|
19
|
-
* @default timeTracker.maxDayHours + 1
|
|
15
|
+
* Used to schedule what date it will be added and removed.
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
24
|
-
* If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.
|
|
25
|
-
* @default undefined
|
|
26
|
-
*/
|
|
27
|
-
fromDay?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
30
|
-
* If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.
|
|
31
|
-
* @default undefined
|
|
32
|
-
*/
|
|
33
|
-
toDay?: number;
|
|
17
|
+
dateScheduling?: DateSchedulingInterface;
|
|
34
18
|
/**
|
|
35
19
|
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
36
20
|
* @default false
|
|
@@ -55,29 +39,13 @@ interface CommitmentProps {
|
|
|
55
39
|
*/
|
|
56
40
|
name?: string;
|
|
57
41
|
/**
|
|
58
|
-
*
|
|
59
|
-
* If you set 3, the commitment will be hidden into hours 1 and 2, and will be shown from hour 3.
|
|
60
|
-
* @default timeTracker.minDayHours
|
|
42
|
+
* Time slot in which activity/commitment will be active.
|
|
61
43
|
*/
|
|
62
|
-
|
|
44
|
+
readonly timeSlot: TimeSchedulingInterface | undefined;
|
|
63
45
|
/**
|
|
64
|
-
*
|
|
65
|
-
* If you set 3, the commitment will be shown into hours 1 and 2 and will be hidden from hour 3.
|
|
66
|
-
* @default timeTracker.maxDayHours + 1
|
|
67
|
-
*/
|
|
68
|
-
toHour?: number;
|
|
69
|
-
/**
|
|
70
|
-
* The day when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
71
|
-
* If you set 3, the commitment will be hidden into days 1 and 2, and will be shown from day 3.
|
|
72
|
-
* @default undefined
|
|
73
|
-
*/
|
|
74
|
-
fromDay?: number;
|
|
75
|
-
/**
|
|
76
|
-
* The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.
|
|
77
|
-
* If you set 3, the commitment will be shown into days 1 and 2 and will be deleted or hidden from day 3.
|
|
78
|
-
* @default undefined
|
|
46
|
+
* Used to schedule what date it will be added and removed.
|
|
79
47
|
*/
|
|
80
|
-
|
|
48
|
+
readonly dateScheduling: DateSchedulingInterface | undefined;
|
|
81
49
|
/**
|
|
82
50
|
* The image ofthe Commitment.
|
|
83
51
|
*/
|
|
@@ -269,20 +237,20 @@ interface StageProps {
|
|
|
269
237
|
*/
|
|
270
238
|
image?: string;
|
|
271
239
|
/**
|
|
272
|
-
* The day required to start the stage.
|
|
273
|
-
* @example If the value is 3, and the previous stage ends on
|
|
240
|
+
* The number of day/date required to start the stage.
|
|
241
|
+
* @example If the value is 3, and the previous stage ends on date 1, the stage will start on date 4.
|
|
274
242
|
*/
|
|
275
|
-
|
|
243
|
+
deltaDateRequired?: number;
|
|
276
244
|
/**
|
|
277
245
|
* The flags required to start the stage.
|
|
278
246
|
* @default []
|
|
279
247
|
*/
|
|
280
|
-
|
|
248
|
+
flagsRequired?: StageFlags[];
|
|
281
249
|
/**
|
|
282
250
|
* The quests required to start the stage.
|
|
283
251
|
* @default []
|
|
284
252
|
*/
|
|
285
|
-
|
|
253
|
+
questsRequired?: QuestsRequiredType[];
|
|
286
254
|
/**
|
|
287
255
|
* The description to request to start the stage.
|
|
288
256
|
* @default ""
|
|
@@ -1,34 +1,48 @@
|
|
|
1
|
-
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface
|
|
1
|
+
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface--jctVS2T.mjs';
|
|
2
2
|
import { OnRunProps } from '@drincs/nqtr';
|
|
3
|
-
import { Q as QuestInterface } from './StageInterface-
|
|
3
|
+
import { Q as QuestInterface } from './StageInterface-C1Zfcpk3.mjs';
|
|
4
4
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
5
|
-
import { TimeSettings, ITimeStlot } from './types/index.mjs';
|
|
5
|
+
import { TimeSettings, ITimeStlot as TimeSlotInterface } from './types/index.mjs';
|
|
6
6
|
|
|
7
7
|
declare class TimeManager {
|
|
8
8
|
initialize(settings: TimeSettings): void;
|
|
9
|
-
get
|
|
10
|
-
get
|
|
9
|
+
get dayStartTime(): number;
|
|
10
|
+
get dayEndTime(): number;
|
|
11
11
|
get defaultTimeSpent(): number;
|
|
12
|
-
get timeSlots():
|
|
12
|
+
get timeSlots(): TimeSlotInterface[];
|
|
13
13
|
get weekLength(): number;
|
|
14
14
|
get weekendStartDay(): number;
|
|
15
|
-
get weekDaysNames(): string[];
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* Week days name
|
|
17
|
+
* @param weekDayNumber The current week day number (from: 1 - to: {@link weekLength}).
|
|
18
|
+
* @returns The name of the week day.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* (weekDayNumber: Date) => {
|
|
22
|
+
* const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
23
|
+
* return weekDaysNames[currentWeekDayNumber - 1];
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
get getDayName(): ((weekDayNumber: number) => string) | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get the current time. Time is a numeric variable used to determine and manage time during a day/date.
|
|
30
|
+
* It's recommended to use currentTime as if it were the current time. If you also want to manage minutes, you can use a float value.
|
|
18
31
|
*/
|
|
19
|
-
get
|
|
20
|
-
set
|
|
32
|
+
get currentTime(): number;
|
|
33
|
+
set currentTime(value: number | undefined);
|
|
21
34
|
/**
|
|
22
|
-
* Get the current
|
|
35
|
+
* Get the current date. Date is a numeric variable used to determine and manage the number of days passed.
|
|
36
|
+
* It's recommended to use currentDate as if it were the current day.
|
|
23
37
|
*/
|
|
24
|
-
get
|
|
25
|
-
set
|
|
38
|
+
get currentDate(): number;
|
|
39
|
+
set currentDate(value: number | undefined);
|
|
26
40
|
/**
|
|
27
41
|
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
28
42
|
*/
|
|
29
43
|
get isWeekend(): boolean;
|
|
30
44
|
/**
|
|
31
|
-
* Get the current week day number (1 - {@link weekLength}).
|
|
45
|
+
* Get the current week day number (from: 1 - to: {@link weekLength}).
|
|
32
46
|
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
33
47
|
*/
|
|
34
48
|
get currentWeekDayNumber(): number;
|
|
@@ -53,26 +67,26 @@ declare class TimeManager {
|
|
|
53
67
|
*/
|
|
54
68
|
get currentTimeSlot(): number;
|
|
55
69
|
/**
|
|
56
|
-
* This function will increase the current
|
|
57
|
-
* If the new
|
|
58
|
-
* @param
|
|
59
|
-
* @returns currentTimeSlot.
|
|
70
|
+
* This function will increase the current time by the given time spent.
|
|
71
|
+
* If the new time is greater than or equal to the max day times, then it will increase the day and set the new time.
|
|
72
|
+
* @param delta is the time spent in times (default: {@link defaultTimeSpent})
|
|
73
|
+
* @returns currentTimeSlot.currentTime
|
|
60
74
|
*/
|
|
61
|
-
|
|
75
|
+
increaseTime(delta?: number): number;
|
|
62
76
|
/**
|
|
63
|
-
* This function will increase the current
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @returns timeTracker.
|
|
77
|
+
* This function will increase the current date by the given delta.
|
|
78
|
+
* @param time is the time of the new day (default: {@link dayStartTime})
|
|
79
|
+
* @param delta is the number of days to increase (default: 1)
|
|
80
|
+
* @returns timeTracker.currentDate
|
|
67
81
|
*/
|
|
68
|
-
|
|
82
|
+
increaseDate(time?: number, delta?: number): number;
|
|
69
83
|
/**
|
|
70
|
-
* This function will check if the current
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @returns true if the current
|
|
84
|
+
* This function will check if the current time is between the given times.
|
|
85
|
+
* @param fromTime the starting time. If the {@link currentTime} is equal to this time, the function will return true.
|
|
86
|
+
* @param toTime the ending time.
|
|
87
|
+
* @returns true if the current time is between the given times, otherwise false.
|
|
74
88
|
*/
|
|
75
|
-
nowIsBetween(
|
|
89
|
+
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
declare class RoutineManager {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CommitmentInterface, A as ActivityInterface } from './RoomInterface-
|
|
2
|
-
import { E as ExecutionType, a as OnRunEvent, Q as QuestInterface, d as QuestsRequiredType, S as StageInterface } from './StageInterface-
|
|
1
|
+
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, A as ActivityInterface } from './RoomInterface-BfsHYFLJ.js';
|
|
2
|
+
import { E as ExecutionType, a as OnRunEvent, Q as QuestInterface, d as QuestsRequiredType, S as StageInterface } from './StageInterface-C1Zfcpk3.js';
|
|
3
3
|
|
|
4
4
|
interface ActivityProps {
|
|
5
5
|
/**
|
|
@@ -8,29 +8,13 @@ interface ActivityProps {
|
|
|
8
8
|
*/
|
|
9
9
|
name?: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.
|
|
13
|
-
* @default timeTracker.minDayHours
|
|
11
|
+
* Time slot in which activity/commitment will be active.
|
|
14
12
|
*/
|
|
15
|
-
|
|
13
|
+
timeSlot?: TimeSchedulingInterface;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
* If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.
|
|
19
|
-
* @default timeTracker.maxDayHours + 1
|
|
15
|
+
* Used to schedule what date it will be added and removed.
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
24
|
-
* If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.
|
|
25
|
-
* @default undefined
|
|
26
|
-
*/
|
|
27
|
-
fromDay?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
30
|
-
* If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.
|
|
31
|
-
* @default undefined
|
|
32
|
-
*/
|
|
33
|
-
toDay?: number;
|
|
17
|
+
dateScheduling?: DateSchedulingInterface;
|
|
34
18
|
/**
|
|
35
19
|
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
36
20
|
* @default false
|
|
@@ -55,29 +39,13 @@ interface CommitmentProps {
|
|
|
55
39
|
*/
|
|
56
40
|
name?: string;
|
|
57
41
|
/**
|
|
58
|
-
*
|
|
59
|
-
* If you set 3, the commitment will be hidden into hours 1 and 2, and will be shown from hour 3.
|
|
60
|
-
* @default timeTracker.minDayHours
|
|
42
|
+
* Time slot in which activity/commitment will be active.
|
|
61
43
|
*/
|
|
62
|
-
|
|
44
|
+
readonly timeSlot: TimeSchedulingInterface | undefined;
|
|
63
45
|
/**
|
|
64
|
-
*
|
|
65
|
-
* If you set 3, the commitment will be shown into hours 1 and 2 and will be hidden from hour 3.
|
|
66
|
-
* @default timeTracker.maxDayHours + 1
|
|
67
|
-
*/
|
|
68
|
-
toHour?: number;
|
|
69
|
-
/**
|
|
70
|
-
* The day when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
71
|
-
* If you set 3, the commitment will be hidden into days 1 and 2, and will be shown from day 3.
|
|
72
|
-
* @default undefined
|
|
73
|
-
*/
|
|
74
|
-
fromDay?: number;
|
|
75
|
-
/**
|
|
76
|
-
* The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.
|
|
77
|
-
* If you set 3, the commitment will be shown into days 1 and 2 and will be deleted or hidden from day 3.
|
|
78
|
-
* @default undefined
|
|
46
|
+
* Used to schedule what date it will be added and removed.
|
|
79
47
|
*/
|
|
80
|
-
|
|
48
|
+
readonly dateScheduling: DateSchedulingInterface | undefined;
|
|
81
49
|
/**
|
|
82
50
|
* The image ofthe Commitment.
|
|
83
51
|
*/
|
|
@@ -269,20 +237,20 @@ interface StageProps {
|
|
|
269
237
|
*/
|
|
270
238
|
image?: string;
|
|
271
239
|
/**
|
|
272
|
-
* The day required to start the stage.
|
|
273
|
-
* @example If the value is 3, and the previous stage ends on
|
|
240
|
+
* The number of day/date required to start the stage.
|
|
241
|
+
* @example If the value is 3, and the previous stage ends on date 1, the stage will start on date 4.
|
|
274
242
|
*/
|
|
275
|
-
|
|
243
|
+
deltaDateRequired?: number;
|
|
276
244
|
/**
|
|
277
245
|
* The flags required to start the stage.
|
|
278
246
|
* @default []
|
|
279
247
|
*/
|
|
280
|
-
|
|
248
|
+
flagsRequired?: StageFlags[];
|
|
281
249
|
/**
|
|
282
250
|
* The quests required to start the stage.
|
|
283
251
|
* @default []
|
|
284
252
|
*/
|
|
285
|
-
|
|
253
|
+
questsRequired?: QuestsRequiredType[];
|
|
286
254
|
/**
|
|
287
255
|
* The description to request to start the stage.
|
|
288
256
|
* @default ""
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pixiVn=require('@drincs/pixi-vn');var be=Object.defineProperty;var Z=(o,e)=>{for(var t in e)be(o,t,{get:e[t],enumerable:true});};var ae={};Z(ae,{ActivityBaseModel:()=>$,ActivityStoredClass:()=>g,CommitmentBaseModel:()=>B,CommitmentStoredClass:()=>I,LocationBaseModel:()=>Y,LocationStoredClass:()=>x,MapBaseModel:()=>F,MapStoredClass:()=>b,QuestBaseModel:()=>z,QuestStoredClass:()=>_,RoomBaseModel:()=>V,RoomStoredClass:()=>R,StageBaseModel:()=>G,StageStoredClass:()=>T});var f="___nqtr-time_manager_data___",h="___nqtr-current_room_memory___",ee="___nqtr-last_event_memory___";var ie={};Z(ie,{navigator:()=>l,questsNotebook:()=>Ee,routine:()=>k,timeTracker:()=>c});var te={};Z(te,{RegisteredActivities:()=>C,RegisteredCommitments:()=>y,RegisteredLocations:()=>D,RegisteredMaps:()=>E,RegisteredQuests:()=>N,RegisteredRooms:()=>S});var u;(a=>(a.log=(i,...n)=>console.log(`[NQTR] ${i}`,...n),a.warn=(i,...n)=>console.warn(`[NQTR] ${i}`,...n),a.error=(i,...n)=>console.error(`[NQTR] ${i}`,...n),a.info=(i,...n)=>console.info(`[NQTR] ${i}`,...n)))(u||={});var K=new pixiVn.CachedMap({cacheSize:20}),oe;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>a.add(n));return}K.set(i.id,i);}a.add=o;function e(i){try{let n=K.get(i);if(!n){console.warn(`[NQTR] Activity ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Activity ${i}`,n);return}}a.get=e;function t(){return Array.from(K.values())}a.values=t;function r(i){return K.has(i)}a.has=r;})(oe||={});var C=oe;var A=new pixiVn.CachedMap({cacheSize:20}),W=new pixiVn.CachedMap({cacheSize:20}),ue;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>a.add(n));return}console.warn(`[NQTR] Registering commitment ${i.id}`,i),A.set(i.id,i);}a.add=o;function e(i){try{let n=A.get(i);if(!n){console.warn(`[NQTR] Commitment ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Commitment ${i}`,n);return}}a.get=e;function t(){return Array.from(A.values())}a.values=t;function r(i){return A.has(i)}a.has=r;})(ue||={});var y=ue;var P=new pixiVn.CachedMap({cacheSize:20}),de;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>o(n));return}P.has(i.id)&&console.warn(`[NQTR] Location id ${i.id} already exists, it will be overwritten`),P.set(i.id,i);}a.add=o;function e(i){try{let n=P.get(i);if(!n){console.warn(`[NQTR] Location ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Location ${i}`,n);return}}a.get=e;function t(){return Array.from(P.values())}a.values=t;function r(i){return P.has(i)}a.has=r;})(de||={});var D=de;var Q=new pixiVn.CachedMap({cacheSize:20}),ce;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>o(n));return}Q.has(i.id)&&console.warn(`[NQTR] Map id ${i.id} already exists, it will be overwritten`),Q.set(i.id,i);}a.add=o;function e(i){try{let n=Q.get(i);if(!n){console.warn(`[NQTR] Map ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Map ${i}`,n);return}}a.get=e;function t(){return Array.from(Q.values())}a.values=t;function r(i){return Q.has(i)}a.has=r;})(ce||={});var E=ce;var j=new pixiVn.CachedMap({cacheSize:5}),me;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>a.add(n));return}j.set(i.id,i);}a.add=o;function e(i){try{let n=j.get(i);if(!n){console.warn(`[NQTR] Quest ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Quest ${i}`,n);return}}a.get=e;function t(){return Array.from(j.values())}a.values=t;function r(i){return j.has(i)}a.has=r;})(me||={});var N=me;var U=new pixiVn.CachedMap({cacheSize:20}),fe;(a=>{function o(i){if(Array.isArray(i)){i.forEach(m=>o(m));return}U.set(i.id,i);let n=i.location;D.add(n);let s=n?.map;s&&E.add(s);}a.add=o;function e(i){try{let n=U.get(i);if(!n){console.warn(`[NQTR] Room ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Room ${i}`,n);return}}a.get=e;function t(){return Array.from(U.values())}a.values=t;function r(i){return U.has(i)}a.has=r;})(fe||={});var S=fe;var M=class{get rooms(){return S.values()}get locations(){return D.values()}get maps(){return E.values()}get currentRoomId(){return pixiVn.storage.getVariable(h)}get currentRoom(){let e=this.currentRoomId;if(!e){u.error("The current room has not yet been set");return}let t=S.get(e);if(!t){u.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!S.get(e)){u.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=pixiVn.storage.getVariable(h);r!==e&&(H({type:"editroom",prev:r,value:e}),pixiVn.storage.setVariable(h,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){S.values().forEach(e=>{e.clearExpiredActivities();});}};var O=class{get quests(){return N.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 N.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var X="___nqtr-temporary_commitment___",q=class{get fixedRoutine(){return [...W.values()]}set fixedRoutine(e){e.forEach(t=>{W.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),W.set(t.id,t);});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(X);return e?e.map(r=>y.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(!y.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);pixiVn.storage.setVariable(X,t);}find(e){return y.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(a=>a.id),r=pixiVn.storage.getVariable(X);r&&(r=r.filter(a=>!t.includes(a)),pixiVn.storage.setVariable(X,r));}clearExpiredRoutine(){y.values().forEach(e=>{e.expired&&A.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(a=>!e[a.id]||t.priority>e[a.id].priority)&&t.characters.forEach(a=>{e[a.id]=t;}):u.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return l.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var L=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:a=1,timeSlots:i=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:m=[]}=e;d.minDayHours=t,d.maxDayHours=r,d.defaultTimeSpent=a,d.timeSlots=i,d.weekLength=n,s>=d.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):d.weekendStartDay=s,m.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):d.weekDaysNames=m;}get minDayHours(){return d.minDayHours}get maxDayHours(){return d.maxDayHours}get defaultTimeSpent(){return d.defaultTimeSpent}get timeSlots(){return d.timeSlots}get weekLength(){return d.weekLength}get weekendStartDay(){return d.weekendStartDay}get weekDaysNames(){return d.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(f)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(f)||{},r={...t};typeof e=="number"?r.currentHour=e:delete r.currentHour,H({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(f,r);}get currentDay(){let e=pixiVn.storage.getVariable(f)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(f)||{},r={...t};typeof e=="number"?r.currentDay=e:delete r.currentDay,H({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(f,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===void 0&&(e=this.minDayHours-1),t===void 0&&(t=this.maxDayHours+1);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var c=new L,l=new M,k=new q,Ee=new O;function H(o){pixiVn.storage.setVariable(ee,o);}function we(){return pixiVn.storage.getVariable(ee)}function le(){let o=we(),e=l.currentRoom;if(!e||!e.automaticFunction){pixiVn.narration.addCurrentStepToHistory();return}switch(o?.type){case "editroom":pixiVn.storage.setVariable(h,o.prev),pixiVn.narration.addCurrentStepToHistory(),pixiVn.storage.setVariable(h,e.id);break;case "edittime":let t=pixiVn.storage.getVariable(f)||{};pixiVn.storage.setVariable(f,o.prev),pixiVn.narration.addCurrentStepToHistory(),pixiVn.storage.setVariable(f,t);break}}var Pe="__nqtr-activity__",g=class extends pixiVn.StoredClassModel{constructor(t,r,a,i=Pe){super(i,t);this._onRun=r;this._fromHour=a.fromHour,this._toHour=a.toHour,this._fromDay=a.fromDay,this._toDay=a.toDay;}_fromHour;get fromHour(){return this._fromHour}_toHour;get toHour(){return this._toHour}_fromDay;get fromDay(){return this._fromDay}_toDay;get toDay(){return this._toDay}get run(){return async t=>(le(),await this._onRun(this,t))}get expired(){return !!(this.toDay&&this.toDay<=c.currentDay)}get isActive(){return !(this.fromDay&&this.fromDay>c.currentDay||this.toDay&&this.toDay<c.currentDay||!c.nowIsBetween(this.fromHour,this.toHour))}};var $=class extends g{constructor(e,t,r){super(e,t,{fromHour:r.fromHour,toHour:r.toHour,fromDay:r.fromDay,toDay:r.toDay}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Qe="__nqtr-commitment__",I=class extends g{constructor(t,r,a,i,n){i=i||(()=>{});super(t,i,n,Qe);this._characters=r;this._room=a;this.defaultExecutionType=n.executionType||"interaction",this.defaultPriority=n.priority;}defaultExecutionType;defaultPriority;get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(t){this.setStorageProperty("executionType",t);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(t){this.setStorageProperty("priority",t);}};var B=class extends I{constructor(e,t,r,a){super(e,t?Array.isArray(t)?t:[t]:[],r,a.onRun,{executionType:a.executionType,priority:a.priority,fromHour:a.fromHour,toHour:a.toHour,fromDay:a.fromDay,toDay:a.toDay}),this._name=a.name||"",this._image=a.image,this.defaultDisabled=a.disabled||false,this.defaultHidden=a.hidden||false,this._icon=a.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.fromDay&&this.fromDay>c.currentDay||!c.nowIsBetween(this.fromHour,this.toHour)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var p=class extends pixiVn.StoredClassModel{constructor(t,r,a=[]){super(t,r);this.defaultActivities=a;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let a=this.excludedActivitiesScheduling;delete a[t],this.setStorageProperty("excludedActivitiesScheduling",a);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let a=this.activeActivityScheduling;a[t]=r,this.setStorageProperty("activeActivityScheduling",a);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let a=this.excludedActivitiesScheduling;a[t]=r,this.setStorageProperty("excludedActivitiesScheduling",a);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:a,fromDay:i,toDay:n}=r,s={};if(a){if(a.from>=a.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=a.from;}if(i===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&n&&i>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(i&&(s.fromDay=i),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let m=this.additionalActivitiesIds;if(m.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}m.push(t.id),this.setStorageProperty("additionalActivitiesIds",m),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}removeActivity(t,r={}){let{toDay:a}=r,i={};a===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),a&&(i.toDay=a);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(i).length){this.editExcludedActivityScheduling(t.id,i);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(i).length){this.editExcludedActivityScheduling(t.id,i);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,a=this.additionalActivitiesIds,i=this.excludedActivitiesIds;a.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<c.currentDay&&(this.removeActivityScheduling(n),a=a.filter(m=>m!==n));}}),i.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<c.currentDay&&(this.removeActivityScheduling(n),i=i.filter(m=>m!==n));}});}get activities(){let t=[],r=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(a=>{let i=C.get(a),{fromDay:n=i?.fromDay,fromHour:s=i?.fromHour,toDay:m=i?.toDay,toHour:xe=i?.toHour}=r[a]||{};i&&c.nowIsBetween(s,xe)&&!(n&&n>c.currentDay)&&!(m&&m<c.currentDay)&&t.push(i);}),Object.entries(this.excludedActivitiesScheduling).forEach(([a,i])=>{let n=C.get(a);n&&n.isActive&&!(i.toDay&&i.toDay>=c.currentDay)&&t.push(n);}),this.defaultActivities.forEach(a=>{a.isActive&&!t.find(i=>i.id===a.id)&&t.push(a);}),t}};var Me="__nqtr-location__",x=class extends p{constructor(t,r,a=[]){super(Me,t,a);this._map=r;}get map(){return this._map}get rooms(){return l.rooms.filter(t=>t.location.id===this.id)}};var Y=class extends x{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var He="__nqtr-map__",b=class extends p{constructor(e,t=[]){super(He,e,t);}get locations(){return l.locations.filter(e=>e.map.id===this.id)}};var F=class extends b{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var Oe="__nqtr-room__",R=class extends p{constructor(t,r,a=[]){super(Oe,t,a);this._location=r;}get routine(){return k.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}get characters(){let t=[];return this.routine.forEach(r=>{t.push(...r.characters);}),t}get automaticFunction(){let t=this.routine.find(r=>r.executionType==="automatic")?.run;if(t)return async r=>{await t(r);}}};var V=class extends R{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}get routine(){return k.currentRoutine.filter(e=>e.room.id===this.id)}};var Le="__nqtr-quest__",_=class extends pixiVn.StoredClassModel{constructor(t,r,a={}){super(Le,t);this._stages=r;this._onStart=a.onStart,this._onNextStage=a.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===void 0||t>=this.stages.length))return this.stages[t]}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(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}async start(t){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 r=this.currentStage;if(r&&r.start)return this.onStart&&await this.onStart(this,t),await r.start(t);u.error(`Quest ${this.id} has no start stage`);}async tryToGoNextStage(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.goNextStage(t):false:(u.error(`Quest ${this.id} has no current stage`),false)}async completeCurrentStageAndGoNext(t){let r=this.currentStage;return r?(r.completed=true,await this.goNextStage(t)):(u.error(`Quest ${this.id} has no current stage`),false)}async goNextStage(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,a=this.currentStageIndex;if(!r||a===void 0)return u.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=a+1,this.onNextStage&&await this.onNextStage(this,t),r&&r.onEnd&&await r.onEnd(r,t);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var z=class extends _{constructor(e,t,r){super(e,t,{onStart:r.onStart,onNextStage:r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};var $e="__nqtr-stage__",T=class extends pixiVn.StoredClassModel{constructor(e,t={}){super($e,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;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 prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==void 0)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===void 0||t+e>c.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=c.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var G=class extends T{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>pixiVn.storage.getFlag(e.flag))?false:super.canStart}};var ve={};var Ie={};var Be={...ae,...te,...ve,...ie,...Ie},Xr=Be;exports.ActivityBaseModel=$;exports.ActivityStoredClass=g;exports.CommitmentBaseModel=B;exports.CommitmentStoredClass=I;exports.LocationBaseModel=Y;exports.LocationStoredClass=x;exports.MapBaseModel=F;exports.MapStoredClass=b;exports.QuestBaseModel=z;exports.QuestStoredClass=_;exports.RegisteredActivities=C;exports.RegisteredCommitments=y;exports.RegisteredLocations=D;exports.RegisteredMaps=E;exports.RegisteredQuests=N;exports.RegisteredRooms=S;exports.RoomBaseModel=V;exports.RoomStoredClass=R;exports.StageBaseModel=G;exports.StageStoredClass=T;exports.default=Xr;exports.navigator=l;exports.questsNotebook=Ee;exports.routine=k;exports.timeTracker=c;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pixiVn=require('@drincs/pixi-vn');var be=Object.defineProperty;var Z=(o,e)=>{for(var t in e)be(o,t,{get:e[t],enumerable:true});};var ae={};Z(ae,{ActivityBaseModel:()=>B,ActivityStoredClass:()=>g,CommitmentBaseModel:()=>z,CommitmentStoredClass:()=>I,LocationBaseModel:()=>Y,LocationStoredClass:()=>x,MapBaseModel:()=>F,MapStoredClass:()=>R,QuestBaseModel:()=>H,QuestStoredClass:()=>b,RoomBaseModel:()=>V,RoomStoredClass:()=>_,StageBaseModel:()=>G,StageStoredClass:()=>T});var m="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",ee="___nqtr-last_event_memory___";var ie={};Z(ie,{navigator:()=>f,questsNotebook:()=>we,routine:()=>k,timeTracker:()=>d});var te={};Z(te,{RegisteredActivities:()=>w,RegisteredCommitments:()=>S,RegisteredLocations:()=>E,RegisteredMaps:()=>D,RegisteredQuests:()=>Q,RegisteredRooms:()=>y});var u;(a=>(a.log=(i,...n)=>console.log(`[NQTR] ${i}`,...n),a.warn=(i,...n)=>console.warn(`[NQTR] ${i}`,...n),a.error=(i,...n)=>console.error(`[NQTR] ${i}`,...n),a.info=(i,...n)=>console.info(`[NQTR] ${i}`,...n)))(u||={});var K=new pixiVn.CachedMap({cacheSize:20}),se;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>a.add(n));return}K.set(i.id,i);}a.add=o;function e(i){try{let n=K.get(i);if(!n){console.warn(`[NQTR] Activity ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Activity ${i}`,n);return}}a.get=e;function t(){return Array.from(K.values())}a.values=t;function r(i){return K.has(i)}a.has=r;})(se||={});var w=se;var A=new pixiVn.CachedMap({cacheSize:20}),j=new pixiVn.CachedMap({cacheSize:20}),de;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>a.add(n));return}console.warn(`[NQTR] Registering commitment ${i.id}`,i),A.set(i.id,i);}a.add=o;function e(i){try{let n=A.get(i);if(!n){console.warn(`[NQTR] Commitment ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Commitment ${i}`,n);return}}a.get=e;function t(){return Array.from(A.values())}a.values=t;function r(i){return A.has(i)}a.has=r;})(de||={});var S=de;var C=new pixiVn.CachedMap({cacheSize:20}),ce;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>o(n));return}C.has(i.id)&&console.warn(`[NQTR] Location id ${i.id} already exists, it will be overwritten`),C.set(i.id,i);}a.add=o;function e(i){try{let n=C.get(i);if(!n){console.warn(`[NQTR] Location ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Location ${i}`,n);return}}a.get=e;function t(){return Array.from(C.values())}a.values=t;function r(i){return C.has(i)}a.has=r;})(ce||={});var E=ce;var M=new pixiVn.CachedMap({cacheSize:20}),le;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>o(n));return}M.has(i.id)&&console.warn(`[NQTR] Map id ${i.id} already exists, it will be overwritten`),M.set(i.id,i);}a.add=o;function e(i){try{let n=M.get(i);if(!n){console.warn(`[NQTR] Map ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Map ${i}`,n);return}}a.get=e;function t(){return Array.from(M.values())}a.values=t;function r(i){return M.has(i)}a.has=r;})(le||={});var D=le;var W=new pixiVn.CachedMap({cacheSize:5}),me;(a=>{function o(i){if(Array.isArray(i)){i.forEach(n=>a.add(n));return}W.set(i.id,i);}a.add=o;function e(i){try{let n=W.get(i);if(!n){console.warn(`[NQTR] Quest ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Quest ${i}`,n);return}}a.get=e;function t(){return Array.from(W.values())}a.values=t;function r(i){return W.has(i)}a.has=r;})(me||={});var Q=me;var U=new pixiVn.CachedMap({cacheSize:20}),fe;(a=>{function o(i){if(Array.isArray(i)){i.forEach(c=>o(c));return}U.set(i.id,i);let n=i.location;E.add(n);let s=n?.map;s&&D.add(s);}a.add=o;function e(i){try{let n=U.get(i);if(!n){console.warn(`[NQTR] Room ${i} not found, you should register it first`);return}return n}catch(n){u.error(`Error while getting Room ${i}`,n);return}}a.get=e;function t(){return Array.from(U.values())}a.values=t;function r(i){return U.has(i)}a.has=r;})(fe||={});var y=fe;var N=class{get rooms(){return y.values()}get locations(){return E.values()}get maps(){return D.values()}get currentRoomId(){return pixiVn.storage.getVariable(p)}get currentRoom(){let e=this.currentRoomId;if(!e){u.error("The current room has not yet been set");return}let t=y.get(e);if(!t){u.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!y.get(e)){u.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=pixiVn.storage.getVariable(p);r!==e&&(O({type:"editroom",prev:r,value:e}),pixiVn.storage.setVariable(p,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){y.values().forEach(e=>{e.clearExpiredActivities();});}};var q=class{get quests(){return Q.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 Q.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var X="___nqtr-temporary_commitment___",L=class{get fixedRoutine(){return [...j.values()]}set fixedRoutine(e){e.forEach(t=>{j.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),j.set(t.id,t);});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(X);return e?e.map(r=>S.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(!S.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);pixiVn.storage.setVariable(X,t);}find(e){return S.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(a=>a.id),r=pixiVn.storage.getVariable(X);r&&(r=r.filter(a=>!t.includes(a)),pixiVn.storage.setVariable(X,r));}clearExpiredRoutine(){S.values().forEach(e=>{e.expired&&A.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(a=>!e[a.id]||t.priority>e[a.id].priority)&&t.characters.forEach(a=>{e[a.id]=t;}):u.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return f.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var l=class{static dayStartTime=0;static dayEndTime=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static getDayName};var $=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:a=1,timeSlots:i=[],weekLength:n=7,weekendStartDay:s=n-1,getDayName:c}=e;l.dayStartTime=t,l.dayEndTime=r,l.defaultTimeSpent=a,l.timeSlots=i,l.weekLength=n,s>=l.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):l.weekendStartDay=s,l.getDayName=c;}get dayStartTime(){return l.dayStartTime}get dayEndTime(){return l.dayEndTime}get defaultTimeSpent(){return l.defaultTimeSpent}get timeSlots(){return l.timeSlots}get weekLength(){return l.weekLength}get weekendStartDay(){return l.weekendStartDay}get getDayName(){return l.getDayName}get currentTime(){let e=pixiVn.storage.getVariable(m)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=pixiVn.storage.getVariable(m)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,O({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(m,r);}get currentDate(){let e=pixiVn.storage.getVariable(m)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=pixiVn.storage.getVariable(m)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,O({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(m,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=this.dayStartTime,t=1){let r=this.currentDate+t;return this.currentDate=r,this.currentTime=e,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 d=new $,f=new N,k=new L,we=new q;function O(o){pixiVn.storage.setVariable(ee,o);}function Ce(){return pixiVn.storage.getVariable(ee)}function ge(){let o=Ce(),e=f.currentRoom;if(!e||!e.automaticFunction){pixiVn.narration.addCurrentStepToHistory();return}switch(o?.type){case "editroom":pixiVn.storage.setVariable(p,o.prev),pixiVn.narration.addCurrentStepToHistory(),pixiVn.storage.setVariable(p,e.id);break;case "edittime":let t=pixiVn.storage.getVariable(m)||{};pixiVn.storage.setVariable(m,o.prev),pixiVn.narration.addCurrentStepToHistory(),pixiVn.storage.setVariable(m,t);break}}var Qe="__nqtr-activity__",g=class extends pixiVn.StoredClassModel{constructor(t,r,a,i=Qe){super(i,t);this._onRun=r;this._timeSlot=a.timeSlot,this._dateScheduling=a.dateScheduling;}_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}get run(){return async t=>(ge(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=d.currentDate)}get isActive(){return !(this.dateScheduling?.from&&this.dateScheduling.from>d.currentDate||this.dateScheduling?.to&&this.dateScheduling.to<d.currentDate||!d.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to))}};var B=class extends g{constructor(e,t,r){super(e,t,{dateScheduling:r.dateScheduling,timeSlot:r.timeSlot}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ne="__nqtr-commitment__",I=class extends g{constructor(t,r,a,i,n){i=i||(()=>{});super(t,i,n,Ne);this._characters=r;this._room=a;this.defaultExecutionType=n.executionType||"interaction",this.defaultPriority=n.priority;}defaultExecutionType;defaultPriority;get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(t){this.setStorageProperty("executionType",t);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(t){this.setStorageProperty("priority",t);}};var z=class extends I{constructor(e,t,r,a){super(e,t?Array.isArray(t)?t:[t]:[],r,a.onRun,{executionType:a.executionType,priority:a.priority,timeSlot:a.timeSlot,dateScheduling:a.dateScheduling}),this._name=a.name||"",this._image=a.image,this.defaultDisabled=a.disabled||false,this.defaultHidden=a.hidden||false,this._icon=a.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.dateScheduling?.from&&this.dateScheduling.from>d.currentDate||!d.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var h=class extends pixiVn.StoredClassModel{constructor(t,r,a=[]){super(t,r);this.defaultActivities=a;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let a=this.excludedActivitiesScheduling;delete a[t],this.setStorageProperty("excludedActivitiesScheduling",a);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let a=this.activeActivityScheduling;a[t]=r,this.setStorageProperty("activeActivityScheduling",a);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let a=this.excludedActivitiesScheduling;a[t]=r,this.setStorageProperty("excludedActivitiesScheduling",a);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{timeSlot:a,dateScheduling:i}=r,{to:n=d.dayEndTime+1}=a||{},s={timeSlot:{},dateScheduling:{}};if(a){if(a.from>=n)throw new Error("[NQTR] The from time must be less than the to time.");s.timeSlot.from=a.from;}if(i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(i?.from!==void 0&&(s.dateScheduling.from=i?.from),i?.to!==void 0&&(s.dateScheduling.to=i?.to),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let c=this.additionalActivitiesIds;if(c.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}c.push(t.id),this.setStorageProperty("additionalActivitiesIds",c),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}removeActivity(t,r={}){let{to:a}=r,i=typeof t=="string"?t:t.id,n={dateScheduling:{}};a!==void 0&&(n.dateScheduling.to=a);let s=this.additionalActivitiesIds;if(s.includes(i)){if(Object.keys(n).length){this.editExcludedActivityScheduling(i,n);return}s=s.filter(c=>c!==i),this.setStorageProperty("additionalActivitiesIds",s);}else if(this.defaultActivitiesIds.includes(i)){if(Object.keys(n).length){this.editExcludedActivityScheduling(i,n);return}let c=this.excludedActivitiesIds;c.push(i),this.setStorageProperty("excludedActivitiesIds",c);}else console.warn(`[NQTR] Activity with id ${i} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,a=this.additionalActivitiesIds,i=this.excludedActivitiesIds;a.forEach(n=>{if(n in t){let{to:s}=t[n].dateScheduling||{};s&&s<d.currentDate&&(this.removeActivityScheduling(n),a=a.filter(c=>c!==n));}}),i.forEach(n=>{if(n in r){let{to:s}=r[n].dateScheduling||{};s&&s<d.currentDate&&(this.removeActivityScheduling(n),i=i.filter(c=>c!==n));}});}get activities(){let t=[],r=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(a=>{let i=w.get(a),{dateScheduling:n,timeSlot:s}=r[a]||{},{from:c=i?.dateScheduling?.from,to:oe=i?.dateScheduling?.to}=n||{},{from:Re=i?.timeSlot?.from,to:_e=i?.timeSlot?.to}=s||{};i&&d.nowIsBetween(Re,_e)&&!(c&&c>d.currentDate)&&!(oe&&oe<d.currentDate)&&t.push(i);}),Object.entries(this.excludedActivitiesScheduling).forEach(([a,i])=>{let n=w.get(a);n&&n.isActive&&!(i.dateScheduling.to!==void 0&&i.dateScheduling.to>=d.currentDate)&&t.push(n);}),this.defaultActivities.forEach(a=>{a.isActive&&!t.find(i=>i.id===a.id)&&t.push(a);}),t}};var qe="__nqtr-location__",x=class extends h{constructor(t,r,a=[]){super(qe,t,a);this._map=r;}get map(){return this._map}get rooms(){return f.rooms.filter(t=>t.location.id===this.id)}};var Y=class extends x{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Le="__nqtr-map__",R=class extends h{constructor(e,t=[]){super(Le,e,t);}get locations(){return f.locations.filter(e=>e.map.id===this.id)}};var F=class extends R{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var $e="__nqtr-room__",_=class extends h{constructor(t,r,a=[]){super($e,t,a);this._location=r;}get routine(){return k.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}get characters(){let t=[];return this.routine.forEach(r=>{t.push(...r.characters);}),t}get automaticFunction(){let t=this.routine.find(r=>r.executionType==="automatic")?.run;if(t)return async r=>{await t(r);}}};var V=class extends _{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}get routine(){return k.currentRoutine.filter(e=>e.room.id===this.id)}};var Be="__nqtr-quest__",b=class extends pixiVn.StoredClassModel{constructor(t,r,a={}){super(Be,t);this._stages=r;this._onStart=a.onStart,this._onNextStage=a.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===void 0||t>=this.stages.length))return this.stages[t]}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(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}async start(t){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 r=this.currentStage;if(r&&r.start)return this.onStart&&await this.onStart(this,t),await r.start(t);u.error(`Quest ${this.id} has no start stage`);}async tryToGoNextStage(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.goNextStage(t):false:(u.error(`Quest ${this.id} has no current stage`),false)}async completeCurrentStageAndGoNext(t){let r=this.currentStage;return r?(r.completed=true,await this.goNextStage(t)):(u.error(`Quest ${this.id} has no current stage`),false)}async goNextStage(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,a=this.currentStageIndex;if(!r||a===void 0)return u.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=a+1,this.onNextStage&&await this.onNextStage(this,t),r&&r.onEnd&&await r.onEnd(r,t);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var H=class extends b{constructor(e,t,r){super(e,t,{onStart:r.onStart,onNextStage:r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};var Ye="__nqtr-stage__",T=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(Ye,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}_onStart;get onStart(){return this._onStart}_onEnd;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>d.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=d.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`);}_deltaDateRequired;get deltaDateRequired(){return this._deltaDateRequired||0}_questsRequired;get questsRequired(){return this._questsRequired||[]}};var G=class extends T{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired}),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||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequired;get flagsRequired(){return this._flagsRequired}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>pixiVn.storage.getFlag(e.flag))?false:super.canStart}};var Ie={};var xe={};var Fe={...ae,...te,...Ie,...ie,...xe},ei=Fe;exports.ActivityBaseModel=B;exports.ActivityStoredClass=g;exports.CommitmentBaseModel=z;exports.CommitmentStoredClass=I;exports.LocationBaseModel=Y;exports.LocationStoredClass=x;exports.MapBaseModel=F;exports.MapStoredClass=R;exports.QuestBaseModel=H;exports.QuestStoredClass=b;exports.RegisteredActivities=w;exports.RegisteredCommitments=S;exports.RegisteredLocations=E;exports.RegisteredMaps=D;exports.RegisteredQuests=Q;exports.RegisteredRooms=y;exports.RoomBaseModel=V;exports.RoomStoredClass=_;exports.StageBaseModel=G;exports.StageStoredClass=T;exports.default=ei;exports.navigator=f;exports.questsNotebook=we;exports.routine=k;exports.timeTracker=d;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|