@drincs/nqtr 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/handlers.cjs +1 -0
- package/dist/handlers.d.mts +606 -0
- package/dist/handlers.d.ts +606 -0
- package/dist/handlers.mjs +1 -0
- package/dist/index.cjs +1 -2
- package/dist/index.d.mts +1391 -23
- package/dist/index.d.ts +1391 -23
- package/dist/index.mjs +1 -2
- package/dist/ink.cjs +1 -0
- package/dist/ink.d.mts +17 -0
- package/dist/ink.d.ts +17 -0
- package/dist/ink.mjs +1 -0
- package/dist/registries.cjs +1 -0
- package/dist/registries.d.mts +516 -0
- package/dist/registries.d.ts +516 -0
- package/dist/registries.mjs +1 -0
- package/package.json +40 -8
- package/dist/RoomInterface-BhP3JgjH.d.ts +0 -182
- package/dist/RoomInterface-V1-hwph_.d.mts +0 -182
- package/dist/StageInterface-v96_K9Tg.d.mts +0 -188
- package/dist/StageInterface-v96_K9Tg.d.ts +0 -188
- package/dist/classes/index.cjs +0 -2
- package/dist/classes/index.cjs.map +0 -1
- package/dist/classes/index.d.mts +0 -515
- package/dist/classes/index.d.ts +0 -515
- package/dist/classes/index.mjs +0 -2
- package/dist/classes/index.mjs.map +0 -1
- package/dist/decorators/index.cjs +0 -2
- package/dist/decorators/index.cjs.map +0 -1
- package/dist/decorators/index.d.mts +0 -164
- package/dist/decorators/index.d.ts +0 -164
- package/dist/decorators/index.mjs +0 -2
- package/dist/decorators/index.mjs.map +0 -1
- package/dist/index-B8O3zxyP.d.ts +0 -269
- package/dist/index-BgY2U2li.d.mts +0 -199
- package/dist/index-CzOd-Rin.d.mts +0 -269
- package/dist/index-cbTx3r0P.d.ts +0 -199
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/interface/index.cjs +0 -2
- package/dist/interface/index.cjs.map +0 -1
- package/dist/interface/index.d.mts +0 -6
- package/dist/interface/index.d.ts +0 -6
- package/dist/interface/index.mjs +0 -2
- package/dist/interface/index.mjs.map +0 -1
- package/dist/managers/index.cjs +0 -2
- package/dist/managers/index.cjs.map +0 -1
- package/dist/managers/index.d.mts +0 -7
- package/dist/managers/index.d.ts +0 -7
- package/dist/managers/index.mjs +0 -2
- package/dist/managers/index.mjs.map +0 -1
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.mts +0 -65
- package/dist/types/index.d.ts +0 -65
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
package/dist/classes/index.d.ts
DELETED
|
@@ -1,515 +0,0 @@
|
|
|
1
|
-
import { A as ActivityInterface, a as ActivityBaseInternalInterface, T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, b as CommitmentBaseInternalInterface, R as RoomInterface, N as NavigationAbstractInterface, c as LocationInternalInterface, M as MapInterface, d as MapBaseInternalInterface, L as LocationInterface, e as RoomBaseInternalInterface } from '../RoomInterface-BhP3JgjH.js';
|
|
2
|
-
import { A as ActivityProps, C as CommitmentProps, L as LocationBaseModelProps, M as MapBaseModelProps, R as RoomBaseModelProps, Q as QuestProps, S as StageProps, a as StageFlags } from '../index-B8O3zxyP.js';
|
|
3
|
-
import { a as OnRunEvent, O as OnRunAsyncFunction, E as ExecutionType, e as QuestBaseInternalInterface, S as StageInterface, Q as QuestInterface, f as StageBaseInternalInterface, d as QuestsRequiredType } from '../StageInterface-v96_K9Tg.js';
|
|
4
|
-
import { StoredClassModel } from '@drincs/pixi-vn/storage';
|
|
5
|
-
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
6
|
-
import { OnRunProps } from '@drincs/nqtr';
|
|
7
|
-
|
|
8
|
-
interface ActivityStoredClassProps {
|
|
9
|
-
/**
|
|
10
|
-
* Time slot in which activity/commitment will be active.
|
|
11
|
-
*/
|
|
12
|
-
timeSlot?: TimeSchedulingInterface;
|
|
13
|
-
/**
|
|
14
|
-
* Used to schedule what date it will be added and removed.
|
|
15
|
-
*/
|
|
16
|
-
dateScheduling?: DateSchedulingInterface;
|
|
17
|
-
}
|
|
18
|
-
declare class ActivityStoredClass<OnRunEventType = ActivityInterface> extends StoredClassModel implements ActivityBaseInternalInterface {
|
|
19
|
-
private readonly _onRun;
|
|
20
|
-
constructor(id: string, _onRun: OnRunEvent<OnRunEventType>, props: ActivityStoredClassProps, category?: string);
|
|
21
|
-
private _timeSlot?;
|
|
22
|
-
get timeSlot(): TimeSchedulingInterface | undefined;
|
|
23
|
-
private _dateScheduling?;
|
|
24
|
-
get dateScheduling(): DateSchedulingInterface | undefined;
|
|
25
|
-
protected addTempHistoryItem(): void;
|
|
26
|
-
get run(): OnRunAsyncFunction;
|
|
27
|
-
get expired(): boolean;
|
|
28
|
-
get isActive(): boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The activity model. It is used to create an activity.
|
|
33
|
-
* @example
|
|
34
|
-
* ```tsx
|
|
35
|
-
* export const nap = new ActivityModel("nap",
|
|
36
|
-
* (_, event) => {
|
|
37
|
-
* if (event) {
|
|
38
|
-
* event.navigate("/game")
|
|
39
|
-
* callLabelWithGoNavigationCallBack(napLabel, event)
|
|
40
|
-
* }
|
|
41
|
-
* else {
|
|
42
|
-
* console.error("Event is undefined")
|
|
43
|
-
* }
|
|
44
|
-
* },
|
|
45
|
-
* {
|
|
46
|
-
* name: "Nap",
|
|
47
|
-
* timeSlot: {
|
|
48
|
-
* from: 5,
|
|
49
|
-
* to: 23,
|
|
50
|
-
* },
|
|
51
|
-
* icon: "https://icon.jpg",
|
|
52
|
-
* }
|
|
53
|
-
* )
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
declare class ActivityBaseModel extends ActivityStoredClass<ActivityInterface> {
|
|
57
|
-
/**
|
|
58
|
-
* @param id The activity id, that must be unique.
|
|
59
|
-
* @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.
|
|
60
|
-
* @param props The activity properties.
|
|
61
|
-
*/
|
|
62
|
-
constructor(id: string, onRun: OnRunEvent<ActivityInterface>, props: ActivityProps);
|
|
63
|
-
private defaultName;
|
|
64
|
-
/**
|
|
65
|
-
* The name of the activity.
|
|
66
|
-
*/
|
|
67
|
-
get name(): string;
|
|
68
|
-
set name(value: string | undefined);
|
|
69
|
-
private defaultDisabled;
|
|
70
|
-
/**
|
|
71
|
-
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
72
|
-
*/
|
|
73
|
-
get disabled(): boolean;
|
|
74
|
-
set disabled(value: boolean | string);
|
|
75
|
-
private defaultHidden;
|
|
76
|
-
/**
|
|
77
|
-
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
78
|
-
*/
|
|
79
|
-
get hidden(): boolean;
|
|
80
|
-
set hidden(value: boolean | string);
|
|
81
|
-
private _icon?;
|
|
82
|
-
/**
|
|
83
|
-
* The icon of the activity.
|
|
84
|
-
*/
|
|
85
|
-
get icon(): string | undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface CommitmentStoredClassProps {
|
|
89
|
-
/**
|
|
90
|
-
* 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.
|
|
91
|
-
* If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
|
|
92
|
-
*/
|
|
93
|
-
executionType?: ExecutionType;
|
|
94
|
-
/**
|
|
95
|
-
* The priority. The higher the number, the higher the priority.
|
|
96
|
-
* 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.
|
|
97
|
-
*/
|
|
98
|
-
priority?: number;
|
|
99
|
-
/**
|
|
100
|
-
* Time slot in which activity/commitment will be active.
|
|
101
|
-
*/
|
|
102
|
-
timeSlot?: TimeSchedulingInterface;
|
|
103
|
-
/**
|
|
104
|
-
* Used to schedule what date it will be added and removed.
|
|
105
|
-
*/
|
|
106
|
-
dateScheduling?: DateSchedulingInterface;
|
|
107
|
-
}
|
|
108
|
-
declare class CommitmentStoredClass extends ActivityStoredClass<CommitmentInterface> implements CommitmentBaseInternalInterface {
|
|
109
|
-
private readonly _characters;
|
|
110
|
-
private readonly _room;
|
|
111
|
-
constructor(id: string, _characters: CharacterInterface[], _room: RoomInterface, onRun: OnRunEvent<CommitmentInterface> | undefined, props: CommitmentStoredClassProps);
|
|
112
|
-
private readonly defaultExecutionType;
|
|
113
|
-
private readonly defaultPriority?;
|
|
114
|
-
get characters(): CharacterInterface[];
|
|
115
|
-
get room(): RoomInterface;
|
|
116
|
-
get executionType(): ExecutionType;
|
|
117
|
-
set executionType(value: ExecutionType);
|
|
118
|
-
get priority(): number;
|
|
119
|
-
set priority(value: number);
|
|
120
|
-
protected addTempHistoryItem(): void;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* The base model of a commitment. I suggest you extend this class to create your own commitment model.
|
|
125
|
-
* You must use the saveRoom function to save the commitment in the registered commitments.
|
|
126
|
-
* @example
|
|
127
|
-
* ```ts
|
|
128
|
-
* export const mcRoom = new CommitmentBaseModel("test", character, room, {
|
|
129
|
-
* name: "Test",
|
|
130
|
-
* image: "https://image.jpg",
|
|
131
|
-
* executionType: ExecutionTypeEnum.INTERACTION,
|
|
132
|
-
* onRun: (commitment) => {
|
|
133
|
-
* // Do something
|
|
134
|
-
* }
|
|
135
|
-
* })
|
|
136
|
-
* saveCommitment(mcRoom)
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
declare class CommitmentBaseModel extends CommitmentStoredClass {
|
|
140
|
-
/**
|
|
141
|
-
* @param id The id of the commitment, it must be unique.
|
|
142
|
-
* @param character The character or characters that are in the commitment and so in the room.
|
|
143
|
-
* @param room The room where the commitment is.
|
|
144
|
-
* @param props The properties of the commitment.
|
|
145
|
-
*/
|
|
146
|
-
constructor(id: string, character: CharacterInterface | CharacterInterface[] | undefined, room: RoomInterface, props: CommitmentProps);
|
|
147
|
-
private _name;
|
|
148
|
-
/**
|
|
149
|
-
* The name of the commitment.
|
|
150
|
-
*/
|
|
151
|
-
get name(): string;
|
|
152
|
-
private _image?;
|
|
153
|
-
/**
|
|
154
|
-
* The image of the commitment.
|
|
155
|
-
*/
|
|
156
|
-
get image(): string | undefined;
|
|
157
|
-
private _icon?;
|
|
158
|
-
/**
|
|
159
|
-
* The icon of the commitment.
|
|
160
|
-
*/
|
|
161
|
-
get icon(): string | undefined;
|
|
162
|
-
private defaultDisabled;
|
|
163
|
-
/**
|
|
164
|
-
* Whether is disabled. You can also pass a Pixi'VN flag name.
|
|
165
|
-
*/
|
|
166
|
-
get disabled(): boolean;
|
|
167
|
-
set disabled(value: boolean | string);
|
|
168
|
-
private defaultHidden;
|
|
169
|
-
/**
|
|
170
|
-
* Whether is hidden. You can also pass a Pixi'VN flag name.
|
|
171
|
-
*/
|
|
172
|
-
get hidden(): boolean;
|
|
173
|
-
set hidden(value: boolean | string);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
declare abstract class NavigationAbstractClass extends StoredClassModel implements NavigationAbstractInterface {
|
|
177
|
-
private defaultActivities;
|
|
178
|
-
constructor(categoryId: string, id: string, defaultActivities?: ActivityInterface[]);
|
|
179
|
-
private get defaultActivitiesIds();
|
|
180
|
-
private get activeActivityScheduling();
|
|
181
|
-
private get excludedActivitiesScheduling();
|
|
182
|
-
private removeActivityScheduling;
|
|
183
|
-
private editActivityScheduling;
|
|
184
|
-
private editExcludedActivityScheduling;
|
|
185
|
-
private get additionalActivitiesIds();
|
|
186
|
-
private get excludedActivitiesIds();
|
|
187
|
-
get activitiesIds(): string[];
|
|
188
|
-
addActivity(activity: ActivityInterface, options?: {
|
|
189
|
-
timeSlot?: TimeSchedulingInterface;
|
|
190
|
-
dateScheduling?: DateSchedulingInterface;
|
|
191
|
-
}): void;
|
|
192
|
-
removeActivity(activity: ActivityInterface | string, options?: Pick<DateSchedulingInterface, "to">): void;
|
|
193
|
-
clearExpiredActivities(): void;
|
|
194
|
-
get activities(): ActivityInterface[];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
declare class LocationStoredClass extends NavigationAbstractClass implements LocationInternalInterface {
|
|
198
|
-
/**
|
|
199
|
-
* The map where the location is.
|
|
200
|
-
*/
|
|
201
|
-
private readonly _map;
|
|
202
|
-
constructor(id: string,
|
|
203
|
-
/**
|
|
204
|
-
* The map where the location is.
|
|
205
|
-
*/
|
|
206
|
-
_map: MapInterface, activities?: ActivityInterface[]);
|
|
207
|
-
get map(): MapInterface;
|
|
208
|
-
get rooms(): RoomInterface[];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* The base model of a location. I suggest you extend this class to create your own location model.
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* export const mcHome = new LocationBaseModel('mc_home', mainMap, {
|
|
216
|
-
* name: 'MC Home',
|
|
217
|
-
* icon: "https://icon.jpg",
|
|
218
|
-
* });
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
declare class LocationBaseModel extends LocationStoredClass implements LocationInternalInterface {
|
|
222
|
-
/**
|
|
223
|
-
* @param id The id of the location, it must be unique.
|
|
224
|
-
* @param map The map where the location is.
|
|
225
|
-
* @param props The properties of the location.
|
|
226
|
-
*/
|
|
227
|
-
constructor(id: string, map: MapInterface, props?: LocationBaseModelProps);
|
|
228
|
-
private defaultName;
|
|
229
|
-
/**
|
|
230
|
-
* The name of the location.
|
|
231
|
-
* If you set undefined, it will return the initial value of name.
|
|
232
|
-
*/
|
|
233
|
-
get name(): string;
|
|
234
|
-
set name(value: string | undefined);
|
|
235
|
-
private defaultDisabled;
|
|
236
|
-
/**
|
|
237
|
-
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
238
|
-
*/
|
|
239
|
-
get disabled(): boolean;
|
|
240
|
-
set disabled(value: boolean | string);
|
|
241
|
-
private defaultHidden;
|
|
242
|
-
/**
|
|
243
|
-
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
244
|
-
*/
|
|
245
|
-
get hidden(): boolean;
|
|
246
|
-
set hidden(value: boolean | string);
|
|
247
|
-
private _icon?;
|
|
248
|
-
/**
|
|
249
|
-
* The icon of the location.
|
|
250
|
-
*/
|
|
251
|
-
get icon(): string | undefined;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
declare class MapStoredClass extends NavigationAbstractClass implements MapBaseInternalInterface {
|
|
255
|
-
constructor(id: string, activities?: ActivityInterface[]);
|
|
256
|
-
get locations(): LocationInterface[];
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* The base model of a map. I suggest you extend this class to create your own map model.
|
|
261
|
-
* @example
|
|
262
|
-
* ```typescript
|
|
263
|
-
* export const mainMap = new MapBaseModel('main_map', {
|
|
264
|
-
* name: 'Main Map',
|
|
265
|
-
* image: "https://image.jpg",
|
|
266
|
-
* });
|
|
267
|
-
* ```
|
|
268
|
-
*/
|
|
269
|
-
declare class MapBaseModel extends MapStoredClass implements MapBaseInternalInterface {
|
|
270
|
-
/**
|
|
271
|
-
* @param id The id of the map, it must be unique.
|
|
272
|
-
* @param props The properties of the map.
|
|
273
|
-
*/
|
|
274
|
-
constructor(id: string, props?: MapBaseModelProps);
|
|
275
|
-
private defaultName;
|
|
276
|
-
/**
|
|
277
|
-
* The name of the map.
|
|
278
|
-
* If you set undefined, it will return the initial value of name.
|
|
279
|
-
*/
|
|
280
|
-
get name(): string;
|
|
281
|
-
set name(value: string | undefined);
|
|
282
|
-
private _image?;
|
|
283
|
-
/**
|
|
284
|
-
* The image of the map.
|
|
285
|
-
*/
|
|
286
|
-
get image(): string | undefined;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
declare class RoomStoredClass extends NavigationAbstractClass implements RoomBaseInternalInterface {
|
|
290
|
-
/**
|
|
291
|
-
* The location where the room is.
|
|
292
|
-
*/
|
|
293
|
-
private readonly _location;
|
|
294
|
-
constructor(id: string,
|
|
295
|
-
/**
|
|
296
|
-
* The location where the room is.
|
|
297
|
-
*/
|
|
298
|
-
_location: LocationInterface, activities?: ActivityInterface[]);
|
|
299
|
-
get routine(): CommitmentInterface[];
|
|
300
|
-
get location(): LocationInterface;
|
|
301
|
-
get characters(): CharacterInterface[];
|
|
302
|
-
get automaticFunctions(): OnRunAsyncFunction[];
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* The base model of a room. I suggest you extend this class to create your own room model.
|
|
307
|
-
* **You must use the {@link RegisteredRooms.add} function to save the room in the registered rooms.**
|
|
308
|
-
* @example
|
|
309
|
-
* ```ts
|
|
310
|
-
* export const mcRoom = new RoomBaseModel('mc_room', mcHome, {
|
|
311
|
-
* name: "MC Room",
|
|
312
|
-
* icon: "https://icon.jpg",
|
|
313
|
-
* image: "https://image.jpg",
|
|
314
|
-
* })
|
|
315
|
-
* RegisteredRooms.add(mcRoom)
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
declare class RoomBaseModel extends RoomStoredClass {
|
|
319
|
-
/**
|
|
320
|
-
* @param id The id of the room, it must be unique.
|
|
321
|
-
* @param location The location where the room is.
|
|
322
|
-
* @param props The properties of the room.
|
|
323
|
-
*/
|
|
324
|
-
constructor(id: string, location: LocationInterface, props?: RoomBaseModelProps);
|
|
325
|
-
private defaultName;
|
|
326
|
-
/**
|
|
327
|
-
* The name.
|
|
328
|
-
* If you set undefined, it will return the initial value of name.
|
|
329
|
-
*/
|
|
330
|
-
get name(): string;
|
|
331
|
-
set name(value: string | undefined);
|
|
332
|
-
private _image?;
|
|
333
|
-
/**
|
|
334
|
-
* The image of the room.
|
|
335
|
-
*/
|
|
336
|
-
get image(): string | undefined;
|
|
337
|
-
private defaultDisabled;
|
|
338
|
-
/**
|
|
339
|
-
* Whether is disabled. If it is a string, it is a Pixi'VN flag name.
|
|
340
|
-
*/
|
|
341
|
-
get disabled(): boolean;
|
|
342
|
-
set disabled(value: boolean | string);
|
|
343
|
-
private defaultHidden;
|
|
344
|
-
/**
|
|
345
|
-
* Whether is hidden. If it is a string, it is a Pixi'VN flag name.
|
|
346
|
-
*/
|
|
347
|
-
get hidden(): boolean;
|
|
348
|
-
set hidden(value: boolean | string);
|
|
349
|
-
private _icon?;
|
|
350
|
-
/**
|
|
351
|
-
* The function for rendering the icon of the room.
|
|
352
|
-
*/
|
|
353
|
-
get icon(): string | undefined;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
interface QuestStoredClassProps {
|
|
357
|
-
/**
|
|
358
|
-
* The function that will be executed when the quest starts.
|
|
359
|
-
*/
|
|
360
|
-
onStart?: OnRunEvent<QuestInterface>;
|
|
361
|
-
/**
|
|
362
|
-
* The function that will be executed when a stage end in the quest.
|
|
363
|
-
*/
|
|
364
|
-
onNextStage?: OnRunEvent<QuestInterface>;
|
|
365
|
-
}
|
|
366
|
-
declare class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {
|
|
367
|
-
private readonly _stages;
|
|
368
|
-
constructor(id: string, _stages: StageInterface[], props?: QuestStoredClassProps);
|
|
369
|
-
get stages(): StageInterface[];
|
|
370
|
-
get currentStageIndex(): number | undefined;
|
|
371
|
-
private set currentStageIndex(value);
|
|
372
|
-
get currentStage(): StageInterface | undefined;
|
|
373
|
-
get started(): boolean;
|
|
374
|
-
get completed(): boolean;
|
|
375
|
-
get inProgress(): boolean;
|
|
376
|
-
get failed(): boolean;
|
|
377
|
-
set failed(value: boolean);
|
|
378
|
-
private _onStart?;
|
|
379
|
-
get onStart(): undefined | OnRunEvent<QuestInterface>;
|
|
380
|
-
private _onNextStage?;
|
|
381
|
-
get onNextStage(): undefined | OnRunEvent<QuestInterface>;
|
|
382
|
-
start(props: OnRunProps): Promise<void>;
|
|
383
|
-
/**
|
|
384
|
-
* @deprecated Use {@link goNextIfCompleted} instead.
|
|
385
|
-
*/
|
|
386
|
-
tryToGoNextStage(props: OnRunProps): Promise<boolean>;
|
|
387
|
-
goNextIfCompleted(props: OnRunProps): Promise<boolean>;
|
|
388
|
-
/**
|
|
389
|
-
* @deprecated Use {@link goNext} instead.
|
|
390
|
-
*/
|
|
391
|
-
completeCurrentStageAndGoNext(props: OnRunProps): Promise<boolean>;
|
|
392
|
-
goNext(props: OnRunProps): Promise<boolean>;
|
|
393
|
-
/**
|
|
394
|
-
* @deprecated Use {@link forceGoNext} instead.
|
|
395
|
-
*/
|
|
396
|
-
goNextStage(props: OnRunProps): Promise<boolean>;
|
|
397
|
-
forceGoNext(props: OnRunProps): Promise<boolean>;
|
|
398
|
-
get currentStageMustStart(): boolean;
|
|
399
|
-
startCurrentStage(props: OnRunProps): Promise<void>;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
declare class QuestBaseModel extends QuestStoredClass {
|
|
403
|
-
constructor(id: string, stages: StageInterface[], props: QuestProps);
|
|
404
|
-
private _name;
|
|
405
|
-
/**
|
|
406
|
-
* The name of the quest.
|
|
407
|
-
*/
|
|
408
|
-
get name(): string;
|
|
409
|
-
private _description;
|
|
410
|
-
/**
|
|
411
|
-
* The description of the quest.
|
|
412
|
-
*/
|
|
413
|
-
get description(): string;
|
|
414
|
-
private _icon?;
|
|
415
|
-
/**
|
|
416
|
-
* Icon of the quest.
|
|
417
|
-
*/
|
|
418
|
-
get icon(): string | undefined;
|
|
419
|
-
private _image?;
|
|
420
|
-
/**
|
|
421
|
-
* Image of the quest.
|
|
422
|
-
*/
|
|
423
|
-
get image(): string | undefined;
|
|
424
|
-
private _inDevelopment;
|
|
425
|
-
/**
|
|
426
|
-
* If the quest is in development.
|
|
427
|
-
*/
|
|
428
|
-
get inDevelopment(): boolean;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
interface StageStoredClassProps {
|
|
432
|
-
/**
|
|
433
|
-
* The function that will be executed when the stage starts.
|
|
434
|
-
*/
|
|
435
|
-
onStart?: OnRunEvent<StageInterface>;
|
|
436
|
-
/**
|
|
437
|
-
* The function that will be executed when the stage ends.
|
|
438
|
-
*/
|
|
439
|
-
onEnd?: OnRunEvent<StageInterface>;
|
|
440
|
-
/**
|
|
441
|
-
* The number of day/date required to start the stage.
|
|
442
|
-
* @example If the value is 3, and the previous stage ends on day 1, the stage will start on day 4.
|
|
443
|
-
*/
|
|
444
|
-
deltaDateRequired?: number;
|
|
445
|
-
/**
|
|
446
|
-
* The quests required to start the stage.
|
|
447
|
-
* @default []
|
|
448
|
-
*/
|
|
449
|
-
questsRequired?: QuestsRequiredType[];
|
|
450
|
-
}
|
|
451
|
-
declare class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {
|
|
452
|
-
constructor(id: string, props?: StageStoredClassProps);
|
|
453
|
-
private _onStart?;
|
|
454
|
-
get onStart(): undefined | OnRunEvent<StageInterface>;
|
|
455
|
-
private _onEnd?;
|
|
456
|
-
get onEnd(): undefined | OnRunEvent<StageInterface>;
|
|
457
|
-
get completed(): boolean;
|
|
458
|
-
set completed(value: boolean);
|
|
459
|
-
get started(): boolean;
|
|
460
|
-
set started(value: boolean);
|
|
461
|
-
private get inizializeDate();
|
|
462
|
-
private set inizializeDate(value);
|
|
463
|
-
get startDate(): number | undefined;
|
|
464
|
-
get canStart(): boolean;
|
|
465
|
-
inizialize(): void;
|
|
466
|
-
start(props: OnRunProps): Promise<void>;
|
|
467
|
-
private _deltaDateRequired?;
|
|
468
|
-
get deltaDateRequired(): number;
|
|
469
|
-
private _questsRequired;
|
|
470
|
-
get questsRequired(): QuestsRequiredType[];
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
declare class StageBaseModel extends StageStoredClass {
|
|
474
|
-
constructor(id: string, props: StageProps);
|
|
475
|
-
private _name;
|
|
476
|
-
/**
|
|
477
|
-
* The name of the stage.
|
|
478
|
-
*/
|
|
479
|
-
get name(): string;
|
|
480
|
-
private _description;
|
|
481
|
-
/**
|
|
482
|
-
* The description of the stage.
|
|
483
|
-
*/
|
|
484
|
-
get description(): string;
|
|
485
|
-
private _adviceDescription;
|
|
486
|
-
/**
|
|
487
|
-
* The advice description of the stage.
|
|
488
|
-
*/
|
|
489
|
-
get adviceDescription(): string;
|
|
490
|
-
private _image?;
|
|
491
|
-
/**
|
|
492
|
-
* The image of the stage.
|
|
493
|
-
*/
|
|
494
|
-
get image(): string | undefined;
|
|
495
|
-
private _flags;
|
|
496
|
-
/**
|
|
497
|
-
* The list of flags that the player must complete to finish the stage.
|
|
498
|
-
*/
|
|
499
|
-
get flags(): StageFlags[];
|
|
500
|
-
private _flagsRequired;
|
|
501
|
-
/**
|
|
502
|
-
* The list of flags required to start the stage.
|
|
503
|
-
*/
|
|
504
|
-
get flagsRequired(): StageFlags[];
|
|
505
|
-
private _requestDescriptionToStart;
|
|
506
|
-
/**
|
|
507
|
-
* The description of the request to start the stage.
|
|
508
|
-
*/
|
|
509
|
-
get requestDescriptionToStart(): string;
|
|
510
|
-
get completed(): boolean;
|
|
511
|
-
set completed(value: boolean);
|
|
512
|
-
get canStart(): boolean;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
export { ActivityBaseModel, ActivityStoredClass, type ActivityStoredClassProps, CommitmentBaseModel, CommitmentStoredClass, type CommitmentStoredClassProps, LocationBaseModel, LocationStoredClass, MapBaseModel, MapStoredClass, QuestBaseModel, QuestStoredClass, type QuestStoredClassProps, RoomBaseModel, RoomStoredClass, StageBaseModel, StageStoredClass, type StageStoredClassProps };
|
package/dist/classes/index.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {StoredClassModel,storage}from'@drincs/pixi-vn/storage';import {narration}from'@drincs/pixi-vn/narration';import {CachedMap}from'@drincs/pixi-vn';var l="___nqtr-time_manager_data___",h="___nqtr-current_room_memory___",X="___nqtr-last_event_memory___";var s;(n=>(n.log=(i,...a)=>console.log(`[NQTR] ${i}`,...a),n.warn=(i,...a)=>console.warn(`[NQTR] ${i}`,...a),n.error=(i,...a)=>console.error(`[NQTR] ${i}`,...a),n.info=(i,...a)=>console.info(`[NQTR] ${i}`,...a)))(s||={});var O=new CachedMap({cacheSize:20}),te;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}O.set(i.id,i);}n.add=o;function e(i){try{let a=O.get(i);if(!a){console.warn(`[NQTR] Activity ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Activity ${i}`,a);return}}n.get=e;function t(){return Array.from(O.values())}n.values=t;function r(i){return O.has(i)}n.has=r;})(te||={});var q=te;var p=new CachedMap({cacheSize:20}),L=new CachedMap({cacheSize:20}),ie;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}p.set(i.id,i);}n.add=o;function e(i){try{let a=p.get(i);if(!a){console.warn(`[NQTR] Commitment ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Commitment ${i}`,a);return}}n.get=e;function t(){return Array.from(p.values())}n.values=t;function r(i){return p.has(i)}n.has=r;})(ie||={});var S=ie;var $=new CachedMap({cacheSize:20}),ne;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>o(a));return}$.set(i.id,i);}n.add=o;function e(i){try{let a=$.get(i);if(!a){console.warn(`[NQTR] Location ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Location ${i}`,a);return}}n.get=e;function t(){return Array.from($.values())}n.values=t;function r(i){return $.has(i)}n.has=r;})(ne||={});var E=ne;var k=new CachedMap({cacheSize:20}),ae;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>o(a));return}k.set(i.id,i);}n.add=o;function e(i){try{let a=k.get(i);if(!a){console.warn(`[NQTR] Map ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Map ${i}`,a);return}}n.get=e;function t(){return Array.from(k.values())}n.values=t;function r(i){return k.has(i)}n.has=r;})(ae||={});var D=ae;var z=new CachedMap({cacheSize:5}),oe;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}z.set(i.id,i);}n.add=o;function e(i){try{let a=z.get(i);if(!a){console.warn(`[NQTR] Quest ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Quest ${i}`,a);return}}n.get=e;function t(){return Array.from(z.values())}n.values=t;function r(i){return z.has(i)}n.has=r;})(oe||={});var Y=new CachedMap({cacheSize:20}),se;(n=>{function o(i){if(Array.isArray(i)){i.forEach(m=>o(m));return}Y.set(i.id,i);let a=i.location;E.add(a);let d=a?.map;d&&D.add(d);}n.add=o;function e(i){try{let a=Y.get(i);if(!a){console.warn(`[NQTR] Room ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Room ${i}`,a);return}}n.get=e;function t(){return Array.from(Y.values())}n.values=t;function r(i){return Y.has(i)}n.has=r;})(se||={});var y=se;function C(o){storage.set(X,o);}function ue(){return storage.get(X)}var P=class{get rooms(){return y.values()}get locations(){return E.values()}get maps(){return D.values()}get currentRoomId(){return storage.get(h)}get currentRoom(){let e=this.currentRoomId;if(!e){s.error("The current room has not yet been set");return}let t=y.get(e);if(!t){s.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!y.get(e)){s.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.get(h);r!==e&&(C({type:"editroom",prev:r,value:e}),storage.set(h,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){y.values().forEach(e=>{e.clearExpiredActivities();});}};var H="___nqtr-temporary_commitment___",N=class{get fixedRoutine(){return [...L.values()]}set fixedRoutine(e){e.forEach(t=>{L.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),L.set(t.id,t);});}get temporaryRoutine(){let e=storage.get(H);return e?e.map(r=>S.get(r)).filter(r=>r!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!S.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);storage.set(H,t);}find(e){return S.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(n=>n.id),r=storage.get(H);r&&(r=r.filter(n=>!t.includes(n)),storage.set(H,r));}clearExpiredRoutine(){S.values().forEach(e=>{e.expired&&p.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(n=>!e[n.id]||t.priority>e[n.id].priority)&&t.characters.forEach(n=>{e[n.id]=t;}):s.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var u=class{static dayStartTime=0;static dayEndTime=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static getDayName};var Q=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:n=1,timeSlots:i=[],weekLength:a=7,weekendStartDay:d=a-1,getDayName:m}=e;u.dayStartTime=t,u.dayEndTime=r,u.defaultTimeSpent=n,u.timeSlots=i,u.weekLength=a,d>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${a}, so will be ignored`):u.weekendStartDay=d,u.getDayName=m;}get dayStartTime(){return u.dayStartTime}get dayEndTime(){return u.dayEndTime}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get getDayName(){return u.getDayName}get currentTime(){let e=storage.get(l)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.get(l)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,C({type:"edittime",prev:t,value:r}),storage.set(l,r);}get currentDate(){let e=storage.get(l)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.get(l)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,C({type:"edittime",prev:t,value:r}),storage.set(l,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var c=new Q,I=new P,ce=new N;var Ae="__nqtr-activity__",g=class extends StoredClassModel{constructor(t,r,n,i=Ae){super(i,t);this._onRun=r;this._timeSlot=n.timeSlot,this._dateScheduling=n.dateScheduling;}_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.addCurrentStepToHistory();}get run(){return async t=>(this.addTempHistoryItem(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=c.currentDate)}get isActive(){return !(this.dateScheduling?.from&&this.dateScheduling.from>c.currentDate||this.dateScheduling?.to&&this.dateScheduling.to<c.currentDate||!c.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to))}};var G=class extends g{constructor(e,t,r){super(e,t,{dateScheduling:r.dateScheduling,timeSlot:r.timeSlot}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var be="__nqtr-commitment__",x=class extends g{constructor(t,r,n,i,a){i=i||(()=>{});super(t,i,a,be);this._characters=r;this._room=n;this.defaultExecutionType=a.executionType||"interaction",this.defaultPriority=a.priority;}defaultExecutionType;defaultPriority;get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(t){this.setStorageProperty("executionType",t);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(t){this.setStorageProperty("priority",t);}addTempHistoryItem(){let t=I.currentRoom;if(!t||this.executionType!=="automatic")return super.addTempHistoryItem();let r=ue();switch(r?.type){case "editroom":storage.set(h,r.prev),super.addTempHistoryItem(),storage.set(h,t.id);break;case "edittime":let n=storage.get(l)||{};storage.set(l,r.prev),super.addTempHistoryItem(),storage.set(l,n);break}}};var K=class extends x{constructor(e,t,r,n){super(e,t?Array.isArray(t)?t:[t]:[],r,n.onRun,{executionType:n.executionType,priority:n.priority,timeSlot:n.timeSlot,dateScheduling:n.dateScheduling}),this._name=n.name||"",this._image=n.image,this.defaultDisabled=n.disabled||false,this.defaultHidden=n.hidden||false,this._icon=n.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.dateScheduling?.from&&this.dateScheduling.from>c.currentDate||!c.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var f=class extends StoredClassModel{constructor(t,r,n=[]){super(t,r);this.defaultActivities=n;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let n=this.excludedActivitiesScheduling;delete n[t],this.setStorageProperty("excludedActivitiesScheduling",n);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let n=this.activeActivityScheduling;n[t]=r,this.setStorageProperty("activeActivityScheduling",n);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let n=this.excludedActivitiesScheduling;n[t]=r,this.setStorageProperty("excludedActivitiesScheduling",n);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(t,r={}){let{timeSlot:n,dateScheduling:i}=r,{to:a=c.dayEndTime+1}=n||{};if(n&&n.from>=a)throw new Error("[NQTR] The from time must be less than the to time.");if(i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let d=this.additionalActivitiesIds;d.includes(t.id)?console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`):(d.push(t.id),this.setStorageProperty("additionalActivitiesIds",d)),this.excludedActivitiesIds.includes(t.id)&&(this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`)),(n||i)&&this.editActivityScheduling(t.id,{timeSlot:n,dateScheduling:i});}removeActivity(t,r={}){let{to:n}=r,i=typeof t=="string"?t:t.id,a=this.additionalActivitiesIds;if(a.includes(i)){if(n!==void 0){this.editExcludedActivityScheduling(i,{dateScheduling:{to:n}});return}a=a.filter(d=>d!==i),this.setStorageProperty("additionalActivitiesIds",a),this.removeActivityScheduling(i);}else if(this.defaultActivitiesIds.includes(i)){if(n!==void 0){this.editExcludedActivityScheduling(i,{dateScheduling:{to:n}});return}let d=this.excludedActivitiesIds;d.push(i),this.setStorageProperty("excludedActivitiesIds",d);}else console.warn(`[NQTR] Activity with id ${i} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,n=this.additionalActivitiesIds,i=this.excludedActivitiesIds;n.forEach(a=>{if(a in t){let{to:d}=t[a].dateScheduling||{};d&&d<c.currentDate&&(this.removeActivityScheduling(a),n=n.filter(m=>m!==a));}}),i.forEach(a=>{if(a in r){let{to:d}=r[a].dateScheduling||{};d&&d<c.currentDate&&(this.removeActivityScheduling(a),i=i.filter(m=>m!==a));}});}get activities(){let t=[],r=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(n=>{let i=q.get(n),{dateScheduling:a,timeSlot:d}=r[n]||{},{from:m=i?.dateScheduling?.from,to:ee=i?.dateScheduling?.to}=a||{},{from:pe=i?.timeSlot?.from,to:Se=i?.timeSlot?.to}=d||{};i&&c.nowIsBetween(pe,Se)&&!(m&&m>c.currentDate)&&!(ee&&ee<c.currentDate)&&t.push(i);}),Object.entries(this.excludedActivitiesScheduling).forEach(([n,i])=>{let a=q.get(n);a&&a.isActive&&!(i.dateScheduling&&i.dateScheduling.to!==void 0&&i.dateScheduling.to>=c.currentDate)&&t.push(a);}),this.defaultActivities.forEach(n=>{n.isActive&&!t.find(i=>i.id===n.id)&&t.push(n);}),t}};var De="__nqtr-location__",_=class extends f{constructor(t,r,n=[]){super(De,t,n);this._map=r;}get map(){return this._map}get rooms(){return I.rooms.filter(t=>t.location.id===this.id)}};var W=class extends _{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ce="__nqtr-map__",R=class extends f{constructor(e,t=[]){super(Ce,e,t);}get locations(){return I.locations.filter(e=>e.map.id===this.id)}};var U=class extends R{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var Pe="__nqtr-room__",T=class extends f{constructor(t,r,n=[]){super(Pe,t,n);this._location=r;}get routine(){return ce.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}get characters(){let t=[];return this.routine.forEach(r=>{t.push(...r.characters);}),t}get automaticFunctions(){return this.routine.filter(t=>t.executionType==="automatic"&&t.run).map(t=>async n=>{await t.run(n);})}};var V=class extends T{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ne="__nqtr-quest__",A=class extends StoredClassModel{constructor(t,r,n={}){super(Ne,t);this._stages=r;this._onStart=n.onStart,this._onNextStage=n.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===void 0||t>=this.stages.length))return this.stages[t]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){s.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r&&r.start)return this.onStart&&await this.onStart(this,t),await r.start(t);s.error(`Quest ${this.id} has no start stage`);}tryToGoNextStage(t){return this.goNextIfCompleted(t)}async goNextIfCompleted(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.forceGoNext(t):false:(s.error(`Quest ${this.id} has no current stage`),false)}completeCurrentStageAndGoNext(t){return this.goNext(t)}async goNext(t){let r=this.currentStage;return r?(r.completed=true,await this.forceGoNext(t)):(s.error(`Quest ${this.id} has no current stage`),false)}goNextStage(t){return this.forceGoNext(t)}async forceGoNext(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,n=this.currentStageIndex;if(!r||n===void 0)return s.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=n+1,this.onNextStage&&await this.onNextStage(this,t),r&&r.onEnd&&await r.onEnd(r,t);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var j=class extends A{constructor(e,t,r){super(e,t,{onStart:r.onStart,onNextStage:r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};var Me="__nqtr-stage__",b=class extends StoredClassModel{constructor(e,t={}){super(Me,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>c.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=c.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_deltaDateRequired;get deltaDateRequired(){return this._deltaDateRequired||0}_questsRequired;get questsRequired(){return this._questsRequired||[]}};var J=class extends b{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequired;get flagsRequired(){return this._flagsRequired}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.getFlag(e.flag))?false:super.canStart}};export{G as ActivityBaseModel,g as ActivityStoredClass,K as CommitmentBaseModel,x as CommitmentStoredClass,W as LocationBaseModel,_ as LocationStoredClass,U as MapBaseModel,R as MapStoredClass,j as QuestBaseModel,A as QuestStoredClass,V as RoomBaseModel,T as RoomStoredClass,J as StageBaseModel,b as StageStoredClass};//# sourceMappingURL=index.mjs.map
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|