@drincs/nqtr 0.2.0 → 0.2.2
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/{StageProps-xLLR0rjD.d.mts → StageProps-D002cyay.d.mts} +109 -2
- package/dist/{StageProps-DCZkZHwZ.d.ts → StageProps-DleWO-vf.d.ts} +109 -2
- 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 +38 -131
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +40 -132
- 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/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 +43 -43
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +43 -43
- package/dist/classes/navigation/Room.mjs.map +1 -1
- package/dist/classes/quest/Goal.d.mts +18 -0
- package/dist/classes/quest/Goal.d.ts +18 -0
- package/dist/classes/quest/Goal.js +18 -0
- package/dist/classes/quest/Goal.js.map +1 -1
- package/dist/classes/quest/Goal.mjs +18 -0
- 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 +206 -25
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +206 -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 +95 -8
- package/dist/classes/quest/Stage.js.map +1 -1
- package/dist/classes/quest/Stage.mjs +95 -8
- 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/CommitmentDecorator.js +1 -1
- package/dist/decorators/CommitmentDecorator.js.map +1 -1
- package/dist/decorators/CommitmentDecorator.mjs +1 -1
- package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
- package/dist/decorators/QuestDecorator.d.mts +4 -3
- package/dist/decorators/QuestDecorator.d.ts +4 -3
- package/dist/decorators/QuestDecorator.js +206 -25
- package/dist/decorators/QuestDecorator.js.map +1 -1
- package/dist/decorators/QuestDecorator.mjs +206 -25
- 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 +3 -3
- package/dist/decorators/index.d.ts +3 -3
- package/dist/decorators/index.js +427 -115
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +428 -116
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/ActivityFunctions.d.mts +3 -3
- package/dist/functions/ActivityFunctions.d.ts +3 -3
- package/dist/functions/ActivityFunctions.js.map +1 -1
- package/dist/functions/ActivityFunctions.mjs.map +1 -1
- package/dist/functions/NavigationFunctions.d.mts +3 -3
- package/dist/functions/NavigationFunctions.d.ts +3 -3
- package/dist/functions/NavigationFunctions.js.map +1 -1
- 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 +3 -3
- package/dist/functions/RoutineFunctions.d.ts +3 -3
- package/dist/functions/RoutineFunctions.js.map +1 -1
- package/dist/functions/RoutineFunctions.mjs.map +1 -1
- package/dist/functions/index.d.mts +4 -3
- package/dist/functions/index.d.ts +4 -3
- package/dist/functions/index.js +13 -0
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +13 -1
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +354 -166
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -166
- 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 +1 -1
- package/dist/{Commitment-BJTIpBQ5.d.ts → Commitment-D3LPSbFX.d.ts} +2 -2
- package/dist/{Commitment-CtNWnNQX.d.mts → Commitment-Eox2652k.d.mts} +2 -2
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) {
|
|
@@ -347,9 +478,15 @@ var Goal = class extends pixiVn.StoredClassModel {
|
|
|
347
478
|
get description() {
|
|
348
479
|
return this._description;
|
|
349
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* The number of times the goal must be completed.
|
|
483
|
+
*/
|
|
350
484
|
get need() {
|
|
351
485
|
return this._need;
|
|
352
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* The default number of times the goal has been completed.
|
|
489
|
+
*/
|
|
353
490
|
get defaultHave() {
|
|
354
491
|
return this._defaultHave;
|
|
355
492
|
}
|
|
@@ -359,12 +496,18 @@ var GoalStage = class extends Goal {
|
|
|
359
496
|
super(id, props);
|
|
360
497
|
this._stageId = stageId;
|
|
361
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* The id of the stage that the goal belongs to.
|
|
501
|
+
*/
|
|
362
502
|
get stageId() {
|
|
363
503
|
return this._stageId;
|
|
364
504
|
}
|
|
365
505
|
set stageId(value) {
|
|
366
506
|
this._stageId = value;
|
|
367
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* The number of times the goal has been completed.
|
|
510
|
+
*/
|
|
368
511
|
get have() {
|
|
369
512
|
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
370
513
|
}
|
|
@@ -375,6 +518,9 @@ var GoalStage = class extends Goal {
|
|
|
375
518
|
}
|
|
376
519
|
this.setStorageProperty("have-" + this._stageId, value);
|
|
377
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* If the goal is completed.
|
|
523
|
+
*/
|
|
378
524
|
get completed() {
|
|
379
525
|
return this.have >= this.need;
|
|
380
526
|
}
|
|
@@ -385,6 +531,9 @@ var GoalStage = class extends Goal {
|
|
|
385
531
|
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
386
532
|
}
|
|
387
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Find the goal. It will increment the have value.
|
|
536
|
+
*/
|
|
388
537
|
find() {
|
|
389
538
|
this.have++;
|
|
390
539
|
}
|
|
@@ -408,12 +557,21 @@ var Stage = class extends pixiVn.StoredClassModel {
|
|
|
408
557
|
this._onStart = props.onStart;
|
|
409
558
|
this._onEnd = props.onEnd;
|
|
410
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* The name of the stage.
|
|
562
|
+
*/
|
|
411
563
|
get name() {
|
|
412
564
|
return this._name;
|
|
413
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* The description of the stage.
|
|
568
|
+
*/
|
|
414
569
|
get description() {
|
|
415
570
|
return this._description;
|
|
416
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* The advice description of the stage.
|
|
574
|
+
*/
|
|
417
575
|
get adviceDescription() {
|
|
418
576
|
return this._adviceDescription;
|
|
419
577
|
}
|
|
@@ -432,6 +590,10 @@ var Stage = class extends pixiVn.StoredClassModel {
|
|
|
432
590
|
}
|
|
433
591
|
return (props) => render;
|
|
434
592
|
}
|
|
593
|
+
/**
|
|
594
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
595
|
+
* This is the list set by the developer. if you want to get the current goals, use the goals property.
|
|
596
|
+
*/
|
|
435
597
|
get defaultGoals() {
|
|
436
598
|
return this._defaultGoals;
|
|
437
599
|
}
|
|
@@ -441,21 +603,39 @@ var Stage = class extends pixiVn.StoredClassModel {
|
|
|
441
603
|
get flags() {
|
|
442
604
|
return this._flags;
|
|
443
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* The number of days required to start the stage.
|
|
608
|
+
*/
|
|
444
609
|
get daysRequiredToStart() {
|
|
445
610
|
return this._daysRequiredToStart || 0;
|
|
446
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* The list of flags required to start the stage.
|
|
614
|
+
*/
|
|
447
615
|
get flagsRequiredToStart() {
|
|
448
616
|
return this._flagsRequiredToStart;
|
|
449
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* The list of quests required to start the stage.
|
|
620
|
+
*/
|
|
450
621
|
get questsRequiredToStart() {
|
|
451
622
|
return this._questsRequiredToStart || [];
|
|
452
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* The description of the request to start the stage.
|
|
626
|
+
*/
|
|
453
627
|
get requestDescriptionToStart() {
|
|
454
628
|
return this._requestDescriptionToStart;
|
|
455
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* The function that will be called when the stage starts.
|
|
632
|
+
*/
|
|
456
633
|
get onStart() {
|
|
457
634
|
return this._onStart;
|
|
458
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* The function that will be called when the stage ends.
|
|
638
|
+
*/
|
|
459
639
|
get onEnd() {
|
|
460
640
|
return this._onEnd;
|
|
461
641
|
}
|
|
@@ -464,22 +644,38 @@ var StageQuest = class extends Stage {
|
|
|
464
644
|
constructor(id, props) {
|
|
465
645
|
super(id, props);
|
|
466
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* Check if the flag and goals are completed.
|
|
649
|
+
* You can force the completion of the stage by setting the completed property to true.
|
|
650
|
+
*/
|
|
467
651
|
get completed() {
|
|
468
652
|
let storedCompleted = this.getStorageProperty("completed");
|
|
469
653
|
if (storedCompleted) {
|
|
470
654
|
return storedCompleted;
|
|
471
655
|
}
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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;
|
|
477
664
|
}
|
|
478
|
-
return
|
|
665
|
+
return false;
|
|
479
666
|
}
|
|
480
667
|
set completed(value) {
|
|
481
668
|
this.setStorageProperty("completed", value);
|
|
482
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
|
+
}
|
|
483
679
|
/**
|
|
484
680
|
* The list of goals that the player needs to complete to finish the stage.
|
|
485
681
|
*/
|
|
@@ -494,6 +690,9 @@ var StageQuest = class extends Stage {
|
|
|
494
690
|
set prevStageEndDay(value) {
|
|
495
691
|
this.setStorageProperty("prevStageEndDay", value);
|
|
496
692
|
}
|
|
693
|
+
/**
|
|
694
|
+
* The day when the stage starts.
|
|
695
|
+
*/
|
|
497
696
|
get startDay() {
|
|
498
697
|
let prevStageEndDay = this.prevStageEndDay;
|
|
499
698
|
if (prevStageEndDay === void 0) {
|
|
@@ -501,6 +700,9 @@ var StageQuest = class extends Stage {
|
|
|
501
700
|
}
|
|
502
701
|
return prevStageEndDay + this.daysRequiredToStart;
|
|
503
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Check if the stage can start.
|
|
705
|
+
*/
|
|
504
706
|
get canStart() {
|
|
505
707
|
let daysRequired = this.daysRequiredToStart;
|
|
506
708
|
if (daysRequired > 0) {
|
|
@@ -522,11 +724,27 @@ var StageQuest = class extends Stage {
|
|
|
522
724
|
}
|
|
523
725
|
return true;
|
|
524
726
|
}
|
|
525
|
-
|
|
727
|
+
/**
|
|
728
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
729
|
+
*/
|
|
730
|
+
inizialize() {
|
|
526
731
|
if (this.daysRequiredToStart > 0) {
|
|
527
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`);
|
|
528
747
|
}
|
|
529
|
-
return super.onStart;
|
|
530
748
|
}
|
|
531
749
|
};
|
|
532
750
|
|
|
@@ -542,14 +760,23 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
542
760
|
this._renderImage = props.renderImage;
|
|
543
761
|
this._isInDevelopment = props.isInDevelopment || false;
|
|
544
762
|
}
|
|
763
|
+
/**
|
|
764
|
+
* The stages of the quest.
|
|
765
|
+
*/
|
|
545
766
|
get stages() {
|
|
546
767
|
return this._stages.map((stage, index) => {
|
|
547
768
|
return new StageQuest(stage.id, stage);
|
|
548
769
|
});
|
|
549
770
|
}
|
|
771
|
+
/**
|
|
772
|
+
* The name of the quest.
|
|
773
|
+
*/
|
|
550
774
|
get name() {
|
|
551
775
|
return this._name;
|
|
552
776
|
}
|
|
777
|
+
/**
|
|
778
|
+
* The description of the quest.
|
|
779
|
+
*/
|
|
553
780
|
get description() {
|
|
554
781
|
return this._description;
|
|
555
782
|
}
|
|
@@ -583,15 +810,24 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
583
810
|
}
|
|
584
811
|
return (props) => render;
|
|
585
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* If the quest is in development.
|
|
815
|
+
*/
|
|
586
816
|
get isInDevelopment() {
|
|
587
817
|
return this._isInDevelopment;
|
|
588
818
|
}
|
|
819
|
+
/**
|
|
820
|
+
* The index of the current stage.
|
|
821
|
+
*/
|
|
589
822
|
get currentStageIndex() {
|
|
590
823
|
return this.getStorageProperty("currentStageIndex");
|
|
591
824
|
}
|
|
592
825
|
set currentStageIndex(value) {
|
|
593
826
|
this.setStorageProperty("currentStageIndex", value);
|
|
594
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* The current stage.
|
|
830
|
+
*/
|
|
595
831
|
get currentStage() {
|
|
596
832
|
let index = this.currentStageIndex;
|
|
597
833
|
if (index === void 0 || index >= this.stages.length) {
|
|
@@ -599,12 +835,26 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
599
835
|
}
|
|
600
836
|
return this.stages[index];
|
|
601
837
|
}
|
|
838
|
+
/**
|
|
839
|
+
* If the quest is started.
|
|
840
|
+
*/
|
|
602
841
|
get started() {
|
|
603
842
|
return this.currentStageIndex !== void 0;
|
|
604
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* If the quest is completed.
|
|
846
|
+
*/
|
|
605
847
|
get completed() {
|
|
606
|
-
|
|
848
|
+
if (this.currentStageIndex === void 0) {
|
|
849
|
+
return false;
|
|
850
|
+
}
|
|
851
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
607
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
* Start the quest.
|
|
855
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
856
|
+
* @returns
|
|
857
|
+
*/
|
|
608
858
|
start(props) {
|
|
609
859
|
if (this.started) {
|
|
610
860
|
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
@@ -616,35 +866,97 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
616
866
|
}
|
|
617
867
|
this.currentStageIndex = 0;
|
|
618
868
|
let currentStage = this.currentStage;
|
|
619
|
-
if (currentStage && currentStage.
|
|
620
|
-
return currentStage.
|
|
869
|
+
if (currentStage && currentStage.start) {
|
|
870
|
+
return currentStage.start(props);
|
|
621
871
|
} else {
|
|
622
872
|
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
623
873
|
}
|
|
624
874
|
}
|
|
875
|
+
/**
|
|
876
|
+
* Go to the next stage if the current stage is completed.
|
|
877
|
+
* If you want to force the change of stage, use goNextStage.
|
|
878
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
879
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
880
|
+
* @returns true if the stage was changed, false otherwise.
|
|
881
|
+
*/
|
|
625
882
|
tryToGoNextStage(startProps, endProps) {
|
|
626
883
|
if (!this.started) {
|
|
627
|
-
return;
|
|
884
|
+
return false;
|
|
628
885
|
}
|
|
629
886
|
if (this.completed) {
|
|
630
|
-
return;
|
|
887
|
+
return false;
|
|
631
888
|
}
|
|
632
889
|
let currentStage = this.currentStage;
|
|
633
|
-
|
|
634
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
890
|
+
if (!currentStage) {
|
|
635
891
|
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
636
|
-
return;
|
|
892
|
+
return false;
|
|
637
893
|
}
|
|
638
894
|
if (currentStage.completed) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
895
|
+
return this.goNextStage(startProps, endProps);
|
|
896
|
+
}
|
|
897
|
+
return false;
|
|
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
|
+
}
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
get currentStageMustStart() {
|
|
948
|
+
let currentStage = this.currentStage;
|
|
949
|
+
if (!currentStage) {
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
953
|
+
}
|
|
954
|
+
startCurrentStage(props) {
|
|
955
|
+
let newCurrentStage = this.currentStage;
|
|
956
|
+
if (newCurrentStage && this.currentStageMustStart) {
|
|
957
|
+
newCurrentStage.start(props);
|
|
958
|
+
} else {
|
|
959
|
+
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
648
960
|
}
|
|
649
961
|
}
|
|
650
962
|
};
|
|
@@ -720,9 +1032,9 @@ exports.getAllMaps = getAllMaps;
|
|
|
720
1032
|
exports.getCommitmentById = getCommitmentById;
|
|
721
1033
|
exports.getQuestById = getQuestById;
|
|
722
1034
|
exports.getRoomById = getRoomById;
|
|
1035
|
+
exports.newActivity = newActivity;
|
|
723
1036
|
exports.newQuest = newQuest;
|
|
724
1037
|
exports.removeCommitment = removeCommitment;
|
|
725
|
-
exports.saveActivity = saveActivity;
|
|
726
1038
|
exports.saveCommitment = saveCommitment;
|
|
727
1039
|
exports.saveRoom = saveRoom;
|
|
728
1040
|
exports.setFixedRoutine = setFixedRoutine;
|