@drincs/nqtr 0.2.1 → 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-CkXejAbn.d.mts → StageProps-D002cyay.d.mts} +30 -2
- package/dist/{StageProps-BFsiCaZT.d.ts → StageProps-DleWO-vf.d.ts} +30 -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 +1 -131
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +3 -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/Quest.d.mts +1 -1
- package/dist/classes/quest/Quest.d.ts +1 -1
- package/dist/classes/quest/Quest.js +107 -25
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +107 -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 +4 -3
- package/dist/decorators/QuestDecorator.d.ts +4 -3
- package/dist/decorators/QuestDecorator.js +107 -25
- package/dist/decorators/QuestDecorator.js.map +1 -1
- package/dist/decorators/QuestDecorator.mjs +107 -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 +328 -115
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +329 -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/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 +254 -165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -165
- 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/index.js
CHANGED
|
@@ -261,136 +261,7 @@ var TimeManager = class _TimeManager {
|
|
|
261
261
|
}
|
|
262
262
|
};
|
|
263
263
|
|
|
264
|
-
// src/classes/
|
|
265
|
-
var ActivityModel = class {
|
|
266
|
-
/**
|
|
267
|
-
* @param id The activity id, that must be unique.
|
|
268
|
-
* @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.
|
|
269
|
-
* @param props The activity properties.
|
|
270
|
-
*/
|
|
271
|
-
constructor(id, onRun, props) {
|
|
272
|
-
this._id = id;
|
|
273
|
-
this._name = props.name;
|
|
274
|
-
this._fromHour = props.fromHour;
|
|
275
|
-
this._toHour = props.toHour;
|
|
276
|
-
this._fromDay = props.fromDay;
|
|
277
|
-
this._toDay = props.toDay;
|
|
278
|
-
this._disabled = props.disabled || false;
|
|
279
|
-
this._hidden = props.hidden || false;
|
|
280
|
-
this._renderIcon = props.renderIcon;
|
|
281
|
-
this._onRun = onRun;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* The activity id, that is unique.
|
|
285
|
-
*/
|
|
286
|
-
get id() {
|
|
287
|
-
return this._id;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* The name
|
|
291
|
-
*/
|
|
292
|
-
get name() {
|
|
293
|
-
return this._name;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
297
|
-
*/
|
|
298
|
-
get fromHour() {
|
|
299
|
-
return this._fromHour;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
303
|
-
*/
|
|
304
|
-
get toHour() {
|
|
305
|
-
return this._toHour;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
309
|
-
*/
|
|
310
|
-
get fromDay() {
|
|
311
|
-
return this._fromDay;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
315
|
-
*/
|
|
316
|
-
get toDay() {
|
|
317
|
-
return this._toDay;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Whether is disabled.
|
|
321
|
-
*/
|
|
322
|
-
get disabled() {
|
|
323
|
-
if (typeof this._disabled === "string") {
|
|
324
|
-
return pixiVn.getFlag(this._disabled);
|
|
325
|
-
}
|
|
326
|
-
return this._disabled;
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
330
|
-
*/
|
|
331
|
-
get hidden() {
|
|
332
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
if (!this.isDeadline) {
|
|
336
|
-
return true;
|
|
337
|
-
}
|
|
338
|
-
if (typeof this._hidden === "string") {
|
|
339
|
-
return pixiVn.getFlag(this._hidden);
|
|
340
|
-
}
|
|
341
|
-
return this._hidden;
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* The function for rendering the icon of the activity.
|
|
345
|
-
*/
|
|
346
|
-
get renderIcon() {
|
|
347
|
-
let render = this._renderIcon;
|
|
348
|
-
if (render === void 0) {
|
|
349
|
-
return void 0;
|
|
350
|
-
}
|
|
351
|
-
if (typeof render === "function") {
|
|
352
|
-
return (props) => {
|
|
353
|
-
return render(this, props);
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
return (props) => render;
|
|
357
|
-
}
|
|
358
|
-
get _initialOnRun() {
|
|
359
|
-
return this._onRun;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* The function that is called when the activity is runned.
|
|
363
|
-
*/
|
|
364
|
-
get run() {
|
|
365
|
-
return (props) => this._onRun(this, props);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Whether the activity is a deadline.
|
|
369
|
-
* @returns Whether the activity is a deadline.
|
|
370
|
-
*/
|
|
371
|
-
isDeadline() {
|
|
372
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Export the activity properties.
|
|
379
|
-
* @returns The activity properties.
|
|
380
|
-
*/
|
|
381
|
-
export() {
|
|
382
|
-
return {
|
|
383
|
-
name: this._name,
|
|
384
|
-
fromHour: this._fromHour,
|
|
385
|
-
toHour: this._toHour,
|
|
386
|
-
fromDay: this._fromDay,
|
|
387
|
-
toDay: this._toDay,
|
|
388
|
-
disabled: this._disabled,
|
|
389
|
-
hidden: this._hidden,
|
|
390
|
-
renderIcon: this._renderIcon
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
};
|
|
264
|
+
// src/classes/Commitment.ts
|
|
394
265
|
var COMMITMENT_CATEGORY = "__nqtr-commitment__";
|
|
395
266
|
var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
|
|
396
267
|
/**
|
|
@@ -1010,18 +881,145 @@ var MapBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
1010
881
|
return getLocationsByMap(this);
|
|
1011
882
|
}
|
|
1012
883
|
};
|
|
884
|
+
var ActivityModel = class {
|
|
885
|
+
/**
|
|
886
|
+
* @param id The activity id, that must be unique.
|
|
887
|
+
* @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.
|
|
888
|
+
* @param props The activity properties.
|
|
889
|
+
*/
|
|
890
|
+
constructor(id, onRun, props) {
|
|
891
|
+
this._id = id;
|
|
892
|
+
this._name = props.name;
|
|
893
|
+
this._fromHour = props.fromHour;
|
|
894
|
+
this._toHour = props.toHour;
|
|
895
|
+
this._fromDay = props.fromDay;
|
|
896
|
+
this._toDay = props.toDay;
|
|
897
|
+
this._disabled = props.disabled || false;
|
|
898
|
+
this._hidden = props.hidden || false;
|
|
899
|
+
this._renderIcon = props.renderIcon;
|
|
900
|
+
this._onRun = onRun;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* The activity id, that is unique.
|
|
904
|
+
*/
|
|
905
|
+
get id() {
|
|
906
|
+
return this._id;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* The name
|
|
910
|
+
*/
|
|
911
|
+
get name() {
|
|
912
|
+
return this._name;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
916
|
+
*/
|
|
917
|
+
get fromHour() {
|
|
918
|
+
return this._fromHour;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
922
|
+
*/
|
|
923
|
+
get toHour() {
|
|
924
|
+
return this._toHour;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
928
|
+
*/
|
|
929
|
+
get fromDay() {
|
|
930
|
+
return this._fromDay;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
934
|
+
*/
|
|
935
|
+
get toDay() {
|
|
936
|
+
return this._toDay;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Whether is disabled.
|
|
940
|
+
*/
|
|
941
|
+
get disabled() {
|
|
942
|
+
if (typeof this._disabled === "string") {
|
|
943
|
+
return pixiVn.getFlag(this._disabled);
|
|
944
|
+
}
|
|
945
|
+
return this._disabled;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
949
|
+
*/
|
|
950
|
+
get hidden() {
|
|
951
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
if (!this.isDeadline) {
|
|
955
|
+
return true;
|
|
956
|
+
}
|
|
957
|
+
if (typeof this._hidden === "string") {
|
|
958
|
+
return pixiVn.getFlag(this._hidden);
|
|
959
|
+
}
|
|
960
|
+
return this._hidden;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* The function for rendering the icon of the activity.
|
|
964
|
+
*/
|
|
965
|
+
get renderIcon() {
|
|
966
|
+
let render = this._renderIcon;
|
|
967
|
+
if (render === void 0) {
|
|
968
|
+
return void 0;
|
|
969
|
+
}
|
|
970
|
+
if (typeof render === "function") {
|
|
971
|
+
return (props) => {
|
|
972
|
+
return render(this, props);
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
return (props) => render;
|
|
976
|
+
}
|
|
977
|
+
get _initialOnRun() {
|
|
978
|
+
return this._onRun;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* The function that is called when the activity is runned.
|
|
982
|
+
*/
|
|
983
|
+
get run() {
|
|
984
|
+
return (props) => this._onRun(this, props);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Whether the activity is a deadline.
|
|
988
|
+
* @returns Whether the activity is a deadline.
|
|
989
|
+
*/
|
|
990
|
+
isDeadline() {
|
|
991
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
992
|
+
return true;
|
|
993
|
+
}
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Export the activity properties.
|
|
998
|
+
* @returns The activity properties.
|
|
999
|
+
*/
|
|
1000
|
+
export() {
|
|
1001
|
+
return {
|
|
1002
|
+
name: this._name,
|
|
1003
|
+
fromHour: this._fromHour,
|
|
1004
|
+
toHour: this._toHour,
|
|
1005
|
+
fromDay: this._fromDay,
|
|
1006
|
+
toDay: this._toDay,
|
|
1007
|
+
disabled: this._disabled,
|
|
1008
|
+
hidden: this._hidden,
|
|
1009
|
+
renderIcon: this._renderIcon
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
1013
|
|
|
1014
1014
|
// src/decorators/ActivityDecorator.ts
|
|
1015
1015
|
var registeredActivities = {};
|
|
1016
|
-
function
|
|
1017
|
-
if (
|
|
1018
|
-
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
if (registeredActivities[activity.id]) {
|
|
1022
|
-
console.warn(`[NQTR] Activity id ${activity.id} already exists, it will be overwritten`);
|
|
1016
|
+
function newActivity(id, onRun, props) {
|
|
1017
|
+
if (registeredActivities[id]) {
|
|
1018
|
+
console.warn(`[NQTR] Activity ${id} already exists, it will be overwritten`);
|
|
1023
1019
|
}
|
|
1024
|
-
|
|
1020
|
+
let activity = new ActivityModel(id, onRun, props);
|
|
1021
|
+
registeredActivities[id] = activity;
|
|
1022
|
+
return activity;
|
|
1025
1023
|
}
|
|
1026
1024
|
function getActivityById(id) {
|
|
1027
1025
|
try {
|
|
@@ -1300,17 +1298,29 @@ var StageQuest = class extends Stage {
|
|
|
1300
1298
|
if (storedCompleted) {
|
|
1301
1299
|
return storedCompleted;
|
|
1302
1300
|
}
|
|
1303
|
-
if (
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1301
|
+
if (this.flags.length > 0 && this.goals.length > 0) {
|
|
1302
|
+
if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
|
|
1303
|
+
return false;
|
|
1304
|
+
}
|
|
1305
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
1306
|
+
return false;
|
|
1307
|
+
}
|
|
1308
|
+
return true;
|
|
1308
1309
|
}
|
|
1309
|
-
return
|
|
1310
|
+
return false;
|
|
1310
1311
|
}
|
|
1311
1312
|
set completed(value) {
|
|
1312
1313
|
this.setStorageProperty("completed", value);
|
|
1313
1314
|
}
|
|
1315
|
+
/**
|
|
1316
|
+
* If the stage is started.
|
|
1317
|
+
*/
|
|
1318
|
+
get started() {
|
|
1319
|
+
return this.getStorageProperty("started") || false;
|
|
1320
|
+
}
|
|
1321
|
+
set started(value) {
|
|
1322
|
+
this.setStorageProperty("started", value);
|
|
1323
|
+
}
|
|
1314
1324
|
/**
|
|
1315
1325
|
* The list of goals that the player needs to complete to finish the stage.
|
|
1316
1326
|
*/
|
|
@@ -1360,13 +1370,26 @@ var StageQuest = class extends Stage {
|
|
|
1360
1370
|
return true;
|
|
1361
1371
|
}
|
|
1362
1372
|
/**
|
|
1363
|
-
*
|
|
1373
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
1364
1374
|
*/
|
|
1365
|
-
|
|
1375
|
+
inizialize() {
|
|
1366
1376
|
if (this.daysRequiredToStart > 0) {
|
|
1367
1377
|
this.prevStageEndDay = TimeManager.currentDay;
|
|
1378
|
+
console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* The function that will be called when the stage starts.
|
|
1383
|
+
*/
|
|
1384
|
+
start(props) {
|
|
1385
|
+
if (this.canStart) {
|
|
1386
|
+
this.started = true;
|
|
1387
|
+
if (this.onStart) {
|
|
1388
|
+
this.onStart(props);
|
|
1389
|
+
}
|
|
1390
|
+
} else {
|
|
1391
|
+
console.warn(`[NQTR] Stage ${this.id} can't start`);
|
|
1368
1392
|
}
|
|
1369
|
-
return super.onStart;
|
|
1370
1393
|
}
|
|
1371
1394
|
};
|
|
1372
1395
|
|
|
@@ -1467,7 +1490,10 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1467
1490
|
* If the quest is completed.
|
|
1468
1491
|
*/
|
|
1469
1492
|
get completed() {
|
|
1470
|
-
|
|
1493
|
+
if (this.currentStageIndex === void 0) {
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
1471
1497
|
}
|
|
1472
1498
|
/**
|
|
1473
1499
|
* Start the quest.
|
|
@@ -1485,14 +1511,15 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1485
1511
|
}
|
|
1486
1512
|
this.currentStageIndex = 0;
|
|
1487
1513
|
let currentStage = this.currentStage;
|
|
1488
|
-
if (currentStage && currentStage.
|
|
1489
|
-
return currentStage.
|
|
1514
|
+
if (currentStage && currentStage.start) {
|
|
1515
|
+
return currentStage.start(props);
|
|
1490
1516
|
} else {
|
|
1491
1517
|
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1492
1518
|
}
|
|
1493
1519
|
}
|
|
1494
1520
|
/**
|
|
1495
|
-
*
|
|
1521
|
+
* Go to the next stage if the current stage is completed.
|
|
1522
|
+
* If you want to force the change of stage, use goNextStage.
|
|
1496
1523
|
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1497
1524
|
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1498
1525
|
* @returns true if the stage was changed, false otherwise.
|
|
@@ -1505,25 +1532,78 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1505
1532
|
return false;
|
|
1506
1533
|
}
|
|
1507
1534
|
let currentStage = this.currentStage;
|
|
1508
|
-
|
|
1509
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
1535
|
+
if (!currentStage) {
|
|
1510
1536
|
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1511
1537
|
return false;
|
|
1512
1538
|
}
|
|
1513
1539
|
if (currentStage.completed) {
|
|
1514
|
-
|
|
1515
|
-
currentStageIndex = nextStageIndex;
|
|
1516
|
-
let nextStage = this.currentStage;
|
|
1517
|
-
if (currentStage && currentStage.onEnd) {
|
|
1518
|
-
currentStage.onEnd(endProps);
|
|
1519
|
-
}
|
|
1520
|
-
if (nextStage && nextStage.onStart) {
|
|
1521
|
-
nextStage.onStart(startProps);
|
|
1522
|
-
}
|
|
1523
|
-
return true;
|
|
1540
|
+
return this.goNextStage(startProps, endProps);
|
|
1524
1541
|
}
|
|
1525
1542
|
return false;
|
|
1526
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Complete the current stage and go to the next stage.
|
|
1546
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1547
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1548
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1549
|
+
* @returns true if the stage was changed, false otherwise.
|
|
1550
|
+
*/
|
|
1551
|
+
completeCurrentStageAndGoNext(startProps, endProps) {
|
|
1552
|
+
let currentStage = this.currentStage;
|
|
1553
|
+
if (!currentStage) {
|
|
1554
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1555
|
+
return false;
|
|
1556
|
+
}
|
|
1557
|
+
currentStage.completed = true;
|
|
1558
|
+
return this.goNextStage(startProps, endProps);
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Go to the next stage without checking if the current stage is completed.
|
|
1562
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1563
|
+
* @param startProps
|
|
1564
|
+
* @param endProps
|
|
1565
|
+
* @returns returns true if the stage was changed, false otherwise.
|
|
1566
|
+
*/
|
|
1567
|
+
goNextStage(startProps, endProps) {
|
|
1568
|
+
if (!this.started) {
|
|
1569
|
+
console.warn(`[NQTR] Quest ${this.id} is not started`);
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
if (this.completed) {
|
|
1573
|
+
console.warn(`[NQTR] Quest ${this.id} is already completed`);
|
|
1574
|
+
return false;
|
|
1575
|
+
}
|
|
1576
|
+
let prevStage = this.currentStage;
|
|
1577
|
+
let currentStageIndex = this.currentStageIndex;
|
|
1578
|
+
if (!prevStage || currentStageIndex === void 0) {
|
|
1579
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1580
|
+
return false;
|
|
1581
|
+
}
|
|
1582
|
+
this.currentStageIndex = currentStageIndex + 1;
|
|
1583
|
+
if (prevStage && prevStage.onEnd) {
|
|
1584
|
+
prevStage.onEnd(endProps);
|
|
1585
|
+
}
|
|
1586
|
+
let nextCurrentStage = this.currentStage;
|
|
1587
|
+
if (nextCurrentStage) {
|
|
1588
|
+
nextCurrentStage.inizialize();
|
|
1589
|
+
}
|
|
1590
|
+
return true;
|
|
1591
|
+
}
|
|
1592
|
+
get currentStageMustStart() {
|
|
1593
|
+
let currentStage = this.currentStage;
|
|
1594
|
+
if (!currentStage) {
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1597
|
+
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
1598
|
+
}
|
|
1599
|
+
startCurrentStage(props) {
|
|
1600
|
+
let newCurrentStage = this.currentStage;
|
|
1601
|
+
if (newCurrentStage && this.currentStageMustStart) {
|
|
1602
|
+
newCurrentStage.start(props);
|
|
1603
|
+
} else {
|
|
1604
|
+
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1527
1607
|
};
|
|
1528
1608
|
|
|
1529
1609
|
// src/decorators/QuestDecorator.ts
|
|
@@ -1895,7 +1975,15 @@ function currentActivities() {
|
|
|
1895
1975
|
return currentRoom.activities.filter((activity) => !activity.hidden);
|
|
1896
1976
|
}
|
|
1897
1977
|
|
|
1898
|
-
|
|
1978
|
+
// src/functions/QuestFunctions.ts
|
|
1979
|
+
function startMustStartStageQuests(props) {
|
|
1980
|
+
Object.entries(registeredQuests).forEach(([_, quest]) => {
|
|
1981
|
+
if (quest.currentStageMustStart) {
|
|
1982
|
+
quest.startCurrentStage(props);
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1899
1987
|
exports.ActivityRoom = ActivityRoom;
|
|
1900
1988
|
exports.CommitmentBaseModel = CommitmentBaseModel;
|
|
1901
1989
|
exports.Goal = Goal;
|
|
@@ -1919,12 +2007,13 @@ exports.getCurrentRoom = getCurrentRoom;
|
|
|
1919
2007
|
exports.getCurrentRoutine = getCurrentRoutine;
|
|
1920
2008
|
exports.getQuestById = getQuestById;
|
|
1921
2009
|
exports.getRoomById = getRoomById;
|
|
2010
|
+
exports.newActivity = newActivity;
|
|
1922
2011
|
exports.newQuest = newQuest;
|
|
1923
2012
|
exports.removeCommitment = removeCommitment;
|
|
1924
|
-
exports.saveActivity = saveActivity;
|
|
1925
2013
|
exports.saveCommitment = saveCommitment;
|
|
1926
2014
|
exports.saveRoom = saveRoom;
|
|
1927
2015
|
exports.setCurrentRoom = setCurrentRoom;
|
|
1928
2016
|
exports.setFixedRoutine = setFixedRoutine;
|
|
2017
|
+
exports.startMustStartStageQuests = startMustStartStageQuests;
|
|
1929
2018
|
//# sourceMappingURL=out.js.map
|
|
1930
2019
|
//# sourceMappingURL=index.js.map
|