@drincs/nqtr 0.1.20 → 0.2.1
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/{ActivityProps-_79x9-BX.d.ts → ActivityProps-BkHX8xkA.d.ts} +1 -1
- package/dist/{ActivityProps-BoJeWa2B.d.mts → ActivityProps-D45DQdcT.d.mts} +1 -1
- package/dist/{Commitment-Cc2kZEy0.d.ts → Commitment-BJTIpBQ5.d.ts} +4 -2
- package/dist/{Commitment-C3Nc2RJH.d.mts → Commitment-CtNWnNQX.d.mts} +4 -2
- package/dist/{Quest-BQ1pwvQ_.d.ts → StageProps-BFsiCaZT.d.ts} +160 -81
- package/dist/{Quest-DaNlPBHb.d.mts → StageProps-CkXejAbn.d.mts} +160 -81
- package/dist/classes/Activity.d.mts +2 -2
- package/dist/classes/Activity.d.ts +2 -2
- package/dist/classes/Activity.js +1 -1
- package/dist/classes/Activity.js.map +1 -1
- package/dist/classes/Activity.mjs +1 -1
- package/dist/classes/Activity.mjs.map +1 -1
- package/dist/classes/ActivityStoredAbstract.d.mts +1 -1
- package/dist/classes/ActivityStoredAbstract.d.ts +1 -1
- package/dist/classes/ActivityStoredAbstract.js +1 -1
- package/dist/classes/ActivityStoredAbstract.js.map +1 -1
- package/dist/classes/ActivityStoredAbstract.mjs +1 -1
- package/dist/classes/ActivityStoredAbstract.mjs.map +1 -1
- package/dist/classes/Commitment.d.mts +2 -2
- package/dist/classes/Commitment.d.ts +2 -2
- package/dist/classes/Commitment.js +2 -2
- package/dist/classes/Commitment.js.map +1 -1
- package/dist/classes/Commitment.mjs +2 -2
- package/dist/classes/Commitment.mjs.map +1 -1
- package/dist/classes/index.d.mts +3 -3
- package/dist/classes/index.d.ts +3 -3
- package/dist/classes/index.js +133 -318
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +134 -318
- 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/ActivityRoom.js +1 -1
- package/dist/classes/navigation/ActivityRoom.js.map +1 -1
- package/dist/classes/navigation/ActivityRoom.mjs +1 -1
- package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
- package/dist/classes/navigation/Location.d.mts +2 -2
- package/dist/classes/navigation/Location.d.ts +2 -2
- package/dist/classes/navigation/Map.d.mts +2 -2
- package/dist/classes/navigation/Map.d.ts +2 -2
- package/dist/classes/navigation/Room.d.mts +2 -2
- package/dist/classes/navigation/Room.d.ts +2 -2
- package/dist/classes/navigation/Room.js +34 -36
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +34 -36
- 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 +107 -8
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +107 -8
- 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 +62 -0
- package/dist/classes/quest/Stage.js.map +1 -1
- package/dist/classes/quest/Stage.mjs +62 -0
- package/dist/classes/quest/Stage.mjs.map +1 -1
- package/dist/decorators/ActivityDecorator.d.mts +1 -1
- package/dist/decorators/ActivityDecorator.d.ts +1 -1
- package/dist/decorators/CommitmentDecorator.d.mts +9 -3
- package/dist/decorators/CommitmentDecorator.d.ts +9 -3
- package/dist/decorators/CommitmentDecorator.js +16 -1
- package/dist/decorators/CommitmentDecorator.js.map +1 -1
- package/dist/decorators/CommitmentDecorator.mjs +16 -2
- package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
- package/dist/decorators/QuestDecorator.d.mts +8 -10
- package/dist/decorators/QuestDecorator.d.ts +8 -10
- package/dist/decorators/QuestDecorator.js +667 -9
- package/dist/decorators/QuestDecorator.js.map +1 -1
- package/dist/decorators/QuestDecorator.mjs +667 -9
- package/dist/decorators/QuestDecorator.mjs.map +1 -1
- package/dist/decorators/RoomDecorator.d.mts +2 -2
- package/dist/decorators/RoomDecorator.d.ts +2 -2
- package/dist/decorators/index.d.mts +5 -5
- package/dist/decorators/index.d.ts +5 -5
- package/dist/decorators/index.js +679 -10
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +679 -11
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/ActivityFunctions.d.mts +2 -2
- package/dist/functions/ActivityFunctions.d.ts +2 -2
- package/dist/functions/ActivityFunctions.js.map +1 -1
- package/dist/functions/ActivityFunctions.mjs.map +1 -1
- package/dist/functions/NavigationFunctions.d.mts +2 -2
- package/dist/functions/NavigationFunctions.d.ts +2 -2
- package/dist/functions/NavigationFunctions.js.map +1 -1
- package/dist/functions/NavigationFunctions.mjs.map +1 -1
- package/dist/functions/RoutineFunctions.d.mts +2 -2
- package/dist/functions/RoutineFunctions.d.ts +2 -2
- package/dist/functions/RoutineFunctions.js.map +1 -1
- package/dist/functions/RoutineFunctions.mjs.map +1 -1
- package/dist/functions/index.d.mts +2 -2
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +505 -392
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +504 -391
- package/dist/index.mjs.map +1 -1
- package/dist/interface/ActivityProps.d.mts +1 -1
- package/dist/interface/ActivityProps.d.ts +1 -1
- package/dist/interface/CommitmentProps.d.mts +2 -2
- package/dist/interface/CommitmentProps.d.ts +2 -2
- package/dist/interface/RoomActivityMemory.d.mts +1 -1
- package/dist/interface/RoomActivityMemory.d.ts +1 -1
- 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 +2 -2
- package/dist/interface/navigation/LocationProps.d.ts +2 -2
- package/dist/interface/navigation/MapProps.d.mts +2 -2
- package/dist/interface/navigation/MapProps.d.ts +2 -2
- 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 +2 -2
package/dist/classes/index.mjs
CHANGED
|
@@ -359,7 +359,7 @@ var ActivityModel = class {
|
|
|
359
359
|
/**
|
|
360
360
|
* The function that is called when the activity is runned.
|
|
361
361
|
*/
|
|
362
|
-
get
|
|
362
|
+
get run() {
|
|
363
363
|
return (props) => this._onRun(this, props);
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
@@ -489,6 +489,7 @@ var CommitmentBaseModel = class extends StoredClassModel {
|
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
491
491
|
* Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
|
|
492
|
+
* If you set "automatic" remember to remove the commitment when it is no longer needed, because otherwise it repeats itself every time.
|
|
492
493
|
*/
|
|
493
494
|
get executionType() {
|
|
494
495
|
return this._executionType;
|
|
@@ -511,10 +512,9 @@ var CommitmentBaseModel = class extends StoredClassModel {
|
|
|
511
512
|
/**
|
|
512
513
|
* Is a function that is called when the player interacts with the character.
|
|
513
514
|
*/
|
|
514
|
-
get
|
|
515
|
+
get run() {
|
|
515
516
|
let onRun = this._onRun;
|
|
516
517
|
if (!onRun) {
|
|
517
|
-
console.warn("[NQTR] onRun() is not defined for commitmen, so it will not run.", this);
|
|
518
518
|
return;
|
|
519
519
|
}
|
|
520
520
|
return (props) => onRun(this, props);
|
|
@@ -689,7 +689,7 @@ var ActivityStoredAbstract = class {
|
|
|
689
689
|
/**
|
|
690
690
|
* The function that is called when the activity is runned.
|
|
691
691
|
*/
|
|
692
|
-
get
|
|
692
|
+
get run() {
|
|
693
693
|
return (props) => {
|
|
694
694
|
return this._onRun(this, props);
|
|
695
695
|
};
|
|
@@ -1021,6 +1021,135 @@ function getTemporaryCommitments() {
|
|
|
1021
1021
|
let commitments = commitmentsIds.map((id) => getCommitmentById(id)).filter((commitment) => commitment !== void 0);
|
|
1022
1022
|
return commitments;
|
|
1023
1023
|
}
|
|
1024
|
+
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
1025
|
+
var Goal = class extends StoredClassModel {
|
|
1026
|
+
constructor(id, props) {
|
|
1027
|
+
super(GOAL_CATEGORY, id);
|
|
1028
|
+
this._description = props.description;
|
|
1029
|
+
this._need = props.need || 1;
|
|
1030
|
+
this._defaultHave = props.have || 0;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* The description of the goal.
|
|
1034
|
+
*/
|
|
1035
|
+
get description() {
|
|
1036
|
+
return this._description;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* The number of times the goal must be completed.
|
|
1040
|
+
*/
|
|
1041
|
+
get need() {
|
|
1042
|
+
return this._need;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* The default number of times the goal has been completed.
|
|
1046
|
+
*/
|
|
1047
|
+
get defaultHave() {
|
|
1048
|
+
return this._defaultHave;
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// src/classes/quest/Stage.ts
|
|
1053
|
+
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
1054
|
+
var Stage = class extends StoredClassModel {
|
|
1055
|
+
constructor(id, props) {
|
|
1056
|
+
super(STAGE_CATEGORY, id);
|
|
1057
|
+
this._name = props.name || "";
|
|
1058
|
+
this._defaultGoals = props.goals || [];
|
|
1059
|
+
this._flags = props.flags || [];
|
|
1060
|
+
this._description = props.description || "";
|
|
1061
|
+
this._adviceDescription = props.adviceDescription || "";
|
|
1062
|
+
this._renderImage = props.renderImage;
|
|
1063
|
+
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1064
|
+
this._flagsRequiredToStart = props.flagsRequired || [];
|
|
1065
|
+
this._questsRequiredToStart = props.questsRequired || [];
|
|
1066
|
+
this._requestDescriptionToStart = props.requestDescription || "";
|
|
1067
|
+
this._onStart = props.onStart;
|
|
1068
|
+
this._onEnd = props.onEnd;
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* The name of the stage.
|
|
1072
|
+
*/
|
|
1073
|
+
get name() {
|
|
1074
|
+
return this._name;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* The description of the stage.
|
|
1078
|
+
*/
|
|
1079
|
+
get description() {
|
|
1080
|
+
return this._description;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* The advice description of the stage.
|
|
1084
|
+
*/
|
|
1085
|
+
get adviceDescription() {
|
|
1086
|
+
return this._adviceDescription;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* The function for rendering the image of the stage.
|
|
1090
|
+
*/
|
|
1091
|
+
get renderImage() {
|
|
1092
|
+
let render = this._renderImage;
|
|
1093
|
+
if (render === void 0) {
|
|
1094
|
+
return void 0;
|
|
1095
|
+
}
|
|
1096
|
+
if (typeof render === "function") {
|
|
1097
|
+
return (props) => {
|
|
1098
|
+
return render(this, props);
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
return (props) => render;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
1105
|
+
* This is the list set by the developer. if you want to get the current goals, use the goals property.
|
|
1106
|
+
*/
|
|
1107
|
+
get defaultGoals() {
|
|
1108
|
+
return this._defaultGoals;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* The list of flags that the player must complete to finish the stage.
|
|
1112
|
+
*/
|
|
1113
|
+
get flags() {
|
|
1114
|
+
return this._flags;
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* The number of days required to start the stage.
|
|
1118
|
+
*/
|
|
1119
|
+
get daysRequiredToStart() {
|
|
1120
|
+
return this._daysRequiredToStart || 0;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* The list of flags required to start the stage.
|
|
1124
|
+
*/
|
|
1125
|
+
get flagsRequiredToStart() {
|
|
1126
|
+
return this._flagsRequiredToStart;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* The list of quests required to start the stage.
|
|
1130
|
+
*/
|
|
1131
|
+
get questsRequiredToStart() {
|
|
1132
|
+
return this._questsRequiredToStart || [];
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* The description of the request to start the stage.
|
|
1136
|
+
*/
|
|
1137
|
+
get requestDescriptionToStart() {
|
|
1138
|
+
return this._requestDescriptionToStart;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The function that will be called when the stage starts.
|
|
1142
|
+
*/
|
|
1143
|
+
get onStart() {
|
|
1144
|
+
return this._onStart;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* The function that will be called when the stage ends.
|
|
1148
|
+
*/
|
|
1149
|
+
get onEnd() {
|
|
1150
|
+
return this._onEnd;
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1024
1153
|
|
|
1025
1154
|
// src/functions/RoutineFunctions.ts
|
|
1026
1155
|
function getCurrentRoutine() {
|
|
@@ -1292,320 +1421,7 @@ var RoomBaseModel = class extends StoredClassModel {
|
|
|
1292
1421
|
return commitments.filter((c) => c.room.id === this.id);
|
|
1293
1422
|
}
|
|
1294
1423
|
};
|
|
1295
|
-
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
1296
|
-
var Goal = class extends StoredClassModel {
|
|
1297
|
-
constructor(id, props) {
|
|
1298
|
-
super(GOAL_CATEGORY, id);
|
|
1299
|
-
this._description = props.description;
|
|
1300
|
-
this._need = props.need || 1;
|
|
1301
|
-
this._defaultHave = props.have || 0;
|
|
1302
|
-
}
|
|
1303
|
-
/**
|
|
1304
|
-
* The description of the goal.
|
|
1305
|
-
*/
|
|
1306
|
-
get description() {
|
|
1307
|
-
return this._description;
|
|
1308
|
-
}
|
|
1309
|
-
get need() {
|
|
1310
|
-
return this._need;
|
|
1311
|
-
}
|
|
1312
|
-
get defaultHave() {
|
|
1313
|
-
return this._defaultHave;
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
var GoalStage = class extends Goal {
|
|
1317
|
-
constructor(id, stageId, props) {
|
|
1318
|
-
super(id, props);
|
|
1319
|
-
this._stageId = stageId;
|
|
1320
|
-
}
|
|
1321
|
-
get stageId() {
|
|
1322
|
-
return this._stageId;
|
|
1323
|
-
}
|
|
1324
|
-
set stageId(value) {
|
|
1325
|
-
this._stageId = value;
|
|
1326
|
-
}
|
|
1327
|
-
get have() {
|
|
1328
|
-
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
1329
|
-
}
|
|
1330
|
-
set have(value) {
|
|
1331
|
-
if (!this._stageId) {
|
|
1332
|
-
console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
|
|
1333
|
-
return;
|
|
1334
|
-
}
|
|
1335
|
-
this.setStorageProperty("have-" + this._stageId, value);
|
|
1336
|
-
}
|
|
1337
|
-
get completed() {
|
|
1338
|
-
return this.have >= this.need;
|
|
1339
|
-
}
|
|
1340
|
-
set completed(value) {
|
|
1341
|
-
if (value) {
|
|
1342
|
-
this.have = this.need;
|
|
1343
|
-
} else {
|
|
1344
|
-
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
find() {
|
|
1348
|
-
this.have++;
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
1352
|
-
var Stage = class extends StoredClassModel {
|
|
1353
|
-
constructor(id, props) {
|
|
1354
|
-
super(STAGE_CATEGORY, id);
|
|
1355
|
-
this._name = props.name || "";
|
|
1356
|
-
this._defaultGoals = props.goals || [];
|
|
1357
|
-
this._flags = props.flags || [];
|
|
1358
|
-
this._description = props.description || "";
|
|
1359
|
-
this._adviceDescription = props.adviceDescription || "";
|
|
1360
|
-
this._renderImage = props.renderImage;
|
|
1361
|
-
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1362
|
-
this._flagsRequiredToStart = props.flagsRequired || [];
|
|
1363
|
-
this._questsRequiredToStart = props.questsRequired || [];
|
|
1364
|
-
this._requestDescriptionToStart = props.requestDescription || "";
|
|
1365
|
-
this._onStart = props.onStart;
|
|
1366
|
-
this._onEnd = props.onEnd;
|
|
1367
|
-
}
|
|
1368
|
-
get name() {
|
|
1369
|
-
return this._name;
|
|
1370
|
-
}
|
|
1371
|
-
get description() {
|
|
1372
|
-
return this._description;
|
|
1373
|
-
}
|
|
1374
|
-
get adviceDescription() {
|
|
1375
|
-
return this._adviceDescription;
|
|
1376
|
-
}
|
|
1377
|
-
/**
|
|
1378
|
-
* The function for rendering the image of the stage.
|
|
1379
|
-
*/
|
|
1380
|
-
get renderImage() {
|
|
1381
|
-
let render = this._renderImage;
|
|
1382
|
-
if (render === void 0) {
|
|
1383
|
-
return void 0;
|
|
1384
|
-
}
|
|
1385
|
-
if (typeof render === "function") {
|
|
1386
|
-
return (props) => {
|
|
1387
|
-
return render(this, props);
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
return (props) => render;
|
|
1391
|
-
}
|
|
1392
|
-
get defaultGoals() {
|
|
1393
|
-
return this._defaultGoals;
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* The list of flags that the player must complete to finish the stage.
|
|
1397
|
-
*/
|
|
1398
|
-
get flags() {
|
|
1399
|
-
return this._flags;
|
|
1400
|
-
}
|
|
1401
|
-
get daysRequiredToStart() {
|
|
1402
|
-
return this._daysRequiredToStart || 0;
|
|
1403
|
-
}
|
|
1404
|
-
get flagsRequiredToStart() {
|
|
1405
|
-
return this._flagsRequiredToStart;
|
|
1406
|
-
}
|
|
1407
|
-
get questsRequiredToStart() {
|
|
1408
|
-
return this._questsRequiredToStart || [];
|
|
1409
|
-
}
|
|
1410
|
-
get requestDescriptionToStart() {
|
|
1411
|
-
return this._requestDescriptionToStart;
|
|
1412
|
-
}
|
|
1413
|
-
get onStart() {
|
|
1414
|
-
return this._onStart;
|
|
1415
|
-
}
|
|
1416
|
-
get onEnd() {
|
|
1417
|
-
return this._onEnd;
|
|
1418
|
-
}
|
|
1419
|
-
};
|
|
1420
|
-
var StageQuest = class extends Stage {
|
|
1421
|
-
constructor(id, props) {
|
|
1422
|
-
super(id, props);
|
|
1423
|
-
}
|
|
1424
|
-
get completed() {
|
|
1425
|
-
let storedCompleted = this.getStorageProperty("completed");
|
|
1426
|
-
if (storedCompleted) {
|
|
1427
|
-
return storedCompleted;
|
|
1428
|
-
}
|
|
1429
|
-
if (!this.flags.every((flag) => getFlag(flag.flag))) {
|
|
1430
|
-
return false;
|
|
1431
|
-
}
|
|
1432
|
-
if (!this.goals.every((goal) => goal.completed)) {
|
|
1433
|
-
return false;
|
|
1434
|
-
}
|
|
1435
|
-
return true;
|
|
1436
|
-
}
|
|
1437
|
-
set completed(value) {
|
|
1438
|
-
this.setStorageProperty("completed", value);
|
|
1439
|
-
}
|
|
1440
|
-
/**
|
|
1441
|
-
* The list of goals that the player needs to complete to finish the stage.
|
|
1442
|
-
*/
|
|
1443
|
-
get goals() {
|
|
1444
|
-
return this.defaultGoals.map((goal) => {
|
|
1445
|
-
return new GoalStage(goal.id, this.id, goal);
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
get prevStageEndDay() {
|
|
1449
|
-
return this.getStorageProperty("prevStageEndDay");
|
|
1450
|
-
}
|
|
1451
|
-
set prevStageEndDay(value) {
|
|
1452
|
-
this.setStorageProperty("prevStageEndDay", value);
|
|
1453
|
-
}
|
|
1454
|
-
get startDay() {
|
|
1455
|
-
let prevStageEndDay = this.prevStageEndDay;
|
|
1456
|
-
if (prevStageEndDay === void 0) {
|
|
1457
|
-
return void 0;
|
|
1458
|
-
}
|
|
1459
|
-
return prevStageEndDay + this.daysRequiredToStart;
|
|
1460
|
-
}
|
|
1461
|
-
get canStart() {
|
|
1462
|
-
let daysRequired = this.daysRequiredToStart;
|
|
1463
|
-
if (daysRequired > 0) {
|
|
1464
|
-
let prevStageEndDay = this.prevStageEndDay;
|
|
1465
|
-
if (prevStageEndDay === void 0) {
|
|
1466
|
-
return false;
|
|
1467
|
-
}
|
|
1468
|
-
if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
|
|
1469
|
-
return false;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {
|
|
1473
|
-
return false;
|
|
1474
|
-
}
|
|
1475
|
-
if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
|
|
1476
|
-
(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
|
|
1477
|
-
)) {
|
|
1478
|
-
return false;
|
|
1479
|
-
}
|
|
1480
|
-
return true;
|
|
1481
|
-
}
|
|
1482
|
-
get onStart() {
|
|
1483
|
-
if (this.daysRequiredToStart > 0) {
|
|
1484
|
-
this.prevStageEndDay = TimeManager.currentDay;
|
|
1485
|
-
}
|
|
1486
|
-
return super.onStart;
|
|
1487
|
-
}
|
|
1488
|
-
};
|
|
1489
|
-
|
|
1490
|
-
// src/classes/quest/Quest.ts
|
|
1491
|
-
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
1492
|
-
var Quest = class extends StoredClassModel {
|
|
1493
|
-
constructor(id, stages, props) {
|
|
1494
|
-
super(QUEST_CATEGORY, id);
|
|
1495
|
-
this._stages = stages;
|
|
1496
|
-
this._name = props.name || "";
|
|
1497
|
-
this._description = props.description || "";
|
|
1498
|
-
this._renderIcon = props.renderIcon;
|
|
1499
|
-
this._renderImage = props.renderImage;
|
|
1500
|
-
this._isInDevelopment = props.isInDevelopment || false;
|
|
1501
|
-
}
|
|
1502
|
-
get stages() {
|
|
1503
|
-
return this._stages.map((stage, index) => {
|
|
1504
|
-
return new StageQuest(stage.id, stage);
|
|
1505
|
-
});
|
|
1506
|
-
}
|
|
1507
|
-
get name() {
|
|
1508
|
-
return this._name;
|
|
1509
|
-
}
|
|
1510
|
-
get description() {
|
|
1511
|
-
return this._description;
|
|
1512
|
-
}
|
|
1513
|
-
/**
|
|
1514
|
-
* The function for rendering the icon of the quest.
|
|
1515
|
-
*/
|
|
1516
|
-
get renderIcon() {
|
|
1517
|
-
let render = this._renderIcon;
|
|
1518
|
-
if (render === void 0) {
|
|
1519
|
-
return void 0;
|
|
1520
|
-
}
|
|
1521
|
-
if (typeof render === "function") {
|
|
1522
|
-
return (props) => {
|
|
1523
|
-
return render(this, props);
|
|
1524
|
-
};
|
|
1525
|
-
}
|
|
1526
|
-
return (props) => render;
|
|
1527
|
-
}
|
|
1528
|
-
/**
|
|
1529
|
-
* The function for rendering the image of the quest.
|
|
1530
|
-
*/
|
|
1531
|
-
get renderImage() {
|
|
1532
|
-
let render = this._renderImage;
|
|
1533
|
-
if (render === void 0) {
|
|
1534
|
-
return void 0;
|
|
1535
|
-
}
|
|
1536
|
-
if (typeof render === "function") {
|
|
1537
|
-
return (props) => {
|
|
1538
|
-
return render(this, props);
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
return (props) => render;
|
|
1542
|
-
}
|
|
1543
|
-
get isInDevelopment() {
|
|
1544
|
-
return this._isInDevelopment;
|
|
1545
|
-
}
|
|
1546
|
-
get currentStageIndex() {
|
|
1547
|
-
return this.getStorageProperty("currentStageIndex");
|
|
1548
|
-
}
|
|
1549
|
-
set currentStageIndex(value) {
|
|
1550
|
-
this.setStorageProperty("currentStageIndex", value);
|
|
1551
|
-
}
|
|
1552
|
-
get currentStage() {
|
|
1553
|
-
let index = this.currentStageIndex;
|
|
1554
|
-
if (index === void 0 || index >= this.stages.length) {
|
|
1555
|
-
return void 0;
|
|
1556
|
-
}
|
|
1557
|
-
return this.stages[index];
|
|
1558
|
-
}
|
|
1559
|
-
get started() {
|
|
1560
|
-
return this.currentStageIndex !== void 0;
|
|
1561
|
-
}
|
|
1562
|
-
get completed() {
|
|
1563
|
-
return this.currentStageIndex === this.stages.length;
|
|
1564
|
-
}
|
|
1565
|
-
start() {
|
|
1566
|
-
if (this.started) {
|
|
1567
|
-
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1570
|
-
if (this.stages.length === 0) {
|
|
1571
|
-
console.error(`[NQTR] Quest ${this.id} has no stages`);
|
|
1572
|
-
return;
|
|
1573
|
-
}
|
|
1574
|
-
this.currentStageIndex = 0;
|
|
1575
|
-
let currentStage = this.currentStage;
|
|
1576
|
-
if (currentStage && currentStage.onStart) {
|
|
1577
|
-
return currentStage.onStart();
|
|
1578
|
-
} else {
|
|
1579
|
-
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
tryToGoNextStage() {
|
|
1583
|
-
if (!this.started) {
|
|
1584
|
-
return;
|
|
1585
|
-
}
|
|
1586
|
-
if (this.completed) {
|
|
1587
|
-
return;
|
|
1588
|
-
}
|
|
1589
|
-
let currentStage = this.currentStage;
|
|
1590
|
-
let currentStageIndex = this.currentStageIndex;
|
|
1591
|
-
if (!currentStage || currentStageIndex === void 0) {
|
|
1592
|
-
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1593
|
-
return;
|
|
1594
|
-
}
|
|
1595
|
-
if (currentStage.completed) {
|
|
1596
|
-
let nextStageIndex = currentStageIndex + 1;
|
|
1597
|
-
currentStageIndex = nextStageIndex;
|
|
1598
|
-
let nextStage = this.currentStage;
|
|
1599
|
-
if (currentStage && currentStage.onEnd) {
|
|
1600
|
-
currentStage.onEnd();
|
|
1601
|
-
}
|
|
1602
|
-
if (nextStage && nextStage.onStart) {
|
|
1603
|
-
return nextStage.onStart();
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
1424
|
|
|
1609
|
-
export { ActivityModel, ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel,
|
|
1425
|
+
export { ActivityModel, ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, RoomBaseModel, Stage };
|
|
1610
1426
|
//# sourceMappingURL=out.js.map
|
|
1611
1427
|
//# sourceMappingURL=index.mjs.map
|