@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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GameStorageManager,
|
|
1
|
+
import { GameStorageManager, StoredClassModel, getFlag } from '@drincs/pixi-vn';
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -259,136 +259,7 @@ var TimeManager = class _TimeManager {
|
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
// src/classes/
|
|
263
|
-
var ActivityModel = class {
|
|
264
|
-
/**
|
|
265
|
-
* @param id The activity id, that must be unique.
|
|
266
|
-
* @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.
|
|
267
|
-
* @param props The activity properties.
|
|
268
|
-
*/
|
|
269
|
-
constructor(id, onRun, props) {
|
|
270
|
-
this._id = id;
|
|
271
|
-
this._name = props.name;
|
|
272
|
-
this._fromHour = props.fromHour;
|
|
273
|
-
this._toHour = props.toHour;
|
|
274
|
-
this._fromDay = props.fromDay;
|
|
275
|
-
this._toDay = props.toDay;
|
|
276
|
-
this._disabled = props.disabled || false;
|
|
277
|
-
this._hidden = props.hidden || false;
|
|
278
|
-
this._renderIcon = props.renderIcon;
|
|
279
|
-
this._onRun = onRun;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* The activity id, that is unique.
|
|
283
|
-
*/
|
|
284
|
-
get id() {
|
|
285
|
-
return this._id;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* The name
|
|
289
|
-
*/
|
|
290
|
-
get name() {
|
|
291
|
-
return this._name;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
295
|
-
*/
|
|
296
|
-
get fromHour() {
|
|
297
|
-
return this._fromHour;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
301
|
-
*/
|
|
302
|
-
get toHour() {
|
|
303
|
-
return this._toHour;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
307
|
-
*/
|
|
308
|
-
get fromDay() {
|
|
309
|
-
return this._fromDay;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
313
|
-
*/
|
|
314
|
-
get toDay() {
|
|
315
|
-
return this._toDay;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Whether is disabled.
|
|
319
|
-
*/
|
|
320
|
-
get disabled() {
|
|
321
|
-
if (typeof this._disabled === "string") {
|
|
322
|
-
return getFlag(this._disabled);
|
|
323
|
-
}
|
|
324
|
-
return this._disabled;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
328
|
-
*/
|
|
329
|
-
get hidden() {
|
|
330
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
331
|
-
return true;
|
|
332
|
-
}
|
|
333
|
-
if (!this.isDeadline) {
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
if (typeof this._hidden === "string") {
|
|
337
|
-
return getFlag(this._hidden);
|
|
338
|
-
}
|
|
339
|
-
return this._hidden;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* The function for rendering the icon of the activity.
|
|
343
|
-
*/
|
|
344
|
-
get renderIcon() {
|
|
345
|
-
let render = this._renderIcon;
|
|
346
|
-
if (render === void 0) {
|
|
347
|
-
return void 0;
|
|
348
|
-
}
|
|
349
|
-
if (typeof render === "function") {
|
|
350
|
-
return (props) => {
|
|
351
|
-
return render(this, props);
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
return (props) => render;
|
|
355
|
-
}
|
|
356
|
-
get _initialOnRun() {
|
|
357
|
-
return this._onRun;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* The function that is called when the activity is runned.
|
|
361
|
-
*/
|
|
362
|
-
get run() {
|
|
363
|
-
return (props) => this._onRun(this, props);
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Whether the activity is a deadline.
|
|
367
|
-
* @returns Whether the activity is a deadline.
|
|
368
|
-
*/
|
|
369
|
-
isDeadline() {
|
|
370
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
373
|
-
return false;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Export the activity properties.
|
|
377
|
-
* @returns The activity properties.
|
|
378
|
-
*/
|
|
379
|
-
export() {
|
|
380
|
-
return {
|
|
381
|
-
name: this._name,
|
|
382
|
-
fromHour: this._fromHour,
|
|
383
|
-
toHour: this._toHour,
|
|
384
|
-
fromDay: this._fromDay,
|
|
385
|
-
toDay: this._toDay,
|
|
386
|
-
disabled: this._disabled,
|
|
387
|
-
hidden: this._hidden,
|
|
388
|
-
renderIcon: this._renderIcon
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
};
|
|
262
|
+
// src/classes/Commitment.ts
|
|
392
263
|
var COMMITMENT_CATEGORY = "__nqtr-commitment__";
|
|
393
264
|
var CommitmentBaseModel = class extends StoredClassModel {
|
|
394
265
|
/**
|
|
@@ -1008,18 +879,145 @@ var MapBaseModel = class extends StoredClassModel {
|
|
|
1008
879
|
return getLocationsByMap(this);
|
|
1009
880
|
}
|
|
1010
881
|
};
|
|
882
|
+
var ActivityModel = class {
|
|
883
|
+
/**
|
|
884
|
+
* @param id The activity id, that must be unique.
|
|
885
|
+
* @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.
|
|
886
|
+
* @param props The activity properties.
|
|
887
|
+
*/
|
|
888
|
+
constructor(id, onRun, props) {
|
|
889
|
+
this._id = id;
|
|
890
|
+
this._name = props.name;
|
|
891
|
+
this._fromHour = props.fromHour;
|
|
892
|
+
this._toHour = props.toHour;
|
|
893
|
+
this._fromDay = props.fromDay;
|
|
894
|
+
this._toDay = props.toDay;
|
|
895
|
+
this._disabled = props.disabled || false;
|
|
896
|
+
this._hidden = props.hidden || false;
|
|
897
|
+
this._renderIcon = props.renderIcon;
|
|
898
|
+
this._onRun = onRun;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* The activity id, that is unique.
|
|
902
|
+
*/
|
|
903
|
+
get id() {
|
|
904
|
+
return this._id;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* The name
|
|
908
|
+
*/
|
|
909
|
+
get name() {
|
|
910
|
+
return this._name;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
914
|
+
*/
|
|
915
|
+
get fromHour() {
|
|
916
|
+
return this._fromHour;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
920
|
+
*/
|
|
921
|
+
get toHour() {
|
|
922
|
+
return this._toHour;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
926
|
+
*/
|
|
927
|
+
get fromDay() {
|
|
928
|
+
return this._fromDay;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
932
|
+
*/
|
|
933
|
+
get toDay() {
|
|
934
|
+
return this._toDay;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Whether is disabled.
|
|
938
|
+
*/
|
|
939
|
+
get disabled() {
|
|
940
|
+
if (typeof this._disabled === "string") {
|
|
941
|
+
return getFlag(this._disabled);
|
|
942
|
+
}
|
|
943
|
+
return this._disabled;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
947
|
+
*/
|
|
948
|
+
get hidden() {
|
|
949
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
if (!this.isDeadline) {
|
|
953
|
+
return true;
|
|
954
|
+
}
|
|
955
|
+
if (typeof this._hidden === "string") {
|
|
956
|
+
return getFlag(this._hidden);
|
|
957
|
+
}
|
|
958
|
+
return this._hidden;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* The function for rendering the icon of the activity.
|
|
962
|
+
*/
|
|
963
|
+
get renderIcon() {
|
|
964
|
+
let render = this._renderIcon;
|
|
965
|
+
if (render === void 0) {
|
|
966
|
+
return void 0;
|
|
967
|
+
}
|
|
968
|
+
if (typeof render === "function") {
|
|
969
|
+
return (props) => {
|
|
970
|
+
return render(this, props);
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
return (props) => render;
|
|
974
|
+
}
|
|
975
|
+
get _initialOnRun() {
|
|
976
|
+
return this._onRun;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* The function that is called when the activity is runned.
|
|
980
|
+
*/
|
|
981
|
+
get run() {
|
|
982
|
+
return (props) => this._onRun(this, props);
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Whether the activity is a deadline.
|
|
986
|
+
* @returns Whether the activity is a deadline.
|
|
987
|
+
*/
|
|
988
|
+
isDeadline() {
|
|
989
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
990
|
+
return true;
|
|
991
|
+
}
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Export the activity properties.
|
|
996
|
+
* @returns The activity properties.
|
|
997
|
+
*/
|
|
998
|
+
export() {
|
|
999
|
+
return {
|
|
1000
|
+
name: this._name,
|
|
1001
|
+
fromHour: this._fromHour,
|
|
1002
|
+
toHour: this._toHour,
|
|
1003
|
+
fromDay: this._fromDay,
|
|
1004
|
+
toDay: this._toDay,
|
|
1005
|
+
disabled: this._disabled,
|
|
1006
|
+
hidden: this._hidden,
|
|
1007
|
+
renderIcon: this._renderIcon
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
1011
|
|
|
1012
1012
|
// src/decorators/ActivityDecorator.ts
|
|
1013
1013
|
var registeredActivities = {};
|
|
1014
|
-
function
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
return;
|
|
1018
|
-
}
|
|
1019
|
-
if (registeredActivities[activity.id]) {
|
|
1020
|
-
console.warn(`[NQTR] Activity id ${activity.id} already exists, it will be overwritten`);
|
|
1014
|
+
function newActivity(id, onRun, props) {
|
|
1015
|
+
if (registeredActivities[id]) {
|
|
1016
|
+
console.warn(`[NQTR] Activity ${id} already exists, it will be overwritten`);
|
|
1021
1017
|
}
|
|
1022
|
-
|
|
1018
|
+
let activity = new ActivityModel(id, onRun, props);
|
|
1019
|
+
registeredActivities[id] = activity;
|
|
1020
|
+
return activity;
|
|
1023
1021
|
}
|
|
1024
1022
|
function getActivityById(id) {
|
|
1025
1023
|
try {
|
|
@@ -1082,7 +1080,7 @@ function addCommitment(commitment) {
|
|
|
1082
1080
|
}
|
|
1083
1081
|
return commitment2.id;
|
|
1084
1082
|
}).filter((id) => id !== void 0);
|
|
1085
|
-
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY,
|
|
1083
|
+
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, commitmentsIds);
|
|
1086
1084
|
}
|
|
1087
1085
|
function removeCommitment(commitment) {
|
|
1088
1086
|
if (!Array.isArray(commitment)) {
|
|
@@ -1123,9 +1121,15 @@ var Goal = class extends StoredClassModel {
|
|
|
1123
1121
|
get description() {
|
|
1124
1122
|
return this._description;
|
|
1125
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* The number of times the goal must be completed.
|
|
1126
|
+
*/
|
|
1126
1127
|
get need() {
|
|
1127
1128
|
return this._need;
|
|
1128
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* The default number of times the goal has been completed.
|
|
1132
|
+
*/
|
|
1129
1133
|
get defaultHave() {
|
|
1130
1134
|
return this._defaultHave;
|
|
1131
1135
|
}
|
|
@@ -1135,12 +1139,18 @@ var GoalStage = class extends Goal {
|
|
|
1135
1139
|
super(id, props);
|
|
1136
1140
|
this._stageId = stageId;
|
|
1137
1141
|
}
|
|
1142
|
+
/**
|
|
1143
|
+
* The id of the stage that the goal belongs to.
|
|
1144
|
+
*/
|
|
1138
1145
|
get stageId() {
|
|
1139
1146
|
return this._stageId;
|
|
1140
1147
|
}
|
|
1141
1148
|
set stageId(value) {
|
|
1142
1149
|
this._stageId = value;
|
|
1143
1150
|
}
|
|
1151
|
+
/**
|
|
1152
|
+
* The number of times the goal has been completed.
|
|
1153
|
+
*/
|
|
1144
1154
|
get have() {
|
|
1145
1155
|
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
1146
1156
|
}
|
|
@@ -1151,6 +1161,9 @@ var GoalStage = class extends Goal {
|
|
|
1151
1161
|
}
|
|
1152
1162
|
this.setStorageProperty("have-" + this._stageId, value);
|
|
1153
1163
|
}
|
|
1164
|
+
/**
|
|
1165
|
+
* If the goal is completed.
|
|
1166
|
+
*/
|
|
1154
1167
|
get completed() {
|
|
1155
1168
|
return this.have >= this.need;
|
|
1156
1169
|
}
|
|
@@ -1161,6 +1174,9 @@ var GoalStage = class extends Goal {
|
|
|
1161
1174
|
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
1162
1175
|
}
|
|
1163
1176
|
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Find the goal. It will increment the have value.
|
|
1179
|
+
*/
|
|
1164
1180
|
find() {
|
|
1165
1181
|
this.have++;
|
|
1166
1182
|
}
|
|
@@ -1184,12 +1200,21 @@ var Stage = class extends StoredClassModel {
|
|
|
1184
1200
|
this._onStart = props.onStart;
|
|
1185
1201
|
this._onEnd = props.onEnd;
|
|
1186
1202
|
}
|
|
1203
|
+
/**
|
|
1204
|
+
* The name of the stage.
|
|
1205
|
+
*/
|
|
1187
1206
|
get name() {
|
|
1188
1207
|
return this._name;
|
|
1189
1208
|
}
|
|
1209
|
+
/**
|
|
1210
|
+
* The description of the stage.
|
|
1211
|
+
*/
|
|
1190
1212
|
get description() {
|
|
1191
1213
|
return this._description;
|
|
1192
1214
|
}
|
|
1215
|
+
/**
|
|
1216
|
+
* The advice description of the stage.
|
|
1217
|
+
*/
|
|
1193
1218
|
get adviceDescription() {
|
|
1194
1219
|
return this._adviceDescription;
|
|
1195
1220
|
}
|
|
@@ -1208,6 +1233,10 @@ var Stage = class extends StoredClassModel {
|
|
|
1208
1233
|
}
|
|
1209
1234
|
return (props) => render;
|
|
1210
1235
|
}
|
|
1236
|
+
/**
|
|
1237
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
1238
|
+
* This is the list set by the developer. if you want to get the current goals, use the goals property.
|
|
1239
|
+
*/
|
|
1211
1240
|
get defaultGoals() {
|
|
1212
1241
|
return this._defaultGoals;
|
|
1213
1242
|
}
|
|
@@ -1217,21 +1246,39 @@ var Stage = class extends StoredClassModel {
|
|
|
1217
1246
|
get flags() {
|
|
1218
1247
|
return this._flags;
|
|
1219
1248
|
}
|
|
1249
|
+
/**
|
|
1250
|
+
* The number of days required to start the stage.
|
|
1251
|
+
*/
|
|
1220
1252
|
get daysRequiredToStart() {
|
|
1221
1253
|
return this._daysRequiredToStart || 0;
|
|
1222
1254
|
}
|
|
1255
|
+
/**
|
|
1256
|
+
* The list of flags required to start the stage.
|
|
1257
|
+
*/
|
|
1223
1258
|
get flagsRequiredToStart() {
|
|
1224
1259
|
return this._flagsRequiredToStart;
|
|
1225
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* The list of quests required to start the stage.
|
|
1263
|
+
*/
|
|
1226
1264
|
get questsRequiredToStart() {
|
|
1227
1265
|
return this._questsRequiredToStart || [];
|
|
1228
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* The description of the request to start the stage.
|
|
1269
|
+
*/
|
|
1229
1270
|
get requestDescriptionToStart() {
|
|
1230
1271
|
return this._requestDescriptionToStart;
|
|
1231
1272
|
}
|
|
1273
|
+
/**
|
|
1274
|
+
* The function that will be called when the stage starts.
|
|
1275
|
+
*/
|
|
1232
1276
|
get onStart() {
|
|
1233
1277
|
return this._onStart;
|
|
1234
1278
|
}
|
|
1279
|
+
/**
|
|
1280
|
+
* The function that will be called when the stage ends.
|
|
1281
|
+
*/
|
|
1235
1282
|
get onEnd() {
|
|
1236
1283
|
return this._onEnd;
|
|
1237
1284
|
}
|
|
@@ -1240,22 +1287,38 @@ var StageQuest = class extends Stage {
|
|
|
1240
1287
|
constructor(id, props) {
|
|
1241
1288
|
super(id, props);
|
|
1242
1289
|
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Check if the flag and goals are completed.
|
|
1292
|
+
* You can force the completion of the stage by setting the completed property to true.
|
|
1293
|
+
*/
|
|
1243
1294
|
get completed() {
|
|
1244
1295
|
let storedCompleted = this.getStorageProperty("completed");
|
|
1245
1296
|
if (storedCompleted) {
|
|
1246
1297
|
return storedCompleted;
|
|
1247
1298
|
}
|
|
1248
|
-
if (
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1299
|
+
if (this.flags.length > 0 && this.goals.length > 0) {
|
|
1300
|
+
if (!this.flags.every((flag) => getFlag(flag.flag))) {
|
|
1301
|
+
return false;
|
|
1302
|
+
}
|
|
1303
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
1304
|
+
return false;
|
|
1305
|
+
}
|
|
1306
|
+
return true;
|
|
1253
1307
|
}
|
|
1254
|
-
return
|
|
1308
|
+
return false;
|
|
1255
1309
|
}
|
|
1256
1310
|
set completed(value) {
|
|
1257
1311
|
this.setStorageProperty("completed", value);
|
|
1258
1312
|
}
|
|
1313
|
+
/**
|
|
1314
|
+
* If the stage is started.
|
|
1315
|
+
*/
|
|
1316
|
+
get started() {
|
|
1317
|
+
return this.getStorageProperty("started") || false;
|
|
1318
|
+
}
|
|
1319
|
+
set started(value) {
|
|
1320
|
+
this.setStorageProperty("started", value);
|
|
1321
|
+
}
|
|
1259
1322
|
/**
|
|
1260
1323
|
* The list of goals that the player needs to complete to finish the stage.
|
|
1261
1324
|
*/
|
|
@@ -1270,6 +1333,9 @@ var StageQuest = class extends Stage {
|
|
|
1270
1333
|
set prevStageEndDay(value) {
|
|
1271
1334
|
this.setStorageProperty("prevStageEndDay", value);
|
|
1272
1335
|
}
|
|
1336
|
+
/**
|
|
1337
|
+
* The day when the stage starts.
|
|
1338
|
+
*/
|
|
1273
1339
|
get startDay() {
|
|
1274
1340
|
let prevStageEndDay = this.prevStageEndDay;
|
|
1275
1341
|
if (prevStageEndDay === void 0) {
|
|
@@ -1277,6 +1343,9 @@ var StageQuest = class extends Stage {
|
|
|
1277
1343
|
}
|
|
1278
1344
|
return prevStageEndDay + this.daysRequiredToStart;
|
|
1279
1345
|
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Check if the stage can start.
|
|
1348
|
+
*/
|
|
1280
1349
|
get canStart() {
|
|
1281
1350
|
let daysRequired = this.daysRequiredToStart;
|
|
1282
1351
|
if (daysRequired > 0) {
|
|
@@ -1298,11 +1367,27 @@ var StageQuest = class extends Stage {
|
|
|
1298
1367
|
}
|
|
1299
1368
|
return true;
|
|
1300
1369
|
}
|
|
1301
|
-
|
|
1370
|
+
/**
|
|
1371
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
1372
|
+
*/
|
|
1373
|
+
inizialize() {
|
|
1302
1374
|
if (this.daysRequiredToStart > 0) {
|
|
1303
1375
|
this.prevStageEndDay = TimeManager.currentDay;
|
|
1376
|
+
console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* The function that will be called when the stage starts.
|
|
1381
|
+
*/
|
|
1382
|
+
start(props) {
|
|
1383
|
+
if (this.canStart) {
|
|
1384
|
+
this.started = true;
|
|
1385
|
+
if (this.onStart) {
|
|
1386
|
+
this.onStart(props);
|
|
1387
|
+
}
|
|
1388
|
+
} else {
|
|
1389
|
+
console.warn(`[NQTR] Stage ${this.id} can't start`);
|
|
1304
1390
|
}
|
|
1305
|
-
return super.onStart;
|
|
1306
1391
|
}
|
|
1307
1392
|
};
|
|
1308
1393
|
|
|
@@ -1318,14 +1403,23 @@ var Quest = class extends StoredClassModel {
|
|
|
1318
1403
|
this._renderImage = props.renderImage;
|
|
1319
1404
|
this._isInDevelopment = props.isInDevelopment || false;
|
|
1320
1405
|
}
|
|
1406
|
+
/**
|
|
1407
|
+
* The stages of the quest.
|
|
1408
|
+
*/
|
|
1321
1409
|
get stages() {
|
|
1322
1410
|
return this._stages.map((stage, index) => {
|
|
1323
1411
|
return new StageQuest(stage.id, stage);
|
|
1324
1412
|
});
|
|
1325
1413
|
}
|
|
1414
|
+
/**
|
|
1415
|
+
* The name of the quest.
|
|
1416
|
+
*/
|
|
1326
1417
|
get name() {
|
|
1327
1418
|
return this._name;
|
|
1328
1419
|
}
|
|
1420
|
+
/**
|
|
1421
|
+
* The description of the quest.
|
|
1422
|
+
*/
|
|
1329
1423
|
get description() {
|
|
1330
1424
|
return this._description;
|
|
1331
1425
|
}
|
|
@@ -1359,15 +1453,24 @@ var Quest = class extends StoredClassModel {
|
|
|
1359
1453
|
}
|
|
1360
1454
|
return (props) => render;
|
|
1361
1455
|
}
|
|
1456
|
+
/**
|
|
1457
|
+
* If the quest is in development.
|
|
1458
|
+
*/
|
|
1362
1459
|
get isInDevelopment() {
|
|
1363
1460
|
return this._isInDevelopment;
|
|
1364
1461
|
}
|
|
1462
|
+
/**
|
|
1463
|
+
* The index of the current stage.
|
|
1464
|
+
*/
|
|
1365
1465
|
get currentStageIndex() {
|
|
1366
1466
|
return this.getStorageProperty("currentStageIndex");
|
|
1367
1467
|
}
|
|
1368
1468
|
set currentStageIndex(value) {
|
|
1369
1469
|
this.setStorageProperty("currentStageIndex", value);
|
|
1370
1470
|
}
|
|
1471
|
+
/**
|
|
1472
|
+
* The current stage.
|
|
1473
|
+
*/
|
|
1371
1474
|
get currentStage() {
|
|
1372
1475
|
let index = this.currentStageIndex;
|
|
1373
1476
|
if (index === void 0 || index >= this.stages.length) {
|
|
@@ -1375,12 +1478,26 @@ var Quest = class extends StoredClassModel {
|
|
|
1375
1478
|
}
|
|
1376
1479
|
return this.stages[index];
|
|
1377
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* If the quest is started.
|
|
1483
|
+
*/
|
|
1378
1484
|
get started() {
|
|
1379
1485
|
return this.currentStageIndex !== void 0;
|
|
1380
1486
|
}
|
|
1487
|
+
/**
|
|
1488
|
+
* If the quest is completed.
|
|
1489
|
+
*/
|
|
1381
1490
|
get completed() {
|
|
1382
|
-
|
|
1491
|
+
if (this.currentStageIndex === void 0) {
|
|
1492
|
+
return false;
|
|
1493
|
+
}
|
|
1494
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
1383
1495
|
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Start the quest.
|
|
1498
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1499
|
+
* @returns
|
|
1500
|
+
*/
|
|
1384
1501
|
start(props) {
|
|
1385
1502
|
if (this.started) {
|
|
1386
1503
|
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
@@ -1392,35 +1509,97 @@ var Quest = class extends StoredClassModel {
|
|
|
1392
1509
|
}
|
|
1393
1510
|
this.currentStageIndex = 0;
|
|
1394
1511
|
let currentStage = this.currentStage;
|
|
1395
|
-
if (currentStage && currentStage.
|
|
1396
|
-
return currentStage.
|
|
1512
|
+
if (currentStage && currentStage.start) {
|
|
1513
|
+
return currentStage.start(props);
|
|
1397
1514
|
} else {
|
|
1398
1515
|
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1399
1516
|
}
|
|
1400
1517
|
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Go to the next stage if the current stage is completed.
|
|
1520
|
+
* If you want to force the change of stage, use goNextStage.
|
|
1521
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1522
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1523
|
+
* @returns true if the stage was changed, false otherwise.
|
|
1524
|
+
*/
|
|
1401
1525
|
tryToGoNextStage(startProps, endProps) {
|
|
1402
1526
|
if (!this.started) {
|
|
1403
|
-
return;
|
|
1527
|
+
return false;
|
|
1404
1528
|
}
|
|
1405
1529
|
if (this.completed) {
|
|
1406
|
-
return;
|
|
1530
|
+
return false;
|
|
1407
1531
|
}
|
|
1408
1532
|
let currentStage = this.currentStage;
|
|
1409
|
-
|
|
1410
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
1533
|
+
if (!currentStage) {
|
|
1411
1534
|
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1412
|
-
return;
|
|
1535
|
+
return false;
|
|
1413
1536
|
}
|
|
1414
1537
|
if (currentStage.completed) {
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1538
|
+
return this.goNextStage(startProps, endProps);
|
|
1539
|
+
}
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Complete the current stage and go to the next stage.
|
|
1544
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1545
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1546
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1547
|
+
* @returns true if the stage was changed, false otherwise.
|
|
1548
|
+
*/
|
|
1549
|
+
completeCurrentStageAndGoNext(startProps, endProps) {
|
|
1550
|
+
let currentStage = this.currentStage;
|
|
1551
|
+
if (!currentStage) {
|
|
1552
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1553
|
+
return false;
|
|
1554
|
+
}
|
|
1555
|
+
currentStage.completed = true;
|
|
1556
|
+
return this.goNextStage(startProps, endProps);
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Go to the next stage without checking if the current stage is completed.
|
|
1560
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1561
|
+
* @param startProps
|
|
1562
|
+
* @param endProps
|
|
1563
|
+
* @returns returns true if the stage was changed, false otherwise.
|
|
1564
|
+
*/
|
|
1565
|
+
goNextStage(startProps, endProps) {
|
|
1566
|
+
if (!this.started) {
|
|
1567
|
+
console.warn(`[NQTR] Quest ${this.id} is not started`);
|
|
1568
|
+
return false;
|
|
1569
|
+
}
|
|
1570
|
+
if (this.completed) {
|
|
1571
|
+
console.warn(`[NQTR] Quest ${this.id} is already completed`);
|
|
1572
|
+
return false;
|
|
1573
|
+
}
|
|
1574
|
+
let prevStage = this.currentStage;
|
|
1575
|
+
let currentStageIndex = this.currentStageIndex;
|
|
1576
|
+
if (!prevStage || currentStageIndex === void 0) {
|
|
1577
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1578
|
+
return false;
|
|
1579
|
+
}
|
|
1580
|
+
this.currentStageIndex = currentStageIndex + 1;
|
|
1581
|
+
if (prevStage && prevStage.onEnd) {
|
|
1582
|
+
prevStage.onEnd(endProps);
|
|
1583
|
+
}
|
|
1584
|
+
let nextCurrentStage = this.currentStage;
|
|
1585
|
+
if (nextCurrentStage) {
|
|
1586
|
+
nextCurrentStage.inizialize();
|
|
1587
|
+
}
|
|
1588
|
+
return true;
|
|
1589
|
+
}
|
|
1590
|
+
get currentStageMustStart() {
|
|
1591
|
+
let currentStage = this.currentStage;
|
|
1592
|
+
if (!currentStage) {
|
|
1593
|
+
return false;
|
|
1594
|
+
}
|
|
1595
|
+
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
1596
|
+
}
|
|
1597
|
+
startCurrentStage(props) {
|
|
1598
|
+
let newCurrentStage = this.currentStage;
|
|
1599
|
+
if (newCurrentStage && this.currentStageMustStart) {
|
|
1600
|
+
newCurrentStage.start(props);
|
|
1601
|
+
} else {
|
|
1602
|
+
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
1424
1603
|
}
|
|
1425
1604
|
}
|
|
1426
1605
|
};
|
|
@@ -1794,6 +1973,15 @@ function currentActivities() {
|
|
|
1794
1973
|
return currentRoom.activities.filter((activity) => !activity.hidden);
|
|
1795
1974
|
}
|
|
1796
1975
|
|
|
1797
|
-
|
|
1976
|
+
// src/functions/QuestFunctions.ts
|
|
1977
|
+
function startMustStartStageQuests(props) {
|
|
1978
|
+
Object.entries(registeredQuests).forEach(([_, quest]) => {
|
|
1979
|
+
if (quest.currentStageMustStart) {
|
|
1980
|
+
quest.startCurrentStage(props);
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
export { ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, RoomBaseModel, Stage, TimeManager, addCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getAllLocations, getAllMaps, getCommitmentByCharacter, getCommitmentById, getCueerntMap, getCurrenrLocation, getCurrentRoom, getCurrentRoutine, getQuestById, getRoomById, newActivity, newQuest, removeCommitment, saveCommitment, saveRoom, setCurrentRoom, setFixedRoutine, startMustStartStageQuests };
|
|
1798
1986
|
//# sourceMappingURL=out.js.map
|
|
1799
1987
|
//# sourceMappingURL=index.mjs.map
|