@drincs/nqtr 0.2.12 → 0.2.13
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/{ActivityProps-BkHX8xkA.d.ts → ActivityProps-LWY7Zucl.d.ts} +2 -2
- package/dist/{ActivityProps-D45DQdcT.d.mts → ActivityProps-WgXDAYbc.d.mts} +2 -2
- package/dist/{Commitment-DJD0f8AH.d.mts → Commitment-BujJuTv8.d.mts} +7 -7
- package/dist/{Commitment-C_qBgeF9.d.ts → Commitment-DFYAApxl.d.ts} +7 -7
- package/dist/{StageProps-CuE_n1Wg.d.mts → StageProps-CqgBUi3e.d.mts} +1 -1
- package/dist/{StageProps-CCjGI625.d.ts → StageProps-DghO7WaT.d.ts} +1 -1
- package/dist/classes/Activity.d.mts +1 -1
- package/dist/classes/Activity.d.ts +1 -1
- package/dist/classes/Activity.js +1 -381
- package/dist/classes/Activity.js.map +1 -1
- package/dist/classes/Activity.mjs +1 -379
- package/dist/classes/Activity.mjs.map +1 -1
- package/dist/classes/ActivityStoredAbstract.d.mts +1 -1
- package/dist/classes/ActivityStoredAbstract.d.ts +1 -1
- package/dist/classes/ActivityStoredAbstract.js +1 -398
- package/dist/classes/ActivityStoredAbstract.js.map +1 -1
- package/dist/classes/ActivityStoredAbstract.mjs +1 -396
- package/dist/classes/ActivityStoredAbstract.mjs.map +1 -1
- package/dist/classes/Commitment.d.mts +2 -2
- package/dist/classes/Commitment.d.ts +2 -2
- package/dist/classes/Commitment.js +1 -438
- package/dist/classes/Commitment.js.map +1 -1
- package/dist/classes/Commitment.mjs +1 -436
- package/dist/classes/Commitment.mjs.map +1 -1
- package/dist/classes/index.d.mts +3 -3
- package/dist/classes/index.d.ts +3 -3
- package/dist/classes/index.js +1 -1700
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +1 -1691
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/navigation/ActivityRoom.d.mts +2 -2
- package/dist/classes/navigation/ActivityRoom.d.ts +2 -2
- package/dist/classes/navigation/ActivityRoom.js +1 -448
- package/dist/classes/navigation/ActivityRoom.js.map +1 -1
- package/dist/classes/navigation/ActivityRoom.mjs +1 -446
- package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
- package/dist/classes/navigation/Location.d.mts +2 -2
- package/dist/classes/navigation/Location.d.ts +2 -2
- package/dist/classes/navigation/Location.js +1 -118
- package/dist/classes/navigation/Location.js.map +1 -1
- package/dist/classes/navigation/Location.mjs +1 -116
- package/dist/classes/navigation/Location.mjs.map +1 -1
- package/dist/classes/navigation/Map.d.mts +2 -2
- package/dist/classes/navigation/Map.d.ts +2 -2
- package/dist/classes/navigation/Map.js +1 -114
- package/dist/classes/navigation/Map.js.map +1 -1
- package/dist/classes/navigation/Map.mjs +1 -112
- package/dist/classes/navigation/Map.mjs.map +1 -1
- package/dist/classes/navigation/Room.d.mts +2 -2
- package/dist/classes/navigation/Room.d.ts +2 -2
- package/dist/classes/navigation/Room.js +1 -778
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +1 -773
- package/dist/classes/navigation/Room.mjs.map +1 -1
- package/dist/classes/quest/Goal.js +1 -85
- package/dist/classes/quest/Goal.js.map +1 -1
- package/dist/classes/quest/Goal.mjs +1 -80
- package/dist/classes/quest/Goal.mjs.map +1 -1
- package/dist/classes/quest/Quest.d.mts +1 -1
- package/dist/classes/quest/Quest.d.ts +1 -1
- package/dist/classes/quest/Quest.js +1 -769
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +1 -767
- package/dist/classes/quest/Quest.mjs.map +1 -1
- package/dist/classes/quest/Stage.d.mts +1 -1
- package/dist/classes/quest/Stage.d.ts +1 -1
- package/dist/classes/quest/Stage.js +1 -536
- package/dist/classes/quest/Stage.js.map +1 -1
- package/dist/classes/quest/Stage.mjs +1 -531
- package/dist/classes/quest/Stage.mjs.map +1 -1
- package/dist/constants.d.mts +4 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +2 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/decorators/ActivityDecorator.d.mts +1 -1
- package/dist/decorators/ActivityDecorator.d.ts +1 -1
- package/dist/decorators/ActivityDecorator.js +1 -407
- package/dist/decorators/ActivityDecorator.js.map +1 -1
- package/dist/decorators/ActivityDecorator.mjs +1 -403
- package/dist/decorators/ActivityDecorator.mjs.map +1 -1
- package/dist/decorators/CommitmentDecorator.d.mts +2 -2
- package/dist/decorators/CommitmentDecorator.d.ts +2 -2
- package/dist/decorators/CommitmentDecorator.js +1 -91
- package/dist/decorators/CommitmentDecorator.js.map +1 -1
- package/dist/decorators/CommitmentDecorator.mjs +1 -81
- package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
- package/dist/decorators/QuestDecorator.d.mts +1 -1
- package/dist/decorators/QuestDecorator.d.ts +1 -1
- package/dist/decorators/QuestDecorator.js +1 -799
- package/dist/decorators/QuestDecorator.js.map +1 -1
- package/dist/decorators/QuestDecorator.mjs +1 -794
- package/dist/decorators/QuestDecorator.mjs.map +1 -1
- package/dist/decorators/RoomDecorator.d.mts +2 -2
- package/dist/decorators/RoomDecorator.d.ts +2 -2
- package/dist/decorators/RoomDecorator.js +1 -56
- package/dist/decorators/RoomDecorator.js.map +1 -1
- package/dist/decorators/RoomDecorator.mjs +1 -48
- package/dist/decorators/RoomDecorator.mjs.map +1 -1
- package/dist/decorators/index.d.mts +3 -3
- package/dist/decorators/index.d.ts +3 -3
- package/dist/decorators/index.js +1 -1068
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +1 -1053
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/ActivityFunctions.d.mts +2 -2
- package/dist/functions/ActivityFunctions.d.ts +2 -2
- package/dist/functions/ActivityFunctions.js +1 -53
- package/dist/functions/ActivityFunctions.js.map +1 -1
- package/dist/functions/ActivityFunctions.mjs +1 -50
- package/dist/functions/ActivityFunctions.mjs.map +1 -1
- package/dist/functions/NavigationFunctions.d.mts +2 -2
- package/dist/functions/NavigationFunctions.d.ts +2 -2
- package/dist/functions/NavigationFunctions.js +1 -181
- package/dist/functions/NavigationFunctions.js.map +1 -1
- package/dist/functions/NavigationFunctions.mjs +1 -176
- package/dist/functions/NavigationFunctions.mjs.map +1 -1
- package/dist/functions/QuestFunctions.js +1 -20
- package/dist/functions/QuestFunctions.js.map +1 -1
- package/dist/functions/QuestFunctions.mjs +1 -18
- package/dist/functions/QuestFunctions.mjs.map +1 -1
- package/dist/functions/RoutineFunctions.d.mts +4 -4
- package/dist/functions/RoutineFunctions.d.ts +4 -4
- package/dist/functions/RoutineFunctions.js +1 -126
- package/dist/functions/RoutineFunctions.js.map +1 -1
- package/dist/functions/RoutineFunctions.mjs +1 -121
- package/dist/functions/RoutineFunctions.mjs.map +1 -1
- package/dist/functions/index.d.mts +2 -2
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/index.js +1 -293
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +1 -281
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +55 -13
- package/dist/index.d.ts +55 -13
- package/dist/index.js +1 -2058
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -2023
- package/dist/index.mjs.map +1 -1
- package/dist/interface/ActivityProps.d.mts +1 -1
- package/dist/interface/ActivityProps.d.ts +1 -1
- package/dist/interface/ActivityProps.js +1 -3
- package/dist/interface/ActivityProps.js.map +1 -1
- package/dist/interface/ActivityProps.mjs +1 -2
- package/dist/interface/ActivityProps.mjs.map +1 -1
- package/dist/interface/CommitmentProps.d.mts +2 -2
- package/dist/interface/CommitmentProps.d.ts +2 -2
- package/dist/interface/CommitmentProps.js +1 -3
- package/dist/interface/CommitmentProps.js.map +1 -1
- package/dist/interface/CommitmentProps.mjs +1 -2
- package/dist/interface/CommitmentProps.mjs.map +1 -1
- package/dist/interface/RoomActivityMemory.d.mts +1 -1
- package/dist/interface/RoomActivityMemory.d.ts +1 -1
- package/dist/interface/RoomActivityMemory.js +1 -3
- package/dist/interface/RoomActivityMemory.js.map +1 -1
- package/dist/interface/RoomActivityMemory.mjs +1 -2
- package/dist/interface/RoomActivityMemory.mjs.map +1 -1
- package/dist/interface/RoomProps.d.mts +2 -2
- package/dist/interface/RoomProps.d.ts +2 -2
- package/dist/interface/RoomProps.js +1 -3
- package/dist/interface/RoomProps.js.map +1 -1
- package/dist/interface/RoomProps.mjs +1 -2
- package/dist/interface/RoomProps.mjs.map +1 -1
- package/dist/interface/index.d.mts +3 -3
- package/dist/interface/index.d.ts +3 -3
- package/dist/interface/index.js +1 -3
- package/dist/interface/index.js.map +1 -1
- package/dist/interface/index.mjs +1 -2
- package/dist/interface/index.mjs.map +1 -1
- package/dist/interface/navigation/LocationProps.d.mts +2 -2
- package/dist/interface/navigation/LocationProps.d.ts +2 -2
- package/dist/interface/navigation/LocationProps.js +1 -3
- package/dist/interface/navigation/LocationProps.js.map +1 -1
- package/dist/interface/navigation/LocationProps.mjs +1 -2
- package/dist/interface/navigation/LocationProps.mjs.map +1 -1
- package/dist/interface/navigation/MapProps.d.mts +2 -2
- package/dist/interface/navigation/MapProps.d.ts +2 -2
- package/dist/interface/navigation/MapProps.js +1 -3
- package/dist/interface/navigation/MapProps.js.map +1 -1
- package/dist/interface/navigation/MapProps.mjs +1 -2
- package/dist/interface/navigation/MapProps.mjs.map +1 -1
- package/dist/interface/quest/GoalProps.js +1 -3
- package/dist/interface/quest/GoalProps.js.map +1 -1
- package/dist/interface/quest/GoalProps.mjs +1 -2
- package/dist/interface/quest/GoalProps.mjs.map +1 -1
- package/dist/interface/quest/QuestProps.d.mts +1 -1
- package/dist/interface/quest/QuestProps.d.ts +1 -1
- package/dist/interface/quest/QuestProps.js +1 -3
- package/dist/interface/quest/QuestProps.js.map +1 -1
- package/dist/interface/quest/QuestProps.mjs +1 -2
- package/dist/interface/quest/QuestProps.mjs.map +1 -1
- package/dist/interface/quest/StageFlags.js +1 -3
- package/dist/interface/quest/StageFlags.js.map +1 -1
- package/dist/interface/quest/StageFlags.mjs +1 -2
- package/dist/interface/quest/StageFlags.mjs.map +1 -1
- package/dist/interface/quest/StageProps.d.mts +1 -1
- package/dist/interface/quest/StageProps.d.ts +1 -1
- package/dist/interface/quest/StageProps.js +1 -3
- package/dist/interface/quest/StageProps.js.map +1 -1
- package/dist/interface/quest/StageProps.mjs +1 -2
- package/dist/interface/quest/StageProps.mjs.map +1 -1
- package/dist/managers/TimeManager.d.mts +30 -31
- package/dist/managers/TimeManager.d.ts +30 -31
- package/dist/managers/TimeManager.js +1 -250
- package/dist/managers/TimeManager.js.map +1 -1
- package/dist/managers/TimeManager.mjs +1 -248
- package/dist/managers/TimeManager.mjs.map +1 -1
- package/dist/managers/index.d.mts +5 -1
- package/dist/managers/index.d.ts +5 -1
- package/dist/managers/index.js +1 -250
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/index.mjs +1 -248
- package/dist/managers/index.mjs.map +1 -1
- package/dist/override/GraphicItemInterface.js +1 -3
- package/dist/override/GraphicItemInterface.js.map +1 -1
- package/dist/override/GraphicItemInterface.mjs +1 -2
- package/dist/override/GraphicItemInterface.mjs.map +1 -1
- package/dist/override/GraphicItemType.d.mts +2 -2
- package/dist/override/GraphicItemType.d.ts +2 -2
- package/dist/override/GraphicItemType.js +1 -3
- package/dist/override/GraphicItemType.js.map +1 -1
- package/dist/override/GraphicItemType.mjs +1 -2
- package/dist/override/GraphicItemType.mjs.map +1 -1
- package/dist/override/NeighboringMapsInterface.js +1 -3
- package/dist/override/NeighboringMapsInterface.js.map +1 -1
- package/dist/override/NeighboringMapsInterface.mjs +1 -2
- package/dist/override/NeighboringMapsInterface.mjs.map +1 -1
- package/dist/override/OnRenderGraphicItemProps.js +1 -3
- package/dist/override/OnRenderGraphicItemProps.js.map +1 -1
- package/dist/override/OnRenderGraphicItemProps.mjs +1 -2
- package/dist/override/OnRenderGraphicItemProps.mjs.map +1 -1
- package/dist/override/OnRunProps.js +1 -3
- package/dist/override/OnRunProps.js.map +1 -1
- package/dist/override/OnRunProps.mjs +1 -2
- package/dist/override/OnRunProps.mjs.map +1 -1
- package/dist/override/OnStartEndStageQuest.js +1 -3
- package/dist/override/OnStartEndStageQuest.js.map +1 -1
- package/dist/override/OnStartEndStageQuest.mjs +1 -2
- package/dist/override/OnStartEndStageQuest.mjs.map +1 -1
- package/dist/override/index.js +1 -3
- package/dist/override/index.js.map +1 -1
- package/dist/override/index.mjs +1 -2
- package/dist/override/index.mjs.map +1 -1
- package/dist/types/ExecutionType.js +1 -3
- package/dist/types/ExecutionType.js.map +1 -1
- package/dist/types/ExecutionType.mjs +1 -2
- package/dist/types/ExecutionType.mjs.map +1 -1
- package/dist/types/OnRunActivityEvent.js +1 -3
- package/dist/types/OnRunActivityEvent.js.map +1 -1
- package/dist/types/OnRunActivityEvent.mjs +1 -2
- package/dist/types/OnRunActivityEvent.mjs.map +1 -1
- package/dist/types/OnRunCommitmentEvent.js +1 -3
- package/dist/types/OnRunCommitmentEvent.js.map +1 -1
- package/dist/types/OnRunCommitmentEvent.mjs +1 -2
- package/dist/types/OnRunCommitmentEvent.mjs.map +1 -1
- package/dist/types/QuestsRequired.d.mts +1 -1
- package/dist/types/QuestsRequired.d.ts +1 -1
- package/dist/types/QuestsRequired.js +1 -3
- package/dist/types/QuestsRequired.js.map +1 -1
- package/dist/types/QuestsRequired.mjs +1 -2
- package/dist/types/QuestsRequired.mjs.map +1 -1
- package/dist/types/TimeDataType.d.mts +6 -0
- package/dist/types/TimeDataType.d.ts +6 -0
- package/dist/types/TimeDataType.js +2 -0
- package/dist/types/TimeDataType.js.map +1 -0
- package/dist/types/TimeDataType.mjs +2 -0
- package/dist/types/TimeDataType.mjs.map +1 -0
- package/dist/types/TimeSettings.d.mts +1 -1
- package/dist/types/TimeSettings.d.ts +1 -1
- package/dist/types/TimeSettings.js +1 -3
- package/dist/types/TimeSettings.js.map +1 -1
- package/dist/types/TimeSettings.mjs +1 -2
- package/dist/types/TimeSettings.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -2
- package/dist/types/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -1,2024 +1,2 @@
|
|
|
1
|
-
import { GameStorageManager, StoredClassModel, getFlag } from '@drincs/pixi-vn';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var TIME_SETTINGS_KEY = "___nqtr-time_manager_settings___";
|
|
20
|
-
var TIME_DATA_KEY = "___nqtr-time_manager_data___";
|
|
21
|
-
var TimeManager = class _TimeManager {
|
|
22
|
-
constructor() {
|
|
23
|
-
}
|
|
24
|
-
static editSettings(settings) {
|
|
25
|
-
let data = {};
|
|
26
|
-
if (typeof settings.minDayHours === "number") {
|
|
27
|
-
data["minDayHours"] = settings.minDayHours;
|
|
28
|
-
}
|
|
29
|
-
if (typeof settings.maxDayHours === "number") {
|
|
30
|
-
data["maxDayHours"] = settings.maxDayHours;
|
|
31
|
-
}
|
|
32
|
-
if (typeof settings.minDayHours === "number") {
|
|
33
|
-
data["defaultTimeSpent"] = settings.defaultTimeSpent;
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(settings.timeSlots)) {
|
|
36
|
-
data["timeSlots"] = settings.timeSlots;
|
|
37
|
-
}
|
|
38
|
-
if (typeof settings.weekLength === "number") {
|
|
39
|
-
data["weekLength"] = settings.weekLength;
|
|
40
|
-
}
|
|
41
|
-
if (typeof settings.weekendStartDay === "number") {
|
|
42
|
-
let weekLength = settings.weekLength || _TimeManager.weekLength;
|
|
43
|
-
if (settings.weekendStartDay >= weekLength) {
|
|
44
|
-
console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`);
|
|
45
|
-
}
|
|
46
|
-
data["weekendStartDay"] = settings.weekendStartDay;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(settings.weekDaysNames)) {
|
|
49
|
-
let weekLength = settings.weekLength || _TimeManager.weekLength;
|
|
50
|
-
if (settings.weekDaysNames.length !== weekLength) {
|
|
51
|
-
console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`);
|
|
52
|
-
}
|
|
53
|
-
data["weekDaysNames"] = settings.weekDaysNames;
|
|
54
|
-
}
|
|
55
|
-
GameStorageManager.setVariable(TIME_SETTINGS_KEY, data);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get time settings
|
|
59
|
-
* @default {}
|
|
60
|
-
*/
|
|
61
|
-
static get settings() {
|
|
62
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY) || {};
|
|
63
|
-
return settings;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 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.
|
|
67
|
-
*/
|
|
68
|
-
static set settings(value) {
|
|
69
|
-
_TimeManager.editSettings(value);
|
|
70
|
-
}
|
|
71
|
-
static get minDayHours() {
|
|
72
|
-
let result = 0;
|
|
73
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
74
|
-
if (settings && settings.hasOwnProperty("minDayHours")) {
|
|
75
|
-
result = settings.minDayHours || 0;
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
static get maxDayHours() {
|
|
80
|
-
let result = 24;
|
|
81
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
82
|
-
if (settings && settings.hasOwnProperty("maxDayHours")) {
|
|
83
|
-
result = settings.maxDayHours || 24;
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
static get defaultTimeSpent() {
|
|
88
|
-
let result = 1;
|
|
89
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
90
|
-
if (settings && settings.hasOwnProperty("defaultTimeSpent")) {
|
|
91
|
-
result = settings.defaultTimeSpent || 1;
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
static get timeSlots() {
|
|
96
|
-
let result = [];
|
|
97
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
98
|
-
if (settings && settings.hasOwnProperty("timeSlots")) {
|
|
99
|
-
result = settings.timeSlots || [];
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
static get weekLength() {
|
|
104
|
-
let result = 7;
|
|
105
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
106
|
-
if (settings && settings.hasOwnProperty("weekLength")) {
|
|
107
|
-
result = settings.weekLength || 7;
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
static get weekendStartDay() {
|
|
112
|
-
let result = _TimeManager.weekLength - 1;
|
|
113
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
114
|
-
if (settings && settings.hasOwnProperty("weekendStartDay")) {
|
|
115
|
-
result = settings.weekendStartDay || _TimeManager.weekLength - 1;
|
|
116
|
-
}
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
static get weekDaysNames() {
|
|
120
|
-
let result = [];
|
|
121
|
-
let settings = GameStorageManager.getVariable(TIME_SETTINGS_KEY);
|
|
122
|
-
if (settings && settings.hasOwnProperty("weekDaysNames")) {
|
|
123
|
-
result = settings.weekDaysNames || result;
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get the current hour
|
|
129
|
-
*/
|
|
130
|
-
static get currentHour() {
|
|
131
|
-
let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
132
|
-
if (data.hasOwnProperty("currentHour") && typeof data.currentHour === "number") {
|
|
133
|
-
return data.currentHour;
|
|
134
|
-
}
|
|
135
|
-
return _TimeManager.minDayHours;
|
|
136
|
-
}
|
|
137
|
-
static set currentHour(value) {
|
|
138
|
-
let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
139
|
-
if (typeof value === "number") {
|
|
140
|
-
data.currentHour = value;
|
|
141
|
-
} else {
|
|
142
|
-
delete data.currentHour;
|
|
143
|
-
}
|
|
144
|
-
GameStorageManager.setVariable(TIME_DATA_KEY, data);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Get the current day
|
|
148
|
-
*/
|
|
149
|
-
static get currentDay() {
|
|
150
|
-
let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
151
|
-
if (data.hasOwnProperty("currentDay") && typeof data.currentDay === "number") {
|
|
152
|
-
return data.currentDay;
|
|
153
|
-
}
|
|
154
|
-
return 0;
|
|
155
|
-
}
|
|
156
|
-
static set currentDay(value) {
|
|
157
|
-
let data = GameStorageManager.getVariable(TIME_DATA_KEY) || {};
|
|
158
|
-
if (typeof value === "number") {
|
|
159
|
-
data.currentDay = value;
|
|
160
|
-
} else {
|
|
161
|
-
delete data.currentDay;
|
|
162
|
-
}
|
|
163
|
-
GameStorageManager.setVariable(TIME_DATA_KEY, data);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
167
|
-
*/
|
|
168
|
-
static get isWeekend() {
|
|
169
|
-
return _TimeManager.currentWeekDayNumber >= _TimeManager.weekendStartDay;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get the current week day number (1-TimeManager.weekLength).
|
|
173
|
-
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
174
|
-
*/
|
|
175
|
-
static get currentWeekDayNumber() {
|
|
176
|
-
let result = _TimeManager.currentDay % _TimeManager.weekLength;
|
|
177
|
-
return result + 1;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Get the current week day name. If the week days names are not defined, then it will return undefined.
|
|
181
|
-
* 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'.
|
|
182
|
-
* @default ""
|
|
183
|
-
*/
|
|
184
|
-
static get currentDayName() {
|
|
185
|
-
let weekDayNumber = _TimeManager.currentWeekDayNumber - 1;
|
|
186
|
-
if (weekDayNumber >= _TimeManager.weekDaysNames.length) {
|
|
187
|
-
console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, _TimeManager.weekDaysNames);
|
|
188
|
-
return "";
|
|
189
|
-
}
|
|
190
|
-
return _TimeManager.weekDaysNames[weekDayNumber];
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Get the current TimeManager.timeSlots index.
|
|
194
|
-
* You can use this property to create "Image that changes based on the time period":
|
|
195
|
-
* @example
|
|
196
|
-
* ```tsx
|
|
197
|
-
* import { TimeManager } from '@drincs/nqtr';
|
|
198
|
-
*
|
|
199
|
-
* function changeBackground() {
|
|
200
|
-
* return (
|
|
201
|
-
* <img src={`background-${TimeManager.currentTimeSlot}.png`} />
|
|
202
|
-
* )
|
|
203
|
-
* }
|
|
204
|
-
*/
|
|
205
|
-
static get currentTimeSlot() {
|
|
206
|
-
if (_TimeManager.timeSlots.length === 0) {
|
|
207
|
-
console.warn("[NQTR] Time slots are not defined");
|
|
208
|
-
return 0;
|
|
209
|
-
}
|
|
210
|
-
for (let index = 0; index < _TimeManager.timeSlots.length; index++) {
|
|
211
|
-
let slot = _TimeManager.timeSlots[index];
|
|
212
|
-
if (_TimeManager.timeSlots.length > index + 1) {
|
|
213
|
-
if (_TimeManager.nowIsBetween(slot.startHour, _TimeManager.timeSlots[index + 1].startHour)) {
|
|
214
|
-
return index;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return _TimeManager.timeSlots.length - 1;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* This function will increase the current hour by the given time spent.
|
|
222
|
-
* 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.
|
|
223
|
-
* @param timeSpent is the time spent in hours (default: TimeManager.defaultTimeSpent)
|
|
224
|
-
* @returns TimeManager.currentHour
|
|
225
|
-
*/
|
|
226
|
-
static increaseHour(timeSpent = _TimeManager.defaultTimeSpent) {
|
|
227
|
-
let newHour = _TimeManager.currentHour + timeSpent;
|
|
228
|
-
if (newHour >= _TimeManager.maxDayHours) {
|
|
229
|
-
_TimeManager.increaseDay();
|
|
230
|
-
newHour = _TimeManager.minDayHours + (newHour - _TimeManager.maxDayHours);
|
|
231
|
-
}
|
|
232
|
-
_TimeManager.currentHour = newHour;
|
|
233
|
-
return _TimeManager.currentHour;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* This function will increase the current day by the given days.
|
|
237
|
-
* @param newDayHour is the hour of the new day (default: TimeManager.minDayHours)
|
|
238
|
-
* @param days is the number of days to increase (default: 1)
|
|
239
|
-
* @returns TimeManager.currentDay
|
|
240
|
-
*/
|
|
241
|
-
static increaseDay(newDayHour = _TimeManager.minDayHours, days = 1) {
|
|
242
|
-
let newDay = _TimeManager.currentDay + days;
|
|
243
|
-
_TimeManager.currentDay = newDay;
|
|
244
|
-
_TimeManager.currentHour = newDayHour;
|
|
245
|
-
return _TimeManager.currentDay;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* This function will check if the current hour is between the given hours.
|
|
249
|
-
* @param fromHour the starting hour. If the TimeManager.currentHour is equal to this hour, the function will return true.
|
|
250
|
-
* @param toHour the ending hour.
|
|
251
|
-
* @returns true if the current hour is between the given hours, otherwise false.
|
|
252
|
-
*/
|
|
253
|
-
static nowIsBetween(fromHour, toHour) {
|
|
254
|
-
let currentHour = _TimeManager.currentHour;
|
|
255
|
-
if (fromHour < toHour) {
|
|
256
|
-
return currentHour >= fromHour && currentHour < toHour;
|
|
257
|
-
}
|
|
258
|
-
return currentHour >= fromHour || currentHour < toHour;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
// src/classes/Commitment.ts
|
|
263
|
-
var COMMITMENT_CATEGORY = "__nqtr-commitment__";
|
|
264
|
-
var CommitmentBaseModel = class extends StoredClassModel {
|
|
265
|
-
/**
|
|
266
|
-
* @param id The id of the commitment, it must be unique.
|
|
267
|
-
* @param character The character or characters that are in the commitment and so in the room.
|
|
268
|
-
* @param room The room where the commitment is.
|
|
269
|
-
* @param props The properties of the commitment.
|
|
270
|
-
*/
|
|
271
|
-
constructor(id, character, room, props) {
|
|
272
|
-
super(COMMITMENT_CATEGORY, id);
|
|
273
|
-
this._characters = character ? Array.isArray(character) ? character : [character] : [];
|
|
274
|
-
this._room = room;
|
|
275
|
-
this._name = props.name || "";
|
|
276
|
-
this.defaultFromHour = props.fromHour;
|
|
277
|
-
this.defaultToHour = props.toHour;
|
|
278
|
-
this.defaultFromDay = props.fromDay;
|
|
279
|
-
this.defaultToDay = props.toDay;
|
|
280
|
-
this._renderImage = props.renderImage;
|
|
281
|
-
this._executionType = props.executionType || "interaction";
|
|
282
|
-
this._onRun = props.onRun;
|
|
283
|
-
this.defaultDisabled = props.disabled || false;
|
|
284
|
-
this.defaultHidden = props.hidden || false;
|
|
285
|
-
this._renderIcon = props.renderIcon;
|
|
286
|
-
this.defaultPriority = props.priority || 0;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* The character or characters that are in the commitment and so in the room.
|
|
290
|
-
*/
|
|
291
|
-
get characters() {
|
|
292
|
-
return this._characters;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* The room where the commitment is.
|
|
296
|
-
*/
|
|
297
|
-
get room() {
|
|
298
|
-
return this._room;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* The name
|
|
302
|
-
*/
|
|
303
|
-
get name() {
|
|
304
|
-
return this._name;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* The hour when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
308
|
-
* If you set undefined, it will return the initial value of fromHour.
|
|
309
|
-
*/
|
|
310
|
-
get fromHour() {
|
|
311
|
-
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
312
|
-
}
|
|
313
|
-
set fromHour(value) {
|
|
314
|
-
this.setStorageProperty("fromHour", value);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* The hour when the commitment ends. If the commitment is ended yet, it will be hidden.
|
|
318
|
-
* If you set undefined, it will return the initial value of toHour.
|
|
319
|
-
*/
|
|
320
|
-
get toHour() {
|
|
321
|
-
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
322
|
-
}
|
|
323
|
-
set toHour(value) {
|
|
324
|
-
this.setStorageProperty("toHour", value);
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* The day when the commitment starts. If the commitment is not started yet, it will be hidden.
|
|
328
|
-
* If you set undefined, it will return the initial value of fromDay.
|
|
329
|
-
*/
|
|
330
|
-
get fromDay() {
|
|
331
|
-
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
332
|
-
}
|
|
333
|
-
set fromDay(value) {
|
|
334
|
-
this.setStorageProperty("fromDay", value);
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.
|
|
338
|
-
* If you set undefined, it will return the initial value of toDay.
|
|
339
|
-
*/
|
|
340
|
-
get toDay() {
|
|
341
|
-
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
342
|
-
}
|
|
343
|
-
set toDay(value) {
|
|
344
|
-
this.setStorageProperty("toDay", value);
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* The function for rendering the image of the room.
|
|
348
|
-
*/
|
|
349
|
-
get renderImage() {
|
|
350
|
-
let render = this._renderImage;
|
|
351
|
-
if (render === void 0) {
|
|
352
|
-
return void 0;
|
|
353
|
-
}
|
|
354
|
-
if (typeof render === "function") {
|
|
355
|
-
return (props) => {
|
|
356
|
-
return render(this, props);
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
return (props) => render;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
|
|
363
|
-
* If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
|
|
364
|
-
*/
|
|
365
|
-
get executionType() {
|
|
366
|
-
return this._executionType;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* The function for rendering the icon of the commitment.
|
|
370
|
-
*/
|
|
371
|
-
get renderIcon() {
|
|
372
|
-
let render = this._renderIcon;
|
|
373
|
-
if (render === void 0) {
|
|
374
|
-
return void 0;
|
|
375
|
-
}
|
|
376
|
-
if (typeof render === "function") {
|
|
377
|
-
return (props) => {
|
|
378
|
-
return render(this, props);
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
return (props) => render;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Is a function that is called when the player interacts with the character.
|
|
385
|
-
*/
|
|
386
|
-
get run() {
|
|
387
|
-
let onRun = this._onRun;
|
|
388
|
-
if (!onRun) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
return (props) => onRun(this, props);
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
395
|
-
*/
|
|
396
|
-
get disabled() {
|
|
397
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
398
|
-
if (typeof value === "string") {
|
|
399
|
-
return getFlag(value);
|
|
400
|
-
}
|
|
401
|
-
return value;
|
|
402
|
-
}
|
|
403
|
-
set disabled(value) {
|
|
404
|
-
this.setStorageProperty("disabled", value);
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Whether is hidden. You can also pass a Pixi'VN flag name.
|
|
408
|
-
*/
|
|
409
|
-
get hidden() {
|
|
410
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
414
|
-
return true;
|
|
415
|
-
}
|
|
416
|
-
if (!this.isExpired) {
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
420
|
-
if (typeof value === "string") {
|
|
421
|
-
return getFlag(value);
|
|
422
|
-
}
|
|
423
|
-
return value;
|
|
424
|
-
}
|
|
425
|
-
set hidden(value) {
|
|
426
|
-
this.setStorageProperty("hidden", value);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* The priority. The higher the number, the higher the priority.
|
|
430
|
-
* To ensure that a character is not in 2 places at the same time, if there are 2 or more valid commits at the same time and with the same character, the one with the highest priority will be chosen.
|
|
431
|
-
*/
|
|
432
|
-
get priority() {
|
|
433
|
-
return this.getStorageProperty("priority") || this.defaultPriority || 0;
|
|
434
|
-
}
|
|
435
|
-
set priority(value) {
|
|
436
|
-
this.setStorageProperty("priority", value);
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Whether the commitment is expired.
|
|
440
|
-
* @returns Whether the commitment is expired.
|
|
441
|
-
*/
|
|
442
|
-
isExpired() {
|
|
443
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
444
|
-
return true;
|
|
445
|
-
}
|
|
446
|
-
return false;
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
var ActivityStoredAbstract = class {
|
|
450
|
-
/**
|
|
451
|
-
* @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
|
|
452
|
-
* @param props The activity properties.
|
|
453
|
-
*/
|
|
454
|
-
constructor(onRun, props) {
|
|
455
|
-
this.defaultName = props.name;
|
|
456
|
-
this.defaultFromHour = props.fromHour;
|
|
457
|
-
this.defaultToHour = props.toHour;
|
|
458
|
-
this.defaultFromDay = props.fromDay;
|
|
459
|
-
this.defaultToDay = props.toDay;
|
|
460
|
-
this.defaultDisabled = props.disabled || false;
|
|
461
|
-
this.defaultHidden = props.hidden || false;
|
|
462
|
-
this._renderIcon = props.renderIcon;
|
|
463
|
-
this._onRun = onRun;
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* The name
|
|
467
|
-
*/
|
|
468
|
-
get name() {
|
|
469
|
-
return this.getStorageProperty("name") || this.defaultName || "";
|
|
470
|
-
}
|
|
471
|
-
set name(value) {
|
|
472
|
-
this.setStorageProperty("name", value);
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
476
|
-
*/
|
|
477
|
-
get fromHour() {
|
|
478
|
-
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
479
|
-
}
|
|
480
|
-
set fromHour(value) {
|
|
481
|
-
this.setStorageProperty("fromHour", value);
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
485
|
-
*/
|
|
486
|
-
get toHour() {
|
|
487
|
-
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
488
|
-
}
|
|
489
|
-
set toHour(value) {
|
|
490
|
-
this.setStorageProperty("toHour", value);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
494
|
-
*/
|
|
495
|
-
get fromDay() {
|
|
496
|
-
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
497
|
-
}
|
|
498
|
-
set fromDay(value) {
|
|
499
|
-
this.setStorageProperty("fromDay", value);
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
503
|
-
*/
|
|
504
|
-
get toDay() {
|
|
505
|
-
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
506
|
-
}
|
|
507
|
-
set toDay(value) {
|
|
508
|
-
this.setStorageProperty("toDay", value);
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Whether is disabled.
|
|
512
|
-
*/
|
|
513
|
-
get disabled() {
|
|
514
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
515
|
-
if (typeof value === "string") {
|
|
516
|
-
return getFlag(value);
|
|
517
|
-
}
|
|
518
|
-
return value;
|
|
519
|
-
}
|
|
520
|
-
set disabled(value) {
|
|
521
|
-
this.setStorageProperty("disabled", value);
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
525
|
-
*/
|
|
526
|
-
get hidden() {
|
|
527
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
528
|
-
return true;
|
|
529
|
-
}
|
|
530
|
-
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
531
|
-
return true;
|
|
532
|
-
}
|
|
533
|
-
if (!this.isExpired) {
|
|
534
|
-
return true;
|
|
535
|
-
}
|
|
536
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
537
|
-
if (typeof value === "string") {
|
|
538
|
-
return getFlag(value);
|
|
539
|
-
}
|
|
540
|
-
return value;
|
|
541
|
-
}
|
|
542
|
-
set hidden(value) {
|
|
543
|
-
this.setStorageProperty("hidden", value);
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* The function for rendering the icon of the activity.
|
|
547
|
-
*/
|
|
548
|
-
get renderIcon() {
|
|
549
|
-
let render = this._renderIcon;
|
|
550
|
-
if (render === void 0) {
|
|
551
|
-
return void 0;
|
|
552
|
-
}
|
|
553
|
-
if (typeof render === "function") {
|
|
554
|
-
return (props) => {
|
|
555
|
-
return render(this, props);
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
return (props) => render;
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* The function that is called when the activity is runned.
|
|
562
|
-
*/
|
|
563
|
-
get run() {
|
|
564
|
-
return (props) => {
|
|
565
|
-
return this._onRun(this, props);
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Whether the activity is a deadline.
|
|
570
|
-
* @returns Whether the activity is a deadline.
|
|
571
|
-
*/
|
|
572
|
-
isExpired() {
|
|
573
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
574
|
-
return true;
|
|
575
|
-
}
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Export the activity properties.
|
|
580
|
-
* @returns The activity properties.
|
|
581
|
-
*/
|
|
582
|
-
export() {
|
|
583
|
-
return {
|
|
584
|
-
name: this.getStorageProperty("name") || this.defaultName,
|
|
585
|
-
fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
|
|
586
|
-
toHour: this.getStorageProperty("toHour") || this.defaultToHour,
|
|
587
|
-
fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
|
|
588
|
-
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
589
|
-
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
590
|
-
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
591
|
-
renderIcon: this._renderIcon
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
// src/classes/navigation/ActivityRoom.ts
|
|
597
|
-
var ActivityRoom = class extends ActivityStoredAbstract {
|
|
598
|
-
constructor(id, room, onRun, props) {
|
|
599
|
-
super(onRun, props);
|
|
600
|
-
this._id = id;
|
|
601
|
-
this._room = room;
|
|
602
|
-
}
|
|
603
|
-
setStorageProperty(_, __) {
|
|
604
|
-
this._room.setActivity(this);
|
|
605
|
-
}
|
|
606
|
-
getStorageProperty(propertyName) {
|
|
607
|
-
let activity = this._room.getActivityMemory(this.id);
|
|
608
|
-
if (!activity || !activity.hasOwnProperty(propertyName)) {
|
|
609
|
-
return void 0;
|
|
610
|
-
}
|
|
611
|
-
return activity[propertyName];
|
|
612
|
-
}
|
|
613
|
-
get id() {
|
|
614
|
-
return this._id;
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* The room where the activity is.
|
|
618
|
-
*/
|
|
619
|
-
get room() {
|
|
620
|
-
return this._room;
|
|
621
|
-
}
|
|
622
|
-
export() {
|
|
623
|
-
let result = {};
|
|
624
|
-
if (this.name !== void 0) {
|
|
625
|
-
result["name"] = this.name;
|
|
626
|
-
}
|
|
627
|
-
if (this.fromHour !== void 0) {
|
|
628
|
-
result["fromHour"] = this.fromHour;
|
|
629
|
-
}
|
|
630
|
-
if (this.toHour !== void 0) {
|
|
631
|
-
result["toHour"] = this.toHour;
|
|
632
|
-
}
|
|
633
|
-
if (this.fromDay !== void 0) {
|
|
634
|
-
result["fromDay"] = this.fromDay;
|
|
635
|
-
}
|
|
636
|
-
if (this.toDay !== void 0) {
|
|
637
|
-
result["toDay"] = this.toDay;
|
|
638
|
-
}
|
|
639
|
-
if (this.disabled !== void 0) {
|
|
640
|
-
result["disabled"] = this.disabled;
|
|
641
|
-
}
|
|
642
|
-
return result;
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
// src/decorators/RoomDecorator.ts
|
|
647
|
-
var registeredRooms = {};
|
|
648
|
-
function saveRoom(room) {
|
|
649
|
-
if (Array.isArray(room)) {
|
|
650
|
-
room.forEach((c) => saveRoom(c));
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
if (registeredRooms[room.id]) {
|
|
654
|
-
console.warn(`[NQTR] Room id ${room.id} already exists, it will be overwritten`);
|
|
655
|
-
}
|
|
656
|
-
registeredRooms[room.id] = room;
|
|
657
|
-
}
|
|
658
|
-
function getRoomById(id) {
|
|
659
|
-
try {
|
|
660
|
-
let room = registeredRooms[id];
|
|
661
|
-
if (!room) {
|
|
662
|
-
console.error(`[NQTR] Room ${id} not found`);
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
return room;
|
|
666
|
-
} catch (e) {
|
|
667
|
-
console.error(`[NQTR] Error while getting Room ${id}`, e);
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
function getRoomsByLocation(location) {
|
|
672
|
-
return Object.values(registeredRooms).filter((room) => room.location.id === location.id);
|
|
673
|
-
}
|
|
674
|
-
function getAllLocations() {
|
|
675
|
-
let result = {};
|
|
676
|
-
Object.values(registeredRooms).forEach((room) => {
|
|
677
|
-
result[room.location.id] = room.location;
|
|
678
|
-
});
|
|
679
|
-
return Object.values(result);
|
|
680
|
-
}
|
|
681
|
-
function getLocationsByMap(map) {
|
|
682
|
-
return getAllLocations().filter((location) => location.map.id === map.id);
|
|
683
|
-
}
|
|
684
|
-
function getAllMaps() {
|
|
685
|
-
let result = {};
|
|
686
|
-
Object.values(registeredRooms).forEach((room) => {
|
|
687
|
-
result[room.location.map.id] = room.location.map;
|
|
688
|
-
});
|
|
689
|
-
return Object.values(result);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// src/classes/navigation/Location.ts
|
|
693
|
-
var LOCATION_CATEGORY = "__nqtr-location__";
|
|
694
|
-
var LocationBaseModel = class extends StoredClassModel {
|
|
695
|
-
/**
|
|
696
|
-
* @param id The id of the location, it must be unique.
|
|
697
|
-
* @param map The map where the location is.
|
|
698
|
-
* @param props The properties of the location.
|
|
699
|
-
*/
|
|
700
|
-
constructor(id, map, props = {}) {
|
|
701
|
-
super(LOCATION_CATEGORY, id);
|
|
702
|
-
this.defaultName = props.name || "";
|
|
703
|
-
this.defaultDisabled = props.disabled || false;
|
|
704
|
-
this.defaultHidden = props.hidden || false;
|
|
705
|
-
this._renderIcon = props.renderIcon;
|
|
706
|
-
this._map = map;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* The name of the location.
|
|
710
|
-
* If you set undefined, it will return the initial value of name.
|
|
711
|
-
*/
|
|
712
|
-
get name() {
|
|
713
|
-
return this.getStorageProperty("name") || this.defaultName;
|
|
714
|
-
}
|
|
715
|
-
set name(value) {
|
|
716
|
-
this.setStorageProperty("name", value);
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
720
|
-
*/
|
|
721
|
-
get disabled() {
|
|
722
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
723
|
-
if (typeof value === "string") {
|
|
724
|
-
return getFlag(value);
|
|
725
|
-
}
|
|
726
|
-
return value;
|
|
727
|
-
}
|
|
728
|
-
set disabled(value) {
|
|
729
|
-
this.setStorageProperty("disabled", value);
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
733
|
-
*/
|
|
734
|
-
get hidden() {
|
|
735
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
736
|
-
if (typeof value === "string") {
|
|
737
|
-
return getFlag(value);
|
|
738
|
-
}
|
|
739
|
-
return value;
|
|
740
|
-
}
|
|
741
|
-
set hidden(value) {
|
|
742
|
-
this.setStorageProperty("hidden", value);
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* The function for rendering the icon of the location.
|
|
746
|
-
*/
|
|
747
|
-
get renderIcon() {
|
|
748
|
-
let render = this._renderIcon;
|
|
749
|
-
if (render === void 0) {
|
|
750
|
-
return void 0;
|
|
751
|
-
}
|
|
752
|
-
if (typeof render === "function") {
|
|
753
|
-
return (props) => {
|
|
754
|
-
return render(this, props);
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
return (props) => render;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* The map where the location is.
|
|
761
|
-
*/
|
|
762
|
-
get map() {
|
|
763
|
-
return this._map;
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Get the entrance room of the location.
|
|
767
|
-
* You can cast the room to a specific type that extends RoomBaseModel.
|
|
768
|
-
* @returns The entrance room or the first room if there is no entrance.
|
|
769
|
-
* @example
|
|
770
|
-
* ```typescript
|
|
771
|
-
* const entranceHome = new RoomBaseModel("entrance-home", home, { isEntrance: true })
|
|
772
|
-
* saveRoom(entranceHome)
|
|
773
|
-
* const home = new LocationBaseModel("home", map, { name: "Home" })
|
|
774
|
-
*
|
|
775
|
-
* const entrance = home.getEntrance() // entrance === entranceHome
|
|
776
|
-
* ```
|
|
777
|
-
*/
|
|
778
|
-
getEntrance() {
|
|
779
|
-
let rooms = this.getRooms();
|
|
780
|
-
if (rooms.length === 0) {
|
|
781
|
-
console.error(`[NQTR] The location ${this.id} has no rooms`);
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
return rooms.find((room) => room.isEntrance) || rooms[0];
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* Get all rooms in the location.
|
|
788
|
-
* You can cast the rooms to a specific type that extends RoomBaseModel.
|
|
789
|
-
* @returns The rooms in the location.
|
|
790
|
-
*/
|
|
791
|
-
getRooms() {
|
|
792
|
-
return getRoomsByLocation(this);
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
var MAP_CATEGORY = "__nqtr-map__";
|
|
796
|
-
var MapBaseModel = class extends StoredClassModel {
|
|
797
|
-
/**
|
|
798
|
-
* @param id The id of the map, it must be unique.
|
|
799
|
-
* @param props The properties of the map.
|
|
800
|
-
*/
|
|
801
|
-
constructor(id, props = {}) {
|
|
802
|
-
super(MAP_CATEGORY, id);
|
|
803
|
-
this.defaultName = props.name || "";
|
|
804
|
-
this._renderImage = props.renderImage;
|
|
805
|
-
this.defaultDisabled = props.disabled || false;
|
|
806
|
-
this.defaultHidden = props.hidden || false;
|
|
807
|
-
this._neighboringMaps = props.neighboringMaps;
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* The name of the map.
|
|
811
|
-
* If you set undefined, it will return the initial value of name.
|
|
812
|
-
*/
|
|
813
|
-
get name() {
|
|
814
|
-
return this.getStorageProperty("name") || this.defaultName;
|
|
815
|
-
}
|
|
816
|
-
set name(value) {
|
|
817
|
-
this.setStorageProperty("name", value);
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* The function for rendering the image of the map.
|
|
821
|
-
*/
|
|
822
|
-
get renderImage() {
|
|
823
|
-
let render = this._renderImage;
|
|
824
|
-
if (render === void 0) {
|
|
825
|
-
return void 0;
|
|
826
|
-
}
|
|
827
|
-
if (typeof render === "function") {
|
|
828
|
-
return (props) => {
|
|
829
|
-
return render(this, props);
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
return (props) => render;
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
836
|
-
*/
|
|
837
|
-
get disabled() {
|
|
838
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
839
|
-
if (typeof value === "string") {
|
|
840
|
-
return getFlag(value);
|
|
841
|
-
}
|
|
842
|
-
return value;
|
|
843
|
-
}
|
|
844
|
-
set disabled(value) {
|
|
845
|
-
this.setStorageProperty("disabled", value);
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
849
|
-
*/
|
|
850
|
-
get hidden() {
|
|
851
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
852
|
-
if (typeof value === "string") {
|
|
853
|
-
return getFlag(value);
|
|
854
|
-
}
|
|
855
|
-
return value;
|
|
856
|
-
}
|
|
857
|
-
set hidden(value) {
|
|
858
|
-
this.setStorageProperty("hidden", value);
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* The neighboring maps that are available in this map.
|
|
862
|
-
* @example
|
|
863
|
-
* ```ts
|
|
864
|
-
* {
|
|
865
|
-
* "north": "atlanta_map_id",
|
|
866
|
-
* "south": "miami_map_id",
|
|
867
|
-
* "east": "new_york_map_id",
|
|
868
|
-
* "west": "los_angeles_map_id"
|
|
869
|
-
* }
|
|
870
|
-
* ```
|
|
871
|
-
*/
|
|
872
|
-
get neighboringMaps() {
|
|
873
|
-
return this._neighboringMaps || {};
|
|
874
|
-
}
|
|
875
|
-
set neighboringMaps(value) {
|
|
876
|
-
this._neighboringMaps = value;
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Get all locations in the map.
|
|
880
|
-
* @returns The locations in the map.
|
|
881
|
-
*/
|
|
882
|
-
getLocations() {
|
|
883
|
-
return getLocationsByMap(this);
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
|
-
var ActivityModel = class {
|
|
887
|
-
/**
|
|
888
|
-
* @param id The activity id, that must be unique.
|
|
889
|
-
* @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
|
|
890
|
-
* @param props The activity properties.
|
|
891
|
-
*/
|
|
892
|
-
constructor(id, onRun, props) {
|
|
893
|
-
this._id = id;
|
|
894
|
-
this._name = props.name;
|
|
895
|
-
this._fromHour = props.fromHour;
|
|
896
|
-
this._toHour = props.toHour;
|
|
897
|
-
this._fromDay = props.fromDay;
|
|
898
|
-
this._toDay = props.toDay;
|
|
899
|
-
this._disabled = props.disabled || false;
|
|
900
|
-
this._hidden = props.hidden || false;
|
|
901
|
-
this._renderIcon = props.renderIcon;
|
|
902
|
-
this._onRun = onRun;
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* The activity id, that is unique.
|
|
906
|
-
*/
|
|
907
|
-
get id() {
|
|
908
|
-
return this._id;
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* The name
|
|
912
|
-
*/
|
|
913
|
-
get name() {
|
|
914
|
-
return this._name;
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
918
|
-
*/
|
|
919
|
-
get fromHour() {
|
|
920
|
-
return this._fromHour;
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
924
|
-
*/
|
|
925
|
-
get toHour() {
|
|
926
|
-
return this._toHour;
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
930
|
-
*/
|
|
931
|
-
get fromDay() {
|
|
932
|
-
return this._fromDay;
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
936
|
-
*/
|
|
937
|
-
get toDay() {
|
|
938
|
-
return this._toDay;
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* Whether is disabled.
|
|
942
|
-
*/
|
|
943
|
-
get disabled() {
|
|
944
|
-
if (typeof this._disabled === "string") {
|
|
945
|
-
return getFlag(this._disabled);
|
|
946
|
-
}
|
|
947
|
-
return this._disabled;
|
|
948
|
-
}
|
|
949
|
-
/**
|
|
950
|
-
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
951
|
-
*/
|
|
952
|
-
get hidden() {
|
|
953
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
954
|
-
return true;
|
|
955
|
-
}
|
|
956
|
-
if (!this.isDeadline) {
|
|
957
|
-
return true;
|
|
958
|
-
}
|
|
959
|
-
if (typeof this._hidden === "string") {
|
|
960
|
-
return getFlag(this._hidden);
|
|
961
|
-
}
|
|
962
|
-
return this._hidden;
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* The function for rendering the icon of the activity.
|
|
966
|
-
*/
|
|
967
|
-
get renderIcon() {
|
|
968
|
-
let render = this._renderIcon;
|
|
969
|
-
if (render === void 0) {
|
|
970
|
-
return void 0;
|
|
971
|
-
}
|
|
972
|
-
if (typeof render === "function") {
|
|
973
|
-
return (props) => {
|
|
974
|
-
return render(this, props);
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
return (props) => render;
|
|
978
|
-
}
|
|
979
|
-
get _initialOnRun() {
|
|
980
|
-
return this._onRun;
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* The function that is called when the activity is runned.
|
|
984
|
-
*/
|
|
985
|
-
get run() {
|
|
986
|
-
return (props) => this._onRun(this, props);
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Whether the activity is a deadline.
|
|
990
|
-
* @returns Whether the activity is a deadline.
|
|
991
|
-
*/
|
|
992
|
-
isDeadline() {
|
|
993
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
994
|
-
return true;
|
|
995
|
-
}
|
|
996
|
-
return false;
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Export the activity properties.
|
|
1000
|
-
* @returns The activity properties.
|
|
1001
|
-
*/
|
|
1002
|
-
export() {
|
|
1003
|
-
return {
|
|
1004
|
-
name: this._name,
|
|
1005
|
-
fromHour: this._fromHour,
|
|
1006
|
-
toHour: this._toHour,
|
|
1007
|
-
fromDay: this._fromDay,
|
|
1008
|
-
toDay: this._toDay,
|
|
1009
|
-
disabled: this._disabled,
|
|
1010
|
-
hidden: this._hidden,
|
|
1011
|
-
renderIcon: this._renderIcon
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
// src/decorators/ActivityDecorator.ts
|
|
1017
|
-
var registeredActivities = {};
|
|
1018
|
-
function newActivity(id, onRun, props) {
|
|
1019
|
-
if (registeredActivities[id]) {
|
|
1020
|
-
console.warn(`[NQTR] Activity ${id} already exists, it will be overwritten`);
|
|
1021
|
-
}
|
|
1022
|
-
let activity = new ActivityModel(id, onRun, props);
|
|
1023
|
-
registeredActivities[id] = activity;
|
|
1024
|
-
return activity;
|
|
1025
|
-
}
|
|
1026
|
-
function getActivityById(id) {
|
|
1027
|
-
try {
|
|
1028
|
-
let activity = registeredActivities[id];
|
|
1029
|
-
if (!activity) {
|
|
1030
|
-
console.error(`[NQTR] Activity ${id} not found`);
|
|
1031
|
-
return;
|
|
1032
|
-
}
|
|
1033
|
-
return activity;
|
|
1034
|
-
} catch (e) {
|
|
1035
|
-
console.error(`[NQTR] Error while getting Activity ${id}`, e);
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
|
|
1040
|
-
var registeredCommitments = {};
|
|
1041
|
-
var fixedCommitments = {};
|
|
1042
|
-
function saveCommitment(commitment) {
|
|
1043
|
-
if (Array.isArray(commitment)) {
|
|
1044
|
-
commitment.forEach((c) => saveCommitment(c));
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
if (registeredCommitments[commitment.id]) {
|
|
1048
|
-
console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`);
|
|
1049
|
-
}
|
|
1050
|
-
registeredCommitments[commitment.id] = commitment;
|
|
1051
|
-
}
|
|
1052
|
-
function getCommitmentById(id) {
|
|
1053
|
-
try {
|
|
1054
|
-
let commitment = registeredCommitments[id];
|
|
1055
|
-
if (!commitment) {
|
|
1056
|
-
console.error(`[NQTR] Commitment ${id} not found`);
|
|
1057
|
-
return;
|
|
1058
|
-
}
|
|
1059
|
-
return commitment;
|
|
1060
|
-
} catch (e) {
|
|
1061
|
-
console.error(`[NQTR] Error while getting Commitment ${id}`, e);
|
|
1062
|
-
return;
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
function setFixedRoutine(commitments) {
|
|
1066
|
-
if (Array.isArray(commitments)) {
|
|
1067
|
-
commitments.forEach((c) => setFixedRoutine(c));
|
|
1068
|
-
return;
|
|
1069
|
-
}
|
|
1070
|
-
if (fixedCommitments[commitments.id]) {
|
|
1071
|
-
console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`);
|
|
1072
|
-
}
|
|
1073
|
-
fixedCommitments[commitments.id] = commitments;
|
|
1074
|
-
}
|
|
1075
|
-
function addCommitment(commitment) {
|
|
1076
|
-
if (!Array.isArray(commitment)) {
|
|
1077
|
-
commitment = [commitment];
|
|
1078
|
-
}
|
|
1079
|
-
let commitmentsIds = commitment.map((commitment2) => {
|
|
1080
|
-
let commitmentTest = getCommitmentById(commitment2.id);
|
|
1081
|
-
if (!commitmentTest) {
|
|
1082
|
-
console.warn(`[NQTR] Commitment ${commitment2.id} not found, it will be ignored`);
|
|
1083
|
-
return void 0;
|
|
1084
|
-
}
|
|
1085
|
-
return commitment2.id;
|
|
1086
|
-
}).filter((id) => id !== void 0);
|
|
1087
|
-
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, commitmentsIds);
|
|
1088
|
-
}
|
|
1089
|
-
function removeCommitment(commitment) {
|
|
1090
|
-
if (!Array.isArray(commitment)) {
|
|
1091
|
-
commitment = [commitment];
|
|
1092
|
-
}
|
|
1093
|
-
let commitmentsIds = commitment.map((commitment2) => {
|
|
1094
|
-
return commitment2.id;
|
|
1095
|
-
});
|
|
1096
|
-
let currentCommitments = GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
1097
|
-
if (!currentCommitments) {
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
currentCommitments = currentCommitments.filter((id) => !commitmentsIds.includes(id));
|
|
1101
|
-
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, currentCommitments);
|
|
1102
|
-
}
|
|
1103
|
-
function getFixedRoutine() {
|
|
1104
|
-
return Object.values(fixedCommitments);
|
|
1105
|
-
}
|
|
1106
|
-
function getTemporaryCommitments() {
|
|
1107
|
-
let commitmentsIds = GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
1108
|
-
if (!commitmentsIds) {
|
|
1109
|
-
return [];
|
|
1110
|
-
}
|
|
1111
|
-
let commitments = commitmentsIds.map((id) => getCommitmentById(id)).filter((commitment) => commitment !== void 0);
|
|
1112
|
-
return commitments;
|
|
1113
|
-
}
|
|
1114
|
-
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
1115
|
-
var Goal = class extends StoredClassModel {
|
|
1116
|
-
constructor(id, props) {
|
|
1117
|
-
super(GOAL_CATEGORY, id);
|
|
1118
|
-
this._description = props.description;
|
|
1119
|
-
this._need = props.need || 1;
|
|
1120
|
-
this._defaultHave = props.have || 0;
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* The description of the goal.
|
|
1124
|
-
*/
|
|
1125
|
-
get description() {
|
|
1126
|
-
return this._description;
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* The number of times the goal must be completed.
|
|
1130
|
-
*/
|
|
1131
|
-
get need() {
|
|
1132
|
-
return this._need;
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* The default number of times the goal has been completed.
|
|
1136
|
-
*/
|
|
1137
|
-
get defaultHave() {
|
|
1138
|
-
return this._defaultHave;
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
var GoalStage = class extends Goal {
|
|
1142
|
-
constructor(id, stageId, props) {
|
|
1143
|
-
super(id, props);
|
|
1144
|
-
this._stageId = stageId;
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* The id of the stage that the goal belongs to.
|
|
1148
|
-
*/
|
|
1149
|
-
get stageId() {
|
|
1150
|
-
return this._stageId;
|
|
1151
|
-
}
|
|
1152
|
-
set stageId(value) {
|
|
1153
|
-
this._stageId = value;
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* The number of times the goal has been completed.
|
|
1157
|
-
*/
|
|
1158
|
-
get have() {
|
|
1159
|
-
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
1160
|
-
}
|
|
1161
|
-
set have(value) {
|
|
1162
|
-
if (!this._stageId) {
|
|
1163
|
-
console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
this.setStorageProperty("have-" + this._stageId, value);
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* If the goal is completed.
|
|
1170
|
-
*/
|
|
1171
|
-
get completed() {
|
|
1172
|
-
return this.have >= this.need;
|
|
1173
|
-
}
|
|
1174
|
-
set completed(value) {
|
|
1175
|
-
if (value) {
|
|
1176
|
-
this.have = this.need;
|
|
1177
|
-
} else {
|
|
1178
|
-
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
/**
|
|
1182
|
-
* Find the goal. It will increment the have value.
|
|
1183
|
-
*/
|
|
1184
|
-
find() {
|
|
1185
|
-
this.have++;
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
|
|
1189
|
-
// src/classes/quest/Stage.ts
|
|
1190
|
-
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
1191
|
-
var Stage = class extends StoredClassModel {
|
|
1192
|
-
constructor(id, props) {
|
|
1193
|
-
super(STAGE_CATEGORY, id);
|
|
1194
|
-
this._name = props.name || "";
|
|
1195
|
-
this._defaultGoals = props.goals || [];
|
|
1196
|
-
this._flags = props.flags || [];
|
|
1197
|
-
this._description = props.description || "";
|
|
1198
|
-
this._adviceDescription = props.adviceDescription || "";
|
|
1199
|
-
this._renderImage = props.renderImage;
|
|
1200
|
-
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1201
|
-
this._flagsRequiredToStart = props.flagsRequiredToStart || [];
|
|
1202
|
-
this._questsRequiredToStart = props.questsRequiredToStart || [];
|
|
1203
|
-
this._requestDescriptionToStart = props.requestDescriptionToStart || "";
|
|
1204
|
-
this._onStart = props.onStart;
|
|
1205
|
-
this._onEnd = props.onEnd;
|
|
1206
|
-
}
|
|
1207
|
-
/**
|
|
1208
|
-
* The name of the stage.
|
|
1209
|
-
*/
|
|
1210
|
-
get name() {
|
|
1211
|
-
return this._name;
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* The description of the stage.
|
|
1215
|
-
*/
|
|
1216
|
-
get description() {
|
|
1217
|
-
return this._description;
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* The advice description of the stage.
|
|
1221
|
-
*/
|
|
1222
|
-
get adviceDescription() {
|
|
1223
|
-
return this._adviceDescription;
|
|
1224
|
-
}
|
|
1225
|
-
/**
|
|
1226
|
-
* The function for rendering the image of the stage.
|
|
1227
|
-
*/
|
|
1228
|
-
get renderImage() {
|
|
1229
|
-
let render = this._renderImage;
|
|
1230
|
-
if (render === void 0) {
|
|
1231
|
-
return void 0;
|
|
1232
|
-
}
|
|
1233
|
-
if (typeof render === "function") {
|
|
1234
|
-
return (props) => {
|
|
1235
|
-
return render(this, props);
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
return (props) => render;
|
|
1239
|
-
}
|
|
1240
|
-
/**
|
|
1241
|
-
* The list of goals that the player needs to complete to finish the stage.
|
|
1242
|
-
* This is the list set by the developer. if you want to get the current goals, use the goals property.
|
|
1243
|
-
*/
|
|
1244
|
-
get defaultGoals() {
|
|
1245
|
-
return this._defaultGoals;
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* The list of flags that the player must complete to finish the stage.
|
|
1249
|
-
*/
|
|
1250
|
-
get flags() {
|
|
1251
|
-
return this._flags;
|
|
1252
|
-
}
|
|
1253
|
-
/**
|
|
1254
|
-
* The number of days required to start the stage.
|
|
1255
|
-
*/
|
|
1256
|
-
get daysRequiredToStart() {
|
|
1257
|
-
return this._daysRequiredToStart || 0;
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* The list of flags required to start the stage.
|
|
1261
|
-
*/
|
|
1262
|
-
get flagsRequiredToStart() {
|
|
1263
|
-
return this._flagsRequiredToStart;
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* The list of quests required to start the stage.
|
|
1267
|
-
*/
|
|
1268
|
-
get questsRequiredToStart() {
|
|
1269
|
-
return this._questsRequiredToStart || [];
|
|
1270
|
-
}
|
|
1271
|
-
/**
|
|
1272
|
-
* The description of the request to start the stage.
|
|
1273
|
-
*/
|
|
1274
|
-
get requestDescriptionToStart() {
|
|
1275
|
-
return this._requestDescriptionToStart;
|
|
1276
|
-
}
|
|
1277
|
-
/**
|
|
1278
|
-
* The function that will be called when the stage starts.
|
|
1279
|
-
*/
|
|
1280
|
-
get onStart() {
|
|
1281
|
-
return this._onStart;
|
|
1282
|
-
}
|
|
1283
|
-
/**
|
|
1284
|
-
* The function that will be called when the stage ends.
|
|
1285
|
-
*/
|
|
1286
|
-
get onEnd() {
|
|
1287
|
-
return this._onEnd;
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
var StageQuest = class extends Stage {
|
|
1291
|
-
constructor(id, props) {
|
|
1292
|
-
super(id, props);
|
|
1293
|
-
}
|
|
1294
|
-
/**
|
|
1295
|
-
* Check if the flag and goals are completed.
|
|
1296
|
-
* You can force the completion of the stage by setting the completed property to true.
|
|
1297
|
-
*/
|
|
1298
|
-
get completed() {
|
|
1299
|
-
let storedCompleted = this.getStorageProperty("completed");
|
|
1300
|
-
if (storedCompleted) {
|
|
1301
|
-
return storedCompleted;
|
|
1302
|
-
}
|
|
1303
|
-
if (this.flags.length > 0 && this.goals.length > 0) {
|
|
1304
|
-
if (!this.flags.every((flag) => getFlag(flag.flag))) {
|
|
1305
|
-
return false;
|
|
1306
|
-
}
|
|
1307
|
-
if (!this.goals.every((goal) => goal.completed)) {
|
|
1308
|
-
return false;
|
|
1309
|
-
}
|
|
1310
|
-
return true;
|
|
1311
|
-
}
|
|
1312
|
-
return false;
|
|
1313
|
-
}
|
|
1314
|
-
set completed(value) {
|
|
1315
|
-
this.setStorageProperty("completed", value);
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* If the stage is started.
|
|
1319
|
-
*/
|
|
1320
|
-
get started() {
|
|
1321
|
-
return this.getStorageProperty("started") || false;
|
|
1322
|
-
}
|
|
1323
|
-
set started(value) {
|
|
1324
|
-
this.setStorageProperty("started", value);
|
|
1325
|
-
}
|
|
1326
|
-
/**
|
|
1327
|
-
* The list of goals that the player needs to complete to finish the stage.
|
|
1328
|
-
*/
|
|
1329
|
-
get goals() {
|
|
1330
|
-
return this.defaultGoals.map((goal) => {
|
|
1331
|
-
return new GoalStage(goal.id, this.id, goal);
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
|
-
get prevStageEndDay() {
|
|
1335
|
-
return this.getStorageProperty("prevStageEndDay");
|
|
1336
|
-
}
|
|
1337
|
-
set prevStageEndDay(value) {
|
|
1338
|
-
this.setStorageProperty("prevStageEndDay", value);
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* The day when the stage starts.
|
|
1342
|
-
*/
|
|
1343
|
-
get startDay() {
|
|
1344
|
-
let prevStageEndDay = this.prevStageEndDay;
|
|
1345
|
-
if (prevStageEndDay === void 0) {
|
|
1346
|
-
return void 0;
|
|
1347
|
-
}
|
|
1348
|
-
return prevStageEndDay + this.daysRequiredToStart;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Check if the stage can start.
|
|
1352
|
-
*/
|
|
1353
|
-
get canStart() {
|
|
1354
|
-
let daysRequired = this.daysRequiredToStart;
|
|
1355
|
-
if (daysRequired > 0) {
|
|
1356
|
-
let prevStageEndDay = this.prevStageEndDay;
|
|
1357
|
-
if (prevStageEndDay === void 0) {
|
|
1358
|
-
return false;
|
|
1359
|
-
}
|
|
1360
|
-
if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
|
|
1361
|
-
return false;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {
|
|
1365
|
-
return false;
|
|
1366
|
-
}
|
|
1367
|
-
if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
|
|
1368
|
-
(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
|
|
1369
|
-
)) {
|
|
1370
|
-
return false;
|
|
1371
|
-
}
|
|
1372
|
-
return true;
|
|
1373
|
-
}
|
|
1374
|
-
/**
|
|
1375
|
-
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
1376
|
-
*/
|
|
1377
|
-
inizialize() {
|
|
1378
|
-
if (this.daysRequiredToStart > 0) {
|
|
1379
|
-
this.prevStageEndDay = TimeManager.currentDay;
|
|
1380
|
-
console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* The function that will be called when the stage starts.
|
|
1385
|
-
*/
|
|
1386
|
-
start(props) {
|
|
1387
|
-
if (this.canStart) {
|
|
1388
|
-
this.started = true;
|
|
1389
|
-
if (this.onStart) {
|
|
1390
|
-
this.onStart(this, props);
|
|
1391
|
-
}
|
|
1392
|
-
} else {
|
|
1393
|
-
console.warn(`[NQTR] Stage ${this.id} can't start`);
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
|
|
1398
|
-
// src/classes/quest/Quest.ts
|
|
1399
|
-
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
1400
|
-
var Quest = class extends StoredClassModel {
|
|
1401
|
-
constructor(id, stages, props) {
|
|
1402
|
-
super(QUEST_CATEGORY, id);
|
|
1403
|
-
this._stages = stages;
|
|
1404
|
-
this._name = props.name || "";
|
|
1405
|
-
this._description = props.description || "";
|
|
1406
|
-
this._renderIcon = props.renderIcon;
|
|
1407
|
-
this._renderImage = props.renderImage;
|
|
1408
|
-
this._isInDevelopment = props.isInDevelopment || false;
|
|
1409
|
-
this._onStart = props.onStart;
|
|
1410
|
-
this._onNextStage = props.onNextStage;
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* The stages of the quest.
|
|
1414
|
-
*/
|
|
1415
|
-
get stages() {
|
|
1416
|
-
return this._stages.map((stage, index) => {
|
|
1417
|
-
return new StageQuest(stage.id, stage);
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
/**
|
|
1421
|
-
* The name of the quest.
|
|
1422
|
-
*/
|
|
1423
|
-
get name() {
|
|
1424
|
-
return this._name;
|
|
1425
|
-
}
|
|
1426
|
-
/**
|
|
1427
|
-
* The description of the quest.
|
|
1428
|
-
*/
|
|
1429
|
-
get description() {
|
|
1430
|
-
return this._description;
|
|
1431
|
-
}
|
|
1432
|
-
/**
|
|
1433
|
-
* The function for rendering the icon of the quest.
|
|
1434
|
-
*/
|
|
1435
|
-
get renderIcon() {
|
|
1436
|
-
let render = this._renderIcon;
|
|
1437
|
-
if (render === void 0) {
|
|
1438
|
-
return void 0;
|
|
1439
|
-
}
|
|
1440
|
-
if (typeof render === "function") {
|
|
1441
|
-
return (props) => {
|
|
1442
|
-
return render(this, props);
|
|
1443
|
-
};
|
|
1444
|
-
}
|
|
1445
|
-
return (props) => render;
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* The function for rendering the image of the quest.
|
|
1449
|
-
*/
|
|
1450
|
-
get renderImage() {
|
|
1451
|
-
let render = this._renderImage;
|
|
1452
|
-
if (render === void 0) {
|
|
1453
|
-
return void 0;
|
|
1454
|
-
}
|
|
1455
|
-
if (typeof render === "function") {
|
|
1456
|
-
return (props) => {
|
|
1457
|
-
return render(this, props);
|
|
1458
|
-
};
|
|
1459
|
-
}
|
|
1460
|
-
return (props) => render;
|
|
1461
|
-
}
|
|
1462
|
-
/**
|
|
1463
|
-
* If the quest is in development.
|
|
1464
|
-
*/
|
|
1465
|
-
get isInDevelopment() {
|
|
1466
|
-
return this._isInDevelopment;
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* The index of the current stage.
|
|
1470
|
-
*/
|
|
1471
|
-
get currentStageIndex() {
|
|
1472
|
-
return this.getStorageProperty("currentStageIndex");
|
|
1473
|
-
}
|
|
1474
|
-
set currentStageIndex(value) {
|
|
1475
|
-
this.setStorageProperty("currentStageIndex", value);
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* The current stage.
|
|
1479
|
-
*/
|
|
1480
|
-
get currentStage() {
|
|
1481
|
-
let index = this.currentStageIndex;
|
|
1482
|
-
if (index === void 0 || index >= this.stages.length) {
|
|
1483
|
-
return void 0;
|
|
1484
|
-
}
|
|
1485
|
-
return this.stages[index];
|
|
1486
|
-
}
|
|
1487
|
-
/**
|
|
1488
|
-
* If the quest is started.
|
|
1489
|
-
*/
|
|
1490
|
-
get started() {
|
|
1491
|
-
return this.currentStageIndex !== void 0;
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* If the quest is completed.
|
|
1495
|
-
*/
|
|
1496
|
-
get completed() {
|
|
1497
|
-
if (this.currentStageIndex === void 0) {
|
|
1498
|
-
return false;
|
|
1499
|
-
}
|
|
1500
|
-
return this.currentStageIndex > this.stages.length - 1;
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
* The function that will be called when the quest starts.
|
|
1504
|
-
*/
|
|
1505
|
-
get onStart() {
|
|
1506
|
-
return this._onStart;
|
|
1507
|
-
}
|
|
1508
|
-
/**
|
|
1509
|
-
* The function that will be called when the quest goes to the next stage.
|
|
1510
|
-
*/
|
|
1511
|
-
get onNextStage() {
|
|
1512
|
-
return this._onNextStage;
|
|
1513
|
-
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Start the quest.
|
|
1516
|
-
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1517
|
-
* @returns
|
|
1518
|
-
*/
|
|
1519
|
-
start(props) {
|
|
1520
|
-
if (this.started) {
|
|
1521
|
-
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
1522
|
-
return;
|
|
1523
|
-
}
|
|
1524
|
-
if (this.stages.length === 0) {
|
|
1525
|
-
console.error(`[NQTR] Quest ${this.id} has no stages`);
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
this.currentStageIndex = 0;
|
|
1529
|
-
let currentStage = this.currentStage;
|
|
1530
|
-
if (currentStage && currentStage.start) {
|
|
1531
|
-
this.onStart && this.onStart(this, props);
|
|
1532
|
-
return currentStage.start(props);
|
|
1533
|
-
} else {
|
|
1534
|
-
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
/**
|
|
1538
|
-
* Go to the next stage if the current stage is completed.
|
|
1539
|
-
* If you want to force the change of stage, use goNextStage.
|
|
1540
|
-
* @param props The properties. If you not want to pass any property, you can pass an {}.
|
|
1541
|
-
* @returns true if the stage was changed, false otherwise.
|
|
1542
|
-
*/
|
|
1543
|
-
tryToGoNextStage(props) {
|
|
1544
|
-
if (!this.started) {
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
if (this.completed) {
|
|
1548
|
-
return false;
|
|
1549
|
-
}
|
|
1550
|
-
let currentStage = this.currentStage;
|
|
1551
|
-
if (!currentStage) {
|
|
1552
|
-
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1553
|
-
return false;
|
|
1554
|
-
}
|
|
1555
|
-
if (currentStage.completed) {
|
|
1556
|
-
return this.goNextStage(props);
|
|
1557
|
-
}
|
|
1558
|
-
return false;
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
* Complete the current stage and go to the next stage.
|
|
1562
|
-
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1563
|
-
* @param props The properties. If you not want to pass any property, you can pass an {}.
|
|
1564
|
-
* @returns true if the stage was changed, false otherwise.
|
|
1565
|
-
*/
|
|
1566
|
-
completeCurrentStageAndGoNext(props) {
|
|
1567
|
-
let currentStage = this.currentStage;
|
|
1568
|
-
if (!currentStage) {
|
|
1569
|
-
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1570
|
-
return false;
|
|
1571
|
-
}
|
|
1572
|
-
currentStage.completed = true;
|
|
1573
|
-
return this.goNextStage(props);
|
|
1574
|
-
}
|
|
1575
|
-
/**
|
|
1576
|
-
* Go to the next stage without checking if the current stage is completed.
|
|
1577
|
-
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1578
|
-
* @param props The properties. If you not want to pass any property, you can pass an {}.
|
|
1579
|
-
* @returns returns true if the stage was changed, false otherwise.
|
|
1580
|
-
*/
|
|
1581
|
-
goNextStage(props) {
|
|
1582
|
-
if (!this.started) {
|
|
1583
|
-
console.warn(`[NQTR] Quest ${this.id} is not started`);
|
|
1584
|
-
return false;
|
|
1585
|
-
}
|
|
1586
|
-
if (this.completed) {
|
|
1587
|
-
console.warn(`[NQTR] Quest ${this.id} is already completed`);
|
|
1588
|
-
return false;
|
|
1589
|
-
}
|
|
1590
|
-
let prevStage = this.currentStage;
|
|
1591
|
-
let currentStageIndex = this.currentStageIndex;
|
|
1592
|
-
if (!prevStage || currentStageIndex === void 0) {
|
|
1593
|
-
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1594
|
-
return false;
|
|
1595
|
-
}
|
|
1596
|
-
this.currentStageIndex = currentStageIndex + 1;
|
|
1597
|
-
this.onNextStage && this.onNextStage(this, props);
|
|
1598
|
-
if (prevStage && prevStage.onEnd) {
|
|
1599
|
-
prevStage.onEnd(prevStage, props);
|
|
1600
|
-
}
|
|
1601
|
-
let nextCurrentStage = this.currentStage;
|
|
1602
|
-
if (nextCurrentStage) {
|
|
1603
|
-
nextCurrentStage.inizialize();
|
|
1604
|
-
if (this.currentStageMustStart) {
|
|
1605
|
-
this.startCurrentStage(props);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
return true;
|
|
1609
|
-
}
|
|
1610
|
-
/**
|
|
1611
|
-
* If the current stage must start. It is true if the current stage is not started, can start and not completed.
|
|
1612
|
-
*/
|
|
1613
|
-
get currentStageMustStart() {
|
|
1614
|
-
let currentStage = this.currentStage;
|
|
1615
|
-
if (!currentStage) {
|
|
1616
|
-
return false;
|
|
1617
|
-
}
|
|
1618
|
-
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
1619
|
-
}
|
|
1620
|
-
/**
|
|
1621
|
-
* Start the current stage.
|
|
1622
|
-
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1623
|
-
*/
|
|
1624
|
-
startCurrentStage(props) {
|
|
1625
|
-
let newCurrentStage = this.currentStage;
|
|
1626
|
-
if (newCurrentStage && this.currentStageMustStart) {
|
|
1627
|
-
newCurrentStage.start(props);
|
|
1628
|
-
} else {
|
|
1629
|
-
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
|
-
|
|
1634
|
-
// src/decorators/QuestDecorator.ts
|
|
1635
|
-
var registeredQuests = {};
|
|
1636
|
-
function newQuest(id, stages, props) {
|
|
1637
|
-
if (registeredQuests[id]) {
|
|
1638
|
-
console.warn(`[NQTR] Quest ${id} already exists, it will be overwritten`);
|
|
1639
|
-
}
|
|
1640
|
-
let quest = new Quest(id, stages, props);
|
|
1641
|
-
registeredQuests[id] = quest;
|
|
1642
|
-
return quest;
|
|
1643
|
-
}
|
|
1644
|
-
function getQuestById(id) {
|
|
1645
|
-
try {
|
|
1646
|
-
let quest = registeredQuests[id];
|
|
1647
|
-
if (!quest) {
|
|
1648
|
-
console.error(`[NQTR] Quest ${id} not found`);
|
|
1649
|
-
return;
|
|
1650
|
-
}
|
|
1651
|
-
return quest;
|
|
1652
|
-
} catch (e) {
|
|
1653
|
-
console.error(`[NQTR] Error while getting Quest ${id}`, e);
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
function getAllStartedQuests() {
|
|
1658
|
-
return Object.values(registeredQuests).filter((quest) => quest.started);
|
|
1659
|
-
}
|
|
1660
|
-
var CURRENT_ROOM_MEMORY_KEY = "___nqtr-current_room_memory___";
|
|
1661
|
-
function setCurrentRoom(room) {
|
|
1662
|
-
if (room instanceof LocationBaseModel) {
|
|
1663
|
-
let entrance = room.getEntrance();
|
|
1664
|
-
if (!entrance) {
|
|
1665
|
-
console.error(`[NQTR] The location ${room.id} has no entrance room`);
|
|
1666
|
-
return;
|
|
1667
|
-
}
|
|
1668
|
-
room = entrance;
|
|
1669
|
-
} else {
|
|
1670
|
-
let roomRegistrated = getRoomById(room.id);
|
|
1671
|
-
if (!roomRegistrated) {
|
|
1672
|
-
console.error(`[NQTR] The room ${room.id} is not registered, so it can't be set as current room`);
|
|
1673
|
-
return;
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
GameStorageManager.setVariable(CURRENT_ROOM_MEMORY_KEY, room.id);
|
|
1677
|
-
}
|
|
1678
|
-
function getCurrentRoom() {
|
|
1679
|
-
let roomId = GameStorageManager.getVariable(CURRENT_ROOM_MEMORY_KEY);
|
|
1680
|
-
if (!roomId) {
|
|
1681
|
-
console.error(`[NQTR] The current room has not yet been set`);
|
|
1682
|
-
return;
|
|
1683
|
-
}
|
|
1684
|
-
let room = getRoomById(roomId);
|
|
1685
|
-
if (!room) {
|
|
1686
|
-
console.error(`[NQTR] Current room ${roomId} not found`);
|
|
1687
|
-
return;
|
|
1688
|
-
}
|
|
1689
|
-
return room;
|
|
1690
|
-
}
|
|
1691
|
-
function getCurrenrLocation() {
|
|
1692
|
-
let room = getCurrentRoom();
|
|
1693
|
-
if (!room) {
|
|
1694
|
-
return;
|
|
1695
|
-
}
|
|
1696
|
-
return room.location;
|
|
1697
|
-
}
|
|
1698
|
-
function getCurrentMap() {
|
|
1699
|
-
let location = getCurrenrLocation();
|
|
1700
|
-
if (!location) {
|
|
1701
|
-
return;
|
|
1702
|
-
}
|
|
1703
|
-
return location.map;
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
// src/functions/RoutineFunctions.ts
|
|
1707
|
-
function clearExpiredRoutine() {
|
|
1708
|
-
Object.entries(registeredCommitments).forEach(([_, commitment]) => {
|
|
1709
|
-
if (commitment.isExpired()) {
|
|
1710
|
-
delete registeredCommitments[commitment.id];
|
|
1711
|
-
}
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
function getCurrentRoutine() {
|
|
1715
|
-
let character_commitments = {};
|
|
1716
|
-
getTemporaryCommitments().reverse().forEach((c) => {
|
|
1717
|
-
if (!c.hidden) {
|
|
1718
|
-
if (c.characters.length > 0) {
|
|
1719
|
-
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
|
|
1720
|
-
if (allAvailable) {
|
|
1721
|
-
c.characters.forEach((ch) => {
|
|
1722
|
-
character_commitments[ch.id] = c;
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1725
|
-
} else {
|
|
1726
|
-
console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
});
|
|
1730
|
-
getFixedRoutine().reverse().forEach((c) => {
|
|
1731
|
-
if (!c.hidden) {
|
|
1732
|
-
if (c.characters.length > 0) {
|
|
1733
|
-
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
|
|
1734
|
-
if (allAvailable) {
|
|
1735
|
-
c.characters.forEach((ch) => {
|
|
1736
|
-
character_commitments[ch.id] = c;
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
} else {
|
|
1740
|
-
console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
});
|
|
1744
|
-
return Object.values(character_commitments);
|
|
1745
|
-
}
|
|
1746
|
-
function getCurrentRoomRoutine() {
|
|
1747
|
-
let room = getCurrentRoom();
|
|
1748
|
-
if (!room) {
|
|
1749
|
-
return [];
|
|
1750
|
-
}
|
|
1751
|
-
return room.getRoutine();
|
|
1752
|
-
}
|
|
1753
|
-
function getCommitmentByCharacter(character) {
|
|
1754
|
-
getCurrentRoutine().forEach((c) => {
|
|
1755
|
-
if (c.characters.map((ch) => ch.id).includes(character.id)) {
|
|
1756
|
-
return c;
|
|
1757
|
-
}
|
|
1758
|
-
});
|
|
1759
|
-
return void 0;
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
// src/classes/navigation/Room.ts
|
|
1763
|
-
var ROOM_CATEGORY = "__nqtr-room__";
|
|
1764
|
-
var RoomBaseModel2 = class extends StoredClassModel {
|
|
1765
|
-
/**
|
|
1766
|
-
* @param id The id of the room, it must be unique.
|
|
1767
|
-
* @param location The location where the room is.
|
|
1768
|
-
* @param props The properties of the room.
|
|
1769
|
-
*/
|
|
1770
|
-
constructor(id, location, props = {}) {
|
|
1771
|
-
var _a;
|
|
1772
|
-
super(ROOM_CATEGORY, id);
|
|
1773
|
-
this._location = location;
|
|
1774
|
-
this.defaultName = props.name || "";
|
|
1775
|
-
this._renderImage = props.renderImage;
|
|
1776
|
-
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
1777
|
-
this.defaultDisabled = props.disabled || false;
|
|
1778
|
-
this.defaultHidden = props.hidden || false;
|
|
1779
|
-
this._renderIcon = props.renderIcon;
|
|
1780
|
-
this._isEntrance = props.isEntrance;
|
|
1781
|
-
}
|
|
1782
|
-
/**
|
|
1783
|
-
* The location where the room is.
|
|
1784
|
-
*/
|
|
1785
|
-
get location() {
|
|
1786
|
-
return this._location;
|
|
1787
|
-
}
|
|
1788
|
-
/**
|
|
1789
|
-
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
1790
|
-
*/
|
|
1791
|
-
get isEntrance() {
|
|
1792
|
-
return this._isEntrance || false;
|
|
1793
|
-
}
|
|
1794
|
-
/**
|
|
1795
|
-
* The name.
|
|
1796
|
-
* If you set undefined, it will return the initial value of name.
|
|
1797
|
-
*/
|
|
1798
|
-
get name() {
|
|
1799
|
-
return this.getStorageProperty("name") || this.defaultName;
|
|
1800
|
-
}
|
|
1801
|
-
set name(value) {
|
|
1802
|
-
this.setStorageProperty("name", value);
|
|
1803
|
-
}
|
|
1804
|
-
/**
|
|
1805
|
-
* The function for rendering the image of the room.
|
|
1806
|
-
*/
|
|
1807
|
-
get renderImage() {
|
|
1808
|
-
let render = this._renderImage;
|
|
1809
|
-
if (render === void 0) {
|
|
1810
|
-
return void 0;
|
|
1811
|
-
}
|
|
1812
|
-
if (typeof render === "function") {
|
|
1813
|
-
return (props) => {
|
|
1814
|
-
return render(this, props);
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
return (props) => render;
|
|
1818
|
-
}
|
|
1819
|
-
/**
|
|
1820
|
-
* The activities that are available in this room.
|
|
1821
|
-
*/
|
|
1822
|
-
get defaultActivities() {
|
|
1823
|
-
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
1824
|
-
let activities = this.defaultActivityIds.map((id) => {
|
|
1825
|
-
let activity = getActivityById(id);
|
|
1826
|
-
if (!activity) {
|
|
1827
|
-
console.warn(`[NQTR] Activity with id ${id} not found, so it will be ignored.`);
|
|
1828
|
-
return void 0;
|
|
1829
|
-
}
|
|
1830
|
-
let memory = activity.export();
|
|
1831
|
-
if (roomMemories && roomMemories[id]) {
|
|
1832
|
-
memory = __spreadValues(__spreadValues({}, memory), roomMemories[id]);
|
|
1833
|
-
}
|
|
1834
|
-
return new ActivityRoom(id, this, activity._initialOnRun, memory);
|
|
1835
|
-
}).filter((activity) => activity !== void 0);
|
|
1836
|
-
return activities;
|
|
1837
|
-
}
|
|
1838
|
-
get activityIds() {
|
|
1839
|
-
let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
|
|
1840
|
-
return this.defaultActivityIds.concat(addedActivityIds);
|
|
1841
|
-
}
|
|
1842
|
-
/**
|
|
1843
|
-
* The activities that are available in this room.
|
|
1844
|
-
*/
|
|
1845
|
-
get activities() {
|
|
1846
|
-
let activities = this.activityIds.map((id) => {
|
|
1847
|
-
return this.getActivity(id);
|
|
1848
|
-
}).filter((activity) => activity !== void 0 && !activity.hidden);
|
|
1849
|
-
return activities;
|
|
1850
|
-
}
|
|
1851
|
-
/**
|
|
1852
|
-
* Get the memory of an activity. This function can be used into olther libraries to get the memory of the activity.
|
|
1853
|
-
* @param id The id of the activity.
|
|
1854
|
-
* @returns The memory of the activity.
|
|
1855
|
-
*/
|
|
1856
|
-
getActivityMemory(id) {
|
|
1857
|
-
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
1858
|
-
let roomMemory = roomMemories[id] || {};
|
|
1859
|
-
return roomMemory;
|
|
1860
|
-
}
|
|
1861
|
-
/**
|
|
1862
|
-
* Get the activity by id.
|
|
1863
|
-
* @param id The id of the activity.
|
|
1864
|
-
* @returns The room activity.
|
|
1865
|
-
*/
|
|
1866
|
-
getActivity(id) {
|
|
1867
|
-
if (!this.activityIds.includes(id)) {
|
|
1868
|
-
console.error(`[NQTR] Activity with id ${id} not found in room ${this.id}`);
|
|
1869
|
-
return void 0;
|
|
1870
|
-
}
|
|
1871
|
-
let activity = getActivityById(id);
|
|
1872
|
-
if (!activity) {
|
|
1873
|
-
console.error(`[NQTR] Activity with id ${id} not found`);
|
|
1874
|
-
return void 0;
|
|
1875
|
-
}
|
|
1876
|
-
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
1877
|
-
let roomMemory = roomMemories[id] || {};
|
|
1878
|
-
roomMemory = __spreadValues(__spreadValues({}, activity.export()), roomMemory);
|
|
1879
|
-
return new ActivityRoom(id, this, activity._initialOnRun, roomMemory);
|
|
1880
|
-
}
|
|
1881
|
-
/**
|
|
1882
|
-
* Set the memory of an activity. This function can be used into olther libraries to set the memory of the activity.
|
|
1883
|
-
* @param id The id of the activity.
|
|
1884
|
-
* @param memory The memory of the activity.
|
|
1885
|
-
*/
|
|
1886
|
-
setActivity(activity) {
|
|
1887
|
-
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
1888
|
-
roomMemories[activity.id] = activity.export();
|
|
1889
|
-
this.setStorageProperty("activities_memory", roomMemories);
|
|
1890
|
-
}
|
|
1891
|
-
/**
|
|
1892
|
-
* Add an activity to the room.
|
|
1893
|
-
* @param activity The activity to add.
|
|
1894
|
-
*/
|
|
1895
|
-
addActivity(activity) {
|
|
1896
|
-
if (this.activityIds.includes(activity.id)) {
|
|
1897
|
-
let currentActivity = this.getActivity(activity.id);
|
|
1898
|
-
if (currentActivity && currentActivity.isExpired()) {
|
|
1899
|
-
this.removeActivity(activity.id);
|
|
1900
|
-
return;
|
|
1901
|
-
} else {
|
|
1902
|
-
console.error(`[NQTR] Activity with id ${activity.id} already exists in room ${this.id}, so it will be ignored.`);
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
|
|
1907
|
-
addedActivityIds.push(activity.id);
|
|
1908
|
-
this.setStorageProperty("addedActivityIds", addedActivityIds);
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* Remove an activity from the room.
|
|
1912
|
-
* @param activity The activity to remove.
|
|
1913
|
-
*/
|
|
1914
|
-
removeActivity(activity) {
|
|
1915
|
-
let activityId = typeof activity === "string" ? activity : activity.id;
|
|
1916
|
-
if (this.defaultActivityIds.includes(activityId)) {
|
|
1917
|
-
console.warn(`[NQTR] Activity with id ${activityId} is a default activity, so it can't be removed. It will be hidden instead.`);
|
|
1918
|
-
let activityToEdit = this.getActivity(activityId);
|
|
1919
|
-
if (!activityToEdit) {
|
|
1920
|
-
console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be hidden.`);
|
|
1921
|
-
return;
|
|
1922
|
-
}
|
|
1923
|
-
activityToEdit.hidden = true;
|
|
1924
|
-
return;
|
|
1925
|
-
}
|
|
1926
|
-
let addedActivityIds = this.getStorageProperty(`addedActivityIds`) || [];
|
|
1927
|
-
let index = addedActivityIds.indexOf(activityId);
|
|
1928
|
-
if (index === -1) {
|
|
1929
|
-
console.error(`[NQTR] Activity with id ${activityId} not found, so it can't be removed.`);
|
|
1930
|
-
return;
|
|
1931
|
-
}
|
|
1932
|
-
addedActivityIds.splice(index, 1);
|
|
1933
|
-
this.setStorageProperty("addedActivityIds", addedActivityIds);
|
|
1934
|
-
let roomMemories = this.getStorageProperty("activities_memory") || {};
|
|
1935
|
-
delete roomMemories[activityId];
|
|
1936
|
-
this.setStorageProperty("activities_memory", roomMemories);
|
|
1937
|
-
}
|
|
1938
|
-
/**
|
|
1939
|
-
* Clear all expired activities.
|
|
1940
|
-
*/
|
|
1941
|
-
clearExpiredActivities() {
|
|
1942
|
-
this.activities.forEach((activity) => {
|
|
1943
|
-
if (activity.isExpired()) {
|
|
1944
|
-
this.removeActivity(activity.id);
|
|
1945
|
-
}
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
/**
|
|
1949
|
-
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
1950
|
-
*/
|
|
1951
|
-
get disabled() {
|
|
1952
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
1953
|
-
if (typeof value === "string") {
|
|
1954
|
-
return getFlag(value);
|
|
1955
|
-
}
|
|
1956
|
-
return value;
|
|
1957
|
-
}
|
|
1958
|
-
set disabled(value) {
|
|
1959
|
-
this.setStorageProperty("disabled", value);
|
|
1960
|
-
}
|
|
1961
|
-
/**
|
|
1962
|
-
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
1963
|
-
*/
|
|
1964
|
-
get hidden() {
|
|
1965
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
1966
|
-
if (typeof value === "string") {
|
|
1967
|
-
return getFlag(value);
|
|
1968
|
-
}
|
|
1969
|
-
return value;
|
|
1970
|
-
}
|
|
1971
|
-
set hidden(value) {
|
|
1972
|
-
this.setStorageProperty("hidden", value);
|
|
1973
|
-
}
|
|
1974
|
-
/**
|
|
1975
|
-
* The function for rendering the icon of the room.
|
|
1976
|
-
*/
|
|
1977
|
-
get renderIcon() {
|
|
1978
|
-
let render = this._renderIcon;
|
|
1979
|
-
if (render === void 0) {
|
|
1980
|
-
return void 0;
|
|
1981
|
-
}
|
|
1982
|
-
if (typeof render === "function") {
|
|
1983
|
-
return (props) => {
|
|
1984
|
-
return render(this, props);
|
|
1985
|
-
};
|
|
1986
|
-
}
|
|
1987
|
-
return (props) => render;
|
|
1988
|
-
}
|
|
1989
|
-
/**
|
|
1990
|
-
* Get the character commitments of the room.
|
|
1991
|
-
* @returns The character commitments of the room.
|
|
1992
|
-
*/
|
|
1993
|
-
getRoutine() {
|
|
1994
|
-
let commitments = getCurrentRoutine();
|
|
1995
|
-
return commitments.filter((c) => c.room.id === this.id);
|
|
1996
|
-
}
|
|
1997
|
-
};
|
|
1998
|
-
|
|
1999
|
-
// src/functions/ActivityFunctions.ts
|
|
2000
|
-
function clearExpiredActivities() {
|
|
2001
|
-
Object.entries(registeredRooms).forEach(([_, room]) => {
|
|
2002
|
-
room.clearExpiredActivities();
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
function currentActivities() {
|
|
2006
|
-
let currentRoom = getCurrentRoom();
|
|
2007
|
-
if (!currentRoom) {
|
|
2008
|
-
return [];
|
|
2009
|
-
}
|
|
2010
|
-
return currentRoom.activities.filter((activity) => !activity.hidden);
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
// src/functions/QuestFunctions.ts
|
|
2014
|
-
function startMustStartStageQuests(props) {
|
|
2015
|
-
Object.entries(registeredQuests).forEach(([_, quest]) => {
|
|
2016
|
-
if (quest.currentStageMustStart) {
|
|
2017
|
-
quest.startCurrentStage(props);
|
|
2018
|
-
}
|
|
2019
|
-
});
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
export { ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, Quest, RoomBaseModel2 as RoomBaseModel, Stage, TimeManager, addCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getAllLocations, getAllMaps, getAllStartedQuests, getCommitmentByCharacter, getCommitmentById, getCurrenrLocation, getCurrentMap, getCurrentRoom, getCurrentRoomRoutine, getCurrentRoutine, getQuestById, getRoomById, newActivity, newQuest, removeCommitment, saveCommitment, saveRoom, setCurrentRoom, setFixedRoutine, startMustStartStageQuests };
|
|
2023
|
-
//# sourceMappingURL=out.js.map
|
|
1
|
+
import {StoredClassModel,getFlag,storage}from'@drincs/pixi-vn';var Re=Object.defineProperty;var M=(r,e)=>{for(var t in e)Re(r,t,{get:e[t],enumerable:true});};var F={};M(F,{ActivityRoom:()=>d,CommitmentBaseModel:()=>S,Goal:()=>c,LocationBaseModel:()=>l,MapBaseModel:()=>R,Quest:()=>p,RoomBaseModel:()=>P,Stage:()=>y});var H={};M(H,{timeTracker:()=>n});var s="___nqtr-time_manager_settings___",u="___nqtr-time_manager_data___";var v=class{editSettings(e){let t={};if(typeof e.minDayHours=="number"&&(t.minDayHours=e.minDayHours),typeof e.maxDayHours=="number"&&(t.maxDayHours=e.maxDayHours),typeof e.minDayHours=="number"&&(t.defaultTimeSpent=e.defaultTimeSpent),Array.isArray(e.timeSlots)&&(t.timeSlots=e.timeSlots),typeof e.weekLength=="number"&&(t.weekLength=e.weekLength),typeof e.weekendStartDay=="number"){let i=e.weekLength||this.weekLength;e.weekendStartDay>=i&&console.warn(`[NQTR] Weekend start day should be less than week length ${i}`),t.weekendStartDay=e.weekendStartDay;}if(Array.isArray(e.weekDaysNames)){let i=e.weekLength||this.weekLength;e.weekDaysNames.length!==i&&console.warn(`[NQTR] Week days names should be equal to week length ${i}`),t.weekDaysNames=e.weekDaysNames;}storage.setVariable(s,t);}get settings(){return storage.getVariable(s)||{}}set settings(e){this.editSettings(e);}get minDayHours(){let e=0,t=storage.getVariable(s);return t&&t.hasOwnProperty("minDayHours")&&(e=t.minDayHours||0),e}get maxDayHours(){let e=24,t=storage.getVariable(s);return t&&t.hasOwnProperty("maxDayHours")&&(e=t.maxDayHours||24),e}get defaultTimeSpent(){let e=1,t=storage.getVariable(s);return t&&t.hasOwnProperty("defaultTimeSpent")&&(e=t.defaultTimeSpent||1),e}get timeSlots(){let e=[],t=storage.getVariable(s);return t&&t.hasOwnProperty("timeSlots")&&(e=t.timeSlots||[]),e}get weekLength(){let e=7,t=storage.getVariable(s);return t&&t.hasOwnProperty("weekLength")&&(e=t.weekLength||7),e}get weekendStartDay(){let e=this.weekLength-1,t=storage.getVariable(s);return t&&t.hasOwnProperty("weekendStartDay")&&(e=t.weekendStartDay||this.weekLength-1),e}get weekDaysNames(){let e=[],t=storage.getVariable(s);return t&&t.hasOwnProperty("weekDaysNames")&&(e=t.weekDaysNames||e),e}get currentHour(){let e=storage.getVariable(u)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(u)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(u,t);}get currentDay(){let e=storage.getVariable(u)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(u)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(u,t);}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 i=this.currentDay+t;return this.currentDay=i,this.currentHour=e,this.currentDay}nowIsBetween(e,t){let i=this.currentHour;return e<t?i>=e&&i<t:i>=e||i<t}};var n=new v;var Ie="__nqtr-commitment__",S=class extends StoredClassModel{constructor(e,t,i,o){super(Ie,e),this._characters=t?Array.isArray(t)?t:[t]:[],this._room=i,this._name=o.name||"",this.defaultFromHour=o.fromHour,this.defaultToHour=o.toHour,this.defaultFromDay=o.fromDay,this.defaultToDay=o.toDay,this._renderImage=o.renderImage,this._executionType=o.executionType||"interaction",this._onRun=o.onRun,this.defaultDisabled=o.disabled||false,this.defaultHidden=o.hidden||false,this._renderIcon=o.renderIcon,this.defaultPriority=o.priority||0;}_characters;get characters(){return this._characters}_room;get room(){return this._room}_name;get name(){return this._name}defaultFromHour;get fromHour(){return this.getStorageProperty("fromHour")||this.defaultFromHour||n.minDayHours}set fromHour(e){this.setStorageProperty("fromHour",e);}defaultToHour;get toHour(){return this.getStorageProperty("toHour")||this.defaultToHour||n.maxDayHours+1}set toHour(e){this.setStorageProperty("toHour",e);}defaultFromDay;get fromDay(){return this.getStorageProperty("fromDay")||this.defaultFromDay}set fromDay(e){this.setStorageProperty("fromDay",e);}defaultToDay;get toDay(){return this.getStorageProperty("toDay")||this.defaultToDay}set toDay(e){this.setStorageProperty("toDay",e);}_renderImage;get renderImage(){let e=this._renderImage;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_executionType;get executionType(){return this._executionType}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_onRun;get run(){let e=this._onRun;if(e)return t=>e(this,t)}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.fromDay&&this.fromDay>n.currentDay||!n.nowIsBetween(this.fromHour,this.toHour)||!this.isExpired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}defaultPriority;get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}isExpired(){return !!(this.toDay&&this.toDay<=n.currentDay)}};var D=class{constructor(e,t){this.defaultName=t.name,this.defaultFromHour=t.fromHour,this.defaultToHour=t.toHour,this.defaultFromDay=t.fromDay,this.defaultToDay=t.toDay,this.defaultDisabled=t.disabled||false,this.defaultHidden=t.hidden||false,this._renderIcon=t.renderIcon,this._onRun=e;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||""}set name(e){this.setStorageProperty("name",e);}defaultFromHour;get fromHour(){return this.getStorageProperty("fromHour")||this.defaultFromHour||n.minDayHours}set fromHour(e){this.setStorageProperty("fromHour",e);}defaultToHour;get toHour(){return this.getStorageProperty("toHour")||this.defaultToHour||n.maxDayHours+1}set toHour(e){this.setStorageProperty("toHour",e);}defaultFromDay;get fromDay(){return this.getStorageProperty("fromDay")||this.defaultFromDay}set fromDay(e){this.setStorageProperty("fromDay",e);}defaultToDay;get toDay(){return this.getStorageProperty("toDay")||this.defaultToDay}set toDay(e){this.setStorageProperty("toDay",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.fromDay&&this.fromDay>n.currentDay||!n.nowIsBetween(this.fromHour,this.toHour)||!this.isExpired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_onRun;get run(){return e=>this._onRun(this,e)}isExpired(){return !!(this.toDay&&this.toDay<=n.currentDay)}export(){return {name:this.getStorageProperty("name")||this.defaultName,fromHour:this.getStorageProperty("fromHour")||this.defaultFromHour,toHour:this.getStorageProperty("toHour")||this.defaultToHour,fromDay:this.getStorageProperty("fromDay")||this.defaultFromDay,toDay:this.getStorageProperty("toDay")||this.defaultToDay,disabled:this.getStorageProperty("disabled")||this.defaultDisabled,hidden:this.getStorageProperty("hidden")||this.defaultHidden,renderIcon:this._renderIcon}}};var d=class extends D{constructor(e,t,i,o){super(i,o),this._id=e,this._room=t;}setStorageProperty(e,t){this._room.setActivity(this);}getStorageProperty(e){let t=this._room.getActivityMemory(this.id);if(!(!t||!t.hasOwnProperty(e)))return t[e]}_id;get id(){return this._id}_room;get room(){return this._room}export(){let e={};return this.name!==undefined&&(e.name=this.name),this.fromHour!==undefined&&(e.fromHour=this.fromHour),this.toHour!==undefined&&(e.toHour=this.toHour),this.fromDay!==undefined&&(e.fromDay=this.fromDay),this.toDay!==undefined&&(e.toDay=this.toDay),this.disabled!==undefined&&(e.disabled=this.disabled),e}};var m={};function w(r){if(Array.isArray(r)){r.forEach(e=>w(e));return}m[r.id]&&console.warn(`[NQTR] Room id ${r.id} already exists, it will be overwritten`),m[r.id]=r;}function b(r){try{let e=m[r];if(!e){console.error(`[NQTR] Room ${r} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${r}`,e);return}}function K(r){return Object.values(m).filter(e=>e.location.id===r.id)}function Q(){let r={};return Object.values(m).forEach(e=>{r[e.location.id]=e.location;}),Object.values(r)}function z(r){return Q().filter(e=>e.map.id===r.id)}function U(){let r={};return Object.values(m).forEach(e=>{r[e.location.map.id]=e.location.map;}),Object.values(r)}var Pe="__nqtr-location__",l=class extends StoredClassModel{constructor(e,t,i={}){super(Pe,e),this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._renderIcon=i.renderIcon,this._map=t;}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"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_map;get map(){return this._map}getEntrance(){let e=this.getRooms();if(e.length===0){console.error(`[NQTR] The location ${this.id} has no rooms`);return}return e.find(t=>t.isEntrance)||e[0]}getRooms(){return K(this)}};var De="__nqtr-map__",R=class extends StoredClassModel{constructor(e,t={}){super(De,e),this.defaultName=t.name||"",this._renderImage=t.renderImage,this.defaultDisabled=t.disabled||false,this.defaultHidden=t.hidden||false,this._neighboringMaps=t.neighboringMaps;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_renderImage;get renderImage(){let e=this._renderImage;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_neighboringMaps;get neighboringMaps(){return this._neighboringMaps||{}}set neighboringMaps(e){this._neighboringMaps=e;}getLocations(){return z(this)}};var k={};M(k,{addCommitment:()=>te,getActivityById:()=>I,getAllLocations:()=>Q,getAllMaps:()=>U,getAllStartedQuests:()=>de,getCommitmentById:()=>O,getQuestById:()=>se,getRoomById:()=>b,newActivity:()=>ee,newQuest:()=>ae,removeCommitment:()=>re,saveCommitment:()=>L,saveRoom:()=>w,setFixedRoutine:()=>q});var _=class{constructor(e,t,i){this._id=e,this._name=i.name,this._fromHour=i.fromHour,this._toHour=i.toHour,this._fromDay=i.fromDay,this._toDay=i.toDay,this._disabled=i.disabled||false,this._hidden=i.hidden||false,this._renderIcon=i.renderIcon,this._onRun=t;}_id;get id(){return this._id}_name;get name(){return this._name}_fromHour;get fromHour(){return this._fromHour}_toHour;get toHour(){return this._toHour}_fromDay;get fromDay(){return this._fromDay}_toDay;get toDay(){return this._toDay}_disabled;get disabled(){return typeof this._disabled=="string"?getFlag(this._disabled):this._disabled}_hidden;get hidden(){return this.fromDay&&this.fromDay>n.currentDay||!this.isDeadline?true:typeof this._hidden=="string"?getFlag(this._hidden):this._hidden}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_onRun;get _initialOnRun(){return this._onRun}get run(){return e=>this._onRun(this,e)}isDeadline(){return !!(this.toDay&&this.toDay<=n.currentDay)}export(){return {name:this._name,fromHour:this._fromHour,toHour:this._toHour,fromDay:this._fromDay,toDay:this._toDay,disabled:this._disabled,hidden:this._hidden,renderIcon:this._renderIcon}}};var B={};function ee(r,e,t){B[r]&&console.warn(`[NQTR] Activity ${r} already exists, it will be overwritten`);let i=new _(r,e,t);return B[r]=i,i}function I(r){try{let e=B[r];if(!e){console.error(`[NQTR] Activity ${r} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${r}`,e);return}}var C="___nqtr-temporary_commitment___",h={},N={};function L(r){if(Array.isArray(r)){r.forEach(e=>L(e));return}h[r.id]&&console.warn(`[NQTR] Commitment id ${r.id} already exists, it will be overwritten`),h[r.id]=r;}function O(r){try{let e=h[r];if(!e){console.error(`[NQTR] Commitment ${r} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${r}`,e);return}}function q(r){if(Array.isArray(r)){r.forEach(e=>q(e));return}N[r.id]&&console.warn(`[NQTR] Commitment id ${r.id} already exists, it will be overwritten`),N[r.id]=r;}function te(r){Array.isArray(r)||(r=[r]);let e=r.map(t=>{if(!O(t.id)){console.warn(`[NQTR] Commitment ${t.id} not found, it will be ignored`);return}return t.id}).filter(t=>t!==undefined);storage.setVariable(C,e);}function re(r){Array.isArray(r)||(r=[r]);let e=r.map(i=>i.id),t=storage.getVariable(C);t&&(t=t.filter(i=>!e.includes(i)),storage.setVariable(C,t));}function ie(){return Object.values(N)}function oe(){let r=storage.getVariable(C);return r?r.map(t=>O(t)).filter(t=>t!==undefined):[]}var Ce="__nqtr-goal__",c=class extends StoredClassModel{constructor(e,t){super(Ce,e),this._description=t.description,this._need=t.need||1,this._defaultHave=t.have||0;}_description;get description(){return this._description}_need;get need(){return this._need}_defaultHave;get defaultHave(){return this._defaultHave}},G=class extends c{constructor(e,t,i){super(e,i),this._stageId=t;}_stageId;get stageId(){return this._stageId}set stageId(e){this._stageId=e;}get have(){return this.getStorageProperty("have-"+this._stageId)||this.defaultHave}set have(e){if(!this._stageId){console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);return}this.setStorageProperty("have-"+this._stageId,e);}get completed(){return this.have>=this.need}set completed(e){e?this.have=this.need:console.warn("[NQTR] The goal can't be set as not completed. You must edit the have value manually.");}find(){this.have++;}};var Ge="__nqtr-stage__",y=class extends StoredClassModel{constructor(e,t){super(Ge,e),this._name=t.name||"",this._defaultGoals=t.goals||[],this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._renderImage=t.renderImage,this._daysRequiredToStart=t.daysRequiredToStart,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._questsRequiredToStart=t.questsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"",this._onStart=t.onStart,this._onEnd=t.onEnd;}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_renderImage;get renderImage(){let e=this._renderImage;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_defaultGoals;get defaultGoals(){return this._defaultGoals}_flags;get flags(){return this._flags}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}},E=class extends y{constructor(e,t){super(e,t);}get completed(){let e=this.getStorageProperty("completed");return e||(this.flags.length>0&&this.goals.length>0?!(!this.flags.every(t=>getFlag(t.flag))||!this.goals.every(t=>t.completed)):false)}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get goals(){return this.defaultGoals.map(e=>new G(e.id,this.id,e))}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>n.currentDay)return false}return !(this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(t=>getFlag(t.flag))||this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=n.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}};var He="__nqtr-quest__",p=class extends StoredClassModel{constructor(e,t,i){super(He,e),this._stages=t,this._name=i.name||"",this._description=i.description||"",this._renderIcon=i.renderIcon,this._renderImage=i.renderImage,this._isInDevelopment=i.isInDevelopment||false,this._onStart=i.onStart,this._onNextStage=i.onNextStage;}_stages;get stages(){return this._stages.map((e,t)=>new E(e.id,e))}_name;get name(){return this._name}_description;get description(){return this._description}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_renderImage;get renderImage(){let e=this._renderImage;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}_isInDevelopment;get isInDevelopment(){return this._isInDevelopment}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===undefined||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==undefined}get completed(){return this.currentStageIndex===undefined?false:this.currentStageIndex>this.stages.length-1}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){console.error(`[NQTR] Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&this.onStart(this,e),t.start(e);console.error(`[NQTR] Quest ${this.id} has no start stage`);}tryToGoNextStage(e){if(!this.started||this.completed)return false;let t=this.currentStage;return t?t.completed?this.goNextStage(e):false:(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}completeCurrentStageAndGoNext(e){let t=this.currentStage;return t?(t.completed=true,this.goNextStage(e)):(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}goNextStage(e){if(!this.started)return console.warn(`[NQTR] Quest ${this.id} is not started`),false;if(this.completed)return console.warn(`[NQTR] Quest ${this.id} is already completed`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===undefined)return console.error(`[NQTR] Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&this.onNextStage(this,e),t&&t.onEnd&&t.onEnd(t,e);let o=this.currentStage;return o&&(o.inizialize(),this.currentStageMustStart&&this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var T={};function ae(r,e,t){T[r]&&console.warn(`[NQTR] Quest ${r} already exists, it will be overwritten`);let i=new p(r,e,t);return T[r]=i,i}function se(r){try{let e=T[r];if(!e){console.error(`[NQTR] Quest ${r} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Quest ${r}`,e);return}}function de(){return Object.values(T).filter(r=>r.started)}var ue="___nqtr-current_room_memory___";function le(r){if(r instanceof l){let e=r.getEntrance();if(!e){console.error(`[NQTR] The location ${r.id} has no entrance room`);return}r=e;}else if(!b(r.id)){console.error(`[NQTR] The room ${r.id} is not registered, so it can't be set as current room`);return}storage.setVariable(ue,r.id);}function f(){let r=storage.getVariable(ue);if(!r){console.error("[NQTR] The current room has not yet been set");return}let e=b(r);if(!e){console.error(`[NQTR] Current room ${r} not found`);return}return e}function $(){let r=f();if(r)return r.location}function pe(){let r=$();if(r)return r.map}function fe(){Object.entries(h).forEach(([r,e])=>{e.isExpired()&&delete h[e.id];});}function x(){let r={};return oe().reverse().forEach(e=>{e.hidden||(e.characters.length>0?e.characters.every(i=>!r[i.id]||e.priority>r[i.id].priority)&&e.characters.forEach(i=>{r[i.id]=e;}):console.error(`[NQTR] The commitment ${e.id} has no characters assigned`));}),ie().reverse().forEach(e=>{e.hidden||(e.characters.length>0?e.characters.every(i=>!r[i.id]||e.priority>r[i.id].priority)&&e.characters.forEach(i=>{r[i.id]=e;}):console.error(`[NQTR] The commitment ${e.id} has no characters assigned`));}),Object.values(r)}function ge(){let r=f();return r?r.getRoutine():[]}function he(r){x().forEach(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e});}var Qe="__nqtr-room__",P=class extends StoredClassModel{constructor(e,t,i={}){super(Qe,e),this._location=t,this.defaultName=i.name||"",this._renderImage=i.renderImage,this.defaultActivityIds=i.defaultActivities?.map(o=>o.id)||[],this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._renderIcon=i.renderIcon,this._isEntrance=i.isEntrance;}_location;get location(){return this._location}_isEntrance;get isEntrance(){return this._isEntrance||false}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_renderImage;get renderImage(){let e=this._renderImage;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}defaultActivityIds;get defaultActivities(){let e=this.getStorageProperty("activities_memory")||{};return this.defaultActivityIds.map(i=>{let o=I(i);if(!o){console.warn(`[NQTR] Activity with id ${i} not found, so it will be ignored.`);return}let g=o.export();return e[i]&&(g={...g,...e[i]}),new d(i,this,o._initialOnRun,g)}).filter(i=>i!==undefined)}get activityIds(){let e=this.getStorageProperty("addedActivityIds")||[];return this.defaultActivityIds.concat(e)}get activities(){return this.activityIds.map(t=>this.getActivity(t)).filter(t=>t!==undefined&&!t.hidden)}getActivityMemory(e){return (this.getStorageProperty("activities_memory")||{})[e]||{}}getActivity(e){if(!this.activityIds.includes(e)){console.error(`[NQTR] Activity with id ${e} not found in room ${this.id}`);return}let t=I(e);if(!t){console.error(`[NQTR] Activity with id ${e} not found`);return}let o=(this.getStorageProperty("activities_memory")||{})[e]||{};return o={...t.export(),...o},new d(e,this,t._initialOnRun,o)}setActivity(e){let t=this.getStorageProperty("activities_memory")||{};t[e.id]=e.export(),this.setStorageProperty("activities_memory",t);}addActivity(e){if(this.activityIds.includes(e.id)){let i=this.getActivity(e.id);if(i&&i.isExpired()){this.removeActivity(e.id);return}else {console.error(`[NQTR] Activity with id ${e.id} already exists in room ${this.id}, so it will be ignored.`);return}}let t=this.getStorageProperty("addedActivityIds")||[];t.push(e.id),this.setStorageProperty("addedActivityIds",t);}removeActivity(e){let t=typeof e=="string"?e:e.id;if(this.defaultActivityIds.includes(t)){console.warn(`[NQTR] Activity with id ${t} is a default activity, so it can't be removed. It will be hidden instead.`);let Y=this.getActivity(t);if(!Y){console.error(`[NQTR] Activity with id ${t} not found, so it can't be hidden.`);return}Y.hidden=true;return}let i=this.getStorageProperty("addedActivityIds")||[],o=i.indexOf(t);if(o===-1){console.error(`[NQTR] Activity with id ${t} not found, so it can't be removed.`);return}i.splice(o,1),this.setStorageProperty("addedActivityIds",i);let g=this.getStorageProperty("activities_memory")||{};delete g[t],this.setStorageProperty("activities_memory",g);}clearExpiredActivities(){this.activities.forEach(e=>{e.isExpired()&&this.removeActivity(e.id);});}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_renderIcon;get renderIcon(){let e=this._renderIcon;if(e!==undefined)return typeof e=="function"?t=>e(this,t):t=>e}getRoutine(){return x().filter(t=>t.room.id===this.id)}};var V={};M(V,{clearExpiredActivities:()=>ye,clearExpiredRoutine:()=>fe,currentActivities:()=>Te,getCommitmentByCharacter:()=>he,getCurrenrLocation:()=>$,getCurrentMap:()=>pe,getCurrentRoom:()=>f,getCurrentRoomRoutine:()=>ge,getCurrentRoutine:()=>x,setCurrentRoom:()=>le,startMustStartStageQuests:()=>ve});function ye(){Object.entries(m).forEach(([r,e])=>{e.clearExpiredActivities();});}function Te(){let r=f();return r?r.activities.filter(e=>!e.hidden):[]}function ve(r){Object.entries(T).forEach(([e,t])=>{t.currentStageMustStart&&t.startCurrentStage(r);});}var Se={};var be={};var Be={...F,...k,...V,...Se,...H,...be},dr=Be;export{d as ActivityRoom,S as CommitmentBaseModel,c as Goal,l as LocationBaseModel,R as MapBaseModel,p as Quest,P as RoomBaseModel,y as Stage,te as addCommitment,ye as clearExpiredActivities,fe as clearExpiredRoutine,Te as currentActivities,dr as default,I as getActivityById,Q as getAllLocations,U as getAllMaps,de as getAllStartedQuests,he as getCommitmentByCharacter,O as getCommitmentById,$ as getCurrenrLocation,pe as getCurrentMap,f as getCurrentRoom,ge as getCurrentRoomRoutine,x as getCurrentRoutine,se as getQuestById,b as getRoomById,ee as newActivity,ae as newQuest,re as removeCommitment,L as saveCommitment,w as saveRoom,le as setCurrentRoom,q as setFixedRoutine,ve as startMustStartStageQuests,n as timeTracker};//# sourceMappingURL=index.mjs.map
|
|
2024
2
|
//# sourceMappingURL=index.mjs.map
|