@drincs/nqtr 0.2.2 → 0.2.4
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/{Commitment-Eox2652k.d.mts → Commitment-BHB-jYOi.d.mts} +2 -2
- package/dist/{Commitment-D3LPSbFX.d.ts → Commitment-D-1lsnnU.d.ts} +2 -2
- package/dist/{StageProps-D002cyay.d.mts → StageProps-W85kcacG.d.mts} +11 -4
- package/dist/{StageProps-DleWO-vf.d.ts → StageProps-vR-NLl0n.d.ts} +11 -4
- package/dist/classes/Commitment.d.mts +1 -1
- package/dist/classes/Commitment.d.ts +1 -1
- package/dist/classes/index.d.mts +2 -2
- package/dist/classes/index.d.ts +2 -2
- package/dist/classes/index.js +386 -5
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +385 -5
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/navigation/ActivityRoom.d.mts +1 -1
- package/dist/classes/navigation/ActivityRoom.d.ts +1 -1
- package/dist/classes/navigation/ActivityRoom.js +3 -0
- package/dist/classes/navigation/ActivityRoom.js.map +1 -1
- package/dist/classes/navigation/ActivityRoom.mjs +3 -0
- package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
- package/dist/classes/navigation/Location.d.mts +1 -1
- package/dist/classes/navigation/Location.d.ts +1 -1
- package/dist/classes/navigation/Map.d.mts +1 -1
- package/dist/classes/navigation/Map.d.ts +1 -1
- package/dist/classes/navigation/Room.d.mts +1 -1
- package/dist/classes/navigation/Room.d.ts +1 -1
- package/dist/classes/navigation/Room.js +37 -34
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +37 -34
- package/dist/classes/navigation/Room.mjs.map +1 -1
- package/dist/classes/quest/Quest.d.mts +1 -1
- package/dist/classes/quest/Quest.d.ts +1 -1
- package/dist/classes/quest/Quest.js +13 -3
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +13 -3
- 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 +3 -3
- package/dist/classes/quest/Stage.js.map +1 -1
- package/dist/classes/quest/Stage.mjs +3 -3
- package/dist/classes/quest/Stage.mjs.map +1 -1
- package/dist/decorators/CommitmentDecorator.d.mts +1 -1
- package/dist/decorators/CommitmentDecorator.d.ts +1 -1
- package/dist/decorators/QuestDecorator.d.mts +7 -2
- package/dist/decorators/QuestDecorator.d.ts +7 -2
- package/dist/decorators/QuestDecorator.js +17 -3
- package/dist/decorators/QuestDecorator.js.map +1 -1
- package/dist/decorators/QuestDecorator.mjs +17 -4
- package/dist/decorators/QuestDecorator.mjs.map +1 -1
- package/dist/decorators/RoomDecorator.d.mts +1 -1
- package/dist/decorators/RoomDecorator.d.ts +1 -1
- package/dist/decorators/index.d.mts +3 -3
- package/dist/decorators/index.d.ts +3 -3
- package/dist/decorators/index.js +17 -3
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +17 -4
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/ActivityFunctions.d.mts +8 -1
- package/dist/functions/ActivityFunctions.d.ts +8 -1
- package/dist/functions/ActivityFunctions.js.map +1 -1
- package/dist/functions/ActivityFunctions.mjs.map +1 -1
- package/dist/functions/NavigationFunctions.d.mts +20 -3
- package/dist/functions/NavigationFunctions.d.ts +20 -3
- package/dist/functions/NavigationFunctions.js +2 -2
- package/dist/functions/NavigationFunctions.js.map +1 -1
- package/dist/functions/NavigationFunctions.mjs +2 -2
- package/dist/functions/NavigationFunctions.mjs.map +1 -1
- package/dist/functions/QuestFunctions.js.map +1 -1
- package/dist/functions/QuestFunctions.mjs.map +1 -1
- package/dist/functions/RoutineFunctions.d.mts +7 -2
- package/dist/functions/RoutineFunctions.d.ts +7 -2
- package/dist/functions/RoutineFunctions.js +40 -0
- package/dist/functions/RoutineFunctions.js.map +1 -1
- package/dist/functions/RoutineFunctions.mjs +40 -1
- package/dist/functions/RoutineFunctions.mjs.map +1 -1
- package/dist/functions/index.d.mts +3 -3
- package/dist/functions/index.d.ts +3 -3
- package/dist/functions/index.js +10 -2
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +9 -2
- 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 +77 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -50
- package/dist/index.mjs.map +1 -1
- package/dist/interface/CommitmentProps.d.mts +1 -1
- package/dist/interface/CommitmentProps.d.ts +1 -1
- package/dist/interface/RoomProps.d.mts +1 -1
- package/dist/interface/RoomProps.d.ts +1 -1
- package/dist/interface/index.d.mts +2 -2
- package/dist/interface/index.d.ts +2 -2
- package/dist/interface/navigation/LocationProps.d.mts +1 -1
- package/dist/interface/navigation/LocationProps.d.ts +1 -1
- package/dist/interface/navigation/MapProps.d.mts +1 -1
- package/dist/interface/navigation/MapProps.d.ts +1 -1
- 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 +5 -5
package/dist/classes/index.mjs
CHANGED
|
@@ -613,6 +613,9 @@ var ActivityRoom = class extends ActivityStoredAbstract {
|
|
|
613
613
|
get id() {
|
|
614
614
|
return this._id;
|
|
615
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* The room where the activity is.
|
|
618
|
+
*/
|
|
616
619
|
get room() {
|
|
617
620
|
return this._room;
|
|
618
621
|
}
|
|
@@ -919,6 +922,53 @@ var Goal = class extends StoredClassModel {
|
|
|
919
922
|
return this._defaultHave;
|
|
920
923
|
}
|
|
921
924
|
};
|
|
925
|
+
var GoalStage = class extends Goal {
|
|
926
|
+
constructor(id, stageId, props) {
|
|
927
|
+
super(id, props);
|
|
928
|
+
this._stageId = stageId;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* The id of the stage that the goal belongs to.
|
|
932
|
+
*/
|
|
933
|
+
get stageId() {
|
|
934
|
+
return this._stageId;
|
|
935
|
+
}
|
|
936
|
+
set stageId(value) {
|
|
937
|
+
this._stageId = value;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* The number of times the goal has been completed.
|
|
941
|
+
*/
|
|
942
|
+
get have() {
|
|
943
|
+
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
944
|
+
}
|
|
945
|
+
set have(value) {
|
|
946
|
+
if (!this._stageId) {
|
|
947
|
+
console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
this.setStorageProperty("have-" + this._stageId, value);
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* If the goal is completed.
|
|
954
|
+
*/
|
|
955
|
+
get completed() {
|
|
956
|
+
return this.have >= this.need;
|
|
957
|
+
}
|
|
958
|
+
set completed(value) {
|
|
959
|
+
if (value) {
|
|
960
|
+
this.have = this.need;
|
|
961
|
+
} else {
|
|
962
|
+
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Find the goal. It will increment the have value.
|
|
967
|
+
*/
|
|
968
|
+
find() {
|
|
969
|
+
this.have++;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
922
972
|
|
|
923
973
|
// src/classes/quest/Stage.ts
|
|
924
974
|
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
@@ -932,9 +982,9 @@ var Stage = class extends StoredClassModel {
|
|
|
932
982
|
this._adviceDescription = props.adviceDescription || "";
|
|
933
983
|
this._renderImage = props.renderImage;
|
|
934
984
|
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
935
|
-
this._flagsRequiredToStart = props.
|
|
936
|
-
this._questsRequiredToStart = props.
|
|
937
|
-
this._requestDescriptionToStart = props.
|
|
985
|
+
this._flagsRequiredToStart = props.flagsRequiredToStart || [];
|
|
986
|
+
this._questsRequiredToStart = props.questsRequiredToStart || [];
|
|
987
|
+
this._requestDescriptionToStart = props.requestDescriptionToStart || "";
|
|
938
988
|
this._onStart = props.onStart;
|
|
939
989
|
this._onEnd = props.onEnd;
|
|
940
990
|
}
|
|
@@ -1021,6 +1071,336 @@ var Stage = class extends StoredClassModel {
|
|
|
1021
1071
|
return this._onEnd;
|
|
1022
1072
|
}
|
|
1023
1073
|
};
|
|
1074
|
+
var StageQuest = class extends Stage {
|
|
1075
|
+
constructor(id, props) {
|
|
1076
|
+
super(id, props);
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Check if the flag and goals are completed.
|
|
1080
|
+
* You can force the completion of the stage by setting the completed property to true.
|
|
1081
|
+
*/
|
|
1082
|
+
get completed() {
|
|
1083
|
+
let storedCompleted = this.getStorageProperty("completed");
|
|
1084
|
+
if (storedCompleted) {
|
|
1085
|
+
return storedCompleted;
|
|
1086
|
+
}
|
|
1087
|
+
if (this.flags.length > 0 && this.goals.length > 0) {
|
|
1088
|
+
if (!this.flags.every((flag) => getFlag(flag.flag))) {
|
|
1089
|
+
return false;
|
|
1090
|
+
}
|
|
1091
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
1092
|
+
return false;
|
|
1093
|
+
}
|
|
1094
|
+
return true;
|
|
1095
|
+
}
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
set completed(value) {
|
|
1099
|
+
this.setStorageProperty("completed", value);
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* If the stage is started.
|
|
1103
|
+
*/
|
|
1104
|
+
get started() {
|
|
1105
|
+
return this.getStorageProperty("started") || false;
|
|
1106
|
+
}
|
|
1107
|
+
set started(value) {
|
|
1108
|
+
this.setStorageProperty("started", value);
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
1112
|
+
*/
|
|
1113
|
+
get goals() {
|
|
1114
|
+
return this.defaultGoals.map((goal) => {
|
|
1115
|
+
return new GoalStage(goal.id, this.id, goal);
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
get prevStageEndDay() {
|
|
1119
|
+
return this.getStorageProperty("prevStageEndDay");
|
|
1120
|
+
}
|
|
1121
|
+
set prevStageEndDay(value) {
|
|
1122
|
+
this.setStorageProperty("prevStageEndDay", value);
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* The day when the stage starts.
|
|
1126
|
+
*/
|
|
1127
|
+
get startDay() {
|
|
1128
|
+
let prevStageEndDay = this.prevStageEndDay;
|
|
1129
|
+
if (prevStageEndDay === void 0) {
|
|
1130
|
+
return void 0;
|
|
1131
|
+
}
|
|
1132
|
+
return prevStageEndDay + this.daysRequiredToStart;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Check if the stage can start.
|
|
1136
|
+
*/
|
|
1137
|
+
get canStart() {
|
|
1138
|
+
let daysRequired = this.daysRequiredToStart;
|
|
1139
|
+
if (daysRequired > 0) {
|
|
1140
|
+
let prevStageEndDay = this.prevStageEndDay;
|
|
1141
|
+
if (prevStageEndDay === void 0) {
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1144
|
+
if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
|
|
1152
|
+
(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
|
|
1153
|
+
)) {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Inizialize the stage. **This function should be called only by the Quest class.**
|
|
1160
|
+
*/
|
|
1161
|
+
inizialize() {
|
|
1162
|
+
if (this.daysRequiredToStart > 0) {
|
|
1163
|
+
this.prevStageEndDay = TimeManager.currentDay;
|
|
1164
|
+
console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* The function that will be called when the stage starts.
|
|
1169
|
+
*/
|
|
1170
|
+
start(props) {
|
|
1171
|
+
if (this.canStart) {
|
|
1172
|
+
this.started = true;
|
|
1173
|
+
if (this.onStart) {
|
|
1174
|
+
this.onStart(props);
|
|
1175
|
+
}
|
|
1176
|
+
} else {
|
|
1177
|
+
console.warn(`[NQTR] Stage ${this.id} can't start`);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
// src/classes/quest/Quest.ts
|
|
1183
|
+
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
1184
|
+
var Quest = class extends StoredClassModel {
|
|
1185
|
+
constructor(id, stages, props) {
|
|
1186
|
+
super(QUEST_CATEGORY, id);
|
|
1187
|
+
this._stages = stages;
|
|
1188
|
+
this._name = props.name || "";
|
|
1189
|
+
this._description = props.description || "";
|
|
1190
|
+
this._renderIcon = props.renderIcon;
|
|
1191
|
+
this._renderImage = props.renderImage;
|
|
1192
|
+
this._isInDevelopment = props.isInDevelopment || false;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* The stages of the quest.
|
|
1196
|
+
*/
|
|
1197
|
+
get stages() {
|
|
1198
|
+
return this._stages.map((stage, index) => {
|
|
1199
|
+
return new StageQuest(stage.id, stage);
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* The name of the quest.
|
|
1204
|
+
*/
|
|
1205
|
+
get name() {
|
|
1206
|
+
return this._name;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* The description of the quest.
|
|
1210
|
+
*/
|
|
1211
|
+
get description() {
|
|
1212
|
+
return this._description;
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* The function for rendering the icon of the quest.
|
|
1216
|
+
*/
|
|
1217
|
+
get renderIcon() {
|
|
1218
|
+
let render = this._renderIcon;
|
|
1219
|
+
if (render === void 0) {
|
|
1220
|
+
return void 0;
|
|
1221
|
+
}
|
|
1222
|
+
if (typeof render === "function") {
|
|
1223
|
+
return (props) => {
|
|
1224
|
+
return render(this, props);
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
return (props) => render;
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* The function for rendering the image of the quest.
|
|
1231
|
+
*/
|
|
1232
|
+
get renderImage() {
|
|
1233
|
+
let render = this._renderImage;
|
|
1234
|
+
if (render === void 0) {
|
|
1235
|
+
return void 0;
|
|
1236
|
+
}
|
|
1237
|
+
if (typeof render === "function") {
|
|
1238
|
+
return (props) => {
|
|
1239
|
+
return render(this, props);
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
return (props) => render;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* If the quest is in development.
|
|
1246
|
+
*/
|
|
1247
|
+
get isInDevelopment() {
|
|
1248
|
+
return this._isInDevelopment;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* The index of the current stage.
|
|
1252
|
+
*/
|
|
1253
|
+
get currentStageIndex() {
|
|
1254
|
+
return this.getStorageProperty("currentStageIndex");
|
|
1255
|
+
}
|
|
1256
|
+
set currentStageIndex(value) {
|
|
1257
|
+
this.setStorageProperty("currentStageIndex", value);
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* The current stage.
|
|
1261
|
+
*/
|
|
1262
|
+
get currentStage() {
|
|
1263
|
+
let index = this.currentStageIndex;
|
|
1264
|
+
if (index === void 0 || index >= this.stages.length) {
|
|
1265
|
+
return void 0;
|
|
1266
|
+
}
|
|
1267
|
+
return this.stages[index];
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* If the quest is started.
|
|
1271
|
+
*/
|
|
1272
|
+
get started() {
|
|
1273
|
+
return this.currentStageIndex !== void 0;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* If the quest is completed.
|
|
1277
|
+
*/
|
|
1278
|
+
get completed() {
|
|
1279
|
+
if (this.currentStageIndex === void 0) {
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
return this.currentStageIndex > this.stages.length - 1;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Start the quest.
|
|
1286
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1287
|
+
* @returns
|
|
1288
|
+
*/
|
|
1289
|
+
start(props) {
|
|
1290
|
+
if (this.started) {
|
|
1291
|
+
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
if (this.stages.length === 0) {
|
|
1295
|
+
console.error(`[NQTR] Quest ${this.id} has no stages`);
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
this.currentStageIndex = 0;
|
|
1299
|
+
let currentStage = this.currentStage;
|
|
1300
|
+
if (currentStage && currentStage.start) {
|
|
1301
|
+
return currentStage.start(props);
|
|
1302
|
+
} else {
|
|
1303
|
+
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Go to the next stage if the current stage is completed.
|
|
1308
|
+
* If you want to force the change of stage, use goNextStage.
|
|
1309
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1310
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1311
|
+
* @returns true if the stage was changed, false otherwise.
|
|
1312
|
+
*/
|
|
1313
|
+
tryToGoNextStage(startProps, endProps) {
|
|
1314
|
+
if (!this.started) {
|
|
1315
|
+
return false;
|
|
1316
|
+
}
|
|
1317
|
+
if (this.completed) {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
let currentStage = this.currentStage;
|
|
1321
|
+
if (!currentStage) {
|
|
1322
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1325
|
+
if (currentStage.completed) {
|
|
1326
|
+
return this.goNextStage(startProps, endProps);
|
|
1327
|
+
}
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Complete the current stage and go to the next stage.
|
|
1332
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1333
|
+
* @param startProps The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1334
|
+
* @param endProps The properties for the end stage. If you not want to pass any property, you can pass an {}.
|
|
1335
|
+
* @returns true if the stage was changed, false otherwise.
|
|
1336
|
+
*/
|
|
1337
|
+
completeCurrentStageAndGoNext(startProps, endProps) {
|
|
1338
|
+
let currentStage = this.currentStage;
|
|
1339
|
+
if (!currentStage) {
|
|
1340
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1341
|
+
return false;
|
|
1342
|
+
}
|
|
1343
|
+
currentStage.completed = true;
|
|
1344
|
+
return this.goNextStage(startProps, endProps);
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Go to the next stage without checking if the current stage is completed.
|
|
1348
|
+
* If you want to go to the next stage only if the current stage is completed, use tryToGoNextStage.
|
|
1349
|
+
* @param startProps
|
|
1350
|
+
* @param endProps
|
|
1351
|
+
* @returns returns true if the stage was changed, false otherwise.
|
|
1352
|
+
*/
|
|
1353
|
+
goNextStage(startProps, endProps) {
|
|
1354
|
+
if (!this.started) {
|
|
1355
|
+
console.warn(`[NQTR] Quest ${this.id} is not started`);
|
|
1356
|
+
return false;
|
|
1357
|
+
}
|
|
1358
|
+
if (this.completed) {
|
|
1359
|
+
console.warn(`[NQTR] Quest ${this.id} is already completed`);
|
|
1360
|
+
return false;
|
|
1361
|
+
}
|
|
1362
|
+
let prevStage = this.currentStage;
|
|
1363
|
+
let currentStageIndex = this.currentStageIndex;
|
|
1364
|
+
if (!prevStage || currentStageIndex === void 0) {
|
|
1365
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1366
|
+
return false;
|
|
1367
|
+
}
|
|
1368
|
+
this.currentStageIndex = currentStageIndex + 1;
|
|
1369
|
+
if (prevStage && prevStage.onEnd) {
|
|
1370
|
+
prevStage.onEnd(endProps);
|
|
1371
|
+
}
|
|
1372
|
+
let nextCurrentStage = this.currentStage;
|
|
1373
|
+
if (nextCurrentStage) {
|
|
1374
|
+
nextCurrentStage.inizialize();
|
|
1375
|
+
if (this.currentStageMustStart) {
|
|
1376
|
+
this.startCurrentStage(startProps);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
return true;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* If the current stage must start. It is true if the current stage is not started, can start and not completed.
|
|
1383
|
+
*/
|
|
1384
|
+
get currentStageMustStart() {
|
|
1385
|
+
let currentStage = this.currentStage;
|
|
1386
|
+
if (!currentStage) {
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
return !currentStage.started && currentStage.canStart && !currentStage.completed;
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Start the current stage.
|
|
1393
|
+
* @param props The properties for the start stage. If you not want to pass any property, you can pass an {}.
|
|
1394
|
+
*/
|
|
1395
|
+
startCurrentStage(props) {
|
|
1396
|
+
let newCurrentStage = this.currentStage;
|
|
1397
|
+
if (newCurrentStage && this.currentStageMustStart) {
|
|
1398
|
+
newCurrentStage.start(props);
|
|
1399
|
+
} else {
|
|
1400
|
+
console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1024
1404
|
|
|
1025
1405
|
// src/functions/RoutineFunctions.ts
|
|
1026
1406
|
function getCurrentRoutine() {
|
|
@@ -1058,7 +1438,7 @@ function getCurrentRoutine() {
|
|
|
1058
1438
|
|
|
1059
1439
|
// src/classes/navigation/Room.ts
|
|
1060
1440
|
var ROOM_CATEGORY = "__nqtr-room__";
|
|
1061
|
-
var
|
|
1441
|
+
var RoomBaseModel2 = class extends StoredClassModel {
|
|
1062
1442
|
/**
|
|
1063
1443
|
* @param id The id of the room, it must be unique.
|
|
1064
1444
|
* @param location The location where the room is.
|
|
@@ -1293,6 +1673,6 @@ var RoomBaseModel = class extends StoredClassModel {
|
|
|
1293
1673
|
}
|
|
1294
1674
|
};
|
|
1295
1675
|
|
|
1296
|
-
export { ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, RoomBaseModel, Stage };
|
|
1676
|
+
export { ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, Quest, RoomBaseModel2 as RoomBaseModel, Stage };
|
|
1297
1677
|
//# sourceMappingURL=out.js.map
|
|
1298
1678
|
//# sourceMappingURL=index.mjs.map
|