@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
|
@@ -1,94 +1,6 @@
|
|
|
1
|
-
import { GameStorageManager,
|
|
1
|
+
import { GameStorageManager, getFlag, StoredClassModel } from '@drincs/pixi-vn';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
4
|
-
var registeredActivities = {};
|
|
5
|
-
function saveActivity(activity) {
|
|
6
|
-
if (Array.isArray(activity)) {
|
|
7
|
-
activity.forEach((c) => saveActivity(c));
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (registeredActivities[activity.id]) {
|
|
11
|
-
console.warn(`[NQTR] Activity id ${activity.id} already exists, it will be overwritten`);
|
|
12
|
-
}
|
|
13
|
-
registeredActivities[activity.id] = activity;
|
|
14
|
-
}
|
|
15
|
-
function getActivityById(id) {
|
|
16
|
-
try {
|
|
17
|
-
let activity = registeredActivities[id];
|
|
18
|
-
if (!activity) {
|
|
19
|
-
console.error(`[NQTR] Activity ${id} not found`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
return activity;
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.error(`[NQTR] Error while getting Activity ${id}`, e);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
|
|
29
|
-
var registeredCommitments = {};
|
|
30
|
-
var fixedCommitments = {};
|
|
31
|
-
function saveCommitment(commitment) {
|
|
32
|
-
if (Array.isArray(commitment)) {
|
|
33
|
-
commitment.forEach((c) => saveCommitment(c));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (registeredCommitments[commitment.id]) {
|
|
37
|
-
console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`);
|
|
38
|
-
}
|
|
39
|
-
registeredCommitments[commitment.id] = commitment;
|
|
40
|
-
}
|
|
41
|
-
function getCommitmentById(id) {
|
|
42
|
-
try {
|
|
43
|
-
let commitment = registeredCommitments[id];
|
|
44
|
-
if (!commitment) {
|
|
45
|
-
console.error(`[NQTR] Commitment ${id} not found`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
return commitment;
|
|
49
|
-
} catch (e) {
|
|
50
|
-
console.error(`[NQTR] Error while getting Commitment ${id}`, e);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function setFixedRoutine(commitments) {
|
|
55
|
-
if (Array.isArray(commitments)) {
|
|
56
|
-
commitments.forEach((c) => setFixedRoutine(c));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (fixedCommitments[commitments.id]) {
|
|
60
|
-
console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`);
|
|
61
|
-
}
|
|
62
|
-
fixedCommitments[commitments.id] = commitments;
|
|
63
|
-
}
|
|
64
|
-
function addCommitment(commitment) {
|
|
65
|
-
if (!Array.isArray(commitment)) {
|
|
66
|
-
commitment = [commitment];
|
|
67
|
-
}
|
|
68
|
-
let commitmentsIds = commitment.map((commitment2) => {
|
|
69
|
-
let commitmentTest = getCommitmentById(commitment2.id);
|
|
70
|
-
if (!commitmentTest) {
|
|
71
|
-
console.warn(`[NQTR] Commitment ${commitment2.id} not found, it will be ignored`);
|
|
72
|
-
return void 0;
|
|
73
|
-
}
|
|
74
|
-
return commitment2.id;
|
|
75
|
-
}).filter((id) => id !== void 0);
|
|
76
|
-
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, [commitmentsIds]);
|
|
77
|
-
}
|
|
78
|
-
function removeCommitment(commitment) {
|
|
79
|
-
if (!Array.isArray(commitment)) {
|
|
80
|
-
commitment = [commitment];
|
|
81
|
-
}
|
|
82
|
-
let commitmentsIds = commitment.map((commitment2) => {
|
|
83
|
-
return commitment2.id;
|
|
84
|
-
});
|
|
85
|
-
let currentCommitments = GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
86
|
-
if (!currentCommitments) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
currentCommitments = currentCommitments.filter((id) => !commitmentsIds.includes(id));
|
|
90
|
-
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, currentCommitments);
|
|
91
|
-
}
|
|
3
|
+
// src/classes/Activity.ts
|
|
92
4
|
var TIME_SETTINGS_KEY = "___nqtr-time_manager_settings___";
|
|
93
5
|
var TIME_DATA_KEY = "___nqtr-time_manager_data___";
|
|
94
6
|
var TimeManager = class _TimeManager {
|
|
@@ -331,6 +243,225 @@ var TimeManager = class _TimeManager {
|
|
|
331
243
|
return currentHour >= fromHour || currentHour < toHour;
|
|
332
244
|
}
|
|
333
245
|
};
|
|
246
|
+
|
|
247
|
+
// src/classes/Activity.ts
|
|
248
|
+
var ActivityModel = class {
|
|
249
|
+
/**
|
|
250
|
+
* @param id The activity id, that must be unique.
|
|
251
|
+
* @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.
|
|
252
|
+
* @param props The activity properties.
|
|
253
|
+
*/
|
|
254
|
+
constructor(id, onRun, props) {
|
|
255
|
+
this._id = id;
|
|
256
|
+
this._name = props.name;
|
|
257
|
+
this._fromHour = props.fromHour;
|
|
258
|
+
this._toHour = props.toHour;
|
|
259
|
+
this._fromDay = props.fromDay;
|
|
260
|
+
this._toDay = props.toDay;
|
|
261
|
+
this._disabled = props.disabled || false;
|
|
262
|
+
this._hidden = props.hidden || false;
|
|
263
|
+
this._renderIcon = props.renderIcon;
|
|
264
|
+
this._onRun = onRun;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The activity id, that is unique.
|
|
268
|
+
*/
|
|
269
|
+
get id() {
|
|
270
|
+
return this._id;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The name
|
|
274
|
+
*/
|
|
275
|
+
get name() {
|
|
276
|
+
return this._name;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
280
|
+
*/
|
|
281
|
+
get fromHour() {
|
|
282
|
+
return this._fromHour;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
286
|
+
*/
|
|
287
|
+
get toHour() {
|
|
288
|
+
return this._toHour;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
292
|
+
*/
|
|
293
|
+
get fromDay() {
|
|
294
|
+
return this._fromDay;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
298
|
+
*/
|
|
299
|
+
get toDay() {
|
|
300
|
+
return this._toDay;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Whether is disabled.
|
|
304
|
+
*/
|
|
305
|
+
get disabled() {
|
|
306
|
+
if (typeof this._disabled === "string") {
|
|
307
|
+
return getFlag(this._disabled);
|
|
308
|
+
}
|
|
309
|
+
return this._disabled;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
313
|
+
*/
|
|
314
|
+
get hidden() {
|
|
315
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
if (!this.isDeadline) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
if (typeof this._hidden === "string") {
|
|
322
|
+
return getFlag(this._hidden);
|
|
323
|
+
}
|
|
324
|
+
return this._hidden;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The function for rendering the icon of the activity.
|
|
328
|
+
*/
|
|
329
|
+
get renderIcon() {
|
|
330
|
+
let render = this._renderIcon;
|
|
331
|
+
if (render === void 0) {
|
|
332
|
+
return void 0;
|
|
333
|
+
}
|
|
334
|
+
if (typeof render === "function") {
|
|
335
|
+
return (props) => {
|
|
336
|
+
return render(this, props);
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
return (props) => render;
|
|
340
|
+
}
|
|
341
|
+
get _initialOnRun() {
|
|
342
|
+
return this._onRun;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* The function that is called when the activity is runned.
|
|
346
|
+
*/
|
|
347
|
+
get run() {
|
|
348
|
+
return (props) => this._onRun(this, props);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Whether the activity is a deadline.
|
|
352
|
+
* @returns Whether the activity is a deadline.
|
|
353
|
+
*/
|
|
354
|
+
isDeadline() {
|
|
355
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Export the activity properties.
|
|
362
|
+
* @returns The activity properties.
|
|
363
|
+
*/
|
|
364
|
+
export() {
|
|
365
|
+
return {
|
|
366
|
+
name: this._name,
|
|
367
|
+
fromHour: this._fromHour,
|
|
368
|
+
toHour: this._toHour,
|
|
369
|
+
fromDay: this._fromDay,
|
|
370
|
+
toDay: this._toDay,
|
|
371
|
+
disabled: this._disabled,
|
|
372
|
+
hidden: this._hidden,
|
|
373
|
+
renderIcon: this._renderIcon
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/decorators/ActivityDecorator.ts
|
|
379
|
+
var registeredActivities = {};
|
|
380
|
+
function newActivity(id, onRun, props) {
|
|
381
|
+
if (registeredActivities[id]) {
|
|
382
|
+
console.warn(`[NQTR] Activity ${id} already exists, it will be overwritten`);
|
|
383
|
+
}
|
|
384
|
+
let activity = new ActivityModel(id, onRun, props);
|
|
385
|
+
registeredActivities[id] = activity;
|
|
386
|
+
return activity;
|
|
387
|
+
}
|
|
388
|
+
function getActivityById(id) {
|
|
389
|
+
try {
|
|
390
|
+
let activity = registeredActivities[id];
|
|
391
|
+
if (!activity) {
|
|
392
|
+
console.error(`[NQTR] Activity ${id} not found`);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
return activity;
|
|
396
|
+
} catch (e) {
|
|
397
|
+
console.error(`[NQTR] Error while getting Activity ${id}`, e);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
var TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY = "___nqtr-temporary_commitment___";
|
|
402
|
+
var registeredCommitments = {};
|
|
403
|
+
var fixedCommitments = {};
|
|
404
|
+
function saveCommitment(commitment) {
|
|
405
|
+
if (Array.isArray(commitment)) {
|
|
406
|
+
commitment.forEach((c) => saveCommitment(c));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (registeredCommitments[commitment.id]) {
|
|
410
|
+
console.warn(`[NQTR] Commitment id ${commitment.id} already exists, it will be overwritten`);
|
|
411
|
+
}
|
|
412
|
+
registeredCommitments[commitment.id] = commitment;
|
|
413
|
+
}
|
|
414
|
+
function getCommitmentById(id) {
|
|
415
|
+
try {
|
|
416
|
+
let commitment = registeredCommitments[id];
|
|
417
|
+
if (!commitment) {
|
|
418
|
+
console.error(`[NQTR] Commitment ${id} not found`);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
return commitment;
|
|
422
|
+
} catch (e) {
|
|
423
|
+
console.error(`[NQTR] Error while getting Commitment ${id}`, e);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function setFixedRoutine(commitments) {
|
|
428
|
+
if (Array.isArray(commitments)) {
|
|
429
|
+
commitments.forEach((c) => setFixedRoutine(c));
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (fixedCommitments[commitments.id]) {
|
|
433
|
+
console.warn(`[NQTR] Commitment id ${commitments.id} already exists, it will be overwritten`);
|
|
434
|
+
}
|
|
435
|
+
fixedCommitments[commitments.id] = commitments;
|
|
436
|
+
}
|
|
437
|
+
function addCommitment(commitment) {
|
|
438
|
+
if (!Array.isArray(commitment)) {
|
|
439
|
+
commitment = [commitment];
|
|
440
|
+
}
|
|
441
|
+
let commitmentsIds = commitment.map((commitment2) => {
|
|
442
|
+
let commitmentTest = getCommitmentById(commitment2.id);
|
|
443
|
+
if (!commitmentTest) {
|
|
444
|
+
console.warn(`[NQTR] Commitment ${commitment2.id} not found, it will be ignored`);
|
|
445
|
+
return void 0;
|
|
446
|
+
}
|
|
447
|
+
return commitment2.id;
|
|
448
|
+
}).filter((id) => id !== void 0);
|
|
449
|
+
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, commitmentsIds);
|
|
450
|
+
}
|
|
451
|
+
function removeCommitment(commitment) {
|
|
452
|
+
if (!Array.isArray(commitment)) {
|
|
453
|
+
commitment = [commitment];
|
|
454
|
+
}
|
|
455
|
+
let commitmentsIds = commitment.map((commitment2) => {
|
|
456
|
+
return commitment2.id;
|
|
457
|
+
});
|
|
458
|
+
let currentCommitments = GameStorageManager.getVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY);
|
|
459
|
+
if (!currentCommitments) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
currentCommitments = currentCommitments.filter((id) => !commitmentsIds.includes(id));
|
|
463
|
+
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, currentCommitments);
|
|
464
|
+
}
|
|
334
465
|
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
335
466
|
var Goal = class extends StoredClassModel {
|
|
336
467
|
constructor(id, props) {
|
|
@@ -345,9 +476,15 @@ var Goal = class extends StoredClassModel {
|
|
|
345
476
|
get description() {
|
|
346
477
|
return this._description;
|
|
347
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* The number of times the goal must be completed.
|
|
481
|
+
*/
|
|
348
482
|
get need() {
|
|
349
483
|
return this._need;
|
|
350
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* The default number of times the goal has been completed.
|
|
487
|
+
*/
|
|
351
488
|
get defaultHave() {
|
|
352
489
|
return this._defaultHave;
|
|
353
490
|
}
|
|
@@ -357,12 +494,18 @@ var GoalStage = class extends Goal {
|
|
|
357
494
|
super(id, props);
|
|
358
495
|
this._stageId = stageId;
|
|
359
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* The id of the stage that the goal belongs to.
|
|
499
|
+
*/
|
|
360
500
|
get stageId() {
|
|
361
501
|
return this._stageId;
|
|
362
502
|
}
|
|
363
503
|
set stageId(value) {
|
|
364
504
|
this._stageId = value;
|
|
365
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* The number of times the goal has been completed.
|
|
508
|
+
*/
|
|
366
509
|
get have() {
|
|
367
510
|
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
368
511
|
}
|
|
@@ -373,6 +516,9 @@ var GoalStage = class extends Goal {
|
|
|
373
516
|
}
|
|
374
517
|
this.setStorageProperty("have-" + this._stageId, value);
|
|
375
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* If the goal is completed.
|
|
521
|
+
*/
|
|
376
522
|
get completed() {
|
|
377
523
|
return this.have >= this.need;
|
|
378
524
|
}
|
|
@@ -383,6 +529,9 @@ var GoalStage = class extends Goal {
|
|
|
383
529
|
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
384
530
|
}
|
|
385
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Find the goal. It will increment the have value.
|
|
534
|
+
*/
|
|
386
535
|
find() {
|
|
387
536
|
this.have++;
|
|
388
537
|
}
|
|
@@ -406,12 +555,21 @@ var Stage = class extends StoredClassModel {
|
|
|
406
555
|
this._onStart = props.onStart;
|
|
407
556
|
this._onEnd = props.onEnd;
|
|
408
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* The name of the stage.
|
|
560
|
+
*/
|
|
409
561
|
get name() {
|
|
410
562
|
return this._name;
|
|
411
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* The description of the stage.
|
|
566
|
+
*/
|
|
412
567
|
get description() {
|
|
413
568
|
return this._description;
|
|
414
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* The advice description of the stage.
|
|
572
|
+
*/
|
|
415
573
|
get adviceDescription() {
|
|
416
574
|
return this._adviceDescription;
|
|
417
575
|
}
|
|
@@ -430,6 +588,10 @@ var Stage = class extends StoredClassModel {
|
|
|
430
588
|
}
|
|
431
589
|
return (props) => render;
|
|
432
590
|
}
|
|
591
|
+
/**
|
|
592
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
593
|
+
* This is the list set by the developer. if you want to get the current goals, use the goals property.
|
|
594
|
+
*/
|
|
433
595
|
get defaultGoals() {
|
|
434
596
|
return this._defaultGoals;
|
|
435
597
|
}
|
|
@@ -439,21 +601,39 @@ var Stage = class extends StoredClassModel {
|
|
|
439
601
|
get flags() {
|
|
440
602
|
return this._flags;
|
|
441
603
|
}
|
|
604
|
+
/**
|
|
605
|
+
* The number of days required to start the stage.
|
|
606
|
+
*/
|
|
442
607
|
get daysRequiredToStart() {
|
|
443
608
|
return this._daysRequiredToStart || 0;
|
|
444
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* The list of flags required to start the stage.
|
|
612
|
+
*/
|
|
445
613
|
get flagsRequiredToStart() {
|
|
446
614
|
return this._flagsRequiredToStart;
|
|
447
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* The list of quests required to start the stage.
|
|
618
|
+
*/
|
|
448
619
|
get questsRequiredToStart() {
|
|
449
620
|
return this._questsRequiredToStart || [];
|
|
450
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* The description of the request to start the stage.
|
|
624
|
+
*/
|
|
451
625
|
get requestDescriptionToStart() {
|
|
452
626
|
return this._requestDescriptionToStart;
|
|
453
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* The function that will be called when the stage starts.
|
|
630
|
+
*/
|
|
454
631
|
get onStart() {
|
|
455
632
|
return this._onStart;
|
|
456
633
|
}
|
|
634
|
+
/**
|
|
635
|
+
* The function that will be called when the stage ends.
|
|
636
|
+
*/
|
|
457
637
|
get onEnd() {
|
|
458
638
|
return this._onEnd;
|
|
459
639
|
}
|
|
@@ -462,22 +642,38 @@ var StageQuest = class extends Stage {
|
|
|
462
642
|
constructor(id, props) {
|
|
463
643
|
super(id, props);
|
|
464
644
|
}
|
|
645
|
+
/**
|
|
646
|
+
* Check if the flag and goals are completed.
|
|
647
|
+
* You can force the completion of the stage by setting the completed property to true.
|
|
648
|
+
*/
|
|
465
649
|
get completed() {
|
|
466
650
|
let storedCompleted = this.getStorageProperty("completed");
|
|
467
651
|
if (storedCompleted) {
|
|
468
652
|
return storedCompleted;
|
|
469
653
|
}
|
|
470
|
-
if (
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
654
|
+
if (this.flags.length > 0 && this.goals.length > 0) {
|
|
655
|
+
if (!this.flags.every((flag) => getFlag(flag.flag))) {
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
659
|
+
return false;
|
|
660
|
+
}
|
|
661
|
+
return true;
|
|
475
662
|
}
|
|
476
|
-
return
|
|
663
|
+
return false;
|
|
477
664
|
}
|
|
478
665
|
set completed(value) {
|
|
479
666
|
this.setStorageProperty("completed", value);
|
|
480
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* If the stage is started.
|
|
670
|
+
*/
|
|
671
|
+
get started() {
|
|
672
|
+
return this.getStorageProperty("started") || false;
|
|
673
|
+
}
|
|
674
|
+
set started(value) {
|
|
675
|
+
this.setStorageProperty("started", value);
|
|
676
|
+
}
|
|
481
677
|
/**
|
|
482
678
|
* The list of goals that the player needs to complete to finish the stage.
|
|
483
679
|
*/
|
|
@@ -492,6 +688,9 @@ var StageQuest = class extends Stage {
|
|
|
492
688
|
set prevStageEndDay(value) {
|
|
493
689
|
this.setStorageProperty("prevStageEndDay", value);
|
|
494
690
|
}
|
|
691
|
+
/**
|
|
692
|
+
* The day when the stage starts.
|
|
693
|
+
*/
|
|
495
694
|
get startDay() {
|
|
496
695
|
let prevStageEndDay = this.prevStageEndDay;
|
|
497
696
|
if (prevStageEndDay === void 0) {
|
|
@@ -499,6 +698,9 @@ var StageQuest = class extends Stage {
|
|
|
499
698
|
}
|
|
500
699
|
return prevStageEndDay + this.daysRequiredToStart;
|
|
501
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Check if the stage can start.
|
|
703
|
+
*/
|
|
502
704
|
get canStart() {
|
|
503
705
|
let daysRequired = this.daysRequiredToStart;
|
|
504
706
|
if (daysRequired > 0) {
|
|
@@ -520,11 +722,27 @@ var StageQuest = class extends Stage {
|
|
|
520
722
|
}
|
|
521
723
|
return true;
|
|
522
724
|
}
|
|
523
|
-
|
|
725
|
+
/**
|
|
726
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
727
|
+
*/
|
|
728
|
+
inizialize() {
|
|
524
729
|
if (this.daysRequiredToStart > 0) {
|
|
525
730
|
this.prevStageEndDay = TimeManager.currentDay;
|
|
731
|
+
console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* The function that will be called when the stage starts.
|
|
736
|
+
*/
|
|
737
|
+
start(props) {
|
|
738
|
+
if (this.canStart) {
|
|
739
|
+
this.started = true;
|
|
740
|
+
if (this.onStart) {
|
|
741
|
+
this.onStart(props);
|
|
742
|
+
}
|
|
743
|
+
} else {
|
|
744
|
+
console.warn(`[NQTR] Stage ${this.id} can't start`);
|
|
526
745
|
}
|
|
527
|
-
return super.onStart;
|
|
528
746
|
}
|
|
529
747
|
};
|
|
530
748
|
|
|
@@ -540,14 +758,23 @@ var Quest = class extends StoredClassModel {
|
|
|
540
758
|
this._renderImage = props.renderImage;
|
|
541
759
|
this._isInDevelopment = props.isInDevelopment || false;
|
|
542
760
|
}
|
|
761
|
+
/**
|
|
762
|
+
* The stages of the quest.
|
|
763
|
+
*/
|
|
543
764
|
get stages() {
|
|
544
765
|
return this._stages.map((stage, index) => {
|
|
545
766
|
return new StageQuest(stage.id, stage);
|
|
546
767
|
});
|
|
547
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* The name of the quest.
|
|
771
|
+
*/
|
|
548
772
|
get name() {
|
|
549
773
|
return this._name;
|
|
550
774
|
}
|
|
775
|
+
/**
|
|
776
|
+
* The description of the quest.
|
|
777
|
+
*/
|
|
551
778
|
get description() {
|
|
552
779
|
return this._description;
|
|
553
780
|
}
|
|
@@ -581,15 +808,24 @@ var Quest = class extends StoredClassModel {
|
|
|
581
808
|
}
|
|
582
809
|
return (props) => render;
|
|
583
810
|
}
|
|
811
|
+
/**
|
|
812
|
+
* If the quest is in development.
|
|
813
|
+
*/
|
|
584
814
|
get isInDevelopment() {
|
|
585
815
|
return this._isInDevelopment;
|
|
586
816
|
}
|
|
817
|
+
/**
|
|
818
|
+
* The index of the current stage.
|
|
819
|
+
*/
|
|
587
820
|
get currentStageIndex() {
|
|
588
821
|
return this.getStorageProperty("currentStageIndex");
|
|
589
822
|
}
|
|
590
823
|
set currentStageIndex(value) {
|
|
591
824
|
this.setStorageProperty("currentStageIndex", value);
|
|
592
825
|
}
|
|
826
|
+
/**
|
|
827
|
+
* The current stage.
|
|
828
|
+
*/
|
|
593
829
|
get currentStage() {
|
|
594
830
|
let index = this.currentStageIndex;
|
|
595
831
|
if (index === void 0 || index >= this.stages.length) {
|
|
@@ -597,12 +833,26 @@ var Quest = class extends StoredClassModel {
|
|
|
597
833
|
}
|
|
598
834
|
return this.stages[index];
|
|
599
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* If the quest is started.
|
|
838
|
+
*/
|
|
600
839
|
get started() {
|
|
601
840
|
return this.currentStageIndex !== void 0;
|
|
602
841
|
}
|
|
842
|
+
/**
|
|
843
|
+
* If the quest is completed.
|
|
844
|
+
*/
|
|
603
845
|
get completed() {
|
|
604
|
-
|
|
846
|
+
if (this.currentStageIndex === void 0) {
|
|
847
|
+
return false;
|
|
848
|
+
}
|
|
849
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
605
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Start the quest.
|
|
853
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
854
|
+
* @returns
|
|
855
|
+
*/
|
|
606
856
|
start(props) {
|
|
607
857
|
if (this.started) {
|
|
608
858
|
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
@@ -614,35 +864,97 @@ var Quest = class extends StoredClassModel {
|
|
|
614
864
|
}
|
|
615
865
|
this.currentStageIndex = 0;
|
|
616
866
|
let currentStage = this.currentStage;
|
|
617
|
-
if (currentStage && currentStage.
|
|
618
|
-
return currentStage.
|
|
867
|
+
if (currentStage && currentStage.start) {
|
|
868
|
+
return currentStage.start(props);
|
|
619
869
|
} else {
|
|
620
870
|
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
621
871
|
}
|
|
622
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* Go to the next stage if the current stage is completed.
|
|
875
|
+
* If you want to force the change of stage, use goNextStage.
|
|
876
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
877
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
878
|
+
* @returns true if the stage was changed, false otherwise.
|
|
879
|
+
*/
|
|
623
880
|
tryToGoNextStage(startProps, endProps) {
|
|
624
881
|
if (!this.started) {
|
|
625
|
-
return;
|
|
882
|
+
return false;
|
|
626
883
|
}
|
|
627
884
|
if (this.completed) {
|
|
628
|
-
return;
|
|
885
|
+
return false;
|
|
629
886
|
}
|
|
630
887
|
let currentStage = this.currentStage;
|
|
631
|
-
|
|
632
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
888
|
+
if (!currentStage) {
|
|
633
889
|
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
634
|
-
return;
|
|
890
|
+
return false;
|
|
635
891
|
}
|
|
636
892
|
if (currentStage.completed) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
893
|
+
return this.goNextStage(startProps, endProps);
|
|
894
|
+
}
|
|
895
|
+
return false;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Complete the current stage and go to the next stage.
|
|
899
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
900
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
901
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
902
|
+
* @returns true if the stage was changed, false otherwise.
|
|
903
|
+
*/
|
|
904
|
+
completeCurrentStageAndGoNext(startProps, endProps) {
|
|
905
|
+
let currentStage = this.currentStage;
|
|
906
|
+
if (!currentStage) {
|
|
907
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
currentStage.completed = true;
|
|
911
|
+
return this.goNextStage(startProps, endProps);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Go to the next stage without checking if the current stage is completed.
|
|
915
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
916
|
+
* @param startProps
|
|
917
|
+
* @param endProps
|
|
918
|
+
* @returns returns true if the stage was changed, false otherwise.
|
|
919
|
+
*/
|
|
920
|
+
goNextStage(startProps, endProps) {
|
|
921
|
+
if (!this.started) {
|
|
922
|
+
console.warn(`[NQTR] Quest ${this.id} is not started`);
|
|
923
|
+
return false;
|
|
924
|
+
}
|
|
925
|
+
if (this.completed) {
|
|
926
|
+
console.warn(`[NQTR] Quest ${this.id} is already completed`);
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
let prevStage = this.currentStage;
|
|
930
|
+
let currentStageIndex = this.currentStageIndex;
|
|
931
|
+
if (!prevStage || currentStageIndex === void 0) {
|
|
932
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
this.currentStageIndex = currentStageIndex + 1;
|
|
936
|
+
if (prevStage && prevStage.onEnd) {
|
|
937
|
+
prevStage.onEnd(endProps);
|
|
938
|
+
}
|
|
939
|
+
let nextCurrentStage = this.currentStage;
|
|
940
|
+
if (nextCurrentStage) {
|
|
941
|
+
nextCurrentStage.inizialize();
|
|
942
|
+
}
|
|
943
|
+
return true;
|
|
944
|
+
}
|
|
945
|
+
get currentStageMustStart() {
|
|
946
|
+
let currentStage = this.currentStage;
|
|
947
|
+
if (!currentStage) {
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
951
|
+
}
|
|
952
|
+
startCurrentStage(props) {
|
|
953
|
+
let newCurrentStage = this.currentStage;
|
|
954
|
+
if (newCurrentStage && this.currentStageMustStart) {
|
|
955
|
+
newCurrentStage.start(props);
|
|
956
|
+
} else {
|
|
957
|
+
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
646
958
|
}
|
|
647
959
|
}
|
|
648
960
|
};
|
|
@@ -711,6 +1023,6 @@ function getAllMaps() {
|
|
|
711
1023
|
return Object.values(result);
|
|
712
1024
|
}
|
|
713
1025
|
|
|
714
|
-
export { addCommitment, getActivityById, getAllLocations, getAllMaps, getCommitmentById, getQuestById, getRoomById, newQuest, removeCommitment,
|
|
1026
|
+
export { addCommitment, getActivityById, getAllLocations, getAllMaps, getCommitmentById, getQuestById, getRoomById, newActivity, newQuest, removeCommitment, saveCommitment, saveRoom, setFixedRoutine };
|
|
715
1027
|
//# sourceMappingURL=out.js.map
|
|
716
1028
|
//# sourceMappingURL=index.mjs.map
|