@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/classes/index.js
CHANGED
|
@@ -409,11 +409,12 @@ var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
409
409
|
this.defaultFromDay = props.fromDay;
|
|
410
410
|
this.defaultToDay = props.toDay;
|
|
411
411
|
this._renderImage = props.renderImage;
|
|
412
|
-
this._executionType = props.executionType || "interaction"
|
|
412
|
+
this._executionType = props.executionType || "interaction";
|
|
413
413
|
this._onRun = props.onRun;
|
|
414
414
|
this.defaultDisabled = props.disabled || false;
|
|
415
415
|
this.defaultHidden = props.hidden || false;
|
|
416
416
|
this._renderIcon = props.renderIcon;
|
|
417
|
+
this.defaultPriority = props.priority || 0;
|
|
417
418
|
}
|
|
418
419
|
/**
|
|
419
420
|
* The character or characters that are in the commitment and so in the room.
|
|
@@ -555,6 +556,16 @@ var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
555
556
|
set hidden(value) {
|
|
556
557
|
this.setStorageProperty("hidden", value);
|
|
557
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* The priority. The higher the number, the higher the priority.
|
|
561
|
+
* 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.
|
|
562
|
+
*/
|
|
563
|
+
get priority() {
|
|
564
|
+
return this.getStorageProperty("priority") || this.defaultPriority || 0;
|
|
565
|
+
}
|
|
566
|
+
set priority(value) {
|
|
567
|
+
this.setStorageProperty("priority", value);
|
|
568
|
+
}
|
|
558
569
|
/**
|
|
559
570
|
* Whether the commitment is expired.
|
|
560
571
|
* @returns Whether the commitment is expired.
|
|
@@ -566,6 +577,199 @@ var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
566
577
|
return false;
|
|
567
578
|
}
|
|
568
579
|
};
|
|
580
|
+
var ActivityStoredAbstract = class {
|
|
581
|
+
/**
|
|
582
|
+
* @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.
|
|
583
|
+
* @param props The activity properties.
|
|
584
|
+
*/
|
|
585
|
+
constructor(onRun, props) {
|
|
586
|
+
this.defaultName = props.name;
|
|
587
|
+
this.defaultFromHour = props.fromHour;
|
|
588
|
+
this.defaultToHour = props.toHour;
|
|
589
|
+
this.defaultFromDay = props.fromDay;
|
|
590
|
+
this.defaultToDay = props.toDay;
|
|
591
|
+
this.defaultDisabled = props.disabled || false;
|
|
592
|
+
this.defaultHidden = props.hidden || false;
|
|
593
|
+
this._renderIcon = props.renderIcon;
|
|
594
|
+
this._onRun = onRun;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* The name
|
|
598
|
+
*/
|
|
599
|
+
get name() {
|
|
600
|
+
return this.getStorageProperty("name") || this.defaultName || "";
|
|
601
|
+
}
|
|
602
|
+
set name(value) {
|
|
603
|
+
this.setStorageProperty("name", value);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
607
|
+
*/
|
|
608
|
+
get fromHour() {
|
|
609
|
+
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
610
|
+
}
|
|
611
|
+
set fromHour(value) {
|
|
612
|
+
this.setStorageProperty("fromHour", value);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
616
|
+
*/
|
|
617
|
+
get toHour() {
|
|
618
|
+
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
619
|
+
}
|
|
620
|
+
set toHour(value) {
|
|
621
|
+
this.setStorageProperty("toHour", value);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
625
|
+
*/
|
|
626
|
+
get fromDay() {
|
|
627
|
+
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
628
|
+
}
|
|
629
|
+
set fromDay(value) {
|
|
630
|
+
this.setStorageProperty("fromDay", value);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
634
|
+
*/
|
|
635
|
+
get toDay() {
|
|
636
|
+
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
637
|
+
}
|
|
638
|
+
set toDay(value) {
|
|
639
|
+
this.setStorageProperty("toDay", value);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Whether is disabled.
|
|
643
|
+
*/
|
|
644
|
+
get disabled() {
|
|
645
|
+
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
646
|
+
if (typeof value === "string") {
|
|
647
|
+
return pixiVn.getFlag(value);
|
|
648
|
+
}
|
|
649
|
+
return value;
|
|
650
|
+
}
|
|
651
|
+
set disabled(value) {
|
|
652
|
+
this.setStorageProperty("disabled", value);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
656
|
+
*/
|
|
657
|
+
get hidden() {
|
|
658
|
+
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
if (!this.isExpired) {
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
668
|
+
if (typeof value === "string") {
|
|
669
|
+
return pixiVn.getFlag(value);
|
|
670
|
+
}
|
|
671
|
+
return value;
|
|
672
|
+
}
|
|
673
|
+
set hidden(value) {
|
|
674
|
+
this.setStorageProperty("hidden", value);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* The function for rendering the icon of the activity.
|
|
678
|
+
*/
|
|
679
|
+
get renderIcon() {
|
|
680
|
+
let render = this._renderIcon;
|
|
681
|
+
if (render === void 0) {
|
|
682
|
+
return void 0;
|
|
683
|
+
}
|
|
684
|
+
if (typeof render === "function") {
|
|
685
|
+
return (props) => {
|
|
686
|
+
return render(this, props);
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
return (props) => render;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* The function that is called when the activity is runned.
|
|
693
|
+
*/
|
|
694
|
+
get onRun() {
|
|
695
|
+
return (props) => {
|
|
696
|
+
return this._onRun(this, props);
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Whether the activity is a deadline.
|
|
701
|
+
* @returns Whether the activity is a deadline.
|
|
702
|
+
*/
|
|
703
|
+
isExpired() {
|
|
704
|
+
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
705
|
+
return true;
|
|
706
|
+
}
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Export the activity properties.
|
|
711
|
+
* @returns The activity properties.
|
|
712
|
+
*/
|
|
713
|
+
export() {
|
|
714
|
+
return {
|
|
715
|
+
name: this.getStorageProperty("name") || this.defaultName,
|
|
716
|
+
fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
|
|
717
|
+
toHour: this.getStorageProperty("toHour") || this.defaultToHour,
|
|
718
|
+
fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
|
|
719
|
+
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
720
|
+
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
721
|
+
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
722
|
+
renderIcon: this._renderIcon
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
// src/classes/navigation/ActivityRoom.ts
|
|
728
|
+
var ActivityRoom = class extends ActivityStoredAbstract {
|
|
729
|
+
constructor(id, room, onRun, props) {
|
|
730
|
+
super(onRun, props);
|
|
731
|
+
this._id = id;
|
|
732
|
+
this._room = room;
|
|
733
|
+
}
|
|
734
|
+
setStorageProperty(_, __) {
|
|
735
|
+
this._room.setActivity(this);
|
|
736
|
+
}
|
|
737
|
+
getStorageProperty(propertyName) {
|
|
738
|
+
let activity = this._room.getActivityMemory(this.id);
|
|
739
|
+
if (!activity || !activity.hasOwnProperty(propertyName)) {
|
|
740
|
+
return void 0;
|
|
741
|
+
}
|
|
742
|
+
return activity[propertyName];
|
|
743
|
+
}
|
|
744
|
+
get id() {
|
|
745
|
+
return this._id;
|
|
746
|
+
}
|
|
747
|
+
get room() {
|
|
748
|
+
return this._room;
|
|
749
|
+
}
|
|
750
|
+
export() {
|
|
751
|
+
let result = {};
|
|
752
|
+
if (this.name !== void 0) {
|
|
753
|
+
result["name"] = this.name;
|
|
754
|
+
}
|
|
755
|
+
if (this.fromHour !== void 0) {
|
|
756
|
+
result["fromHour"] = this.fromHour;
|
|
757
|
+
}
|
|
758
|
+
if (this.toHour !== void 0) {
|
|
759
|
+
result["toHour"] = this.toHour;
|
|
760
|
+
}
|
|
761
|
+
if (this.fromDay !== void 0) {
|
|
762
|
+
result["fromDay"] = this.fromDay;
|
|
763
|
+
}
|
|
764
|
+
if (this.toDay !== void 0) {
|
|
765
|
+
result["toDay"] = this.toDay;
|
|
766
|
+
}
|
|
767
|
+
if (this.disabled !== void 0) {
|
|
768
|
+
result["disabled"] = this.disabled;
|
|
769
|
+
}
|
|
770
|
+
return result;
|
|
771
|
+
}
|
|
772
|
+
};
|
|
569
773
|
|
|
570
774
|
// src/decorators/RoomDecorator.ts
|
|
571
775
|
var registeredRooms = {};
|
|
@@ -808,7 +1012,7 @@ function getCommitmentById(id) {
|
|
|
808
1012
|
return;
|
|
809
1013
|
}
|
|
810
1014
|
}
|
|
811
|
-
function
|
|
1015
|
+
function getFixedRoutine() {
|
|
812
1016
|
return Object.values(fixedCommitments);
|
|
813
1017
|
}
|
|
814
1018
|
function getTemporaryCommitments() {
|
|
@@ -821,273 +1025,80 @@ function getTemporaryCommitments() {
|
|
|
821
1025
|
}
|
|
822
1026
|
|
|
823
1027
|
// src/functions/RoutineFunctions.ts
|
|
824
|
-
function
|
|
1028
|
+
function getCurrentRoutine() {
|
|
825
1029
|
let character_commitments = {};
|
|
826
|
-
let oltherCommitments = [];
|
|
827
1030
|
getTemporaryCommitments().reverse().forEach((c) => {
|
|
828
1031
|
if (!c.hidden) {
|
|
829
|
-
if (c.characters.length >
|
|
830
|
-
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id]);
|
|
1032
|
+
if (c.characters.length > 0) {
|
|
1033
|
+
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
|
|
831
1034
|
if (allAvailable) {
|
|
832
1035
|
c.characters.forEach((ch) => {
|
|
833
1036
|
character_commitments[ch.id] = c;
|
|
834
1037
|
});
|
|
835
1038
|
}
|
|
836
1039
|
} else {
|
|
837
|
-
|
|
1040
|
+
console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
|
|
838
1041
|
}
|
|
839
1042
|
}
|
|
840
1043
|
});
|
|
841
|
-
|
|
1044
|
+
getFixedRoutine().reverse().forEach((c) => {
|
|
842
1045
|
if (!c.hidden) {
|
|
843
|
-
if (c.characters.length >
|
|
844
|
-
c.characters.
|
|
845
|
-
|
|
1046
|
+
if (c.characters.length > 0) {
|
|
1047
|
+
let allAvailable = c.characters.every((ch) => !character_commitments[ch.id] || c.priority > character_commitments[ch.id].priority);
|
|
1048
|
+
if (allAvailable) {
|
|
1049
|
+
c.characters.forEach((ch) => {
|
|
846
1050
|
character_commitments[ch.id] = c;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
849
1053
|
} else {
|
|
850
|
-
|
|
1054
|
+
console.error(`[NQTR] The commitment ${c.id} has no characters assigned`);
|
|
851
1055
|
}
|
|
852
1056
|
}
|
|
853
1057
|
});
|
|
854
|
-
return Object.values(character_commitments)
|
|
1058
|
+
return Object.values(character_commitments);
|
|
855
1059
|
}
|
|
856
|
-
|
|
1060
|
+
|
|
1061
|
+
// src/classes/navigation/Room.ts
|
|
1062
|
+
var ROOM_CATEGORY = "__nqtr-room__";
|
|
1063
|
+
var RoomBaseModel = class extends pixiVn.StoredClassModel {
|
|
857
1064
|
/**
|
|
858
|
-
* @param
|
|
859
|
-
* @param
|
|
1065
|
+
* @param id The id of the room, it must be unique.
|
|
1066
|
+
* @param location The location where the room is.
|
|
1067
|
+
* @param props The properties of the room.
|
|
860
1068
|
*/
|
|
861
|
-
constructor(
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
this.
|
|
865
|
-
this.
|
|
866
|
-
this.
|
|
1069
|
+
constructor(id, location, props = {}) {
|
|
1070
|
+
var _a;
|
|
1071
|
+
super(ROOM_CATEGORY, id);
|
|
1072
|
+
this._location = location;
|
|
1073
|
+
this.defaultName = props.name || "";
|
|
1074
|
+
this._renderImage = props.renderImage;
|
|
1075
|
+
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
867
1076
|
this.defaultDisabled = props.disabled || false;
|
|
868
1077
|
this.defaultHidden = props.hidden || false;
|
|
869
1078
|
this._renderIcon = props.renderIcon;
|
|
870
|
-
this.
|
|
1079
|
+
this._isEntrance = props.isEntrance;
|
|
871
1080
|
}
|
|
872
1081
|
/**
|
|
873
|
-
* The
|
|
1082
|
+
* The location where the room is.
|
|
874
1083
|
*/
|
|
875
|
-
get
|
|
876
|
-
return this.
|
|
877
|
-
}
|
|
878
|
-
set name(value) {
|
|
879
|
-
this.setStorageProperty("name", value);
|
|
1084
|
+
get location() {
|
|
1085
|
+
return this._location;
|
|
880
1086
|
}
|
|
881
1087
|
/**
|
|
882
|
-
*
|
|
1088
|
+
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
883
1089
|
*/
|
|
884
|
-
get
|
|
885
|
-
return this.
|
|
886
|
-
}
|
|
887
|
-
set fromHour(value) {
|
|
888
|
-
this.setStorageProperty("fromHour", value);
|
|
1090
|
+
get isEntrance() {
|
|
1091
|
+
return this._isEntrance || false;
|
|
889
1092
|
}
|
|
890
1093
|
/**
|
|
891
|
-
* The
|
|
1094
|
+
* The name.
|
|
1095
|
+
* If you set undefined, it will return the initial value of name.
|
|
892
1096
|
*/
|
|
893
|
-
get
|
|
894
|
-
return this.getStorageProperty("
|
|
1097
|
+
get name() {
|
|
1098
|
+
return this.getStorageProperty("name") || this.defaultName;
|
|
895
1099
|
}
|
|
896
|
-
set
|
|
897
|
-
this.setStorageProperty("
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
901
|
-
*/
|
|
902
|
-
get fromDay() {
|
|
903
|
-
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
904
|
-
}
|
|
905
|
-
set fromDay(value) {
|
|
906
|
-
this.setStorageProperty("fromDay", value);
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
910
|
-
*/
|
|
911
|
-
get toDay() {
|
|
912
|
-
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
913
|
-
}
|
|
914
|
-
set toDay(value) {
|
|
915
|
-
this.setStorageProperty("toDay", value);
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Whether is disabled.
|
|
919
|
-
*/
|
|
920
|
-
get disabled() {
|
|
921
|
-
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
922
|
-
if (typeof value === "string") {
|
|
923
|
-
return pixiVn.getFlag(value);
|
|
924
|
-
}
|
|
925
|
-
return value;
|
|
926
|
-
}
|
|
927
|
-
set disabled(value) {
|
|
928
|
-
this.setStorageProperty("disabled", value);
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
932
|
-
*/
|
|
933
|
-
get hidden() {
|
|
934
|
-
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
935
|
-
return true;
|
|
936
|
-
}
|
|
937
|
-
if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {
|
|
938
|
-
return true;
|
|
939
|
-
}
|
|
940
|
-
if (!this.isExpired) {
|
|
941
|
-
return true;
|
|
942
|
-
}
|
|
943
|
-
let value = this.getStorageProperty("hidden") || this.defaultHidden;
|
|
944
|
-
if (typeof value === "string") {
|
|
945
|
-
return pixiVn.getFlag(value);
|
|
946
|
-
}
|
|
947
|
-
return value;
|
|
948
|
-
}
|
|
949
|
-
set hidden(value) {
|
|
950
|
-
this.setStorageProperty("hidden", value);
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* The function for rendering the icon of the activity.
|
|
954
|
-
*/
|
|
955
|
-
get renderIcon() {
|
|
956
|
-
let render = this._renderIcon;
|
|
957
|
-
if (render === void 0) {
|
|
958
|
-
return void 0;
|
|
959
|
-
}
|
|
960
|
-
if (typeof render === "function") {
|
|
961
|
-
return (props) => {
|
|
962
|
-
return render(this, props);
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
return (props) => render;
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* The function that is called when the activity is runned.
|
|
969
|
-
*/
|
|
970
|
-
get onRun() {
|
|
971
|
-
return (props) => {
|
|
972
|
-
return this._onRun(this, props);
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Whether the activity is a deadline.
|
|
977
|
-
* @returns Whether the activity is a deadline.
|
|
978
|
-
*/
|
|
979
|
-
isExpired() {
|
|
980
|
-
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
981
|
-
return true;
|
|
982
|
-
}
|
|
983
|
-
return false;
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* Export the activity properties.
|
|
987
|
-
* @returns The activity properties.
|
|
988
|
-
*/
|
|
989
|
-
export() {
|
|
990
|
-
return {
|
|
991
|
-
name: this.getStorageProperty("name") || this.defaultName,
|
|
992
|
-
fromHour: this.getStorageProperty("fromHour") || this.defaultFromHour,
|
|
993
|
-
toHour: this.getStorageProperty("toHour") || this.defaultToHour,
|
|
994
|
-
fromDay: this.getStorageProperty("fromDay") || this.defaultFromDay,
|
|
995
|
-
toDay: this.getStorageProperty("toDay") || this.defaultToDay,
|
|
996
|
-
disabled: this.getStorageProperty("disabled") || this.defaultDisabled,
|
|
997
|
-
hidden: this.getStorageProperty("hidden") || this.defaultHidden,
|
|
998
|
-
renderIcon: this._renderIcon
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
|
|
1003
|
-
// src/classes/navigation/ActivityRoom.ts
|
|
1004
|
-
var ActivityRoom = class extends ActivityStoredAbstract {
|
|
1005
|
-
constructor(id, room, onRun, props) {
|
|
1006
|
-
super(onRun, props);
|
|
1007
|
-
this._id = id;
|
|
1008
|
-
this._room = room;
|
|
1009
|
-
}
|
|
1010
|
-
setStorageProperty(_, __) {
|
|
1011
|
-
this._room.setActivity(this);
|
|
1012
|
-
}
|
|
1013
|
-
getStorageProperty(propertyName) {
|
|
1014
|
-
let activity = this._room.getActivityMemory(this.id);
|
|
1015
|
-
if (!activity || !activity.hasOwnProperty(propertyName)) {
|
|
1016
|
-
return void 0;
|
|
1017
|
-
}
|
|
1018
|
-
return activity[propertyName];
|
|
1019
|
-
}
|
|
1020
|
-
get id() {
|
|
1021
|
-
return this._id;
|
|
1022
|
-
}
|
|
1023
|
-
get room() {
|
|
1024
|
-
return this._room;
|
|
1025
|
-
}
|
|
1026
|
-
export() {
|
|
1027
|
-
let result = {};
|
|
1028
|
-
if (this.name !== void 0) {
|
|
1029
|
-
result["name"] = this.name;
|
|
1030
|
-
}
|
|
1031
|
-
if (this.fromHour !== void 0) {
|
|
1032
|
-
result["fromHour"] = this.fromHour;
|
|
1033
|
-
}
|
|
1034
|
-
if (this.toHour !== void 0) {
|
|
1035
|
-
result["toHour"] = this.toHour;
|
|
1036
|
-
}
|
|
1037
|
-
if (this.fromDay !== void 0) {
|
|
1038
|
-
result["fromDay"] = this.fromDay;
|
|
1039
|
-
}
|
|
1040
|
-
if (this.toDay !== void 0) {
|
|
1041
|
-
result["toDay"] = this.toDay;
|
|
1042
|
-
}
|
|
1043
|
-
if (this.disabled !== void 0) {
|
|
1044
|
-
result["disabled"] = this.disabled;
|
|
1045
|
-
}
|
|
1046
|
-
return result;
|
|
1047
|
-
}
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
// src/classes/navigation/Room.ts
|
|
1051
|
-
var ROOM_CATEGORY = "__nqtr-room__";
|
|
1052
|
-
var RoomBaseModel = class extends pixiVn.StoredClassModel {
|
|
1053
|
-
/**
|
|
1054
|
-
* @param id The id of the room, it must be unique.
|
|
1055
|
-
* @param location The location where the room is.
|
|
1056
|
-
* @param props The properties of the room.
|
|
1057
|
-
*/
|
|
1058
|
-
constructor(id, location, props = {}) {
|
|
1059
|
-
var _a;
|
|
1060
|
-
super(ROOM_CATEGORY, id);
|
|
1061
|
-
this._location = location;
|
|
1062
|
-
this.defaultName = props.name || "";
|
|
1063
|
-
this._renderImage = props.renderImage;
|
|
1064
|
-
this.defaultActivityIds = ((_a = props.defaultActivities) == null ? void 0 : _a.map((activity) => activity.id)) || [];
|
|
1065
|
-
this.defaultDisabled = props.disabled || false;
|
|
1066
|
-
this.defaultHidden = props.hidden || false;
|
|
1067
|
-
this._renderIcon = props.renderIcon;
|
|
1068
|
-
this._isEntrance = props.isEntrance;
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* The location where the room is.
|
|
1072
|
-
*/
|
|
1073
|
-
get location() {
|
|
1074
|
-
return this._location;
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Whether is an entrance room, so when the player enters in the location, it will be the first room to be shown.
|
|
1078
|
-
*/
|
|
1079
|
-
get isEntrance() {
|
|
1080
|
-
return this._isEntrance || false;
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* The name.
|
|
1084
|
-
* If you set undefined, it will return the initial value of name.
|
|
1085
|
-
*/
|
|
1086
|
-
get name() {
|
|
1087
|
-
return this.getStorageProperty("name") || this.defaultName;
|
|
1088
|
-
}
|
|
1089
|
-
set name(value) {
|
|
1090
|
-
this.setStorageProperty("name", value);
|
|
1100
|
+
set name(value) {
|
|
1101
|
+
this.setStorageProperty("name", value);
|
|
1091
1102
|
}
|
|
1092
1103
|
/**
|
|
1093
1104
|
* The function for rendering the image of the room.
|
|
@@ -1279,51 +1290,82 @@ var RoomBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
1279
1290
|
* @returns The character commitments of the room.
|
|
1280
1291
|
*/
|
|
1281
1292
|
getRoutine() {
|
|
1282
|
-
let commitments =
|
|
1293
|
+
let commitments = getCurrentRoutine();
|
|
1283
1294
|
return commitments.filter((c) => c.room.id === this.id);
|
|
1284
1295
|
}
|
|
1285
1296
|
};
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1297
|
+
var GOAL_CATEGORY = "__nqtr-goal__";
|
|
1298
|
+
var Goal = class extends pixiVn.StoredClassModel {
|
|
1299
|
+
constructor(id, props) {
|
|
1300
|
+
super(GOAL_CATEGORY, id);
|
|
1290
1301
|
this._description = props.description;
|
|
1291
|
-
this.
|
|
1292
|
-
this.
|
|
1302
|
+
this._need = props.need || 1;
|
|
1303
|
+
this._defaultHave = props.have || 0;
|
|
1293
1304
|
}
|
|
1305
|
+
/**
|
|
1306
|
+
* The description of the goal.
|
|
1307
|
+
*/
|
|
1294
1308
|
get description() {
|
|
1295
1309
|
return this._description;
|
|
1296
1310
|
}
|
|
1297
|
-
get
|
|
1311
|
+
get need() {
|
|
1312
|
+
return this._need;
|
|
1313
|
+
}
|
|
1314
|
+
get defaultHave() {
|
|
1315
|
+
return this._defaultHave;
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
var GoalStage = class extends Goal {
|
|
1319
|
+
constructor(id, stageId, props) {
|
|
1320
|
+
super(id, props);
|
|
1321
|
+
this._stageId = stageId;
|
|
1322
|
+
}
|
|
1323
|
+
get stageId() {
|
|
1324
|
+
return this._stageId;
|
|
1325
|
+
}
|
|
1326
|
+
set stageId(value) {
|
|
1327
|
+
this._stageId = value;
|
|
1328
|
+
}
|
|
1329
|
+
get have() {
|
|
1330
|
+
return this.getStorageProperty("have-" + this._stageId) || this.defaultHave;
|
|
1331
|
+
}
|
|
1332
|
+
set have(value) {
|
|
1333
|
+
if (!this._stageId) {
|
|
1334
|
+
console.error(`[NQTR] The stage id is not set for the goal ${this.id}, so the have value can't be set.`);
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
this.setStorageProperty("have-" + this._stageId, value);
|
|
1338
|
+
}
|
|
1339
|
+
get completed() {
|
|
1298
1340
|
return this.have >= this.need;
|
|
1299
1341
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1342
|
+
set completed(value) {
|
|
1343
|
+
if (value) {
|
|
1344
|
+
this.have = this.need;
|
|
1345
|
+
} else {
|
|
1346
|
+
console.warn(`[NQTR] The goal can't be set as not completed. You must edit the have value manually.`);
|
|
1347
|
+
}
|
|
1302
1348
|
}
|
|
1303
1349
|
find() {
|
|
1304
1350
|
this.have++;
|
|
1305
1351
|
}
|
|
1306
|
-
get export() {
|
|
1307
|
-
return {
|
|
1308
|
-
description: this.description,
|
|
1309
|
-
need: this.need,
|
|
1310
|
-
have: this.have
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
1352
|
};
|
|
1314
|
-
var
|
|
1315
|
-
var
|
|
1316
|
-
constructor(id,
|
|
1317
|
-
super(
|
|
1318
|
-
this._stages = stages;
|
|
1353
|
+
var STAGE_CATEGORY = "__nqtr-stage__";
|
|
1354
|
+
var Stage = class extends pixiVn.StoredClassModel {
|
|
1355
|
+
constructor(id, props) {
|
|
1356
|
+
super(STAGE_CATEGORY, id);
|
|
1319
1357
|
this._name = props.name || "";
|
|
1358
|
+
this._defaultGoals = props.goals || [];
|
|
1359
|
+
this._flags = props.flags || [];
|
|
1320
1360
|
this._description = props.description || "";
|
|
1321
|
-
this.
|
|
1322
|
-
this.
|
|
1323
|
-
this.
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1361
|
+
this._adviceDescription = props.adviceDescription || "";
|
|
1362
|
+
this._renderImage = props.renderImage;
|
|
1363
|
+
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1364
|
+
this._flagsRequiredToStart = props.flagsRequired || [];
|
|
1365
|
+
this._questsRequiredToStart = props.questsRequired || [];
|
|
1366
|
+
this._requestDescriptionToStart = props.requestDescription || "";
|
|
1367
|
+
this._onStart = props.onStart;
|
|
1368
|
+
this._onEnd = props.onEnd;
|
|
1327
1369
|
}
|
|
1328
1370
|
get name() {
|
|
1329
1371
|
return this._name;
|
|
@@ -1331,50 +1373,138 @@ var QuestBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
1331
1373
|
get description() {
|
|
1332
1374
|
return this._description;
|
|
1333
1375
|
}
|
|
1334
|
-
get
|
|
1335
|
-
return this.
|
|
1376
|
+
get adviceDescription() {
|
|
1377
|
+
return this._adviceDescription;
|
|
1336
1378
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1379
|
+
/**
|
|
1380
|
+
* The function for rendering the image of the stage.
|
|
1381
|
+
*/
|
|
1382
|
+
get renderImage() {
|
|
1383
|
+
let render = this._renderImage;
|
|
1384
|
+
if (render === void 0) {
|
|
1385
|
+
return void 0;
|
|
1386
|
+
}
|
|
1387
|
+
if (typeof render === "function") {
|
|
1388
|
+
return (props) => {
|
|
1389
|
+
return render(this, props);
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
return (props) => render;
|
|
1339
1393
|
}
|
|
1340
|
-
get
|
|
1341
|
-
return this.
|
|
1394
|
+
get defaultGoals() {
|
|
1395
|
+
return this._defaultGoals;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* The list of flags that the player must complete to finish the stage.
|
|
1399
|
+
*/
|
|
1400
|
+
get flags() {
|
|
1401
|
+
return this._flags;
|
|
1402
|
+
}
|
|
1403
|
+
get daysRequiredToStart() {
|
|
1404
|
+
return this._daysRequiredToStart || 0;
|
|
1405
|
+
}
|
|
1406
|
+
get flagsRequiredToStart() {
|
|
1407
|
+
return this._flagsRequiredToStart;
|
|
1408
|
+
}
|
|
1409
|
+
get questsRequiredToStart() {
|
|
1410
|
+
return this._questsRequiredToStart || [];
|
|
1411
|
+
}
|
|
1412
|
+
get requestDescriptionToStart() {
|
|
1413
|
+
return this._requestDescriptionToStart;
|
|
1414
|
+
}
|
|
1415
|
+
get onStart() {
|
|
1416
|
+
return this._onStart;
|
|
1417
|
+
}
|
|
1418
|
+
get onEnd() {
|
|
1419
|
+
return this._onEnd;
|
|
1342
1420
|
}
|
|
1343
1421
|
};
|
|
1344
|
-
var
|
|
1345
|
-
var StageBaseModel = class extends pixiVn.StoredClassModel {
|
|
1422
|
+
var StageQuest = class extends Stage {
|
|
1346
1423
|
constructor(id, props) {
|
|
1347
|
-
super(
|
|
1348
|
-
this._completed = false;
|
|
1349
|
-
this._active = false;
|
|
1350
|
-
this.defaultGoals = [];
|
|
1351
|
-
this._name = props.name || "";
|
|
1352
|
-
this._description = props.description || "";
|
|
1353
|
-
this._adviceDescription = props.adviceDescription || "";
|
|
1354
|
-
this._image = props.image || "";
|
|
1355
|
-
this._daysRequiredToStart = props.daysRequiredToStart;
|
|
1356
|
-
this._flagsRequired = props.flagsRequired;
|
|
1357
|
-
this._questsRequired = props.questsRequired;
|
|
1358
|
-
this._requestDescription = props.requestDescription || "";
|
|
1359
|
-
this._onStart = props.onStart;
|
|
1360
|
-
this._onEnd = props.onEnd;
|
|
1424
|
+
super(id, props);
|
|
1361
1425
|
}
|
|
1362
1426
|
get completed() {
|
|
1363
|
-
|
|
1427
|
+
let storedCompleted = this.getStorageProperty("completed");
|
|
1428
|
+
if (storedCompleted) {
|
|
1429
|
+
return storedCompleted;
|
|
1430
|
+
}
|
|
1431
|
+
if (!this.flags.every((flag) => pixiVn.getFlag(flag.flag))) {
|
|
1432
|
+
return false;
|
|
1433
|
+
}
|
|
1434
|
+
if (!this.goals.every((goal) => goal.completed)) {
|
|
1435
|
+
return false;
|
|
1436
|
+
}
|
|
1437
|
+
return true;
|
|
1364
1438
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1439
|
+
set completed(value) {
|
|
1440
|
+
this.setStorageProperty("completed", value);
|
|
1367
1441
|
}
|
|
1442
|
+
/**
|
|
1443
|
+
* The list of goals that the player needs to complete to finish the stage.
|
|
1444
|
+
*/
|
|
1368
1445
|
get goals() {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1446
|
+
return this.defaultGoals.map((goal) => {
|
|
1447
|
+
return new GoalStage(goal.id, this.id, goal);
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
get prevStageEndDay() {
|
|
1451
|
+
return this.getStorageProperty("prevStageEndDay");
|
|
1452
|
+
}
|
|
1453
|
+
set prevStageEndDay(value) {
|
|
1454
|
+
this.setStorageProperty("prevStageEndDay", value);
|
|
1455
|
+
}
|
|
1456
|
+
get startDay() {
|
|
1457
|
+
let prevStageEndDay = this.prevStageEndDay;
|
|
1458
|
+
if (prevStageEndDay === void 0) {
|
|
1459
|
+
return void 0;
|
|
1460
|
+
}
|
|
1461
|
+
return prevStageEndDay + this.daysRequiredToStart;
|
|
1462
|
+
}
|
|
1463
|
+
get canStart() {
|
|
1464
|
+
let daysRequired = this.daysRequiredToStart;
|
|
1465
|
+
if (daysRequired > 0) {
|
|
1466
|
+
let prevStageEndDay = this.prevStageEndDay;
|
|
1467
|
+
if (prevStageEndDay === void 0) {
|
|
1468
|
+
return false;
|
|
1469
|
+
}
|
|
1470
|
+
if (prevStageEndDay + daysRequired > TimeManager.currentDay) {
|
|
1471
|
+
return false;
|
|
1472
|
+
}
|
|
1372
1473
|
}
|
|
1373
|
-
|
|
1474
|
+
if (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => pixiVn.getFlag(flag.flag))) {
|
|
1475
|
+
return false;
|
|
1476
|
+
}
|
|
1477
|
+
if (this.questsRequiredToStart.length > 0 && !this.questsRequiredToStart.every(
|
|
1478
|
+
(q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber
|
|
1479
|
+
)) {
|
|
1480
|
+
return false;
|
|
1481
|
+
}
|
|
1482
|
+
return true;
|
|
1483
|
+
}
|
|
1484
|
+
get onStart() {
|
|
1485
|
+
if (this.daysRequiredToStart > 0) {
|
|
1486
|
+
this.prevStageEndDay = TimeManager.currentDay;
|
|
1487
|
+
}
|
|
1488
|
+
return super.onStart;
|
|
1489
|
+
}
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
// src/classes/quest/Quest.ts
|
|
1493
|
+
var QUEST_CATEGORY = "__nqtr-quest__";
|
|
1494
|
+
var Quest = class extends pixiVn.StoredClassModel {
|
|
1495
|
+
constructor(id, stages, props) {
|
|
1496
|
+
super(QUEST_CATEGORY, id);
|
|
1497
|
+
this._stages = stages;
|
|
1498
|
+
this._name = props.name || "";
|
|
1499
|
+
this._description = props.description || "";
|
|
1500
|
+
this._renderIcon = props.renderIcon;
|
|
1501
|
+
this._renderImage = props.renderImage;
|
|
1502
|
+
this._isInDevelopment = props.isInDevelopment || false;
|
|
1374
1503
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1504
|
+
get stages() {
|
|
1505
|
+
return this._stages.map((stage, index) => {
|
|
1506
|
+
return new StageQuest(stage.id, stage);
|
|
1507
|
+
});
|
|
1378
1508
|
}
|
|
1379
1509
|
get name() {
|
|
1380
1510
|
return this._name;
|
|
@@ -1382,39 +1512,110 @@ var StageBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
1382
1512
|
get description() {
|
|
1383
1513
|
return this._description;
|
|
1384
1514
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1515
|
+
/**
|
|
1516
|
+
* The function for rendering the icon of the quest.
|
|
1517
|
+
*/
|
|
1518
|
+
get renderIcon() {
|
|
1519
|
+
let render = this._renderIcon;
|
|
1520
|
+
if (render === void 0) {
|
|
1521
|
+
return void 0;
|
|
1522
|
+
}
|
|
1523
|
+
if (typeof render === "function") {
|
|
1524
|
+
return (props) => {
|
|
1525
|
+
return render(this, props);
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
return (props) => render;
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* The function for rendering the image of the quest.
|
|
1532
|
+
*/
|
|
1533
|
+
get renderImage() {
|
|
1534
|
+
let render = this._renderImage;
|
|
1535
|
+
if (render === void 0) {
|
|
1536
|
+
return void 0;
|
|
1537
|
+
}
|
|
1538
|
+
if (typeof render === "function") {
|
|
1539
|
+
return (props) => {
|
|
1540
|
+
return render(this, props);
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
return (props) => render;
|
|
1387
1544
|
}
|
|
1388
|
-
get
|
|
1389
|
-
return this.
|
|
1545
|
+
get isInDevelopment() {
|
|
1546
|
+
return this._isInDevelopment;
|
|
1390
1547
|
}
|
|
1391
|
-
get
|
|
1392
|
-
return this.
|
|
1548
|
+
get currentStageIndex() {
|
|
1549
|
+
return this.getStorageProperty("currentStageIndex");
|
|
1550
|
+
}
|
|
1551
|
+
set currentStageIndex(value) {
|
|
1552
|
+
this.setStorageProperty("currentStageIndex", value);
|
|
1393
1553
|
}
|
|
1394
|
-
get
|
|
1395
|
-
|
|
1554
|
+
get currentStage() {
|
|
1555
|
+
let index = this.currentStageIndex;
|
|
1556
|
+
if (index === void 0 || index >= this.stages.length) {
|
|
1557
|
+
return void 0;
|
|
1558
|
+
}
|
|
1559
|
+
return this.stages[index];
|
|
1396
1560
|
}
|
|
1397
|
-
get
|
|
1398
|
-
return this.
|
|
1561
|
+
get started() {
|
|
1562
|
+
return this.currentStageIndex !== void 0;
|
|
1399
1563
|
}
|
|
1400
|
-
get
|
|
1401
|
-
return this.
|
|
1564
|
+
get completed() {
|
|
1565
|
+
return this.currentStageIndex === this.stages.length;
|
|
1402
1566
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1567
|
+
start() {
|
|
1568
|
+
if (this.started) {
|
|
1569
|
+
console.warn(`[NQTR] Quest ${this.id} is already started`);
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
if (this.stages.length === 0) {
|
|
1573
|
+
console.error(`[NQTR] Quest ${this.id} has no stages`);
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
this.currentStageIndex = 0;
|
|
1577
|
+
let currentStage = this.currentStage;
|
|
1578
|
+
if (currentStage && currentStage.onStart) {
|
|
1579
|
+
return currentStage.onStart();
|
|
1580
|
+
} else {
|
|
1581
|
+
console.error(`[NQTR] Quest ${this.id} has no start stage`);
|
|
1582
|
+
}
|
|
1405
1583
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1584
|
+
tryToGoNextStage() {
|
|
1585
|
+
if (!this.started) {
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
if (this.completed) {
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
let currentStage = this.currentStage;
|
|
1592
|
+
let currentStageIndex = this.currentStageIndex;
|
|
1593
|
+
if (!currentStage || currentStageIndex === void 0) {
|
|
1594
|
+
console.error(`[NQTR] Quest ${this.id} has no current stage`);
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
if (currentStage.completed) {
|
|
1598
|
+
let nextStageIndex = currentStageIndex + 1;
|
|
1599
|
+
currentStageIndex = nextStageIndex;
|
|
1600
|
+
let nextStage = this.currentStage;
|
|
1601
|
+
if (currentStage && currentStage.onEnd) {
|
|
1602
|
+
currentStage.onEnd();
|
|
1603
|
+
}
|
|
1604
|
+
if (nextStage && nextStage.onStart) {
|
|
1605
|
+
return nextStage.onStart();
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1408
1608
|
}
|
|
1409
1609
|
};
|
|
1410
1610
|
|
|
1411
1611
|
exports.ActivityModel = ActivityModel;
|
|
1612
|
+
exports.ActivityRoom = ActivityRoom;
|
|
1412
1613
|
exports.CommitmentBaseModel = CommitmentBaseModel;
|
|
1413
1614
|
exports.Goal = Goal;
|
|
1414
1615
|
exports.LocationBaseModel = LocationBaseModel;
|
|
1415
1616
|
exports.MapBaseModel = MapBaseModel;
|
|
1416
|
-
exports.
|
|
1617
|
+
exports.Quest = Quest;
|
|
1417
1618
|
exports.RoomBaseModel = RoomBaseModel;
|
|
1418
|
-
exports.
|
|
1619
|
+
exports.Stage = Stage;
|
|
1419
1620
|
//# sourceMappingURL=out.js.map
|
|
1420
1621
|
//# sourceMappingURL=index.js.map
|