@drincs/nqtr 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Commitment-CtNWnNQX.d.mts → Commitment-BHB-jYOi.d.mts} +4 -4
- package/dist/{Commitment-BJTIpBQ5.d.ts → Commitment-D-1lsnnU.d.ts} +4 -4
- package/dist/{StageProps-CkXejAbn.d.mts → StageProps-CJSp_a54.d.mts} +38 -3
- package/dist/{StageProps-BFsiCaZT.d.ts → StageProps-CV4rWD7t.d.ts} +38 -3
- package/dist/classes/Commitment.d.mts +2 -2
- package/dist/classes/Commitment.d.ts +2 -2
- package/dist/classes/index.d.mts +4 -4
- package/dist/classes/index.d.ts +4 -4
- package/dist/classes/index.js +384 -133
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +384 -133
- 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 +3 -0
- package/dist/classes/navigation/ActivityRoom.js.map +1 -1
- package/dist/classes/navigation/ActivityRoom.mjs +3 -0
- package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
- package/dist/classes/navigation/Location.d.mts +3 -3
- package/dist/classes/navigation/Location.d.ts +3 -3
- package/dist/classes/navigation/Map.d.mts +3 -3
- package/dist/classes/navigation/Map.d.ts +3 -3
- package/dist/classes/navigation/Room.d.mts +1 -1
- package/dist/classes/navigation/Room.d.ts +1 -1
- package/dist/classes/navigation/Room.js +76 -73
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +76 -73
- package/dist/classes/navigation/Room.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 +117 -25
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +117 -25
- 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 +34 -9
- package/dist/classes/quest/Stage.js.map +1 -1
- package/dist/classes/quest/Stage.mjs +34 -9
- package/dist/classes/quest/Stage.mjs.map +1 -1
- package/dist/decorators/ActivityDecorator.d.mts +10 -11
- package/dist/decorators/ActivityDecorator.d.ts +10 -11
- package/dist/decorators/ActivityDecorator.js +384 -9
- package/dist/decorators/ActivityDecorator.js.map +1 -1
- package/dist/decorators/ActivityDecorator.mjs +384 -9
- package/dist/decorators/ActivityDecorator.mjs.map +1 -1
- package/dist/decorators/CommitmentDecorator.d.mts +3 -3
- package/dist/decorators/CommitmentDecorator.d.ts +3 -3
- package/dist/decorators/QuestDecorator.d.mts +10 -4
- package/dist/decorators/QuestDecorator.d.ts +10 -4
- package/dist/decorators/QuestDecorator.js +121 -25
- package/dist/decorators/QuestDecorator.js.map +1 -1
- package/dist/decorators/QuestDecorator.mjs +121 -26
- package/dist/decorators/QuestDecorator.mjs.map +1 -1
- package/dist/decorators/RoomDecorator.d.mts +3 -3
- package/dist/decorators/RoomDecorator.d.ts +3 -3
- package/dist/decorators/index.d.mts +4 -4
- package/dist/decorators/index.d.ts +4 -4
- package/dist/decorators/index.js +342 -115
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +342 -116
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/ActivityFunctions.d.mts +10 -3
- package/dist/functions/ActivityFunctions.d.ts +10 -3
- package/dist/functions/ActivityFunctions.js.map +1 -1
- package/dist/functions/ActivityFunctions.mjs.map +1 -1
- package/dist/functions/NavigationFunctions.d.mts +22 -5
- package/dist/functions/NavigationFunctions.d.ts +22 -5
- package/dist/functions/NavigationFunctions.js +2 -2
- package/dist/functions/NavigationFunctions.js.map +1 -1
- package/dist/functions/NavigationFunctions.mjs +2 -2
- package/dist/functions/NavigationFunctions.mjs.map +1 -1
- package/dist/functions/QuestFunctions.d.mts +8 -0
- package/dist/functions/QuestFunctions.d.ts +8 -0
- package/dist/functions/QuestFunctions.js +21 -0
- package/dist/functions/QuestFunctions.js.map +1 -0
- package/dist/functions/QuestFunctions.mjs +19 -0
- package/dist/functions/QuestFunctions.mjs.map +1 -0
- package/dist/functions/RoutineFunctions.d.mts +9 -4
- package/dist/functions/RoutineFunctions.d.ts +9 -4
- package/dist/functions/RoutineFunctions.js +40 -0
- package/dist/functions/RoutineFunctions.js.map +1 -1
- package/dist/functions/RoutineFunctions.mjs +40 -1
- package/dist/functions/RoutineFunctions.mjs.map +1 -1
- package/dist/functions/index.d.mts +6 -5
- package/dist/functions/index.d.ts +6 -5
- package/dist/functions/index.js +23 -2
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +21 -2
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +328 -213
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +323 -211
- package/dist/index.mjs.map +1 -1
- package/dist/interface/CommitmentProps.d.mts +2 -2
- package/dist/interface/CommitmentProps.d.ts +2 -2
- package/dist/interface/RoomProps.d.mts +2 -2
- package/dist/interface/RoomProps.d.ts +2 -2
- package/dist/interface/index.d.mts +3 -3
- package/dist/interface/index.d.ts +3 -3
- package/dist/interface/navigation/LocationProps.d.mts +3 -3
- package/dist/interface/navigation/LocationProps.d.ts +3 -3
- package/dist/interface/navigation/MapProps.d.mts +3 -3
- package/dist/interface/navigation/MapProps.d.ts +3 -3
- package/dist/interface/quest/QuestProps.d.mts +1 -1
- package/dist/interface/quest/QuestProps.d.ts +1 -1
- package/dist/interface/quest/StageProps.d.mts +1 -1
- package/dist/interface/quest/StageProps.d.ts +1 -1
- package/dist/types/QuestsRequired.d.mts +1 -1
- package/dist/types/QuestsRequired.d.ts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +5 -5
package/dist/decorators/index.js
CHANGED
|
@@ -2,95 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var pixiVn = require('@drincs/pixi-vn');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
6
|
-
var registeredActivities = {};
|
|
7
|
-
function saveActivity(activity) {
|
|
8
|
-
if (Array.isArray(activity)) {
|
|
9
|
-
activity.forEach((c) => saveActivity(c));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (registeredActivities[activity.id]) {
|
|
13
|
-
console.warn(`[NQTR] Activity id ${activity.id} already exists, it will be overwritten`);
|
|
14
|
-
}
|
|
15
|
-
registeredActivities[activity.id] = activity;
|
|
16
|
-
}
|
|
17
|
-
function getActivityById(id) {
|
|
18
|
-
try {
|
|
19
|
-
let activity = registeredActivities[id];
|
|
20
|
-
if (!activity) {
|
|
21
|
-
console.error(`[NQTR] Activity ${id} not found`);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
return activity;
|
|
25
|
-
} catch (e) {
|
|
26
|
-
console.error(`[NQTR] Error while getting Activity ${id}`, e);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
|
|
31
|
-
var registeredCommitments = {};
|
|
32
|
-
var fixedCommitments = {};
|
|
33
|
-
function saveCommitment(commitment) {
|
|
34
|
-
if (Array.isArray(commitment)) {
|
|
35
|
-
commitment.forEach((c) => saveCommitment(c));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (registeredCommitments[commitment.id]) {
|
|
39
|
-
console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`);
|
|
40
|
-
}
|
|
41
|
-
registeredCommitments[commitment.id] = commitment;
|
|
42
|
-
}
|
|
43
|
-
function getCommitmentById(id) {
|
|
44
|
-
try {
|
|
45
|
-
let commitment = registeredCommitments[id];
|
|
46
|
-
if (!commitment) {
|
|
47
|
-
console.error(`[NQTR] Commitment ${id} not found`);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
return commitment;
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.error(`[NQTR] Error while getting Commitment ${id}`, e);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function setFixedRoutine(commitments) {
|
|
57
|
-
if (Array.isArray(commitments)) {
|
|
58
|
-
commitments.forEach((c) => setFixedRoutine(c));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (fixedCommitments[commitments.id]) {
|
|
62
|
-
console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`);
|
|
63
|
-
}
|
|
64
|
-
fixedCommitments[commitments.id] = commitments;
|
|
65
|
-
}
|
|
66
|
-
function addCommitment(commitment) {
|
|
67
|
-
if (!Array.isArray(commitment)) {
|
|
68
|
-
commitment = [commitment];
|
|
69
|
-
}
|
|
70
|
-
let commitmentsIds = commitment.map((commitment2) => {
|
|
71
|
-
let commitmentTest = getCommitmentById(commitment2.id);
|
|
72
|
-
if (!commitmentTest) {
|
|
73
|
-
console.warn(`[NQTR] Commitment ${commitment2.id} not found, it will be ignored`);
|
|
74
|
-
return void 0;
|
|
75
|
-
}
|
|
76
|
-
return commitment2.id;
|
|
77
|
-
}).filter((id) => id !== void 0);
|
|
78
|
-
pixiVn.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, commitmentsIds);
|
|
79
|
-
}
|
|
80
|
-
function removeCommitment(commitment) {
|
|
81
|
-
if (!Array.isArray(commitment)) {
|
|
82
|
-
commitment = [commitment];
|
|
83
|
-
}
|
|
84
|
-
let commitmentsIds = commitment.map((commitment2) => {
|
|
85
|
-
return commitment2.id;
|
|
86
|
-
});
|
|
87
|
-
let currentCommitments = pixiVn.GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
88
|
-
if (!currentCommitments) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
currentCommitments = currentCommitments.filter((id) => !commitmentsIds.includes(id));
|
|
92
|
-
pixiVn.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, currentCommitments);
|
|
93
|
-
}
|
|
5
|
+
// src/classes/Activity.ts
|
|
94
6
|
var TIME_SETTINGS_KEY = "___nqtr-time_manager_settings___";
|
|
95
7
|
var TIME_DATA_KEY = "___nqtr-time_manager_data___";
|
|
96
8
|
var TimeManager = class _TimeManager {
|
|
@@ -333,6 +245,225 @@ var TimeManager = class _TimeManager {
|
|
|
333
245
|
return currentHour >= fromHour || currentHour < toHour;
|
|
334
246
|
}
|
|
335
247
|
};
|
|
248
|
+
|
|
249
|
+
// src/classes/Activity.ts
|
|
250
|
+
var ActivityModel = class {
|
|
251
|
+
/**
|
|
252
|
+
* @param id The activity id, that must be unique.
|
|
253
|
+
* @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.
|
|
254
|
+
* @param props The activity properties.
|
|
255
|
+
*/
|
|
256
|
+
constructor(id, onRun, props) {
|
|
257
|
+
this._id = id;
|
|
258
|
+
this._name = props.name;
|
|
259
|
+
this._fromHour = props.fromHour;
|
|
260
|
+
this._toHour = props.toHour;
|
|
261
|
+
this._fromDay = props.fromDay;
|
|
262
|
+
this._toDay = props.toDay;
|
|
263
|
+
this._disabled = props.disabled || false;
|
|
264
|
+
this._hidden = props.hidden || false;
|
|
265
|
+
this._renderIcon = props.renderIcon;
|
|
266
|
+
this._onRun = onRun;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The activity id, that is unique.
|
|
270
|
+
*/
|
|
271
|
+
get id() {
|
|
272
|
+
return this._id;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The name
|
|
276
|
+
*/
|
|
277
|
+
get name() {
|
|
278
|
+
return this._name;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
282
|
+
*/
|
|
283
|
+
get fromHour() {
|
|
284
|
+
return this._fromHour;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
288
|
+
*/
|
|
289
|
+
get toHour() {
|
|
290
|
+
return this._toHour;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
294
|
+
*/
|
|
295
|
+
get fromDay() {
|
|
296
|
+
return this._fromDay;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
300
|
+
*/
|
|
301
|
+
get toDay() {
|
|
302
|
+
return this._toDay;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Whether is disabled.
|
|
306
|
+
*/
|
|
307
|
+
get disabled() {
|
|
308
|
+
if (typeof this._disabled === "string") {
|
|
309
|
+
return pixiVn.getFlag(this._disabled);
|
|
310
|
+
}
|
|
311
|
+
return this._disabled;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
315
|
+
*/
|
|
316
|
+
get hidden() {
|
|
317
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
if (!this.isDeadline) {
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
if (typeof this._hidden === "string") {
|
|
324
|
+
return pixiVn.getFlag(this._hidden);
|
|
325
|
+
}
|
|
326
|
+
return this._hidden;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The function for rendering the icon of the activity.
|
|
330
|
+
*/
|
|
331
|
+
get renderIcon() {
|
|
332
|
+
let render = this._renderIcon;
|
|
333
|
+
if (render === void 0) {
|
|
334
|
+
return void 0;
|
|
335
|
+
}
|
|
336
|
+
if (typeof render === "function") {
|
|
337
|
+
return (props) => {
|
|
338
|
+
return render(this, props);
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
return (props) => render;
|
|
342
|
+
}
|
|
343
|
+
get _initialOnRun() {
|
|
344
|
+
return this._onRun;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The function that is called when the activity is runned.
|
|
348
|
+
*/
|
|
349
|
+
get run() {
|
|
350
|
+
return (props) => this._onRun(this, props);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Whether the activity is a deadline.
|
|
354
|
+
* @returns Whether the activity is a deadline.
|
|
355
|
+
*/
|
|
356
|
+
isDeadline() {
|
|
357
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Export the activity properties.
|
|
364
|
+
* @returns The activity properties.
|
|
365
|
+
*/
|
|
366
|
+
export() {
|
|
367
|
+
return {
|
|
368
|
+
name: this._name,
|
|
369
|
+
fromHour: this._fromHour,
|
|
370
|
+
toHour: this._toHour,
|
|
371
|
+
fromDay: this._fromDay,
|
|
372
|
+
toDay: this._toDay,
|
|
373
|
+
disabled: this._disabled,
|
|
374
|
+
hidden: this._hidden,
|
|
375
|
+
renderIcon: this._renderIcon
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// src/decorators/ActivityDecorator.ts
|
|
381
|
+
var registeredActivities = {};
|
|
382
|
+
function newActivity(id, onRun, props) {
|
|
383
|
+
if (registeredActivities[id]) {
|
|
384
|
+
console.warn(`[NQTR] Activity ${id} already exists, it will be overwritten`);
|
|
385
|
+
}
|
|
386
|
+
let activity = new ActivityModel(id, onRun, props);
|
|
387
|
+
registeredActivities[id] = activity;
|
|
388
|
+
return activity;
|
|
389
|
+
}
|
|
390
|
+
function getActivityById(id) {
|
|
391
|
+
try {
|
|
392
|
+
let activity = registeredActivities[id];
|
|
393
|
+
if (!activity) {
|
|
394
|
+
console.error(`[NQTR] Activity ${id} not found`);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
return activity;
|
|
398
|
+
} catch (e) {
|
|
399
|
+
console.error(`[NQTR] Error while getting Activity ${id}`, e);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
|
|
404
|
+
var registeredCommitments = {};
|
|
405
|
+
var fixedCommitments = {};
|
|
406
|
+
function saveCommitment(commitment) {
|
|
407
|
+
if (Array.isArray(commitment)) {
|
|
408
|
+
commitment.forEach((c) => saveCommitment(c));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (registeredCommitments[commitment.id]) {
|
|
412
|
+
console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`);
|
|
413
|
+
}
|
|
414
|
+
registeredCommitments[commitment.id] = commitment;
|
|
415
|
+
}
|
|
416
|
+
function getCommitmentById(id) {
|
|
417
|
+
try {
|
|
418
|
+
let commitment = registeredCommitments[id];
|
|
419
|
+
if (!commitment) {
|
|
420
|
+
console.error(`[NQTR] Commitment ${id} not found`);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
return commitment;
|
|
424
|
+
} catch (e) {
|
|
425
|
+
console.error(`[NQTR] Error while getting Commitment ${id}`, e);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function setFixedRoutine(commitments) {
|
|
430
|
+
if (Array.isArray(commitments)) {
|
|
431
|
+
commitments.forEach((c) => setFixedRoutine(c));
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (fixedCommitments[commitments.id]) {
|
|
435
|
+
console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`);
|
|
436
|
+
}
|
|
437
|
+
fixedCommitments[commitments.id] = commitments;
|
|
438
|
+
}
|
|
439
|
+
function addCommitment(commitment) {
|
|
440
|
+
if (!Array.isArray(commitment)) {
|
|
441
|
+
commitment = [commitment];
|
|
442
|
+
}
|
|
443
|
+
let commitmentsIds = commitment.map((commitment2) => {
|
|
444
|
+
let commitmentTest = getCommitmentById(commitment2.id);
|
|
445
|
+
if (!commitmentTest) {
|
|
446
|
+
console.warn(`[NQTR] Commitment ${commitment2.id} not found, it will be ignored`);
|
|
447
|
+
return void 0;
|
|
448
|
+
}
|
|
449
|
+
return commitment2.id;
|
|
450
|
+
}).filter((id) => id !== void 0);
|
|
451
|
+
pixiVn.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, commitmentsIds);
|
|
452
|
+
}
|
|
453
|
+
function removeCommitment(commitment) {
|
|
454
|
+
if (!Array.isArray(commitment)) {
|
|
455
|
+
commitment = [commitment];
|
|
456
|
+
}
|
|
457
|
+
let commitmentsIds = commitment.map((commitment2) => {
|
|
458
|
+
return commitment2.id;
|
|
459
|
+
});
|
|
460
|
+
let currentCommitments = pixiVn.GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
461
|
+
if (!currentCommitments) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
currentCommitments = currentCommitments.filter((id) => !commitmentsIds.includes(id));
|
|
465
|
+
pixiVn.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, currentCommitments);
|
|
466
|
+
}
|
|
336
467
|
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
337
468
|
var Goal = class extends pixiVn.StoredClassModel {
|
|
338
469
|
constructor(id, props) {
|
|
@@ -522,17 +653,29 @@ var StageQuest = class extends Stage {
|
|
|
522
653
|
if (storedCompleted) {
|
|
523
654
|
return storedCompleted;
|
|
524
655
|
}
|
|
525
|
-
if (
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
656
|
+
if (this.flags.length > 0 && this.goals.length > 0) {
|
|
657
|
+
if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
return true;
|
|
530
664
|
}
|
|
531
|
-
return
|
|
665
|
+
return false;
|
|
532
666
|
}
|
|
533
667
|
set completed(value) {
|
|
534
668
|
this.setStorageProperty("completed", value);
|
|
535
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* If the stage is started.
|
|
672
|
+
*/
|
|
673
|
+
get started() {
|
|
674
|
+
return this.getStorageProperty("started") || false;
|
|
675
|
+
}
|
|
676
|
+
set started(value) {
|
|
677
|
+
this.setStorageProperty("started", value);
|
|
678
|
+
}
|
|
536
679
|
/**
|
|
537
680
|
* The list of goals that the player needs to complete to finish the stage.
|
|
538
681
|
*/
|
|
@@ -582,13 +725,26 @@ var StageQuest = class extends Stage {
|
|
|
582
725
|
return true;
|
|
583
726
|
}
|
|
584
727
|
/**
|
|
585
|
-
*
|
|
728
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
586
729
|
*/
|
|
587
|
-
|
|
730
|
+
inizialize() {
|
|
588
731
|
if (this.daysRequiredToStart > 0) {
|
|
589
732
|
this.prevStageEndDay = TimeManager.currentDay;
|
|
733
|
+
console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* The function that will be called when the stage starts.
|
|
738
|
+
*/
|
|
739
|
+
start(props) {
|
|
740
|
+
if (this.canStart) {
|
|
741
|
+
this.started = true;
|
|
742
|
+
if (this.onStart) {
|
|
743
|
+
this.onStart(props);
|
|
744
|
+
}
|
|
745
|
+
} else {
|
|
746
|
+
console.warn(`[NQTR] Stage ${this.id} can't start`);
|
|
590
747
|
}
|
|
591
|
-
return super.onStart;
|
|
592
748
|
}
|
|
593
749
|
};
|
|
594
750
|
|
|
@@ -689,7 +845,10 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
689
845
|
* If the quest is completed.
|
|
690
846
|
*/
|
|
691
847
|
get completed() {
|
|
692
|
-
|
|
848
|
+
if (this.currentStageIndex === void 0) {
|
|
849
|
+
return false;
|
|
850
|
+
}
|
|
851
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
693
852
|
}
|
|
694
853
|
/**
|
|
695
854
|
* Start the quest.
|
|
@@ -707,14 +866,15 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
707
866
|
}
|
|
708
867
|
this.currentStageIndex = 0;
|
|
709
868
|
let currentStage = this.currentStage;
|
|
710
|
-
if (currentStage && currentStage.
|
|
711
|
-
return currentStage.
|
|
869
|
+
if (currentStage && currentStage.start) {
|
|
870
|
+
return currentStage.start(props);
|
|
712
871
|
} else {
|
|
713
872
|
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
714
873
|
}
|
|
715
874
|
}
|
|
716
875
|
/**
|
|
717
|
-
*
|
|
876
|
+
* Go to the next stage if the current stage is completed.
|
|
877
|
+
* If you want to force the change of stage, use goNextStage.
|
|
718
878
|
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
719
879
|
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
720
880
|
* @returns true if the stage was changed, false otherwise.
|
|
@@ -727,25 +887,88 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
727
887
|
return false;
|
|
728
888
|
}
|
|
729
889
|
let currentStage = this.currentStage;
|
|
730
|
-
|
|
731
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
890
|
+
if (!currentStage) {
|
|
732
891
|
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
733
892
|
return false;
|
|
734
893
|
}
|
|
735
894
|
if (currentStage.completed) {
|
|
736
|
-
|
|
737
|
-
currentStageIndex = nextStageIndex;
|
|
738
|
-
let nextStage = this.currentStage;
|
|
739
|
-
if (currentStage && currentStage.onEnd) {
|
|
740
|
-
currentStage.onEnd(endProps);
|
|
741
|
-
}
|
|
742
|
-
if (nextStage && nextStage.onStart) {
|
|
743
|
-
nextStage.onStart(startProps);
|
|
744
|
-
}
|
|
745
|
-
return true;
|
|
895
|
+
return this.goNextStage(startProps, endProps);
|
|
746
896
|
}
|
|
747
897
|
return false;
|
|
748
898
|
}
|
|
899
|
+
/**
|
|
900
|
+
* Complete the current stage and go to the next stage.
|
|
901
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
902
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
903
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
904
|
+
* @returns true if the stage was changed, false otherwise.
|
|
905
|
+
*/
|
|
906
|
+
completeCurrentStageAndGoNext(startProps, endProps) {
|
|
907
|
+
let currentStage = this.currentStage;
|
|
908
|
+
if (!currentStage) {
|
|
909
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
currentStage.completed = true;
|
|
913
|
+
return this.goNextStage(startProps, endProps);
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Go to the next stage without checking if the current stage is completed.
|
|
917
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
918
|
+
* @param startProps
|
|
919
|
+
* @param endProps
|
|
920
|
+
* @returns returns true if the stage was changed, false otherwise.
|
|
921
|
+
*/
|
|
922
|
+
goNextStage(startProps, endProps) {
|
|
923
|
+
if (!this.started) {
|
|
924
|
+
console.warn(`[NQTR] Quest ${this.id} is not started`);
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
if (this.completed) {
|
|
928
|
+
console.warn(`[NQTR] Quest ${this.id} is already completed`);
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
let prevStage = this.currentStage;
|
|
932
|
+
let currentStageIndex = this.currentStageIndex;
|
|
933
|
+
if (!prevStage || currentStageIndex === void 0) {
|
|
934
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
this.currentStageIndex = currentStageIndex + 1;
|
|
938
|
+
if (prevStage && prevStage.onEnd) {
|
|
939
|
+
prevStage.onEnd(endProps);
|
|
940
|
+
}
|
|
941
|
+
let nextCurrentStage = this.currentStage;
|
|
942
|
+
if (nextCurrentStage) {
|
|
943
|
+
nextCurrentStage.inizialize();
|
|
944
|
+
if (this.currentStageMustStart) {
|
|
945
|
+
this.startCurrentStage(startProps);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* If the current stage must start. It is true if the current stage is not started, can start and not completed.
|
|
952
|
+
*/
|
|
953
|
+
get currentStageMustStart() {
|
|
954
|
+
let currentStage = this.currentStage;
|
|
955
|
+
if (!currentStage) {
|
|
956
|
+
return false;
|
|
957
|
+
}
|
|
958
|
+
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Start the current stage.
|
|
962
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
963
|
+
*/
|
|
964
|
+
startCurrentStage(props) {
|
|
965
|
+
let newCurrentStage = this.currentStage;
|
|
966
|
+
if (newCurrentStage && this.currentStageMustStart) {
|
|
967
|
+
newCurrentStage.start(props);
|
|
968
|
+
} else {
|
|
969
|
+
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
749
972
|
};
|
|
750
973
|
|
|
751
974
|
// src/decorators/QuestDecorator.ts
|
|
@@ -771,6 +994,9 @@ function getQuestById(id) {
|
|
|
771
994
|
return;
|
|
772
995
|
}
|
|
773
996
|
}
|
|
997
|
+
function getAllStartedQuests() {
|
|
998
|
+
return Object.values(registeredQuests).filter((quest) => quest.started);
|
|
999
|
+
}
|
|
774
1000
|
|
|
775
1001
|
// src/decorators/RoomDecorator.ts
|
|
776
1002
|
var registeredRooms = {};
|
|
@@ -816,12 +1042,13 @@ exports.addCommitment = addCommitment;
|
|
|
816
1042
|
exports.getActivityById = getActivityById;
|
|
817
1043
|
exports.getAllLocations = getAllLocations;
|
|
818
1044
|
exports.getAllMaps = getAllMaps;
|
|
1045
|
+
exports.getAllStartedQuests = getAllStartedQuests;
|
|
819
1046
|
exports.getCommitmentById = getCommitmentById;
|
|
820
1047
|
exports.getQuestById = getQuestById;
|
|
821
1048
|
exports.getRoomById = getRoomById;
|
|
1049
|
+
exports.newActivity = newActivity;
|
|
822
1050
|
exports.newQuest = newQuest;
|
|
823
1051
|
exports.removeCommitment = removeCommitment;
|
|
824
|
-
exports.saveActivity = saveActivity;
|
|
825
1052
|
exports.saveCommitment = saveCommitment;
|
|
826
1053
|
exports.saveRoom = saveRoom;
|
|
827
1054
|
exports.setFixedRoutine = setFixedRoutine;
|