@drincs/nqtr 0.0.1 → 0.0.3
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/LICENSE +674 -0
- package/README.md +11 -1
- package/dist/index.d.mts +104 -13
- package/dist/index.d.ts +104 -13
- package/dist/index.js +122 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Navigation Quest Time Routine for Pixi'VN
|
|
2
|
+
|
|
3
|
+
The Navigation Quest Time Routine (NQTR) is a library that introduces a navigation, quest, and time system to the Pixi'VN visual novel engine.
|
|
4
|
+
|
|
5
|
+
## Get Started
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @drincs/nqtr
|
|
11
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -507,14 +507,49 @@ declare function clearExpiredRoutine(): void;
|
|
|
507
507
|
declare function getCurrentCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[];
|
|
508
508
|
declare function getCommitmentByCharacter<TCommitment extends CommitmentBaseModel = CommitmentBaseModel, TCharacter extends CharacterBaseModel = CharacterBaseModel>(character: TCharacter): TCommitment | undefined;
|
|
509
509
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Time Settings, which can be set using `TimeManager.editSettings`
|
|
512
|
+
*/
|
|
513
|
+
interface TimeSettings {
|
|
514
|
+
/**
|
|
515
|
+
* Minimum hour of the day (default: 0)
|
|
516
|
+
*/
|
|
517
|
+
minDayHours?: number;
|
|
518
|
+
/**
|
|
519
|
+
* Maximum hour of the day (default: 24)
|
|
520
|
+
*/
|
|
521
|
+
maxDayHours?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Default time spent (default: 1)
|
|
524
|
+
*/
|
|
513
525
|
defaultTimeSpent?: number;
|
|
526
|
+
/**
|
|
527
|
+
* Time slots (default: [])
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* [
|
|
531
|
+
* { name: 'Morning', startHour: 5 },
|
|
532
|
+
* { name: 'Afternoon', startHour: 12 },
|
|
533
|
+
* { name: 'Evening', startHour: 18 },
|
|
534
|
+
* { name: 'Night', startHour: 22 }
|
|
535
|
+
* ]
|
|
536
|
+
*/
|
|
514
537
|
timeSlots?: ITimeStlot[];
|
|
538
|
+
/**
|
|
539
|
+
* Week length (default: 7)
|
|
540
|
+
*/
|
|
515
541
|
weekLength?: number;
|
|
516
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Weekend start day. For example, if the real life weekend starts on Saturday, then the value should be 6 (default: weekLength - 1)
|
|
544
|
+
*/
|
|
517
545
|
weekendStartDay?: number;
|
|
546
|
+
/**
|
|
547
|
+
* Week days names (default: [])
|
|
548
|
+
* @example
|
|
549
|
+
* ```ts
|
|
550
|
+
* ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
518
553
|
weekDaysNames?: string[];
|
|
519
554
|
}
|
|
520
555
|
interface ITimeStlot {
|
|
@@ -523,25 +558,81 @@ interface ITimeStlot {
|
|
|
523
558
|
}
|
|
524
559
|
declare class TimeManager {
|
|
525
560
|
private constructor();
|
|
526
|
-
static
|
|
527
|
-
|
|
528
|
-
|
|
561
|
+
private static editSettings;
|
|
562
|
+
/**
|
|
563
|
+
* Get time settings
|
|
564
|
+
*/
|
|
565
|
+
static get settings(): TimeSettings;
|
|
566
|
+
/**
|
|
567
|
+
* Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.
|
|
568
|
+
*/
|
|
569
|
+
static set settings(value: TimeSettings);
|
|
570
|
+
static get minDayHours(): number;
|
|
571
|
+
static get maxDayHours(): number;
|
|
529
572
|
static get defaultTimeSpent(): number;
|
|
530
|
-
static get newDayHour(): number;
|
|
531
573
|
static get timeSlots(): ITimeStlot[];
|
|
532
574
|
static get weekLength(): number;
|
|
533
575
|
static get weekendStartDay(): number;
|
|
534
576
|
static get weekDaysNames(): string[];
|
|
577
|
+
/**
|
|
578
|
+
* Get the current hour
|
|
579
|
+
*/
|
|
535
580
|
static get currentHour(): number;
|
|
536
581
|
static set currentHour(value: number | undefined);
|
|
582
|
+
/**
|
|
583
|
+
* Get the current day
|
|
584
|
+
*/
|
|
537
585
|
static get currentDay(): number;
|
|
538
586
|
static set currentDay(value: number | undefined);
|
|
587
|
+
/**
|
|
588
|
+
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
589
|
+
*/
|
|
539
590
|
static get isWeekend(): boolean;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
591
|
+
/**
|
|
592
|
+
* Get the current week day number (1-TimeManager.weekLength).
|
|
593
|
+
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
594
|
+
*/
|
|
595
|
+
static get currentWeekDayNumber(): number;
|
|
596
|
+
/**
|
|
597
|
+
* Get the current week day name. If the week days names are not defined, then it will return undefined.
|
|
598
|
+
* For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
|
|
599
|
+
*/
|
|
600
|
+
static get currentDayName(): string | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* Get the current TimeManager.timeSlots index.
|
|
603
|
+
* You can use this property to create "Image that changes based on the time period":
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* import { TimeManager } from '@drincs/nqtr';
|
|
607
|
+
*
|
|
608
|
+
* function changeBackground() {
|
|
609
|
+
* return (
|
|
610
|
+
* <img src={`background-${TimeManager.currentTimeSlot}.png`} />
|
|
611
|
+
* )
|
|
612
|
+
* }
|
|
613
|
+
*/
|
|
614
|
+
static get currentTimeSlots(): number;
|
|
615
|
+
/**
|
|
616
|
+
* This function will increase the current hour by the given time spent.
|
|
617
|
+
* If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.
|
|
618
|
+
* @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)
|
|
619
|
+
* @returns TimeManager.currentHour
|
|
620
|
+
*/
|
|
621
|
+
static increaseHour(timeSpent?: number): number;
|
|
622
|
+
/**
|
|
623
|
+
* This function will increase the current day by the given days.
|
|
624
|
+
* @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)
|
|
625
|
+
* @param days is the number of days to increase (default: 1)
|
|
626
|
+
* @returns TimeManager.currentDay
|
|
627
|
+
*/
|
|
628
|
+
static increaseDay(newDayHour?: number, days?: number): number;
|
|
629
|
+
/**
|
|
630
|
+
* This function will check if the current hour is between the given hours.
|
|
631
|
+
* @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.
|
|
632
|
+
* @param toHour the ending hour.
|
|
633
|
+
* @returns true if the current hour is between the given hours, otherwise false.
|
|
634
|
+
*/
|
|
544
635
|
static nowIsBetween(fromHour: number, toHour: number): boolean;
|
|
545
636
|
}
|
|
546
637
|
|
|
547
|
-
export { ActivityModel, type ActivityProps, ExecutionTypeEnum,
|
|
638
|
+
export { ActivityModel, type ActivityProps, ExecutionTypeEnum, Goal, type GoalProps, LocationBaseModel, type LocationBaseModelProps, MapBaseModel, type MapBaseModelProps, QuestBaseModel, type QuestBaseModelProps, type QuestsRequiredType, RoomBaseModel, type RoomBaseModelProps, StageBaseModel, type StageBaseModelProps, TimeManager, type TimeSettings, addTemporaryCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getCommitmentByCharacter, getCommitmentById, getCueerntMap, getCurrenrLocation, getCurrentCommitments, getCurrentRoom, getFixedCommitments, getRoomById, getTemporaryCommitments, saveActivity, saveCommitment, saveRoom, setCurrentRoom, setFixedCommitments };
|
package/dist/index.d.ts
CHANGED
|
@@ -507,14 +507,49 @@ declare function clearExpiredRoutine(): void;
|
|
|
507
507
|
declare function getCurrentCommitments<TCommitment extends CommitmentBaseModel = CommitmentBaseModel>(): TCommitment[];
|
|
508
508
|
declare function getCommitmentByCharacter<TCommitment extends CommitmentBaseModel = CommitmentBaseModel, TCharacter extends CharacterBaseModel = CharacterBaseModel>(character: TCharacter): TCommitment | undefined;
|
|
509
509
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Time Settings, which can be set using `TimeManager.editSettings`
|
|
512
|
+
*/
|
|
513
|
+
interface TimeSettings {
|
|
514
|
+
/**
|
|
515
|
+
* Minimum hour of the day (default: 0)
|
|
516
|
+
*/
|
|
517
|
+
minDayHours?: number;
|
|
518
|
+
/**
|
|
519
|
+
* Maximum hour of the day (default: 24)
|
|
520
|
+
*/
|
|
521
|
+
maxDayHours?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Default time spent (default: 1)
|
|
524
|
+
*/
|
|
513
525
|
defaultTimeSpent?: number;
|
|
526
|
+
/**
|
|
527
|
+
* Time slots (default: [])
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* [
|
|
531
|
+
* { name: 'Morning', startHour: 5 },
|
|
532
|
+
* { name: 'Afternoon', startHour: 12 },
|
|
533
|
+
* { name: 'Evening', startHour: 18 },
|
|
534
|
+
* { name: 'Night', startHour: 22 }
|
|
535
|
+
* ]
|
|
536
|
+
*/
|
|
514
537
|
timeSlots?: ITimeStlot[];
|
|
538
|
+
/**
|
|
539
|
+
* Week length (default: 7)
|
|
540
|
+
*/
|
|
515
541
|
weekLength?: number;
|
|
516
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Weekend start day. For example, if the real life weekend starts on Saturday, then the value should be 6 (default: weekLength - 1)
|
|
544
|
+
*/
|
|
517
545
|
weekendStartDay?: number;
|
|
546
|
+
/**
|
|
547
|
+
* Week days names (default: [])
|
|
548
|
+
* @example
|
|
549
|
+
* ```ts
|
|
550
|
+
* ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
518
553
|
weekDaysNames?: string[];
|
|
519
554
|
}
|
|
520
555
|
interface ITimeStlot {
|
|
@@ -523,25 +558,81 @@ interface ITimeStlot {
|
|
|
523
558
|
}
|
|
524
559
|
declare class TimeManager {
|
|
525
560
|
private constructor();
|
|
526
|
-
static
|
|
527
|
-
|
|
528
|
-
|
|
561
|
+
private static editSettings;
|
|
562
|
+
/**
|
|
563
|
+
* Get time settings
|
|
564
|
+
*/
|
|
565
|
+
static get settings(): TimeSettings;
|
|
566
|
+
/**
|
|
567
|
+
* Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.
|
|
568
|
+
*/
|
|
569
|
+
static set settings(value: TimeSettings);
|
|
570
|
+
static get minDayHours(): number;
|
|
571
|
+
static get maxDayHours(): number;
|
|
529
572
|
static get defaultTimeSpent(): number;
|
|
530
|
-
static get newDayHour(): number;
|
|
531
573
|
static get timeSlots(): ITimeStlot[];
|
|
532
574
|
static get weekLength(): number;
|
|
533
575
|
static get weekendStartDay(): number;
|
|
534
576
|
static get weekDaysNames(): string[];
|
|
577
|
+
/**
|
|
578
|
+
* Get the current hour
|
|
579
|
+
*/
|
|
535
580
|
static get currentHour(): number;
|
|
536
581
|
static set currentHour(value: number | undefined);
|
|
582
|
+
/**
|
|
583
|
+
* Get the current day
|
|
584
|
+
*/
|
|
537
585
|
static get currentDay(): number;
|
|
538
586
|
static set currentDay(value: number | undefined);
|
|
587
|
+
/**
|
|
588
|
+
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
589
|
+
*/
|
|
539
590
|
static get isWeekend(): boolean;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
591
|
+
/**
|
|
592
|
+
* Get the current week day number (1-TimeManager.weekLength).
|
|
593
|
+
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
594
|
+
*/
|
|
595
|
+
static get currentWeekDayNumber(): number;
|
|
596
|
+
/**
|
|
597
|
+
* Get the current week day name. If the week days names are not defined, then it will return undefined.
|
|
598
|
+
* For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
|
|
599
|
+
*/
|
|
600
|
+
static get currentDayName(): string | undefined;
|
|
601
|
+
/**
|
|
602
|
+
* Get the current TimeManager.timeSlots index.
|
|
603
|
+
* You can use this property to create "Image that changes based on the time period":
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* import { TimeManager } from '@drincs/nqtr';
|
|
607
|
+
*
|
|
608
|
+
* function changeBackground() {
|
|
609
|
+
* return (
|
|
610
|
+
* <img src={`background-${TimeManager.currentTimeSlot}.png`} />
|
|
611
|
+
* )
|
|
612
|
+
* }
|
|
613
|
+
*/
|
|
614
|
+
static get currentTimeSlots(): number;
|
|
615
|
+
/**
|
|
616
|
+
* This function will increase the current hour by the given time spent.
|
|
617
|
+
* If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.
|
|
618
|
+
* @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)
|
|
619
|
+
* @returns TimeManager.currentHour
|
|
620
|
+
*/
|
|
621
|
+
static increaseHour(timeSpent?: number): number;
|
|
622
|
+
/**
|
|
623
|
+
* This function will increase the current day by the given days.
|
|
624
|
+
* @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)
|
|
625
|
+
* @param days is the number of days to increase (default: 1)
|
|
626
|
+
* @returns TimeManager.currentDay
|
|
627
|
+
*/
|
|
628
|
+
static increaseDay(newDayHour?: number, days?: number): number;
|
|
629
|
+
/**
|
|
630
|
+
* This function will check if the current hour is between the given hours.
|
|
631
|
+
* @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.
|
|
632
|
+
* @param toHour the ending hour.
|
|
633
|
+
* @returns true if the current hour is between the given hours, otherwise false.
|
|
634
|
+
*/
|
|
544
635
|
static nowIsBetween(fromHour: number, toHour: number): boolean;
|
|
545
636
|
}
|
|
546
637
|
|
|
547
|
-
export { ActivityModel, type ActivityProps, ExecutionTypeEnum,
|
|
638
|
+
export { ActivityModel, type ActivityProps, ExecutionTypeEnum, Goal, type GoalProps, LocationBaseModel, type LocationBaseModelProps, MapBaseModel, type MapBaseModelProps, QuestBaseModel, type QuestBaseModelProps, type QuestsRequiredType, RoomBaseModel, type RoomBaseModelProps, StageBaseModel, type StageBaseModelProps, TimeManager, type TimeSettings, addTemporaryCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getCommitmentByCharacter, getCommitmentById, getCueerntMap, getCurrenrLocation, getCurrentCommitments, getCurrentRoom, getFixedCommitments, getRoomById, getTemporaryCommitments, saveActivity, saveCommitment, saveRoom, setCurrentRoom, setFixedCommitments };
|
package/dist/index.js
CHANGED
|
@@ -36,13 +36,13 @@ var src_exports = {};
|
|
|
36
36
|
__export(src_exports, {
|
|
37
37
|
ActivityModel: () => ActivityModel,
|
|
38
38
|
ExecutionTypeEnum: () => ExecutionTypeEnum,
|
|
39
|
-
GameStepManager: () => TimeManager,
|
|
40
39
|
Goal: () => Goal,
|
|
41
40
|
LocationBaseModel: () => LocationBaseModel,
|
|
42
41
|
MapBaseModel: () => MapBaseModel,
|
|
43
42
|
QuestBaseModel: () => QuestBaseModel,
|
|
44
43
|
RoomBaseModel: () => RoomBaseModel,
|
|
45
44
|
StageBaseModel: () => StageBaseModel,
|
|
45
|
+
TimeManager: () => TimeManager,
|
|
46
46
|
addTemporaryCommitment: () => addTemporaryCommitment,
|
|
47
47
|
clearExpiredActivities: () => clearExpiredActivities,
|
|
48
48
|
clearExpiredRoutine: () => clearExpiredRoutine,
|
|
@@ -75,55 +75,65 @@ var TIME_DATA_KEY = "___nqtr-time_manager_data___";
|
|
|
75
75
|
var TimeManager = class _TimeManager {
|
|
76
76
|
constructor() {
|
|
77
77
|
}
|
|
78
|
-
static
|
|
79
|
-
let
|
|
80
|
-
if (typeof
|
|
81
|
-
|
|
78
|
+
static editSettings(settings) {
|
|
79
|
+
let data = {};
|
|
80
|
+
if (typeof settings.minDayHours === "number") {
|
|
81
|
+
data["minDayHours"] = settings.minDayHours;
|
|
82
82
|
}
|
|
83
|
-
if (typeof
|
|
84
|
-
|
|
83
|
+
if (typeof settings.maxDayHours === "number") {
|
|
84
|
+
data["maxDayHours"] = settings.maxDayHours;
|
|
85
85
|
}
|
|
86
|
-
if (typeof
|
|
87
|
-
|
|
86
|
+
if (typeof settings.minDayHours === "number") {
|
|
87
|
+
data["defaultTimeSpent"] = settings.defaultTimeSpent;
|
|
88
88
|
}
|
|
89
|
-
if (Array.isArray(
|
|
90
|
-
|
|
89
|
+
if (Array.isArray(settings.timeSlots)) {
|
|
90
|
+
data["timeSlots"] = settings.timeSlots;
|
|
91
91
|
}
|
|
92
|
-
if (typeof
|
|
93
|
-
|
|
92
|
+
if (typeof settings.weekLength === "number") {
|
|
93
|
+
data["weekLength"] = settings.weekLength;
|
|
94
94
|
}
|
|
95
|
-
if (typeof
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (typeof value.weekendStartDay === "number") {
|
|
99
|
-
let weekLength = value.weekLength || _TimeManager.weekLength;
|
|
100
|
-
if (value.weekendStartDay >= weekLength) {
|
|
95
|
+
if (typeof settings.weekendStartDay === "number") {
|
|
96
|
+
let weekLength = settings.weekLength || _TimeManager.weekLength;
|
|
97
|
+
if (settings.weekendStartDay >= weekLength) {
|
|
101
98
|
console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`);
|
|
102
99
|
}
|
|
103
|
-
|
|
100
|
+
data["weekendStartDay"] = settings.weekendStartDay;
|
|
104
101
|
}
|
|
105
|
-
if (Array.isArray(
|
|
106
|
-
let weekLength =
|
|
107
|
-
if (
|
|
102
|
+
if (Array.isArray(settings.weekDaysNames)) {
|
|
103
|
+
let weekLength = settings.weekLength || _TimeManager.weekLength;
|
|
104
|
+
if (settings.weekDaysNames.length !== weekLength) {
|
|
108
105
|
console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`);
|
|
109
106
|
}
|
|
110
|
-
|
|
107
|
+
data["weekDaysNames"] = settings.weekDaysNames;
|
|
111
108
|
}
|
|
112
|
-
import_pixi_vn.GameStorageManager.setVariable(TIME_SETTINGS_KEY,
|
|
113
|
-
}
|
|
114
|
-
|
|
109
|
+
import_pixi_vn.GameStorageManager.setVariable(TIME_SETTINGS_KEY, data);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get time settings
|
|
113
|
+
*/
|
|
114
|
+
static get settings() {
|
|
115
|
+
let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY) || {};
|
|
116
|
+
return settings;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.
|
|
120
|
+
*/
|
|
121
|
+
static set settings(value) {
|
|
122
|
+
_TimeManager.editSettings(value);
|
|
123
|
+
}
|
|
124
|
+
static get minDayHours() {
|
|
115
125
|
let result = 0;
|
|
116
126
|
let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
117
|
-
if (settings && settings.hasOwnProperty("
|
|
118
|
-
result = settings.
|
|
127
|
+
if (settings && settings.hasOwnProperty("minDayHours")) {
|
|
128
|
+
result = settings.minDayHours || 0;
|
|
119
129
|
}
|
|
120
130
|
return result;
|
|
121
131
|
}
|
|
122
|
-
static get
|
|
132
|
+
static get maxDayHours() {
|
|
123
133
|
let result = 24;
|
|
124
134
|
let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
125
|
-
if (settings && settings.hasOwnProperty("
|
|
126
|
-
result = settings.
|
|
135
|
+
if (settings && settings.hasOwnProperty("maxDayHours")) {
|
|
136
|
+
result = settings.maxDayHours || 24;
|
|
127
137
|
}
|
|
128
138
|
return result;
|
|
129
139
|
}
|
|
@@ -135,14 +145,6 @@ var TimeManager = class _TimeManager {
|
|
|
135
145
|
}
|
|
136
146
|
return result;
|
|
137
147
|
}
|
|
138
|
-
static get newDayHour() {
|
|
139
|
-
let result = 0;
|
|
140
|
-
let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
141
|
-
if (settings && settings.hasOwnProperty("newDayHour")) {
|
|
142
|
-
result = settings.newDayHour || 0;
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
148
|
static get timeSlots() {
|
|
147
149
|
let result = [];
|
|
148
150
|
let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
@@ -175,12 +177,15 @@ var TimeManager = class _TimeManager {
|
|
|
175
177
|
}
|
|
176
178
|
return result;
|
|
177
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Get the current hour
|
|
182
|
+
*/
|
|
178
183
|
static get currentHour() {
|
|
179
184
|
let data = import_pixi_vn.GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
180
185
|
if (data.hasOwnProperty("currentHour") && typeof data.currentHour === "number") {
|
|
181
186
|
return data.currentHour;
|
|
182
187
|
}
|
|
183
|
-
return _TimeManager.
|
|
188
|
+
return _TimeManager.minDayHours;
|
|
184
189
|
}
|
|
185
190
|
static set currentHour(value) {
|
|
186
191
|
let data = import_pixi_vn.GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
@@ -191,6 +196,9 @@ var TimeManager = class _TimeManager {
|
|
|
191
196
|
}
|
|
192
197
|
import_pixi_vn.GameStorageManager.setVariable(TIME_DATA_KEY, data);
|
|
193
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the current day
|
|
201
|
+
*/
|
|
194
202
|
static get currentDay() {
|
|
195
203
|
let data = import_pixi_vn.GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
196
204
|
if (data.hasOwnProperty("currentDay") && typeof data.currentDay === "number") {
|
|
@@ -207,35 +215,92 @@ var TimeManager = class _TimeManager {
|
|
|
207
215
|
}
|
|
208
216
|
import_pixi_vn.GameStorageManager.setVariable(TIME_DATA_KEY, data);
|
|
209
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
220
|
+
*/
|
|
210
221
|
static get isWeekend() {
|
|
211
|
-
return _TimeManager.
|
|
222
|
+
return _TimeManager.currentWeekDayNumber >= _TimeManager.weekendStartDay;
|
|
212
223
|
}
|
|
213
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Get the current week day number (1-TimeManager.weekLength).
|
|
226
|
+
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
227
|
+
*/
|
|
228
|
+
static get currentWeekDayNumber() {
|
|
214
229
|
let result = _TimeManager.currentDay % _TimeManager.weekLength;
|
|
215
230
|
return result + 1;
|
|
216
231
|
}
|
|
217
|
-
|
|
218
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Get the current week day name. If the week days names are not defined, then it will return undefined.
|
|
234
|
+
* For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
|
|
235
|
+
*/
|
|
236
|
+
static get currentDayName() {
|
|
237
|
+
let weekDayNumber = _TimeManager.currentWeekDayNumber - 1;
|
|
219
238
|
if (weekDayNumber >= _TimeManager.weekDaysNames.length) {
|
|
220
239
|
console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, _TimeManager.weekDaysNames);
|
|
221
240
|
return void 0;
|
|
222
241
|
}
|
|
223
242
|
return _TimeManager.weekDaysNames[weekDayNumber];
|
|
224
243
|
}
|
|
225
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Get the current TimeManager.timeSlots index.
|
|
246
|
+
* You can use this property to create "Image that changes based on the time period":
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* import { TimeManager } from '@drincs/nqtr';
|
|
250
|
+
*
|
|
251
|
+
* function changeBackground() {
|
|
252
|
+
* return (
|
|
253
|
+
* <img src={`background-${TimeManager.currentTimeSlot}.png`} />
|
|
254
|
+
* )
|
|
255
|
+
* }
|
|
256
|
+
*/
|
|
257
|
+
static get currentTimeSlots() {
|
|
258
|
+
if (_TimeManager.timeSlots.length === 0) {
|
|
259
|
+
console.warn("[NQTR] Time slots are not defined");
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
_TimeManager.timeSlots.forEach((slot, index) => {
|
|
263
|
+
if (_TimeManager.timeSlots.length > index + 1) {
|
|
264
|
+
if (_TimeManager.nowIsBetween(slot.startHour, _TimeManager.timeSlots[index + 1].startHour)) {
|
|
265
|
+
return index;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* This function will increase the current hour by the given time spent.
|
|
273
|
+
* If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.
|
|
274
|
+
* @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)
|
|
275
|
+
* @returns TimeManager.currentHour
|
|
276
|
+
*/
|
|
277
|
+
static increaseHour(timeSpent = _TimeManager.defaultTimeSpent) {
|
|
226
278
|
let newHour = _TimeManager.currentHour + timeSpent;
|
|
227
|
-
if (newHour >= _TimeManager.
|
|
228
|
-
_TimeManager.
|
|
229
|
-
newHour = _TimeManager.
|
|
279
|
+
if (newHour >= _TimeManager.maxDayHours) {
|
|
280
|
+
_TimeManager.increaseDay();
|
|
281
|
+
newHour = _TimeManager.minDayHours + (newHour - _TimeManager.maxDayHours);
|
|
230
282
|
}
|
|
231
283
|
_TimeManager.currentHour = newHour;
|
|
232
|
-
return
|
|
233
|
-
}
|
|
234
|
-
|
|
284
|
+
return _TimeManager.currentHour;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* This function will increase the current day by the given days.
|
|
288
|
+
* @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)
|
|
289
|
+
* @param days is the number of days to increase (default: 1)
|
|
290
|
+
* @returns TimeManager.currentDay
|
|
291
|
+
*/
|
|
292
|
+
static increaseDay(newDayHour = _TimeManager.minDayHours, days = 1) {
|
|
235
293
|
let newDay = _TimeManager.currentDay + days;
|
|
236
294
|
_TimeManager.currentDay = newDay;
|
|
237
|
-
|
|
238
|
-
|
|
295
|
+
_TimeManager.currentHour = newDayHour;
|
|
296
|
+
return _TimeManager.currentDay;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* This function will check if the current hour is between the given hours.
|
|
300
|
+
* @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.
|
|
301
|
+
* @param toHour the ending hour.
|
|
302
|
+
* @returns true if the current hour is between the given hours, otherwise false.
|
|
303
|
+
*/
|
|
239
304
|
static nowIsBetween(fromHour, toHour) {
|
|
240
305
|
let currentHour = _TimeManager.currentHour;
|
|
241
306
|
if (fromHour < toHour) {
|
|
@@ -265,13 +330,13 @@ var ActivityStoredAbstract = class {
|
|
|
265
330
|
this.setStorageProperty("name", value);
|
|
266
331
|
}
|
|
267
332
|
get fromHour() {
|
|
268
|
-
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.
|
|
333
|
+
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
269
334
|
}
|
|
270
335
|
set fromHour(value) {
|
|
271
336
|
this.setStorageProperty("fromHour", value);
|
|
272
337
|
}
|
|
273
338
|
get toHour() {
|
|
274
|
-
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.
|
|
339
|
+
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
275
340
|
}
|
|
276
341
|
set toHour(value) {
|
|
277
342
|
this.setStorageProperty("toHour", value);
|
|
@@ -1078,13 +1143,13 @@ function currentActivities() {
|
|
|
1078
1143
|
0 && (module.exports = {
|
|
1079
1144
|
ActivityModel,
|
|
1080
1145
|
ExecutionTypeEnum,
|
|
1081
|
-
GameStepManager,
|
|
1082
1146
|
Goal,
|
|
1083
1147
|
LocationBaseModel,
|
|
1084
1148
|
MapBaseModel,
|
|
1085
1149
|
QuestBaseModel,
|
|
1086
1150
|
RoomBaseModel,
|
|
1087
1151
|
StageBaseModel,
|
|
1152
|
+
TimeManager,
|
|
1088
1153
|
addTemporaryCommitment,
|
|
1089
1154
|
clearExpiredActivities,
|
|
1090
1155
|
clearExpiredRoutine,
|