@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/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 {
|
|
@@ -1084,7 +1082,7 @@ function addCommitment(commitment) {
|
|
|
1084
1082
|
}
|
|
1085
1083
|
return commitment2.id;
|
|
1086
1084
|
}).filter((id) => id !== void 0);
|
|
1087
|
-
pixiVn.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY,
|
|
1085
|
+
pixiVn.GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, commitmentsIds);
|
|
1088
1086
|
}
|
|
1089
1087
|
function removeCommitment(commitment) {
|
|
1090
1088
|
if (!Array.isArray(commitment)) {
|
|
@@ -1125,9 +1123,15 @@ var Goal = class extends pixiVn.StoredClassModel {
|
|
|
1125
1123
|
get description() {
|
|
1126
1124
|
return this._description;
|
|
1127
1125
|
}
|
|
1126
|
+
/**
|
|
1127
|
+
* The number of times the goal must be completed.
|
|
1128
|
+
*/
|
|
1128
1129
|
get need() {
|
|
1129
1130
|
return this._need;
|
|
1130
1131
|
}
|
|
1132
|
+
/**
|
|
1133
|
+
* The default number of times the goal has been completed.
|
|
1134
|
+
*/
|
|
1131
1135
|
get defaultHave() {
|
|
1132
1136
|
return this._defaultHave;
|
|
1133
1137
|
}
|
|
@@ -1137,12 +1141,18 @@ var GoalStage = class extends Goal {
|
|
|
1137
1141
|
super(id, props);
|
|
1138
1142
|
this._stageId = stageId;
|
|
1139
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* The id of the stage that the goal belongs to.
|
|
1146
|
+
*/
|
|
1140
1147
|
get stageId() {
|
|
1141
1148
|
return this._stageId;
|
|
1142
1149
|
}
|
|
1143
1150
|
set stageId(value) {
|
|
1144
1151
|
this._stageId = value;
|
|
1145
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* The number of times the goal has been completed.
|
|
1155
|
+
*/
|
|
1146
1156
|
get have() {
|
|
1147
1157
|
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
1148
1158
|
}
|
|
@@ -1153,6 +1163,9 @@ var GoalStage = class extends Goal {
|
|
|
1153
1163
|
}
|
|
1154
1164
|
this.setStorageProperty("have-" + this._stageId, value);
|
|
1155
1165
|
}
|
|
1166
|
+
/**
|
|
1167
|
+
* If the goal is completed.
|
|
1168
|
+
*/
|
|
1156
1169
|
get completed() {
|
|
1157
1170
|
return this.have >= this.need;
|
|
1158
1171
|
}
|
|
@@ -1163,6 +1176,9 @@ var GoalStage = class extends Goal {
|
|
|
1163
1176
|
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
1164
1177
|
}
|
|
1165
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Find the goal. It will increment the have value.
|
|
1181
|
+
*/
|
|
1166
1182
|
find() {
|
|
1167
1183
|
this.have++;
|
|
1168
1184
|
}
|
|
@@ -1186,12 +1202,21 @@ var Stage = class extends pixiVn.StoredClassModel {
|
|
|
1186
1202
|
this._onStart = props.onStart;
|
|
1187
1203
|
this._onEnd = props.onEnd;
|
|
1188
1204
|
}
|
|
1205
|
+
/**
|
|
1206
|
+
* The name of the stage.
|
|
1207
|
+
*/
|
|
1189
1208
|
get name() {
|
|
1190
1209
|
return this._name;
|
|
1191
1210
|
}
|
|
1211
|
+
/**
|
|
1212
|
+
* The description of the stage.
|
|
1213
|
+
*/
|
|
1192
1214
|
get description() {
|
|
1193
1215
|
return this._description;
|
|
1194
1216
|
}
|
|
1217
|
+
/**
|
|
1218
|
+
* The advice description of the stage.
|
|
1219
|
+
*/
|
|
1195
1220
|
get adviceDescription() {
|
|
1196
1221
|
return this._adviceDescription;
|
|
1197
1222
|
}
|
|
@@ -1210,6 +1235,10 @@ var Stage = class extends pixiVn.StoredClassModel {
|
|
|
1210
1235
|
}
|
|
1211
1236
|
return (props) => render;
|
|
1212
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
1240
|
+
* This is the list set by the developer. if you want to get the current goals, use the goals property.
|
|
1241
|
+
*/
|
|
1213
1242
|
get defaultGoals() {
|
|
1214
1243
|
return this._defaultGoals;
|
|
1215
1244
|
}
|
|
@@ -1219,21 +1248,39 @@ var Stage = class extends pixiVn.StoredClassModel {
|
|
|
1219
1248
|
get flags() {
|
|
1220
1249
|
return this._flags;
|
|
1221
1250
|
}
|
|
1251
|
+
/**
|
|
1252
|
+
* The number of days required to start the stage.
|
|
1253
|
+
*/
|
|
1222
1254
|
get daysRequiredToStart() {
|
|
1223
1255
|
return this._daysRequiredToStart || 0;
|
|
1224
1256
|
}
|
|
1257
|
+
/**
|
|
1258
|
+
* The list of flags required to start the stage.
|
|
1259
|
+
*/
|
|
1225
1260
|
get flagsRequiredToStart() {
|
|
1226
1261
|
return this._flagsRequiredToStart;
|
|
1227
1262
|
}
|
|
1263
|
+
/**
|
|
1264
|
+
* The list of quests required to start the stage.
|
|
1265
|
+
*/
|
|
1228
1266
|
get questsRequiredToStart() {
|
|
1229
1267
|
return this._questsRequiredToStart || [];
|
|
1230
1268
|
}
|
|
1269
|
+
/**
|
|
1270
|
+
* The description of the request to start the stage.
|
|
1271
|
+
*/
|
|
1231
1272
|
get requestDescriptionToStart() {
|
|
1232
1273
|
return this._requestDescriptionToStart;
|
|
1233
1274
|
}
|
|
1275
|
+
/**
|
|
1276
|
+
* The function that will be called when the stage starts.
|
|
1277
|
+
*/
|
|
1234
1278
|
get onStart() {
|
|
1235
1279
|
return this._onStart;
|
|
1236
1280
|
}
|
|
1281
|
+
/**
|
|
1282
|
+
* The function that will be called when the stage ends.
|
|
1283
|
+
*/
|
|
1237
1284
|
get onEnd() {
|
|
1238
1285
|
return this._onEnd;
|
|
1239
1286
|
}
|
|
@@ -1242,22 +1289,38 @@ var StageQuest = class extends Stage {
|
|
|
1242
1289
|
constructor(id, props) {
|
|
1243
1290
|
super(id, props);
|
|
1244
1291
|
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Check if the flag and goals are completed.
|
|
1294
|
+
* You can force the completion of the stage by setting the completed property to true.
|
|
1295
|
+
*/
|
|
1245
1296
|
get completed() {
|
|
1246
1297
|
let storedCompleted = this.getStorageProperty("completed");
|
|
1247
1298
|
if (storedCompleted) {
|
|
1248
1299
|
return storedCompleted;
|
|
1249
1300
|
}
|
|
1250
|
-
if (
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
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;
|
|
1255
1309
|
}
|
|
1256
|
-
return
|
|
1310
|
+
return false;
|
|
1257
1311
|
}
|
|
1258
1312
|
set completed(value) {
|
|
1259
1313
|
this.setStorageProperty("completed", value);
|
|
1260
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
|
+
}
|
|
1261
1324
|
/**
|
|
1262
1325
|
* The list of goals that the player needs to complete to finish the stage.
|
|
1263
1326
|
*/
|
|
@@ -1272,6 +1335,9 @@ var StageQuest = class extends Stage {
|
|
|
1272
1335
|
set prevStageEndDay(value) {
|
|
1273
1336
|
this.setStorageProperty("prevStageEndDay", value);
|
|
1274
1337
|
}
|
|
1338
|
+
/**
|
|
1339
|
+
* The day when the stage starts.
|
|
1340
|
+
*/
|
|
1275
1341
|
get startDay() {
|
|
1276
1342
|
let prevStageEndDay = this.prevStageEndDay;
|
|
1277
1343
|
if (prevStageEndDay === void 0) {
|
|
@@ -1279,6 +1345,9 @@ var StageQuest = class extends Stage {
|
|
|
1279
1345
|
}
|
|
1280
1346
|
return prevStageEndDay + this.daysRequiredToStart;
|
|
1281
1347
|
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Check if the stage can start.
|
|
1350
|
+
*/
|
|
1282
1351
|
get canStart() {
|
|
1283
1352
|
let daysRequired = this.daysRequiredToStart;
|
|
1284
1353
|
if (daysRequired > 0) {
|
|
@@ -1300,11 +1369,27 @@ var StageQuest = class extends Stage {
|
|
|
1300
1369
|
}
|
|
1301
1370
|
return true;
|
|
1302
1371
|
}
|
|
1303
|
-
|
|
1372
|
+
/**
|
|
1373
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
1374
|
+
*/
|
|
1375
|
+
inizialize() {
|
|
1304
1376
|
if (this.daysRequiredToStart > 0) {
|
|
1305
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`);
|
|
1306
1392
|
}
|
|
1307
|
-
return super.onStart;
|
|
1308
1393
|
}
|
|
1309
1394
|
};
|
|
1310
1395
|
|
|
@@ -1320,14 +1405,23 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1320
1405
|
this._renderImage = props.renderImage;
|
|
1321
1406
|
this._isInDevelopment = props.isInDevelopment || false;
|
|
1322
1407
|
}
|
|
1408
|
+
/**
|
|
1409
|
+
* The stages of the quest.
|
|
1410
|
+
*/
|
|
1323
1411
|
get stages() {
|
|
1324
1412
|
return this._stages.map((stage, index) => {
|
|
1325
1413
|
return new StageQuest(stage.id, stage);
|
|
1326
1414
|
});
|
|
1327
1415
|
}
|
|
1416
|
+
/**
|
|
1417
|
+
* The name of the quest.
|
|
1418
|
+
*/
|
|
1328
1419
|
get name() {
|
|
1329
1420
|
return this._name;
|
|
1330
1421
|
}
|
|
1422
|
+
/**
|
|
1423
|
+
* The description of the quest.
|
|
1424
|
+
*/
|
|
1331
1425
|
get description() {
|
|
1332
1426
|
return this._description;
|
|
1333
1427
|
}
|
|
@@ -1361,15 +1455,24 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1361
1455
|
}
|
|
1362
1456
|
return (props) => render;
|
|
1363
1457
|
}
|
|
1458
|
+
/**
|
|
1459
|
+
* If the quest is in development.
|
|
1460
|
+
*/
|
|
1364
1461
|
get isInDevelopment() {
|
|
1365
1462
|
return this._isInDevelopment;
|
|
1366
1463
|
}
|
|
1464
|
+
/**
|
|
1465
|
+
* The index of the current stage.
|
|
1466
|
+
*/
|
|
1367
1467
|
get currentStageIndex() {
|
|
1368
1468
|
return this.getStorageProperty("currentStageIndex");
|
|
1369
1469
|
}
|
|
1370
1470
|
set currentStageIndex(value) {
|
|
1371
1471
|
this.setStorageProperty("currentStageIndex", value);
|
|
1372
1472
|
}
|
|
1473
|
+
/**
|
|
1474
|
+
* The current stage.
|
|
1475
|
+
*/
|
|
1373
1476
|
get currentStage() {
|
|
1374
1477
|
let index = this.currentStageIndex;
|
|
1375
1478
|
if (index === void 0 || index >= this.stages.length) {
|
|
@@ -1377,12 +1480,26 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1377
1480
|
}
|
|
1378
1481
|
return this.stages[index];
|
|
1379
1482
|
}
|
|
1483
|
+
/**
|
|
1484
|
+
* If the quest is started.
|
|
1485
|
+
*/
|
|
1380
1486
|
get started() {
|
|
1381
1487
|
return this.currentStageIndex !== void 0;
|
|
1382
1488
|
}
|
|
1489
|
+
/**
|
|
1490
|
+
* If the quest is completed.
|
|
1491
|
+
*/
|
|
1383
1492
|
get completed() {
|
|
1384
|
-
|
|
1493
|
+
if (this.currentStageIndex === void 0) {
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
1385
1497
|
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Start the quest.
|
|
1500
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1501
|
+
* @returns
|
|
1502
|
+
*/
|
|
1386
1503
|
start(props) {
|
|
1387
1504
|
if (this.started) {
|
|
1388
1505
|
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
@@ -1394,35 +1511,97 @@ var Quest = class extends pixiVn.StoredClassModel {
|
|
|
1394
1511
|
}
|
|
1395
1512
|
this.currentStageIndex = 0;
|
|
1396
1513
|
let currentStage = this.currentStage;
|
|
1397
|
-
if (currentStage && currentStage.
|
|
1398
|
-
return currentStage.
|
|
1514
|
+
if (currentStage && currentStage.start) {
|
|
1515
|
+
return currentStage.start(props);
|
|
1399
1516
|
} else {
|
|
1400
1517
|
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1401
1518
|
}
|
|
1402
1519
|
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Go to the next stage if the current stage is completed.
|
|
1522
|
+
* If you want to force the change of stage, use goNextStage.
|
|
1523
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1524
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1525
|
+
* @returns true if the stage was changed, false otherwise.
|
|
1526
|
+
*/
|
|
1403
1527
|
tryToGoNextStage(startProps, endProps) {
|
|
1404
1528
|
if (!this.started) {
|
|
1405
|
-
return;
|
|
1529
|
+
return false;
|
|
1406
1530
|
}
|
|
1407
1531
|
if (this.completed) {
|
|
1408
|
-
return;
|
|
1532
|
+
return false;
|
|
1409
1533
|
}
|
|
1410
1534
|
let currentStage = this.currentStage;
|
|
1411
|
-
|
|
1412
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
1535
|
+
if (!currentStage) {
|
|
1413
1536
|
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1414
|
-
return;
|
|
1537
|
+
return false;
|
|
1415
1538
|
}
|
|
1416
1539
|
if (currentStage.completed) {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1540
|
+
return this.goNextStage(startProps, endProps);
|
|
1541
|
+
}
|
|
1542
|
+
return false;
|
|
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`);
|
|
1426
1605
|
}
|
|
1427
1606
|
}
|
|
1428
1607
|
};
|
|
@@ -1796,7 +1975,15 @@ function currentActivities() {
|
|
|
1796
1975
|
return currentRoom.activities.filter((activity) => !activity.hidden);
|
|
1797
1976
|
}
|
|
1798
1977
|
|
|
1799
|
-
|
|
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
|
+
|
|
1800
1987
|
exports.ActivityRoom = ActivityRoom;
|
|
1801
1988
|
exports.CommitmentBaseModel = CommitmentBaseModel;
|
|
1802
1989
|
exports.Goal = Goal;
|
|
@@ -1820,12 +2007,13 @@ exports.getCurrentRoom = getCurrentRoom;
|
|
|
1820
2007
|
exports.getCurrentRoutine = getCurrentRoutine;
|
|
1821
2008
|
exports.getQuestById = getQuestById;
|
|
1822
2009
|
exports.getRoomById = getRoomById;
|
|
2010
|
+
exports.newActivity = newActivity;
|
|
1823
2011
|
exports.newQuest = newQuest;
|
|
1824
2012
|
exports.removeCommitment = removeCommitment;
|
|
1825
|
-
exports.saveActivity = saveActivity;
|
|
1826
2013
|
exports.saveCommitment = saveCommitment;
|
|
1827
2014
|
exports.saveRoom = saveRoom;
|
|
1828
2015
|
exports.setCurrentRoom = setCurrentRoom;
|
|
1829
2016
|
exports.setFixedRoutine = setFixedRoutine;
|
|
2017
|
+
exports.startMustStartStageQuests = startMustStartStageQuests;
|
|
1830
2018
|
//# sourceMappingURL=out.js.map
|
|
1831
2019
|
//# sourceMappingURL=index.js.map
|