@drincs/nqtr 0.1.18 → 0.1.20
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-DNn_TEgV.d.mts → Commitment-C3Nc2RJH.d.mts} +17 -4
- package/dist/{Commitment-GIA4EK_q.d.ts → Commitment-Cc2kZEy0.d.ts} +17 -4
- package/dist/Quest-BQ1pwvQ_.d.ts +197 -0
- package/dist/Quest-DaNlPBHb.d.mts +197 -0
- package/dist/classes/Commitment.d.mts +2 -2
- package/dist/classes/Commitment.d.ts +2 -2
- package/dist/classes/Commitment.js +12 -1
- package/dist/classes/Commitment.js.map +1 -1
- package/dist/classes/Commitment.mjs +12 -1
- package/dist/classes/Commitment.mjs.map +1 -1
- package/dist/classes/index.d.mts +4 -4
- package/dist/classes/index.d.ts +4 -4
- package/dist/classes/index.js +514 -313
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +512 -312
- 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/Location.js.map +1 -1
- package/dist/classes/navigation/Location.mjs.map +1 -1
- package/dist/classes/navigation/Map.d.mts +2 -2
- package/dist/classes/navigation/Map.d.ts +2 -2
- package/dist/classes/navigation/Map.js.map +1 -1
- package/dist/classes/navigation/Map.mjs.map +1 -1
- package/dist/classes/navigation/Room.d.mts +2 -2
- package/dist/classes/navigation/Room.d.ts +2 -2
- package/dist/classes/navigation/Room.js +15 -15
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +15 -15
- package/dist/classes/navigation/Room.mjs.map +1 -1
- package/dist/classes/quest/Goal.d.mts +21 -13
- package/dist/classes/quest/Goal.d.ts +21 -13
- package/dist/classes/quest/Goal.js +50 -15
- package/dist/classes/quest/Goal.js.map +1 -1
- package/dist/classes/quest/Goal.mjs +47 -15
- package/dist/classes/quest/Goal.mjs.map +1 -1
- package/dist/classes/quest/Quest.d.mts +3 -2
- package/dist/classes/quest/Quest.d.ts +3 -2
- package/dist/classes/quest/Quest.js +536 -9
- package/dist/classes/quest/Quest.js.map +1 -1
- package/dist/classes/quest/Quest.mjs +537 -10
- package/dist/classes/quest/Quest.mjs.map +1 -1
- package/dist/classes/quest/Stage.d.mts +3 -2
- package/dist/classes/quest/Stage.d.ts +3 -2
- package/dist/classes/quest/Stage.js +396 -51
- package/dist/classes/quest/Stage.js.map +1 -1
- package/dist/classes/quest/Stage.mjs +394 -52
- 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/ActivityDecorator.js.map +1 -1
- package/dist/decorators/ActivityDecorator.mjs.map +1 -1
- package/dist/decorators/CommitmentDecorator.d.mts +32 -6
- package/dist/decorators/CommitmentDecorator.d.ts +32 -6
- package/dist/decorators/CommitmentDecorator.js +7 -7
- package/dist/decorators/CommitmentDecorator.js.map +1 -1
- package/dist/decorators/CommitmentDecorator.mjs +5 -5
- package/dist/decorators/CommitmentDecorator.mjs.map +1 -1
- package/dist/decorators/QuestDecorator.d.mts +28 -0
- package/dist/decorators/QuestDecorator.d.ts +28 -0
- package/dist/decorators/QuestDecorator.js +33 -0
- package/dist/decorators/QuestDecorator.js.map +1 -0
- package/dist/decorators/QuestDecorator.mjs +29 -0
- package/dist/decorators/QuestDecorator.mjs.map +1 -0
- package/dist/decorators/RoomDecorator.d.mts +3 -3
- package/dist/decorators/RoomDecorator.d.ts +3 -3
- package/dist/decorators/RoomDecorator.js.map +1 -1
- package/dist/decorators/RoomDecorator.mjs.map +1 -1
- package/dist/decorators/index.d.mts +8 -3
- package/dist/decorators/index.d.ts +8 -3
- package/dist/decorators/index.js +30 -15
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +27 -12
- 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 +21 -4
- package/dist/functions/RoutineFunctions.d.ts +21 -4
- package/dist/functions/RoutineFunctions.js +16 -16
- package/dist/functions/RoutineFunctions.js.map +1 -1
- package/dist/functions/RoutineFunctions.mjs +16 -16
- 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 +16 -16
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +16 -16
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +543 -326
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +536 -319
- 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 +4 -4
- package/dist/interface/index.d.ts +4 -4
- 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/GoalProps.d.mts +12 -0
- package/dist/interface/quest/GoalProps.d.ts +12 -0
- package/dist/interface/quest/QuestProps.d.mts +6 -9
- package/dist/interface/quest/QuestProps.d.ts +6 -9
- package/dist/interface/quest/StageFlags.d.mts +12 -0
- package/dist/interface/quest/StageFlags.d.ts +12 -0
- package/dist/interface/quest/StageFlags.js +4 -0
- package/dist/interface/quest/StageFlags.js.map +1 -0
- package/dist/interface/quest/StageFlags.mjs +3 -0
- package/dist/interface/quest/StageFlags.mjs.map +1 -0
- package/dist/interface/quest/StageProps.d.mts +3 -2
- package/dist/interface/quest/StageProps.d.ts +3 -2
- package/dist/override/OnEndStage.d.mts +19 -0
- package/dist/override/OnEndStage.d.ts +19 -0
- package/dist/override/OnEndStage.js +4 -0
- package/dist/override/OnEndStage.js.map +1 -0
- package/dist/override/OnEndStage.mjs +3 -0
- package/dist/override/OnEndStage.mjs.map +1 -0
- package/dist/override/OnStartStage.d.mts +19 -0
- package/dist/override/OnStartStage.d.ts +19 -0
- package/dist/override/OnStartStage.js +4 -0
- package/dist/override/OnStartStage.js.map +1 -0
- package/dist/override/OnStartStage.mjs +3 -0
- package/dist/override/OnStartStage.mjs.map +1 -0
- package/dist/override/index.d.mts +2 -0
- package/dist/override/index.d.ts +2 -0
- package/dist/types/ExecutionType.d.mts +3 -0
- package/dist/types/ExecutionType.d.ts +3 -0
- package/dist/types/ExecutionType.js +4 -0
- package/dist/types/ExecutionType.js.map +1 -0
- package/dist/types/ExecutionType.mjs +3 -0
- package/dist/types/ExecutionType.mjs.map +1 -0
- package/dist/types/QuestsRequired.d.mts +3 -2
- package/dist/types/QuestsRequired.d.ts +3 -2
- package/dist/types/index.d.mts +4 -2
- package/dist/types/index.d.ts +4 -2
- package/package.json +1 -1
- package/dist/Quest-Bdm0R9LA.d.mts +0 -71
- package/dist/Quest-CxJcXETG.d.ts +0 -71
- package/dist/enums/ExecutionTypeEnum.d.mts +0 -6
- package/dist/enums/ExecutionTypeEnum.d.ts +0 -6
- package/dist/enums/ExecutionTypeEnum.js +0 -12
- package/dist/enums/ExecutionTypeEnum.js.map +0 -1
- package/dist/enums/ExecutionTypeEnum.mjs +0 -10
- package/dist/enums/ExecutionTypeEnum.mjs.map +0 -1
- package/dist/enums/index.d.mts +0 -1
- package/dist/enums/index.d.ts +0 -1
- package/dist/enums/index.js +0 -12
- package/dist/enums/index.js.map +0 -1
- package/dist/enums/index.mjs +0 -10
- package/dist/enums/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -389,15 +389,6 @@ var ActivityModel = class {
|
|
|
389
389
|
};
|
|
390
390
|
}
|
|
391
391
|
};
|
|
392
|
-
|
|
393
|
-
// src/enums/ExecutionTypeEnum.ts
|
|
394
|
-
var ExecutionTypeEnum = /* @__PURE__ */ ((ExecutionTypeEnum2) => {
|
|
395
|
-
ExecutionTypeEnum2["AUTOMATIC"] = "automatic";
|
|
396
|
-
ExecutionTypeEnum2["INTERACTION"] = "interaction";
|
|
397
|
-
return ExecutionTypeEnum2;
|
|
398
|
-
})(ExecutionTypeEnum || {});
|
|
399
|
-
|
|
400
|
-
// src/classes/Commitment.ts
|
|
401
392
|
var COMMITMENT_CATEGORY = "__nqtr-commitment__";
|
|
402
393
|
var CommitmentBaseModel = class extends StoredClassModel {
|
|
403
394
|
/**
|
|
@@ -416,11 +407,12 @@ var CommitmentBaseModel = class extends StoredClassModel {
|
|
|
416
407
|
this.defaultFromDay = props.fromDay;
|
|
417
408
|
this.defaultToDay = props.toDay;
|
|
418
409
|
this._renderImage = props.renderImage;
|
|
419
|
-
this._executionType = props.executionType || "interaction"
|
|
410
|
+
this._executionType = props.executionType || "interaction";
|
|
420
411
|
this._onRun = props.onRun;
|
|
421
412
|
this.defaultDisabled = props.disabled || false;
|
|
422
413
|
this.defaultHidden = props.hidden || false;
|
|
423
414
|
this._renderIcon = props.renderIcon;
|
|
415
|
+
this.defaultPriority = props.priority || 0;
|
|
424
416
|
}
|
|
425
417
|
/**
|
|
426
418
|
* The character or characters that are in the commitment and so in the room.
|
|
@@ -562,6 +554,16 @@ var CommitmentBaseModel = class extends StoredClassModel {
|
|
|
562
554
|
set hidden(value) {
|
|
563
555
|
this.setStorageProperty("hidden", value);
|
|
564
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* The priority. The higher the number, the higher the priority.
|
|
559
|
+
* To ensure that a character is not in 2 places at the same time, if there are 2 or more valid commits at the same time and with the same character, the one with the highest priority will be chosen.
|
|
560
|
+
*/
|
|
561
|
+
get priority() {
|
|
562
|
+
return this.getStorageProperty("priority") || this.defaultPriority || 0;
|
|
563
|
+
}
|
|
564
|
+
set priority(value) {
|
|
565
|
+
this.setStorageProperty("priority", value);
|
|
566
|
+
}
|
|
565
567
|
/**
|
|
566
568
|
* Whether the commitment is expired.
|
|
567
569
|
* @returns Whether the commitment is expired.
|
|
@@ -573,6 +575,199 @@ var CommitmentBaseModel = class extends StoredClassModel {
|
|
|
573
575
|
return false;
|
|
574
576
|
}
|
|
575
577
|
};
|
|
578
|
+
var ActivityStoredAbstract = class {
|
|
579
|
+
/**
|
|
580
|
+
* @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.
|
|
581
|
+
* @param props The activity properties.
|
|
582
|
+
*/
|
|
583
|
+
constructor(onRun, props) {
|
|
584
|
+
this.defaultName = props.name;
|
|
585
|
+
this.defaultFromHour = props.fromHour;
|
|
586
|
+
this.defaultToHour = props.toHour;
|
|
587
|
+
this.defaultFromDay = props.fromDay;
|
|
588
|
+
this.defaultToDay = props.toDay;
|
|
589
|
+
this.defaultDisabled = props.disabled || false;
|
|
590
|
+
this.defaultHidden = props.hidden || false;
|
|
591
|
+
this._renderIcon = props.renderIcon;
|
|
592
|
+
this._onRun = onRun;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* The name
|
|
596
|
+
*/
|
|
597
|
+
get name() {
|
|
598
|
+
return this.getStorageProperty("name") || this.defaultName || "";
|
|
599
|
+
}
|
|
600
|
+
set name(value) {
|
|
601
|
+
this.setStorageProperty("name", value);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
605
|
+
*/
|
|
606
|
+
get fromHour() {
|
|
607
|
+
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
608
|
+
}
|
|
609
|
+
set fromHour(value) {
|
|
610
|
+
this.setStorageProperty("fromHour", value);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
614
|
+
*/
|
|
615
|
+
get toHour() {
|
|
616
|
+
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
617
|
+
}
|
|
618
|
+
set toHour(value) {
|
|
619
|
+
this.setStorageProperty("toHour", value);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
623
|
+
*/
|
|
624
|
+
get fromDay() {
|
|
625
|
+
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
626
|
+
}
|
|
627
|
+
set fromDay(value) {
|
|
628
|
+
this.setStorageProperty("fromDay", value);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
632
|
+
*/
|
|
633
|
+
get toDay() {
|
|
634
|
+
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
635
|
+
}
|
|
636
|
+
set toDay(value) {
|
|
637
|
+
this.setStorageProperty("toDay", value);
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Whether is disabled.
|
|
641
|
+
*/
|
|
642
|
+
get disabled() {
|
|
643
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
644
|
+
if (typeof value === "string") {
|
|
645
|
+
return getFlag(value);
|
|
646
|
+
}
|
|
647
|
+
return value;
|
|
648
|
+
}
|
|
649
|
+
set disabled(value) {
|
|
650
|
+
this.setStorageProperty("disabled", value);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
654
|
+
*/
|
|
655
|
+
get hidden() {
|
|
656
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
if (!this.isExpired) {
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
666
|
+
if (typeof value === "string") {
|
|
667
|
+
return getFlag(value);
|
|
668
|
+
}
|
|
669
|
+
return value;
|
|
670
|
+
}
|
|
671
|
+
set hidden(value) {
|
|
672
|
+
this.setStorageProperty("hidden", value);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* The function for rendering the icon of the activity.
|
|
676
|
+
*/
|
|
677
|
+
get renderIcon() {
|
|
678
|
+
let render = this._renderIcon;
|
|
679
|
+
if (render === void 0) {
|
|
680
|
+
return void 0;
|
|
681
|
+
}
|
|
682
|
+
if (typeof render === "function") {
|
|
683
|
+
return (props) => {
|
|
684
|
+
return render(this, props);
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
return (props) => render;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* The function that is called when the activity is runned.
|
|
691
|
+
*/
|
|
692
|
+
get onRun() {
|
|
693
|
+
return (props) => {
|
|
694
|
+
return this._onRun(this, props);
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Whether the activity is a deadline.
|
|
699
|
+
* @returns Whether the activity is a deadline.
|
|
700
|
+
*/
|
|
701
|
+
isExpired() {
|
|
702
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Export the activity properties.
|
|
709
|
+
* @returns The activity properties.
|
|
710
|
+
*/
|
|
711
|
+
export() {
|
|
712
|
+
return {
|
|
713
|
+
name: this.getStorageProperty("name") || this.defaultName,
|
|
714
|
+
fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
|
|
715
|
+
toHour: this.getStorageProperty("toHour") || this.defaultToHour,
|
|
716
|
+
fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
|
|
717
|
+
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
718
|
+
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
719
|
+
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
720
|
+
renderIcon: this._renderIcon
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
// src/classes/navigation/ActivityRoom.ts
|
|
726
|
+
var ActivityRoom = class extends ActivityStoredAbstract {
|
|
727
|
+
constructor(id, room, onRun, props) {
|
|
728
|
+
super(onRun, props);
|
|
729
|
+
this._id = id;
|
|
730
|
+
this._room = room;
|
|
731
|
+
}
|
|
732
|
+
setStorageProperty(_, __) {
|
|
733
|
+
this._room.setActivity(this);
|
|
734
|
+
}
|
|
735
|
+
getStorageProperty(propertyName) {
|
|
736
|
+
let activity = this._room.getActivityMemory(this.id);
|
|
737
|
+
if (!activity || !activity.hasOwnProperty(propertyName)) {
|
|
738
|
+
return void 0;
|
|
739
|
+
}
|
|
740
|
+
return activity[propertyName];
|
|
741
|
+
}
|
|
742
|
+
get id() {
|
|
743
|
+
return this._id;
|
|
744
|
+
}
|
|
745
|
+
get room() {
|
|
746
|
+
return this._room;
|
|
747
|
+
}
|
|
748
|
+
export() {
|
|
749
|
+
let result = {};
|
|
750
|
+
if (this.name !== void 0) {
|
|
751
|
+
result["name"] = this.name;
|
|
752
|
+
}
|
|
753
|
+
if (this.fromHour !== void 0) {
|
|
754
|
+
result["fromHour"] = this.fromHour;
|
|
755
|
+
}
|
|
756
|
+
if (this.toHour !== void 0) {
|
|
757
|
+
result["toHour"] = this.toHour;
|
|
758
|
+
}
|
|
759
|
+
if (this.fromDay !== void 0) {
|
|
760
|
+
result["fromDay"] = this.fromDay;
|
|
761
|
+
}
|
|
762
|
+
if (this.toDay !== void 0) {
|
|
763
|
+
result["toDay"] = this.toDay;
|
|
764
|
+
}
|
|
765
|
+
if (this.disabled !== void 0) {
|
|
766
|
+
result["disabled"] = this.disabled;
|
|
767
|
+
}
|
|
768
|
+
return result;
|
|
769
|
+
}
|
|
770
|
+
};
|
|
576
771
|
|
|
577
772
|
// src/decorators/RoomDecorator.ts
|
|
578
773
|
var registeredRooms = {};
|
|
@@ -865,9 +1060,9 @@ function getCommitmentById(id) {
|
|
|
865
1060
|
return;
|
|
866
1061
|
}
|
|
867
1062
|
}
|
|
868
|
-
function
|
|
1063
|
+
function setFixedRoutine(commitments) {
|
|
869
1064
|
if (Array.isArray(commitments)) {
|
|
870
|
-
commitments.forEach((c) =>
|
|
1065
|
+
commitments.forEach((c) => setFixedRoutine(c));
|
|
871
1066
|
return;
|
|
872
1067
|
}
|
|
873
1068
|
if (fixedCommitments[commitments.id]) {
|
|
@@ -875,7 +1070,7 @@ function setFixedCommitments(commitments) {
|
|
|
875
1070
|
}
|
|
876
1071
|
fixedCommitments[commitments.id] = commitments;
|
|
877
1072
|
}
|
|
878
|
-
function
|
|
1073
|
+
function addCommitment(commitment) {
|
|
879
1074
|
if (!Array.isArray(commitment)) {
|
|
880
1075
|
commitment = [commitment];
|
|
881
1076
|
}
|
|
@@ -889,7 +1084,7 @@ function addTemporaryCommitment(commitment) {
|
|
|
889
1084
|
}).filter((id) => id !== void 0);
|
|
890
1085
|
GameStorageManager.setVariable(TEMPORARY_COMMITMENT_CATEGORY_MEMORY_KEY, [commitmentsIds]);
|
|
891
1086
|
}
|
|
892
|
-
function
|
|
1087
|
+
function getFixedRoutine() {
|
|
893
1088
|
return Object.values(fixedCommitments);
|
|
894
1089
|
}
|
|
895
1090
|
function getTemporaryCommitments() {
|
|
@@ -901,6 +1096,32 @@ function getTemporaryCommitments() {
|
|
|
901
1096
|
return commitments;
|
|
902
1097
|
}
|
|
903
1098
|
|
|
1099
|
+
// src/decorators/QuestDecorator.ts
|
|
1100
|
+
var registeredQuests = {};
|
|
1101
|
+
function saveQuest(quest) {
|
|
1102
|
+
if (Array.isArray(quest)) {
|
|
1103
|
+
quest.forEach((c) => saveQuest(c));
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if (registeredQuests[quest.id]) {
|
|
1107
|
+
console.warn(`[NQTR] Quest id ${quest.id} already exists, it will be overwritten`);
|
|
1108
|
+
}
|
|
1109
|
+
registeredQuests[quest.id] = quest;
|
|
1110
|
+
}
|
|
1111
|
+
function getQuestById(id) {
|
|
1112
|
+
try {
|
|
1113
|
+
let quest = registeredQuests[id];
|
|
1114
|
+
if (!quest) {
|
|
1115
|
+
console.error(`[NQTR] Quest ${id} not found`);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
return quest;
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
console.error(`[NQTR] Error while getting Quest ${id}`, e);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
|
|
904
1125
|
// src/functions/RoutineFunctions.ts
|
|
905
1126
|
function clearExpiredRoutine() {
|
|
906
1127
|
Object.entries(registeredCommitments).forEach(([_, commitment]) => {
|
|
@@ -909,271 +1130,78 @@ function clearExpiredRoutine() {
|
|
|
909
1130
|
}
|
|
910
1131
|
});
|
|
911
1132
|
}
|
|
912
|
-
function
|
|
1133
|
+
function getCurrentRoutine() {
|
|
913
1134
|
let character_commitments = {};
|
|
914
|
-
let oltherCommitments = [];
|
|
915
1135
|
getTemporaryCommitments().reverse().forEach((c) => {
|
|
916
1136
|
if (!c.hidden) {
|
|
917
|
-
if (c.characters.length >
|
|
918
|
-
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id]);
|
|
1137
|
+
if (c.characters.length > 0) {
|
|
1138
|
+
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
|
|
919
1139
|
if (allAvailable) {
|
|
920
1140
|
c.characters.forEach((ch) => {
|
|
921
1141
|
character_commitments[ch.id] = c;
|
|
922
1142
|
});
|
|
923
1143
|
}
|
|
924
1144
|
} else {
|
|
925
|
-
|
|
1145
|
+
console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
|
|
926
1146
|
}
|
|
927
1147
|
}
|
|
928
1148
|
});
|
|
929
|
-
|
|
1149
|
+
getFixedRoutine().reverse().forEach((c) => {
|
|
930
1150
|
if (!c.hidden) {
|
|
931
|
-
if (c.characters.length >
|
|
932
|
-
c.characters.
|
|
933
|
-
|
|
1151
|
+
if (c.characters.length > 0) {
|
|
1152
|
+
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
|
|
1153
|
+
if (allAvailable) {
|
|
1154
|
+
c.characters.forEach((ch) => {
|
|
934
1155
|
character_commitments[ch.id] = c;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
937
1158
|
} else {
|
|
938
|
-
|
|
1159
|
+
console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
|
|
939
1160
|
}
|
|
940
1161
|
}
|
|
941
1162
|
});
|
|
942
|
-
return Object.values(character_commitments)
|
|
1163
|
+
return Object.values(character_commitments);
|
|
943
1164
|
}
|
|
944
1165
|
function getCommitmentByCharacter(character) {
|
|
945
|
-
|
|
1166
|
+
getCurrentRoutine().forEach((c) => {
|
|
946
1167
|
if (c.characters.map((ch) => ch.id).includes(character.id)) {
|
|
947
1168
|
return c;
|
|
948
1169
|
}
|
|
949
1170
|
});
|
|
950
1171
|
return void 0;
|
|
951
1172
|
}
|
|
952
|
-
|
|
1173
|
+
|
|
1174
|
+
// src/classes/navigation/Room.ts
|
|
1175
|
+
var ROOM_CATEGORY = "__nqtr-room__";
|
|
1176
|
+
var RoomBaseModel = class extends StoredClassModel {
|
|
953
1177
|
/**
|
|
954
|
-
* @param
|
|
955
|
-
* @param
|
|
1178
|
+
* @param id The id of the room, it must be unique.
|
|
1179
|
+
* @param location The location where the room is.
|
|
1180
|
+
* @param props The properties of the room.
|
|
956
1181
|
*/
|
|
957
|
-
constructor(
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
this.
|
|
961
|
-
this.
|
|
962
|
-
this.
|
|
1182
|
+
constructor(id, location, props = {}) {
|
|
1183
|
+
var _a;
|
|
1184
|
+
super(ROOM_CATEGORY, id);
|
|
1185
|
+
this._location = location;
|
|
1186
|
+
this.defaultName = props.name || "";
|
|
1187
|
+
this._renderImage = props.renderImage;
|
|
1188
|
+
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
963
1189
|
this.defaultDisabled = props.disabled || false;
|
|
964
1190
|
this.defaultHidden = props.hidden || false;
|
|
965
1191
|
this._renderIcon = props.renderIcon;
|
|
966
|
-
this.
|
|
1192
|
+
this._isEntrance = props.isEntrance;
|
|
967
1193
|
}
|
|
968
1194
|
/**
|
|
969
|
-
* The
|
|
1195
|
+
* The location where the room is.
|
|
970
1196
|
*/
|
|
971
|
-
get
|
|
972
|
-
return this.
|
|
973
|
-
}
|
|
974
|
-
set name(value) {
|
|
975
|
-
this.setStorageProperty("name", value);
|
|
1197
|
+
get location() {
|
|
1198
|
+
return this._location;
|
|
976
1199
|
}
|
|
977
1200
|
/**
|
|
978
|
-
*
|
|
1201
|
+
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
979
1202
|
*/
|
|
980
|
-
get
|
|
981
|
-
return this.
|
|
982
|
-
}
|
|
983
|
-
set fromHour(value) {
|
|
984
|
-
this.setStorageProperty("fromHour", value);
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
988
|
-
*/
|
|
989
|
-
get toHour() {
|
|
990
|
-
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
991
|
-
}
|
|
992
|
-
set toHour(value) {
|
|
993
|
-
this.setStorageProperty("toHour", value);
|
|
994
|
-
}
|
|
995
|
-
/**
|
|
996
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
997
|
-
*/
|
|
998
|
-
get fromDay() {
|
|
999
|
-
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
1000
|
-
}
|
|
1001
|
-
set fromDay(value) {
|
|
1002
|
-
this.setStorageProperty("fromDay", value);
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
1006
|
-
*/
|
|
1007
|
-
get toDay() {
|
|
1008
|
-
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
1009
|
-
}
|
|
1010
|
-
set toDay(value) {
|
|
1011
|
-
this.setStorageProperty("toDay", value);
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Whether is disabled.
|
|
1015
|
-
*/
|
|
1016
|
-
get disabled() {
|
|
1017
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
1018
|
-
if (typeof value === "string") {
|
|
1019
|
-
return getFlag(value);
|
|
1020
|
-
}
|
|
1021
|
-
return value;
|
|
1022
|
-
}
|
|
1023
|
-
set disabled(value) {
|
|
1024
|
-
this.setStorageProperty("disabled", value);
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
1028
|
-
*/
|
|
1029
|
-
get hidden() {
|
|
1030
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
1031
|
-
return true;
|
|
1032
|
-
}
|
|
1033
|
-
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
1034
|
-
return true;
|
|
1035
|
-
}
|
|
1036
|
-
if (!this.isExpired) {
|
|
1037
|
-
return true;
|
|
1038
|
-
}
|
|
1039
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
1040
|
-
if (typeof value === "string") {
|
|
1041
|
-
return getFlag(value);
|
|
1042
|
-
}
|
|
1043
|
-
return value;
|
|
1044
|
-
}
|
|
1045
|
-
set hidden(value) {
|
|
1046
|
-
this.setStorageProperty("hidden", value);
|
|
1047
|
-
}
|
|
1048
|
-
/**
|
|
1049
|
-
* The function for rendering the icon of the activity.
|
|
1050
|
-
*/
|
|
1051
|
-
get renderIcon() {
|
|
1052
|
-
let render = this._renderIcon;
|
|
1053
|
-
if (render === void 0) {
|
|
1054
|
-
return void 0;
|
|
1055
|
-
}
|
|
1056
|
-
if (typeof render === "function") {
|
|
1057
|
-
return (props) => {
|
|
1058
|
-
return render(this, props);
|
|
1059
|
-
};
|
|
1060
|
-
}
|
|
1061
|
-
return (props) => render;
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* The function that is called when the activity is runned.
|
|
1065
|
-
*/
|
|
1066
|
-
get onRun() {
|
|
1067
|
-
return (props) => {
|
|
1068
|
-
return this._onRun(this, props);
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Whether the activity is a deadline.
|
|
1073
|
-
* @returns Whether the activity is a deadline.
|
|
1074
|
-
*/
|
|
1075
|
-
isExpired() {
|
|
1076
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
1077
|
-
return true;
|
|
1078
|
-
}
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Export the activity properties.
|
|
1083
|
-
* @returns The activity properties.
|
|
1084
|
-
*/
|
|
1085
|
-
export() {
|
|
1086
|
-
return {
|
|
1087
|
-
name: this.getStorageProperty("name") || this.defaultName,
|
|
1088
|
-
fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
|
|
1089
|
-
toHour: this.getStorageProperty("toHour") || this.defaultToHour,
|
|
1090
|
-
fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
|
|
1091
|
-
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
1092
|
-
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
1093
|
-
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
1094
|
-
renderIcon: this._renderIcon
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
// src/classes/navigation/ActivityRoom.ts
|
|
1100
|
-
var ActivityRoom = class extends ActivityStoredAbstract {
|
|
1101
|
-
constructor(id, room, onRun, props) {
|
|
1102
|
-
super(onRun, props);
|
|
1103
|
-
this._id = id;
|
|
1104
|
-
this._room = room;
|
|
1105
|
-
}
|
|
1106
|
-
setStorageProperty(_, __) {
|
|
1107
|
-
this._room.setActivity(this);
|
|
1108
|
-
}
|
|
1109
|
-
getStorageProperty(propertyName) {
|
|
1110
|
-
let activity = this._room.getActivityMemory(this.id);
|
|
1111
|
-
if (!activity || !activity.hasOwnProperty(propertyName)) {
|
|
1112
|
-
return void 0;
|
|
1113
|
-
}
|
|
1114
|
-
return activity[propertyName];
|
|
1115
|
-
}
|
|
1116
|
-
get id() {
|
|
1117
|
-
return this._id;
|
|
1118
|
-
}
|
|
1119
|
-
get room() {
|
|
1120
|
-
return this._room;
|
|
1121
|
-
}
|
|
1122
|
-
export() {
|
|
1123
|
-
let result = {};
|
|
1124
|
-
if (this.name !== void 0) {
|
|
1125
|
-
result["name"] = this.name;
|
|
1126
|
-
}
|
|
1127
|
-
if (this.fromHour !== void 0) {
|
|
1128
|
-
result["fromHour"] = this.fromHour;
|
|
1129
|
-
}
|
|
1130
|
-
if (this.toHour !== void 0) {
|
|
1131
|
-
result["toHour"] = this.toHour;
|
|
1132
|
-
}
|
|
1133
|
-
if (this.fromDay !== void 0) {
|
|
1134
|
-
result["fromDay"] = this.fromDay;
|
|
1135
|
-
}
|
|
1136
|
-
if (this.toDay !== void 0) {
|
|
1137
|
-
result["toDay"] = this.toDay;
|
|
1138
|
-
}
|
|
1139
|
-
if (this.disabled !== void 0) {
|
|
1140
|
-
result["disabled"] = this.disabled;
|
|
1141
|
-
}
|
|
1142
|
-
return result;
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
// src/classes/navigation/Room.ts
|
|
1147
|
-
var ROOM_CATEGORY = "__nqtr-room__";
|
|
1148
|
-
var RoomBaseModel = class extends StoredClassModel {
|
|
1149
|
-
/**
|
|
1150
|
-
* @param id The id of the room, it must be unique.
|
|
1151
|
-
* @param location The location where the room is.
|
|
1152
|
-
* @param props The properties of the room.
|
|
1153
|
-
*/
|
|
1154
|
-
constructor(id, location, props = {}) {
|
|
1155
|
-
var _a;
|
|
1156
|
-
super(ROOM_CATEGORY, id);
|
|
1157
|
-
this._location = location;
|
|
1158
|
-
this.defaultName = props.name || "";
|
|
1159
|
-
this._renderImage = props.renderImage;
|
|
1160
|
-
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
1161
|
-
this.defaultDisabled = props.disabled || false;
|
|
1162
|
-
this.defaultHidden = props.hidden || false;
|
|
1163
|
-
this._renderIcon = props.renderIcon;
|
|
1164
|
-
this._isEntrance = props.isEntrance;
|
|
1165
|
-
}
|
|
1166
|
-
/**
|
|
1167
|
-
* The location where the room is.
|
|
1168
|
-
*/
|
|
1169
|
-
get location() {
|
|
1170
|
-
return this._location;
|
|
1171
|
-
}
|
|
1172
|
-
/**
|
|
1173
|
-
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
1174
|
-
*/
|
|
1175
|
-
get isEntrance() {
|
|
1176
|
-
return this._isEntrance || false;
|
|
1203
|
+
get isEntrance() {
|
|
1204
|
+
return this._isEntrance || false;
|
|
1177
1205
|
}
|
|
1178
1206
|
/**
|
|
1179
1207
|
* The name.
|
|
@@ -1375,51 +1403,82 @@ var RoomBaseModel = class extends StoredClassModel {
|
|
|
1375
1403
|
* @returns The character commitments of the room.
|
|
1376
1404
|
*/
|
|
1377
1405
|
getRoutine() {
|
|
1378
|
-
let commitments =
|
|
1406
|
+
let commitments = getCurrentRoutine();
|
|
1379
1407
|
return commitments.filter((c) => c.room.id === this.id);
|
|
1380
1408
|
}
|
|
1381
1409
|
};
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1410
|
+
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
1411
|
+
var Goal = class extends StoredClassModel {
|
|
1412
|
+
constructor(id, props) {
|
|
1413
|
+
super(GOAL_CATEGORY, id);
|
|
1386
1414
|
this._description = props.description;
|
|
1387
|
-
this.
|
|
1388
|
-
this.
|
|
1415
|
+
this._need = props.need || 1;
|
|
1416
|
+
this._defaultHave = props.have || 0;
|
|
1389
1417
|
}
|
|
1418
|
+
/**
|
|
1419
|
+
* The description of the goal.
|
|
1420
|
+
*/
|
|
1390
1421
|
get description() {
|
|
1391
1422
|
return this._description;
|
|
1392
1423
|
}
|
|
1393
|
-
get
|
|
1424
|
+
get need() {
|
|
1425
|
+
return this._need;
|
|
1426
|
+
}
|
|
1427
|
+
get defaultHave() {
|
|
1428
|
+
return this._defaultHave;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
var GoalStage = class extends Goal {
|
|
1432
|
+
constructor(id, stageId, props) {
|
|
1433
|
+
super(id, props);
|
|
1434
|
+
this._stageId = stageId;
|
|
1435
|
+
}
|
|
1436
|
+
get stageId() {
|
|
1437
|
+
return this._stageId;
|
|
1438
|
+
}
|
|
1439
|
+
set stageId(value) {
|
|
1440
|
+
this._stageId = value;
|
|
1441
|
+
}
|
|
1442
|
+
get have() {
|
|
1443
|
+
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
1444
|
+
}
|
|
1445
|
+
set have(value) {
|
|
1446
|
+
if (!this._stageId) {
|
|
1447
|
+
console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
this.setStorageProperty("have-" + this._stageId, value);
|
|
1451
|
+
}
|
|
1452
|
+
get completed() {
|
|
1394
1453
|
return this.have >= this.need;
|
|
1395
1454
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1455
|
+
set completed(value) {
|
|
1456
|
+
if (value) {
|
|
1457
|
+
this.have = this.need;
|
|
1458
|
+
} else {
|
|
1459
|
+
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
1460
|
+
}
|
|
1398
1461
|
}
|
|
1399
1462
|
find() {
|
|
1400
1463
|
this.have++;
|
|
1401
1464
|
}
|
|
1402
|
-
get export() {
|
|
1403
|
-
return {
|
|
1404
|
-
description: this.description,
|
|
1405
|
-
need: this.need,
|
|
1406
|
-
have: this.have
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
1465
|
};
|
|
1410
|
-
var
|
|
1411
|
-
var
|
|
1412
|
-
constructor(id,
|
|
1413
|
-
super(
|
|
1414
|
-
this._stages = stages;
|
|
1466
|
+
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
1467
|
+
var Stage = class extends StoredClassModel {
|
|
1468
|
+
constructor(id, props) {
|
|
1469
|
+
super(STAGE_CATEGORY, id);
|
|
1415
1470
|
this._name = props.name || "";
|
|
1471
|
+
this._defaultGoals = props.goals || [];
|
|
1472
|
+
this._flags = props.flags || [];
|
|
1416
1473
|
this._description = props.description || "";
|
|
1417
|
-
this.
|
|
1418
|
-
this.
|
|
1419
|
-
this.
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1474
|
+
this._adviceDescription = props.adviceDescription || "";
|
|
1475
|
+
this._renderImage = props.renderImage;
|
|
1476
|
+
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1477
|
+
this._flagsRequiredToStart = props.flagsRequired || [];
|
|
1478
|
+
this._questsRequiredToStart = props.questsRequired || [];
|
|
1479
|
+
this._requestDescriptionToStart = props.requestDescription || "";
|
|
1480
|
+
this._onStart = props.onStart;
|
|
1481
|
+
this._onEnd = props.onEnd;
|
|
1423
1482
|
}
|
|
1424
1483
|
get name() {
|
|
1425
1484
|
return this._name;
|
|
@@ -1427,50 +1486,138 @@ var QuestBaseModel = class extends StoredClassModel {
|
|
|
1427
1486
|
get description() {
|
|
1428
1487
|
return this._description;
|
|
1429
1488
|
}
|
|
1430
|
-
get
|
|
1431
|
-
return this.
|
|
1489
|
+
get adviceDescription() {
|
|
1490
|
+
return this._adviceDescription;
|
|
1432
1491
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1492
|
+
/**
|
|
1493
|
+
* The function for rendering the image of the stage.
|
|
1494
|
+
*/
|
|
1495
|
+
get renderImage() {
|
|
1496
|
+
let render = this._renderImage;
|
|
1497
|
+
if (render === void 0) {
|
|
1498
|
+
return void 0;
|
|
1499
|
+
}
|
|
1500
|
+
if (typeof render === "function") {
|
|
1501
|
+
return (props) => {
|
|
1502
|
+
return render(this, props);
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
return (props) => render;
|
|
1435
1506
|
}
|
|
1436
|
-
get
|
|
1437
|
-
return this.
|
|
1507
|
+
get defaultGoals() {
|
|
1508
|
+
return this._defaultGoals;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* The list of flags that the player must complete to finish the stage.
|
|
1512
|
+
*/
|
|
1513
|
+
get flags() {
|
|
1514
|
+
return this._flags;
|
|
1515
|
+
}
|
|
1516
|
+
get daysRequiredToStart() {
|
|
1517
|
+
return this._daysRequiredToStart || 0;
|
|
1518
|
+
}
|
|
1519
|
+
get flagsRequiredToStart() {
|
|
1520
|
+
return this._flagsRequiredToStart;
|
|
1521
|
+
}
|
|
1522
|
+
get questsRequiredToStart() {
|
|
1523
|
+
return this._questsRequiredToStart || [];
|
|
1524
|
+
}
|
|
1525
|
+
get requestDescriptionToStart() {
|
|
1526
|
+
return this._requestDescriptionToStart;
|
|
1527
|
+
}
|
|
1528
|
+
get onStart() {
|
|
1529
|
+
return this._onStart;
|
|
1530
|
+
}
|
|
1531
|
+
get onEnd() {
|
|
1532
|
+
return this._onEnd;
|
|
1438
1533
|
}
|
|
1439
1534
|
};
|
|
1440
|
-
var
|
|
1441
|
-
var StageBaseModel = class extends StoredClassModel {
|
|
1535
|
+
var StageQuest = class extends Stage {
|
|
1442
1536
|
constructor(id, props) {
|
|
1443
|
-
super(
|
|
1444
|
-
this._completed = false;
|
|
1445
|
-
this._active = false;
|
|
1446
|
-
this.defaultGoals = [];
|
|
1447
|
-
this._name = props.name || "";
|
|
1448
|
-
this._description = props.description || "";
|
|
1449
|
-
this._adviceDescription = props.adviceDescription || "";
|
|
1450
|
-
this._image = props.image || "";
|
|
1451
|
-
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1452
|
-
this._flagsRequired = props.flagsRequired;
|
|
1453
|
-
this._questsRequired = props.questsRequired;
|
|
1454
|
-
this._requestDescription = props.requestDescription || "";
|
|
1455
|
-
this._onStart = props.onStart;
|
|
1456
|
-
this._onEnd = props.onEnd;
|
|
1537
|
+
super(id, props);
|
|
1457
1538
|
}
|
|
1458
1539
|
get completed() {
|
|
1459
|
-
|
|
1540
|
+
let storedCompleted = this.getStorageProperty("completed");
|
|
1541
|
+
if (storedCompleted) {
|
|
1542
|
+
return storedCompleted;
|
|
1543
|
+
}
|
|
1544
|
+
if (!this.flags.every((flag) => getFlag(flag.flag))) {
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
1548
|
+
return false;
|
|
1549
|
+
}
|
|
1550
|
+
return true;
|
|
1460
1551
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1552
|
+
set completed(value) {
|
|
1553
|
+
this.setStorageProperty("completed", value);
|
|
1463
1554
|
}
|
|
1555
|
+
/**
|
|
1556
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
1557
|
+
*/
|
|
1464
1558
|
get goals() {
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1559
|
+
return this.defaultGoals.map((goal) => {
|
|
1560
|
+
return new GoalStage(goal.id, this.id, goal);
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
get prevStageEndDay() {
|
|
1564
|
+
return this.getStorageProperty("prevStageEndDay");
|
|
1565
|
+
}
|
|
1566
|
+
set prevStageEndDay(value) {
|
|
1567
|
+
this.setStorageProperty("prevStageEndDay", value);
|
|
1568
|
+
}
|
|
1569
|
+
get startDay() {
|
|
1570
|
+
let prevStageEndDay = this.prevStageEndDay;
|
|
1571
|
+
if (prevStageEndDay === void 0) {
|
|
1572
|
+
return void 0;
|
|
1468
1573
|
}
|
|
1469
|
-
return
|
|
1574
|
+
return prevStageEndDay + this.daysRequiredToStart;
|
|
1470
1575
|
}
|
|
1471
|
-
|
|
1472
|
-
let
|
|
1473
|
-
|
|
1576
|
+
get canStart() {
|
|
1577
|
+
let daysRequired = this.daysRequiredToStart;
|
|
1578
|
+
if (daysRequired > 0) {
|
|
1579
|
+
let prevStageEndDay = this.prevStageEndDay;
|
|
1580
|
+
if (prevStageEndDay === void 0) {
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
|
|
1584
|
+
return false;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {
|
|
1588
|
+
return false;
|
|
1589
|
+
}
|
|
1590
|
+
if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
|
|
1591
|
+
(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
|
|
1592
|
+
)) {
|
|
1593
|
+
return false;
|
|
1594
|
+
}
|
|
1595
|
+
return true;
|
|
1596
|
+
}
|
|
1597
|
+
get onStart() {
|
|
1598
|
+
if (this.daysRequiredToStart > 0) {
|
|
1599
|
+
this.prevStageEndDay = TimeManager.currentDay;
|
|
1600
|
+
}
|
|
1601
|
+
return super.onStart;
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
// src/classes/quest/Quest.ts
|
|
1606
|
+
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
1607
|
+
var Quest = class extends StoredClassModel {
|
|
1608
|
+
constructor(id, stages, props) {
|
|
1609
|
+
super(QUEST_CATEGORY, id);
|
|
1610
|
+
this._stages = stages;
|
|
1611
|
+
this._name = props.name || "";
|
|
1612
|
+
this._description = props.description || "";
|
|
1613
|
+
this._renderIcon = props.renderIcon;
|
|
1614
|
+
this._renderImage = props.renderImage;
|
|
1615
|
+
this._isInDevelopment = props.isInDevelopment || false;
|
|
1616
|
+
}
|
|
1617
|
+
get stages() {
|
|
1618
|
+
return this._stages.map((stage, index) => {
|
|
1619
|
+
return new StageQuest(stage.id, stage);
|
|
1620
|
+
});
|
|
1474
1621
|
}
|
|
1475
1622
|
get name() {
|
|
1476
1623
|
return this._name;
|
|
@@ -1478,29 +1625,99 @@ var StageBaseModel = class extends StoredClassModel {
|
|
|
1478
1625
|
get description() {
|
|
1479
1626
|
return this._description;
|
|
1480
1627
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1628
|
+
/**
|
|
1629
|
+
* The function for rendering the icon of the quest.
|
|
1630
|
+
*/
|
|
1631
|
+
get renderIcon() {
|
|
1632
|
+
let render = this._renderIcon;
|
|
1633
|
+
if (render === void 0) {
|
|
1634
|
+
return void 0;
|
|
1635
|
+
}
|
|
1636
|
+
if (typeof render === "function") {
|
|
1637
|
+
return (props) => {
|
|
1638
|
+
return render(this, props);
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
return (props) => render;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* The function for rendering the image of the quest.
|
|
1645
|
+
*/
|
|
1646
|
+
get renderImage() {
|
|
1647
|
+
let render = this._renderImage;
|
|
1648
|
+
if (render === void 0) {
|
|
1649
|
+
return void 0;
|
|
1650
|
+
}
|
|
1651
|
+
if (typeof render === "function") {
|
|
1652
|
+
return (props) => {
|
|
1653
|
+
return render(this, props);
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
return (props) => render;
|
|
1483
1657
|
}
|
|
1484
|
-
get
|
|
1485
|
-
return this.
|
|
1658
|
+
get isInDevelopment() {
|
|
1659
|
+
return this._isInDevelopment;
|
|
1486
1660
|
}
|
|
1487
|
-
get
|
|
1488
|
-
return this.
|
|
1661
|
+
get currentStageIndex() {
|
|
1662
|
+
return this.getStorageProperty("currentStageIndex");
|
|
1663
|
+
}
|
|
1664
|
+
set currentStageIndex(value) {
|
|
1665
|
+
this.setStorageProperty("currentStageIndex", value);
|
|
1489
1666
|
}
|
|
1490
|
-
get
|
|
1491
|
-
|
|
1667
|
+
get currentStage() {
|
|
1668
|
+
let index = this.currentStageIndex;
|
|
1669
|
+
if (index === void 0 || index >= this.stages.length) {
|
|
1670
|
+
return void 0;
|
|
1671
|
+
}
|
|
1672
|
+
return this.stages[index];
|
|
1492
1673
|
}
|
|
1493
|
-
get
|
|
1494
|
-
return this.
|
|
1674
|
+
get started() {
|
|
1675
|
+
return this.currentStageIndex !== void 0;
|
|
1495
1676
|
}
|
|
1496
|
-
get
|
|
1497
|
-
return this.
|
|
1677
|
+
get completed() {
|
|
1678
|
+
return this.currentStageIndex === this.stages.length;
|
|
1498
1679
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1680
|
+
start() {
|
|
1681
|
+
if (this.started) {
|
|
1682
|
+
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
if (this.stages.length === 0) {
|
|
1686
|
+
console.error(`[NQTR] Quest ${this.id} has no stages`);
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
this.currentStageIndex = 0;
|
|
1690
|
+
let currentStage = this.currentStage;
|
|
1691
|
+
if (currentStage && currentStage.onStart) {
|
|
1692
|
+
return currentStage.onStart();
|
|
1693
|
+
} else {
|
|
1694
|
+
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1695
|
+
}
|
|
1501
1696
|
}
|
|
1502
|
-
|
|
1503
|
-
|
|
1697
|
+
tryToGoNextStage() {
|
|
1698
|
+
if (!this.started) {
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
if (this.completed) {
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
let currentStage = this.currentStage;
|
|
1705
|
+
let currentStageIndex = this.currentStageIndex;
|
|
1706
|
+
if (!currentStage || currentStageIndex === void 0) {
|
|
1707
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
if (currentStage.completed) {
|
|
1711
|
+
let nextStageIndex = currentStageIndex + 1;
|
|
1712
|
+
currentStageIndex = nextStageIndex;
|
|
1713
|
+
let nextStage = this.currentStage;
|
|
1714
|
+
if (currentStage && currentStage.onEnd) {
|
|
1715
|
+
currentStage.onEnd();
|
|
1716
|
+
}
|
|
1717
|
+
if (nextStage && nextStage.onStart) {
|
|
1718
|
+
return nextStage.onStart();
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1504
1721
|
}
|
|
1505
1722
|
};
|
|
1506
1723
|
var CURRENT_ROOM_MEMORY_KEY = "___nqtr-current_room_memory___";
|
|
@@ -1563,6 +1780,6 @@ function currentActivities() {
|
|
|
1563
1780
|
return currentRoom.activities.filter((activity) => !activity.hidden);
|
|
1564
1781
|
}
|
|
1565
1782
|
|
|
1566
|
-
export { ActivityModel,
|
|
1783
|
+
export { ActivityModel, ActivityRoom, CommitmentBaseModel, Goal, LocationBaseModel, MapBaseModel, Quest, RoomBaseModel, Stage, TimeManager, addCommitment, clearExpiredActivities, clearExpiredRoutine, currentActivities, getActivityById, getAllLocations, getAllMaps, getCommitmentByCharacter, getCommitmentById, getCueerntMap, getCurrenrLocation, getCurrentRoom, getCurrentRoutine, getQuestById, getRoomById, saveActivity, saveCommitment, saveQuest, saveRoom, setCurrentRoom, setFixedRoutine };
|
|
1567
1784
|
//# sourceMappingURL=out.js.map
|
|
1568
1785
|
//# sourceMappingURL=index.mjs.map
|