@drincs/nqtr 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{RoomInterface-D7qXKwBI.d.ts → RoomInterface-BglEhkQT.d.ts} +12 -12
- package/dist/{RoomInterface-C7Sg80EF.d.mts → RoomInterface-DsZAp6Pv.d.mts} +12 -12
- package/dist/{StageInterface-DmLgfrk4.d.mts → StageInterface-DJ7l0ubG.d.mts} +17 -17
- package/dist/{StageInterface-DmLgfrk4.d.ts → StageInterface-DJ7l0ubG.d.ts} +17 -17
- package/dist/classes/ActivityBaseModel.d.mts +4 -4
- package/dist/classes/ActivityBaseModel.d.ts +4 -4
- package/dist/classes/ActivityBaseModel.js +1 -1
- package/dist/classes/ActivityBaseModel.js.map +1 -1
- package/dist/classes/ActivityBaseModel.mjs +1 -1
- package/dist/classes/ActivityBaseModel.mjs.map +1 -1
- package/dist/classes/ActivityStoredClass.d.mts +4 -4
- package/dist/classes/ActivityStoredClass.d.ts +4 -4
- package/dist/classes/ActivityStoredClass.js +1 -1
- package/dist/classes/ActivityStoredClass.js.map +1 -1
- package/dist/classes/ActivityStoredClass.mjs +1 -1
- package/dist/classes/ActivityStoredClass.mjs.map +1 -1
- package/dist/classes/CommitmentBaseModel.d.mts +3 -3
- package/dist/classes/CommitmentBaseModel.d.ts +3 -3
- package/dist/classes/CommitmentBaseModel.js +1 -1
- package/dist/classes/CommitmentBaseModel.js.map +1 -1
- package/dist/classes/CommitmentBaseModel.mjs +1 -1
- package/dist/classes/CommitmentBaseModel.mjs.map +1 -1
- package/dist/classes/CommitmentStoredClass.d.mts +5 -5
- package/dist/classes/CommitmentStoredClass.d.ts +5 -5
- package/dist/classes/CommitmentStoredClass.js +1 -1
- package/dist/classes/CommitmentStoredClass.js.map +1 -1
- package/dist/classes/CommitmentStoredClass.mjs +1 -1
- package/dist/classes/CommitmentStoredClass.mjs.map +1 -1
- package/dist/classes/index.d.mts +6 -6
- package/dist/classes/index.d.ts +6 -6
- package/dist/classes/index.js +1 -1
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +1 -1
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/navigation/LocationBaseModel.d.mts +3 -3
- package/dist/classes/navigation/LocationBaseModel.d.ts +3 -3
- package/dist/classes/navigation/LocationBaseModel.js +1 -1
- package/dist/classes/navigation/LocationBaseModel.mjs +1 -1
- package/dist/classes/navigation/LocationStoredClass.d.mts +6 -6
- package/dist/classes/navigation/LocationStoredClass.d.ts +6 -6
- package/dist/classes/navigation/LocationStoredClass.js +1 -1
- package/dist/classes/navigation/LocationStoredClass.mjs +1 -1
- package/dist/classes/navigation/MapBaseModel.d.mts +2 -2
- package/dist/classes/navigation/MapBaseModel.d.ts +2 -2
- package/dist/classes/navigation/MapBaseModel.js +1 -1
- package/dist/classes/navigation/MapBaseModel.mjs +1 -1
- package/dist/classes/navigation/MapStoredClass.d.mts +5 -5
- package/dist/classes/navigation/MapStoredClass.d.ts +5 -5
- package/dist/classes/navigation/NavigationAbstractClass.d.mts +6 -6
- package/dist/classes/navigation/NavigationAbstractClass.d.ts +6 -6
- package/dist/classes/navigation/NavigationAbstractClass.js +1 -1
- package/dist/classes/navigation/NavigationAbstractClass.mjs +1 -1
- package/dist/classes/navigation/RoomBaseModel.d.mts +4 -4
- package/dist/classes/navigation/RoomBaseModel.d.ts +4 -4
- package/dist/classes/navigation/RoomBaseModel.js +1 -1
- package/dist/classes/navigation/RoomBaseModel.mjs +1 -1
- package/dist/classes/navigation/RoomStoredClass.d.mts +6 -6
- package/dist/classes/navigation/RoomStoredClass.d.ts +6 -6
- package/dist/classes/navigation/RoomStoredClass.js +1 -1
- package/dist/classes/navigation/RoomStoredClass.mjs +1 -1
- package/dist/classes/quest/QuestBaseModel.d.mts +3 -3
- package/dist/classes/quest/QuestBaseModel.d.ts +3 -3
- package/dist/classes/quest/QuestBaseModel.js +1 -1
- package/dist/classes/quest/QuestBaseModel.js.map +1 -1
- package/dist/classes/quest/QuestBaseModel.mjs +1 -1
- package/dist/classes/quest/QuestBaseModel.mjs.map +1 -1
- package/dist/classes/quest/QuestStoredClass.d.mts +14 -14
- package/dist/classes/quest/QuestStoredClass.d.ts +14 -14
- package/dist/classes/quest/QuestStoredClass.js +1 -1
- package/dist/classes/quest/QuestStoredClass.js.map +1 -1
- package/dist/classes/quest/QuestStoredClass.mjs +1 -1
- package/dist/classes/quest/QuestStoredClass.mjs.map +1 -1
- package/dist/classes/quest/StageBaseModel.d.mts +2 -2
- package/dist/classes/quest/StageBaseModel.d.ts +2 -2
- package/dist/classes/quest/StageBaseModel.js +1 -1
- package/dist/classes/quest/StageBaseModel.js.map +1 -1
- package/dist/classes/quest/StageBaseModel.mjs +1 -1
- package/dist/classes/quest/StageBaseModel.mjs.map +1 -1
- package/dist/classes/quest/StageStoredClass.d.mts +7 -7
- package/dist/classes/quest/StageStoredClass.d.ts +7 -7
- package/dist/classes/quest/StageStoredClass.js +1 -1
- package/dist/classes/quest/StageStoredClass.js.map +1 -1
- package/dist/classes/quest/StageStoredClass.mjs +1 -1
- package/dist/classes/quest/StageStoredClass.mjs.map +1 -1
- package/dist/decorators/ActivityDecorator.d.mts +5 -5
- package/dist/decorators/ActivityDecorator.d.ts +5 -5
- package/dist/decorators/CommitmentDecorator.d.mts +6 -6
- package/dist/decorators/CommitmentDecorator.d.ts +6 -6
- package/dist/decorators/QuestDecorator.d.mts +5 -5
- package/dist/decorators/QuestDecorator.d.ts +5 -5
- package/dist/decorators/RoomDecorator.d.mts +5 -5
- package/dist/decorators/RoomDecorator.d.ts +5 -5
- package/dist/decorators/index.d.mts +3 -3
- package/dist/decorators/index.d.ts +3 -3
- package/dist/index.d.mts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interface/ActivityInterface.d.mts +3 -3
- package/dist/interface/ActivityInterface.d.ts +3 -3
- package/dist/interface/CommitmentInterface.d.mts +2 -2
- package/dist/interface/CommitmentInterface.d.ts +2 -2
- package/dist/interface/CommitmentProps.d.mts +3 -3
- package/dist/interface/CommitmentProps.d.ts +3 -3
- package/dist/interface/index.d.mts +3 -3
- package/dist/interface/index.d.ts +3 -3
- package/dist/interface/navigation/LocationBaseModelProps.d.mts +3 -3
- package/dist/interface/navigation/LocationBaseModelProps.d.ts +3 -3
- package/dist/interface/navigation/LocationInterface.d.mts +2 -2
- package/dist/interface/navigation/LocationInterface.d.ts +2 -2
- package/dist/interface/navigation/MapBaseModelProps.d.mts +3 -3
- package/dist/interface/navigation/MapBaseModelProps.d.ts +3 -3
- package/dist/interface/navigation/MapInterface.d.mts +2 -2
- package/dist/interface/navigation/MapInterface.d.ts +2 -2
- package/dist/interface/navigation/NavigationAbstractClass.d.mts +5 -5
- package/dist/interface/navigation/NavigationAbstractClass.d.ts +5 -5
- package/dist/interface/navigation/RoomBaseModelProps.d.mts +3 -3
- package/dist/interface/navigation/RoomBaseModelProps.d.ts +3 -3
- package/dist/interface/navigation/RoomInterface.d.mts +2 -2
- package/dist/interface/navigation/RoomInterface.d.ts +2 -2
- package/dist/interface/quest/QuestInterface.d.mts +2 -2
- package/dist/interface/quest/QuestInterface.d.ts +2 -2
- package/dist/interface/quest/QuestProps.d.mts +4 -4
- package/dist/interface/quest/QuestProps.d.ts +4 -4
- package/dist/interface/quest/StageInterface.d.mts +2 -2
- package/dist/interface/quest/StageInterface.d.ts +2 -2
- package/dist/interface/quest/StageProps.d.mts +4 -4
- package/dist/interface/quest/StageProps.d.ts +4 -4
- package/dist/managers/NavigatorManager.d.mts +9 -9
- package/dist/managers/NavigatorManager.d.ts +9 -9
- package/dist/managers/QuestManager.d.mts +9 -9
- package/dist/managers/QuestManager.d.ts +9 -9
- package/dist/managers/QuestManager.js +1 -1
- package/dist/managers/QuestManager.js.map +1 -1
- package/dist/managers/QuestManager.mjs +1 -1
- package/dist/managers/QuestManager.mjs.map +1 -1
- package/dist/managers/RoutineManager.d.mts +12 -12
- package/dist/managers/RoutineManager.d.ts +12 -12
- package/dist/managers/RoutineManager.js +1 -1
- package/dist/managers/RoutineManager.mjs +1 -1
- package/dist/managers/index.d.mts +3 -3
- package/dist/managers/index.d.ts +3 -3
- package/dist/managers/index.js +1 -1
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/index.mjs +1 -1
- package/dist/managers/index.mjs.map +1 -1
- package/dist/nqtr.d.d.mts +195 -0
- package/dist/nqtr.d.d.ts +195 -0
- package/dist/nqtr.d.js +2 -0
- package/dist/nqtr.d.js.map +1 -0
- package/dist/nqtr.d.mjs +2 -0
- package/dist/nqtr.d.mjs.map +1 -0
- package/dist/types/OnRunEvent.d.mts +3 -2
- package/dist/types/OnRunEvent.d.ts +3 -2
- package/dist/types/QuestsRequired.d.mts +2 -2
- package/dist/types/QuestsRequired.d.ts +2 -2
- package/dist/types/index.d.mts +3 -2
- package/dist/types/index.d.ts +3 -2
- package/package.json +1 -2
- package/dist/override/ActivityInterface.d.mts +0 -28
- package/dist/override/ActivityInterface.d.ts +0 -28
- package/dist/override/ActivityInterface.js +0 -2
- package/dist/override/ActivityInterface.js.map +0 -1
- package/dist/override/ActivityInterface.mjs +0 -2
- package/dist/override/ActivityInterface.mjs.map +0 -1
- package/dist/override/CommitmentInterface.d.mts +0 -24
- package/dist/override/CommitmentInterface.d.ts +0 -24
- package/dist/override/CommitmentInterface.js +0 -2
- package/dist/override/CommitmentInterface.js.map +0 -1
- package/dist/override/CommitmentInterface.mjs +0 -2
- package/dist/override/CommitmentInterface.mjs.map +0 -1
- package/dist/override/GraphicItemInterface.d.mts +0 -19
- package/dist/override/GraphicItemInterface.d.ts +0 -19
- package/dist/override/GraphicItemInterface.js +0 -2
- package/dist/override/GraphicItemInterface.js.map +0 -1
- package/dist/override/GraphicItemInterface.mjs +0 -2
- package/dist/override/GraphicItemInterface.mjs.map +0 -1
- package/dist/override/LocationInterface.d.mts +0 -29
- package/dist/override/LocationInterface.d.ts +0 -29
- package/dist/override/LocationInterface.js +0 -2
- package/dist/override/LocationInterface.js.map +0 -1
- package/dist/override/LocationInterface.mjs +0 -2
- package/dist/override/LocationInterface.mjs.map +0 -1
- package/dist/override/MapInterface.d.mts +0 -12
- package/dist/override/MapInterface.d.ts +0 -12
- package/dist/override/MapInterface.js +0 -2
- package/dist/override/MapInterface.js.map +0 -1
- package/dist/override/MapInterface.mjs +0 -2
- package/dist/override/MapInterface.mjs.map +0 -1
- package/dist/override/OnRenderGraphicItemProps.d.mts +0 -19
- package/dist/override/OnRenderGraphicItemProps.d.ts +0 -19
- package/dist/override/OnRenderGraphicItemProps.js +0 -2
- package/dist/override/OnRenderGraphicItemProps.js.map +0 -1
- package/dist/override/OnRenderGraphicItemProps.mjs +0 -2
- package/dist/override/OnRenderGraphicItemProps.mjs.map +0 -1
- package/dist/override/OnRunProps.d.mts +0 -19
- package/dist/override/OnRunProps.d.ts +0 -19
- package/dist/override/OnRunProps.js +0 -2
- package/dist/override/OnRunProps.js.map +0 -1
- package/dist/override/OnRunProps.mjs +0 -2
- package/dist/override/OnRunProps.mjs.map +0 -1
- package/dist/override/OnStartEndStageQuest.d.mts +0 -19
- package/dist/override/OnStartEndStageQuest.d.ts +0 -19
- package/dist/override/OnStartEndStageQuest.js +0 -2
- package/dist/override/OnStartEndStageQuest.js.map +0 -1
- package/dist/override/OnStartEndStageQuest.mjs +0 -2
- package/dist/override/OnStartEndStageQuest.mjs.map +0 -1
- package/dist/override/QuestInterface.d.mts +0 -24
- package/dist/override/QuestInterface.d.ts +0 -24
- package/dist/override/QuestInterface.js +0 -2
- package/dist/override/QuestInterface.js.map +0 -1
- package/dist/override/QuestInterface.mjs +0 -2
- package/dist/override/QuestInterface.mjs.map +0 -1
- package/dist/override/RoomInterface.d.mts +0 -33
- package/dist/override/RoomInterface.d.ts +0 -33
- package/dist/override/RoomInterface.js +0 -2
- package/dist/override/RoomInterface.js.map +0 -1
- package/dist/override/RoomInterface.mjs +0 -2
- package/dist/override/RoomInterface.mjs.map +0 -1
- package/dist/override/StageInterface.d.mts +0 -34
- package/dist/override/StageInterface.d.ts +0 -34
- package/dist/override/StageInterface.js +0 -2
- package/dist/override/StageInterface.js.map +0 -1
- package/dist/override/StageInterface.mjs +0 -2
- package/dist/override/StageInterface.mjs.map +0 -1
- package/dist/override/index.d.mts +0 -12
- package/dist/override/index.d.ts +0 -12
- package/dist/override/index.js +0 -2
- package/dist/override/index.js.map +0 -1
- package/dist/override/index.mjs +0 -2
- package/dist/override/index.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as
|
|
1
|
+
import { L as LocationInterface, C as CommitmentInterface } from '../../RoomInterface-DsZAp6Pv.mjs';
|
|
2
2
|
import RoomBaseModelProps from '../../interface/navigation/RoomBaseModelProps.mjs';
|
|
3
3
|
import RoomStoredClass from './RoomStoredClass.mjs';
|
|
4
|
-
import '@drincs/nqtr
|
|
4
|
+
import '@drincs/nqtr';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '../../interface/ActivityInterface.mjs';
|
|
7
7
|
import '../../types/ExecutionType.mjs';
|
|
@@ -27,7 +27,7 @@ declare class RoomBaseModel extends RoomStoredClass {
|
|
|
27
27
|
* @param location The location where the room is.
|
|
28
28
|
* @param props The properties of the room.
|
|
29
29
|
*/
|
|
30
|
-
constructor(id: string, location:
|
|
30
|
+
constructor(id: string, location: LocationInterface, props?: RoomBaseModelProps);
|
|
31
31
|
private defaultName;
|
|
32
32
|
/**
|
|
33
33
|
* The name.
|
|
@@ -61,7 +61,7 @@ declare class RoomBaseModel extends RoomStoredClass {
|
|
|
61
61
|
* Get the character commitments of the room.
|
|
62
62
|
* @returns The character commitments of the room.
|
|
63
63
|
*/
|
|
64
|
-
get routine():
|
|
64
|
+
get routine(): CommitmentInterface[];
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export { RoomBaseModel as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as
|
|
1
|
+
import { L as LocationInterface, C as CommitmentInterface } from '../../RoomInterface-BglEhkQT.js';
|
|
2
2
|
import RoomBaseModelProps from '../../interface/navigation/RoomBaseModelProps.js';
|
|
3
3
|
import RoomStoredClass from './RoomStoredClass.js';
|
|
4
|
-
import '@drincs/nqtr
|
|
4
|
+
import '@drincs/nqtr';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '../../interface/ActivityInterface.js';
|
|
7
7
|
import '../../types/ExecutionType.js';
|
|
@@ -27,7 +27,7 @@ declare class RoomBaseModel extends RoomStoredClass {
|
|
|
27
27
|
* @param location The location where the room is.
|
|
28
28
|
* @param props The properties of the room.
|
|
29
29
|
*/
|
|
30
|
-
constructor(id: string, location:
|
|
30
|
+
constructor(id: string, location: LocationInterface, props?: RoomBaseModelProps);
|
|
31
31
|
private defaultName;
|
|
32
32
|
/**
|
|
33
33
|
* The name.
|
|
@@ -61,7 +61,7 @@ declare class RoomBaseModel extends RoomStoredClass {
|
|
|
61
61
|
* Get the character commitments of the room.
|
|
62
62
|
* @returns The character commitments of the room.
|
|
63
63
|
*/
|
|
64
|
-
get routine():
|
|
64
|
+
get routine(): CommitmentInterface[];
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export { RoomBaseModel as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var pixiVn=require('@drincs/pixi-vn');var m={};function _(a){try{let e=m[a];if(!e){console.error(`[NQTR] Room ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${a}`,e);return}}var C="___nqtr-current_room_memory___",g=class{get rooms(){return Object.values(m)}get locations(){let e={};return Object.values(m).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(m).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=pixiVn.storage.getVariable(C);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=_(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!_(e.id)){console.error(`[NQTR] The room ${e.id} is not registered, so it can't be set as current room`);return}pixiVn.storage.setVariable(C,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(m).forEach(([e,t])=>{t.clearExpiredActivities();});}};var I={},S={};function w(a){try{let e=I[a];if(!e){console.error(`[NQTR] Commitment ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${a}`,e);return}}var D="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return Object.values(S)}set fixedRoutine(e){e.forEach(t=>{S[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),S[t.id]=t;});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(D);return e?e.map(r=>w(r)).filter(r=>r!==undefined):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!w(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==undefined);pixiVn.storage.setVariable(D,t);}find(e){return w(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=pixiVn.storage.getVariable(D);r&&(r=r.filter(i=>!t.includes(i)),pixiVn.storage.setVariable(D,r));}clearExpiredRoutine(){Object.values(I).forEach(e=>{e.expired&&delete I[e.id];});}get currentRoutine(){let e={};return [...this.temporaryRoutine,...this.fixedRoutine].reverse().forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):console.error(`[NQTR] The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return H.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d="___nqtr-time_manager_data___";var c=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var p=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:o=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:u=[]}=e;c.minDayHours=t,c.maxDayHours=r,c.defaultTimeSpent=i,c.timeSlots=o,c.weekLength=n,s>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):c.weekendStartDay=s,u.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):c.weekDaysNames=u;}get minDayHours(){return c.minDayHours}get maxDayHours(){return c.maxDayHours}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get weekDaysNames(){return c.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(d,t);}get currentDay(){let e=pixiVn.storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var l=new p,H=new g,R=new y;var $={};function T(a){try{let e=$[a];if(!e){console.error(`[NQTR] Activity ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${a}`,e);return}}var v=class extends pixiVn.StoredClassModel{constructor(t,r,i=[]){super(t,r);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let i=this.excludedActivitiesScheduling;delete i[t],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.activeActivityScheduling;i[t]=r,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.excludedActivitiesScheduling;i[t]=r,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:i,fromDay:o,toDay:n}=r,s={};if(i){if(i.from>=i.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=i.from;}if(o===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),o&&n&&o>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(o&&(s.fromDay=o),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let u=this.additionalActivitiesIds;if(u.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}u.push(t.id),this.setStorageProperty("additionalActivitiesIds",u),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,o={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(o.toDay=i);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,o=this.excludedActivitiesIds;i.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),i=i.filter(u=>u!==n));}}),o.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),o=o.filter(u=>u!==n));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let o=T(r),{fromDay:n=o?.fromDay,fromHour:s=o?.fromHour,toDay:u=o?.toDay,toHour:E=o?.toHour}=i;o&&!(s&&E&&!l.nowIsBetween(s,E))&&!(n&&n>l.currentDay)&&!(u&&u<l.currentDay)&&t.push(o);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let o=T(r);o&&o.isActive&&!(i.toDay&&i.toDay>=l.currentDay)&&t.push(o);}),t}};var M="__nqtr-room__",b=class extends v{constructor(t,r,i=[]){super(M,t,i);this._location=r;}get routine(){return R.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};var Q=class extends b{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}get routine(){return R.currentRoutine.filter(e=>e.room.id===this.id)}};module.exports=Q;//# sourceMappingURL=RoomBaseModel.js.map
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn');var m={};function _(a){try{let e=m[a];if(!e){console.error(`[NQTR] Room ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${a}`,e);return}}var C="___nqtr-current_room_memory___",g=class{get rooms(){return Object.values(m)}get locations(){let e={};return Object.values(m).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(m).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=pixiVn.storage.getVariable(C);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=_(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!_(e.id)){console.error(`[NQTR] The room ${e.id} is not registered, so it can't be set as current room`);return}pixiVn.storage.setVariable(C,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(m).forEach(([e,t])=>{t.clearExpiredActivities();});}};var I={},S={};function w(a){try{let e=I[a];if(!e){console.error(`[NQTR] Commitment ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${a}`,e);return}}var D="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return Object.values(S)}set fixedRoutine(e){e.forEach(t=>{S[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),S[t.id]=t;});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(D);return e?e.map(r=>w(r)).filter(r=>r!==undefined):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!w(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==undefined);pixiVn.storage.setVariable(D,t);}find(e){return w(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=pixiVn.storage.getVariable(D);r&&(r=r.filter(i=>!t.includes(i)),pixiVn.storage.setVariable(D,r));}clearExpiredRoutine(){Object.values(I).forEach(e=>{e.expired&&delete I[e.id];});}get currentRoutine(){let e={};return [...this.temporaryRoutine,...this.fixedRoutine].reverse().forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):console.error(`[NQTR] The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return H.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d="___nqtr-time_manager_data___";var c=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var p=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:o=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:u=[]}=e;c.minDayHours=t,c.maxDayHours=r,c.defaultTimeSpent=i,c.timeSlots=o,c.weekLength=n,s>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):c.weekendStartDay=s,u.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):c.weekDaysNames=u;}get minDayHours(){return c.minDayHours}get maxDayHours(){return c.maxDayHours}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get weekDaysNames(){return c.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(d,t);}get currentDay(){let e=pixiVn.storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var l=new p,H=new g,R=new y;var P={};function T(a){try{let e=P[a];if(!e){console.error(`[NQTR] Activity ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${a}`,e);return}}var v=class extends pixiVn.StoredClassModel{constructor(t,r,i=[]){super(t,r);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let i=this.excludedActivitiesScheduling;delete i[t],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.activeActivityScheduling;i[t]=r,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.excludedActivitiesScheduling;i[t]=r,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:i,fromDay:o,toDay:n}=r,s={};if(i){if(i.from>=i.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=i.from;}if(o===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),o&&n&&o>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(o&&(s.fromDay=o),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let u=this.additionalActivitiesIds;if(u.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}u.push(t.id),this.setStorageProperty("additionalActivitiesIds",u),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,o={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(o.toDay=i);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,o=this.excludedActivitiesIds;i.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),i=i.filter(u=>u!==n));}}),o.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),o=o.filter(u=>u!==n));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let o=T(r),{fromDay:n=o?.fromDay,fromHour:s=o?.fromHour,toDay:u=o?.toDay,toHour:N=o?.toHour}=i;o&&!(s&&N&&!l.nowIsBetween(s,N))&&!(n&&n>l.currentDay)&&!(u&&u<l.currentDay)&&t.push(o);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let o=T(r);o&&o.isActive&&!(i.toDay&&i.toDay>=l.currentDay)&&t.push(o);}),t}};var M="__nqtr-room__",b=class extends v{constructor(t,r,i=[]){super(M,t,i);this._location=r;}get routine(){return R.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};var Q=class extends b{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?pixiVn.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}get routine(){return R.currentRoutine.filter(e=>e.room.id===this.id)}};module.exports=Q;//# sourceMappingURL=RoomBaseModel.js.map
|
|
2
2
|
//# sourceMappingURL=RoomBaseModel.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {getFlag,storage,StoredClassModel}from'@drincs/pixi-vn';var m={};function _(a){try{let e=m[a];if(!e){console.error(`[NQTR] Room ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${a}`,e);return}}var C="___nqtr-current_room_memory___",g=class{get rooms(){return Object.values(m)}get locations(){let e={};return Object.values(m).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(m).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=storage.getVariable(C);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=_(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!_(e.id)){console.error(`[NQTR] The room ${e.id} is not registered, so it can't be set as current room`);return}storage.setVariable(C,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(m).forEach(([e,t])=>{t.clearExpiredActivities();});}};var I={},S={};function w(a){try{let e=I[a];if(!e){console.error(`[NQTR] Commitment ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${a}`,e);return}}var D="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return Object.values(S)}set fixedRoutine(e){e.forEach(t=>{S[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),S[t.id]=t;});}get temporaryRoutine(){let e=storage.getVariable(D);return e?e.map(r=>w(r)).filter(r=>r!==undefined):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!w(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==undefined);storage.setVariable(D,t);}find(e){return w(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=storage.getVariable(D);r&&(r=r.filter(i=>!t.includes(i)),storage.setVariable(D,r));}clearExpiredRoutine(){Object.values(I).forEach(e=>{e.expired&&delete I[e.id];});}get currentRoutine(){let e={};return [...this.temporaryRoutine,...this.fixedRoutine].reverse().forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):console.error(`[NQTR] The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return H.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d="___nqtr-time_manager_data___";var c=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var p=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:o=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:u=[]}=e;c.minDayHours=t,c.maxDayHours=r,c.defaultTimeSpent=i,c.timeSlots=o,c.weekLength=n,s>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):c.weekendStartDay=s,u.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):c.weekDaysNames=u;}get minDayHours(){return c.minDayHours}get maxDayHours(){return c.maxDayHours}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get weekDaysNames(){return c.weekDaysNames}get currentHour(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(d,t);}get currentDay(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var l=new p,H=new g,R=new y;var $={};function T(a){try{let e=$[a];if(!e){console.error(`[NQTR] Activity ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${a}`,e);return}}var v=class extends StoredClassModel{constructor(t,r,i=[]){super(t,r);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let i=this.excludedActivitiesScheduling;delete i[t],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.activeActivityScheduling;i[t]=r,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.excludedActivitiesScheduling;i[t]=r,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:i,fromDay:o,toDay:n}=r,s={};if(i){if(i.from>=i.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=i.from;}if(o===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),o&&n&&o>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(o&&(s.fromDay=o),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let u=this.additionalActivitiesIds;if(u.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}u.push(t.id),this.setStorageProperty("additionalActivitiesIds",u),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,o={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(o.toDay=i);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,o=this.excludedActivitiesIds;i.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),i=i.filter(u=>u!==n));}}),o.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),o=o.filter(u=>u!==n));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let o=T(r),{fromDay:n=o?.fromDay,fromHour:s=o?.fromHour,toDay:u=o?.toDay,toHour:E=o?.toHour}=i;o&&!(s&&E&&!l.nowIsBetween(s,E))&&!(n&&n>l.currentDay)&&!(u&&u<l.currentDay)&&t.push(o);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let o=T(r);o&&o.isActive&&!(i.toDay&&i.toDay>=l.currentDay)&&t.push(o);}),t}};var M="__nqtr-room__",b=class extends v{constructor(t,r,i=[]){super(M,t,i);this._location=r;}get routine(){return R.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};var Q=class extends b{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}get routine(){return R.currentRoutine.filter(e=>e.room.id===this.id)}};export{Q as default};//# sourceMappingURL=RoomBaseModel.mjs.map
|
|
1
|
+
import {getFlag,storage,StoredClassModel}from'@drincs/pixi-vn';var m={};function _(a){try{let e=m[a];if(!e){console.error(`[NQTR] Room ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${a}`,e);return}}var C="___nqtr-current_room_memory___",g=class{get rooms(){return Object.values(m)}get locations(){let e={};return Object.values(m).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(m).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=storage.getVariable(C);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=_(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!_(e.id)){console.error(`[NQTR] The room ${e.id} is not registered, so it can't be set as current room`);return}storage.setVariable(C,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(m).forEach(([e,t])=>{t.clearExpiredActivities();});}};var I={},S={};function w(a){try{let e=I[a];if(!e){console.error(`[NQTR] Commitment ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${a}`,e);return}}var D="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return Object.values(S)}set fixedRoutine(e){e.forEach(t=>{S[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),S[t.id]=t;});}get temporaryRoutine(){let e=storage.getVariable(D);return e?e.map(r=>w(r)).filter(r=>r!==undefined):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!w(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==undefined);storage.setVariable(D,t);}find(e){return w(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=storage.getVariable(D);r&&(r=r.filter(i=>!t.includes(i)),storage.setVariable(D,r));}clearExpiredRoutine(){Object.values(I).forEach(e=>{e.expired&&delete I[e.id];});}get currentRoutine(){let e={};return [...this.temporaryRoutine,...this.fixedRoutine].reverse().forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):console.error(`[NQTR] The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return H.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d="___nqtr-time_manager_data___";var c=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var p=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:o=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:u=[]}=e;c.minDayHours=t,c.maxDayHours=r,c.defaultTimeSpent=i,c.timeSlots=o,c.weekLength=n,s>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):c.weekendStartDay=s,u.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):c.weekDaysNames=u;}get minDayHours(){return c.minDayHours}get maxDayHours(){return c.maxDayHours}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get weekDaysNames(){return c.weekDaysNames}get currentHour(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(d,t);}get currentDay(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var l=new p,H=new g,R=new y;var P={};function T(a){try{let e=P[a];if(!e){console.error(`[NQTR] Activity ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${a}`,e);return}}var v=class extends StoredClassModel{constructor(t,r,i=[]){super(t,r);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let i=this.excludedActivitiesScheduling;delete i[t],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.activeActivityScheduling;i[t]=r,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.excludedActivitiesScheduling;i[t]=r,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:i,fromDay:o,toDay:n}=r,s={};if(i){if(i.from>=i.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=i.from;}if(o===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),o&&n&&o>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(o&&(s.fromDay=o),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let u=this.additionalActivitiesIds;if(u.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}u.push(t.id),this.setStorageProperty("additionalActivitiesIds",u),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,o={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(o.toDay=i);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,o=this.excludedActivitiesIds;i.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),i=i.filter(u=>u!==n));}}),o.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<l.currentDay&&(this.removeActivityScheduling(n),o=o.filter(u=>u!==n));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let o=T(r),{fromDay:n=o?.fromDay,fromHour:s=o?.fromHour,toDay:u=o?.toDay,toHour:N=o?.toHour}=i;o&&!(s&&N&&!l.nowIsBetween(s,N))&&!(n&&n>l.currentDay)&&!(u&&u<l.currentDay)&&t.push(o);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let o=T(r);o&&o.isActive&&!(i.toDay&&i.toDay>=l.currentDay)&&t.push(o);}),t}};var M="__nqtr-room__",b=class extends v{constructor(t,r,i=[]){super(M,t,i);this._location=r;}get routine(){return R.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};var Q=class extends b{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}get routine(){return R.currentRoutine.filter(e=>e.room.id===this.id)}};export{Q as default};//# sourceMappingURL=RoomBaseModel.mjs.map
|
|
2
2
|
//# sourceMappingURL=RoomBaseModel.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { d as RoomBaseInternalInterface, L as
|
|
1
|
+
import ActivityInterface from '../../interface/ActivityInterface.mjs';
|
|
2
|
+
import { d as RoomBaseInternalInterface, L as LocationInterface, C as CommitmentInterface } from '../../RoomInterface-DsZAp6Pv.mjs';
|
|
3
3
|
import NavigationAbstractClass from './NavigationAbstractClass.mjs';
|
|
4
|
-
import '@drincs/nqtr
|
|
4
|
+
import '@drincs/nqtr';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '../../types/ExecutionType.mjs';
|
|
7
7
|
import '../../interface/navigation/NavigationAbstractClass.mjs';
|
|
@@ -15,9 +15,9 @@ declare class RoomStoredClass extends NavigationAbstractClass implements RoomBas
|
|
|
15
15
|
/**
|
|
16
16
|
* The location where the room is.
|
|
17
17
|
*/
|
|
18
|
-
_location:
|
|
19
|
-
get routine():
|
|
20
|
-
get location():
|
|
18
|
+
_location: LocationInterface, activities?: ActivityInterface[]);
|
|
19
|
+
get routine(): CommitmentInterface[];
|
|
20
|
+
get location(): LocationInterface;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export { RoomStoredClass as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { d as RoomBaseInternalInterface, L as
|
|
1
|
+
import ActivityInterface from '../../interface/ActivityInterface.js';
|
|
2
|
+
import { d as RoomBaseInternalInterface, L as LocationInterface, C as CommitmentInterface } from '../../RoomInterface-BglEhkQT.js';
|
|
3
3
|
import NavigationAbstractClass from './NavigationAbstractClass.js';
|
|
4
|
-
import '@drincs/nqtr
|
|
4
|
+
import '@drincs/nqtr';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '../../types/ExecutionType.js';
|
|
7
7
|
import '../../interface/navigation/NavigationAbstractClass.js';
|
|
@@ -15,9 +15,9 @@ declare class RoomStoredClass extends NavigationAbstractClass implements RoomBas
|
|
|
15
15
|
/**
|
|
16
16
|
* The location where the room is.
|
|
17
17
|
*/
|
|
18
|
-
_location:
|
|
19
|
-
get routine():
|
|
20
|
-
get location():
|
|
18
|
+
_location: LocationInterface, activities?: ActivityInterface[]);
|
|
19
|
+
get routine(): CommitmentInterface[];
|
|
20
|
+
get location(): LocationInterface;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export { RoomStoredClass as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var pixiVn=require('@drincs/pixi-vn');var l={};function
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn');var l={};function R(a){try{let e=l[a];if(!e){console.error(`[NQTR] Room ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${a}`,e);return}}var E="___nqtr-current_room_memory___",h=class{get rooms(){return Object.values(l)}get locations(){let e={};return Object.values(l).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(l).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=pixiVn.storage.getVariable(E);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=R(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!R(e.id)){console.error(`[NQTR] The room ${e.id} is not registered, so it can't be set as current room`);return}pixiVn.storage.setVariable(E,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(l).forEach(([e,t])=>{t.clearExpiredActivities();});}};var I={},b={};function S(a){try{let e=I[a];if(!e){console.error(`[NQTR] Commitment ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${a}`,e);return}}var x="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return Object.values(b)}set fixedRoutine(e){e.forEach(t=>{b[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),b[t.id]=t;});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(x);return e?e.map(r=>S(r)).filter(r=>r!==undefined):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!S(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==undefined);pixiVn.storage.setVariable(x,t);}find(e){return S(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=pixiVn.storage.getVariable(x);r&&(r=r.filter(i=>!t.includes(i)),pixiVn.storage.setVariable(x,r));}clearExpiredRoutine(){Object.values(I).forEach(e=>{e.expired&&delete I[e.id];});}get currentRoutine(){let e={};return [...this.temporaryRoutine,...this.fixedRoutine].reverse().forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):console.error(`[NQTR] The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return C.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d="___nqtr-time_manager_data___";var c=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var p=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:o=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:u=[]}=e;c.minDayHours=t,c.maxDayHours=r,c.defaultTimeSpent=i,c.timeSlots=o,c.weekLength=n,s>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):c.weekendStartDay=s,u.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):c.weekDaysNames=u;}get minDayHours(){return c.minDayHours}get maxDayHours(){return c.maxDayHours}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get weekDaysNames(){return c.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(d,t);}get currentDay(){let e=pixiVn.storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var m=new p,C=new h,k=new y;var H={};function D(a){try{let e=H[a];if(!e){console.error(`[NQTR] Activity ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${a}`,e);return}}var v=class extends pixiVn.StoredClassModel{constructor(t,r,i=[]){super(t,r);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let i=this.excludedActivitiesScheduling;delete i[t],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.activeActivityScheduling;i[t]=r,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.excludedActivitiesScheduling;i[t]=r,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:i,fromDay:o,toDay:n}=r,s={};if(i){if(i.from>=i.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=i.from;}if(o===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),o&&n&&o>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(o&&(s.fromDay=o),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let u=this.additionalActivitiesIds;if(u.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}u.push(t.id),this.setStorageProperty("additionalActivitiesIds",u),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,o={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(o.toDay=i);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,o=this.excludedActivitiesIds;i.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<m.currentDay&&(this.removeActivityScheduling(n),i=i.filter(u=>u!==n));}}),o.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<m.currentDay&&(this.removeActivityScheduling(n),o=o.filter(u=>u!==n));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let o=D(r),{fromDay:n=o?.fromDay,fromHour:s=o?.fromHour,toDay:u=o?.toDay,toHour:Q=o?.toHour}=i;o&&!(s&&Q&&!m.nowIsBetween(s,Q))&&!(n&&n>m.currentDay)&&!(u&&u<m.currentDay)&&t.push(o);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let o=D(r);o&&o.isActive&&!(i.toDay&&i.toDay>=m.currentDay)&&t.push(o);}),t}};var $="__nqtr-room__",T=class extends v{constructor(t,r,i=[]){super($,t,i);this._location=r;}get routine(){return k.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};module.exports=T;//# sourceMappingURL=RoomStoredClass.js.map
|
|
2
2
|
//# sourceMappingURL=RoomStoredClass.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {StoredClassModel,storage}from'@drincs/pixi-vn';var l={};function
|
|
1
|
+
import {StoredClassModel,storage}from'@drincs/pixi-vn';var l={};function R(a){try{let e=l[a];if(!e){console.error(`[NQTR] Room ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${a}`,e);return}}var E="___nqtr-current_room_memory___",h=class{get rooms(){return Object.values(l)}get locations(){let e={};return Object.values(l).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(l).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=storage.getVariable(E);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=R(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!R(e.id)){console.error(`[NQTR] The room ${e.id} is not registered, so it can't be set as current room`);return}storage.setVariable(E,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(l).forEach(([e,t])=>{t.clearExpiredActivities();});}};var I={},b={};function S(a){try{let e=I[a];if(!e){console.error(`[NQTR] Commitment ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${a}`,e);return}}var x="___nqtr-temporary_commitment___",y=class{get fixedRoutine(){return Object.values(b)}set fixedRoutine(e){e.forEach(t=>{b[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),b[t.id]=t;});}get temporaryRoutine(){let e=storage.getVariable(x);return e?e.map(r=>S(r)).filter(r=>r!==undefined):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!S(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==undefined);storage.setVariable(x,t);}find(e){return S(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=storage.getVariable(x);r&&(r=r.filter(i=>!t.includes(i)),storage.setVariable(x,r));}clearExpiredRoutine(){Object.values(I).forEach(e=>{e.expired&&delete I[e.id];});}get currentRoutine(){let e={};return [...this.temporaryRoutine,...this.fixedRoutine].reverse().forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(i=>!e[i.id]||t.priority>e[i.id].priority)&&t.characters.forEach(i=>{e[i.id]=t;}):console.error(`[NQTR] The commitment ${t.id} has no characters assigned`));}),Object.values(e)}get currentRoomRoutine(){return C.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var d="___nqtr-time_manager_data___";var c=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var p=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:o=[],weekLength:n=7,weekendStartDay:s=n-1,weekDaysNames:u=[]}=e;c.minDayHours=t,c.maxDayHours=r,c.defaultTimeSpent=i,c.timeSlots=o,c.weekLength=n,s>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${n}, so will be ignored`):c.weekendStartDay=s,u.length!==n?console.warn(`[NQTR] Week days names should be equal to week length ${n}, so will be ignored`):c.weekDaysNames=u;}get minDayHours(){return c.minDayHours}get maxDayHours(){return c.maxDayHours}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get weekDaysNames(){return c.weekDaysNames}get currentHour(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,storage.setVariable(d,t);}get currentDay(){let e=storage.getVariable(d)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=storage.getVariable(d)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,storage.setVariable(d,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDay%this.weekLength+1}get currentDayName(){let e=this.currentWeekDayNumber-1;return e>=this.weekDaysNames.length?(console.warn(`[NQTR] Week day name is not defined for day ${e}`,this.weekDaysNames),""):this.weekDaysNames[e]}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startHour,this.timeSlots[e+1].startHour))return e}return this.timeSlots.length-1}increaseHour(e=this.defaultTimeSpent){let t=this.currentHour+e;return t>=this.maxDayHours&&(this.increaseDay(),t=this.minDayHours+(t-this.maxDayHours)),this.currentHour=t,this.currentHour}increaseDay(e=this.minDayHours,t=1){let r=this.currentDay+t;return this.currentDay=r,this.currentHour=e,this.currentDay}nowIsBetween(e,t){e===undefined&&(e=this.minDayHours),t===undefined&&(t=this.maxDayHours);let r=this.currentHour;return e<t?r>=e&&r<t:r>=e||r<t}};var m=new p,C=new h,k=new y;var H={};function D(a){try{let e=H[a];if(!e){console.error(`[NQTR] Activity ${a} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${a}`,e);return}}var v=class extends StoredClassModel{constructor(t,r,i=[]){super(t,r);this.defaultActivities=i;}get defaultActivitiesIds(){return this.defaultActivities.map(t=>t.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(t){let r=this.activeActivityScheduling;delete r[t],this.setStorageProperty("activeActivityScheduling",r);let i=this.excludedActivitiesScheduling;delete i[t],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.activeActivityScheduling;i[t]=r,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let i=this.excludedActivitiesScheduling;i[t]=r,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{hours:i,fromDay:o,toDay:n}=r,s={};if(i){if(i.from>=i.to)throw new Error("[NQTR] The from hour must be less than the to hour.");s.fromHour=i.from;}if(o===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),n===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),o&&n&&o>=n)throw new Error("[NQTR] The from day must be less than the to day.");if(o&&(s.fromDay=o),n&&(s.toDay=n),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let u=this.additionalActivitiesIds;if(u.includes(t.id)){if(Object.keys(s).length){this.editActivityScheduling(t.id,s);return}else if(this.excludedActivitiesIds.includes(t.id)){this.removeActivityScheduling(t.id),console.log(`[NQTR] Activity with id ${t.id} was excluded, so it will be associated with this class again.`);return}console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}u.push(t.id),this.setStorageProperty("additionalActivitiesIds",u),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,o={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(o.toDay=i);let n=this.additionalActivitiesIds;if(n.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}n=n.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",n);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(o).length){this.editExcludedActivityScheduling(t.id,o);return}let s=this.excludedActivitiesIds;s.push(t.id),this.setStorageProperty("excludedActivitiesIds",s);}else console.warn(`[NQTR] Activity with id ${t.id} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,o=this.excludedActivitiesIds;i.forEach(n=>{if(n in t){let{toDay:s}=t[n];s&&s<m.currentDay&&(this.removeActivityScheduling(n),i=i.filter(u=>u!==n));}}),o.forEach(n=>{if(n in r){let{toDay:s}=r[n];s&&s<m.currentDay&&(this.removeActivityScheduling(n),o=o.filter(u=>u!==n));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let o=D(r),{fromDay:n=o?.fromDay,fromHour:s=o?.fromHour,toDay:u=o?.toDay,toHour:Q=o?.toHour}=i;o&&!(s&&Q&&!m.nowIsBetween(s,Q))&&!(n&&n>m.currentDay)&&!(u&&u<m.currentDay)&&t.push(o);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let o=D(r);o&&o.isActive&&!(i.toDay&&i.toDay>=m.currentDay)&&t.push(o);}),t}};var $="__nqtr-room__",T=class extends v{constructor(t,r,i=[]){super($,t,i);this._location=r;}get routine(){return k.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};export{T as default};//# sourceMappingURL=RoomStoredClass.mjs.map
|
|
2
2
|
//# sourceMappingURL=RoomStoredClass.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import QuestProps from '../../interface/quest/QuestProps.mjs';
|
|
2
|
-
import { S as
|
|
2
|
+
import { S as StageInterface } from '../../StageInterface-DJ7l0ubG.mjs';
|
|
3
3
|
import QuestStoredClass from './QuestStoredClass.mjs';
|
|
4
|
-
import '@drincs/nqtr
|
|
4
|
+
import '@drincs/nqtr';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
|
|
7
7
|
declare class QuestBaseModel extends QuestStoredClass {
|
|
8
|
-
constructor(id: string, stages:
|
|
8
|
+
constructor(id: string, stages: StageInterface[], props: QuestProps);
|
|
9
9
|
private _name;
|
|
10
10
|
/**
|
|
11
11
|
* The name of the quest.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import QuestProps from '../../interface/quest/QuestProps.js';
|
|
2
|
-
import { S as
|
|
2
|
+
import { S as StageInterface } from '../../StageInterface-DJ7l0ubG.js';
|
|
3
3
|
import QuestStoredClass from './QuestStoredClass.js';
|
|
4
|
-
import '@drincs/nqtr
|
|
4
|
+
import '@drincs/nqtr';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
|
|
7
7
|
declare class QuestBaseModel extends QuestStoredClass {
|
|
8
|
-
constructor(id: string, stages:
|
|
8
|
+
constructor(id: string, stages: StageInterface[], props: QuestProps);
|
|
9
9
|
private _name;
|
|
10
10
|
/**
|
|
11
11
|
* The name of the quest.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var pixiVn=require('@drincs/pixi-vn');var
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn');var g="__nqtr-quest__",n=class extends pixiVn.StoredClassModel{constructor(e,t,r={}){super(g,e);this._stages=t;this._onStart=r.onStart,this._onNextStage=r.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===undefined||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==undefined}get completed(){return this.currentStageIndex===undefined?false:this.currentStageIndex>this.stages.length-1}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){console.error(`[NQTR] Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&this.onStart(this,e),t.start(e);console.error(`[NQTR] Quest ${this.id} has no start stage`);}tryToGoNextStage(e){if(!this.started||this.completed)return false;let t=this.currentStage;return t?t.completed?this.goNextStage(e):false:(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}completeCurrentStageAndGoNext(e){let t=this.currentStage;return t?(t.completed=true,this.goNextStage(e)):(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}goNextStage(e){if(!this.started)return console.warn(`[NQTR] Quest ${this.id} is not started`),false;if(this.completed)return console.warn(`[NQTR] Quest ${this.id} is already completed`),false;let t=this.currentStage,r=this.currentStageIndex;if(!t||r===undefined)return console.error(`[NQTR] Quest ${this.id} has no current stage`),false;this.currentStageIndex=r+1,this.onNextStage&&this.onNextStage(this,e),t&&t.onEnd&&t.onEnd(t,e);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var s=class extends n{constructor(a,e,t){super(a,e,{onStart:t.onStart,onNextStage:t.onNextStage}),this._name=t.name||"",this._description=t.description||"",this._icon=t.icon,this._image=t.image,this._inDevelopment=t.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};module.exports=s;//# sourceMappingURL=QuestBaseModel.js.map
|
|
2
2
|
//# sourceMappingURL=QuestBaseModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts","../../../src/classes/quest/QuestBaseModel.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage","QuestBaseModel","stages"],"mappings":"mDAMA,IAAMA,CAAAA,CAAiB,iBACFC,CAArB,CAAA,cAA8CC,uBAAuD,CACpG,WACCC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,EACH,CAAA,CACD,KAAML,CAAAA,CAAAA,CAAgBG,CAAE,CAAA,CAZP,IAAAC,CAAAA,OAAAA,CAAAA,CAAAA,CAajB,IAAK,CAAA,QAAA,CAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC3B,CAEA,IAAI,MAAA,EAA2B,CAC9B,OAAO,IAAA,CAAK,OACb,CAEA,IAAI,iBAAA,EAAwC,CAC3C,OAAO,IAAA,CAAK,kBAA2B,CAAA,mBAAmB,CAC3D,CACA,IAAY,iBAAA,CAAkBC,CAA2B,CAAA,CACxD,IAAK,CAAA,kBAAA,CAAmB,mBAAqBA,CAAAA,CAAK,EACnD,CAEA,IAAI,YAA2C,EAAA,CAC9C,IAAIC,CAAAA,CAAQ,KAAK,iBACjB,CAAA,GAAI,EAAAA,CAAAA,GAAU,SAA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A,EAAQ,EAC3B,CAAA,IAAA,CAAK,aAAeA,CAAM,CAAA,WAAA,EAAe,EACzC,CAAA,IAAA,CAAK,KAAQA,CAAAA,CAAAA,CAAM,KACnB,IAAK,CAAA,MAAA,CAASA,CAAM,CAAA,KAAA,CACpB,IAAK,CAAA,cAAA,CAAiBA,EAAM,aAAiB,EAAA,MAC9C,CAEQ,KAAA,CAIR,IAAI,IAAA,EAAe,CAClB,OAAO,IAAK,CAAA,KACb,CAEQ,YAAA,CAIR,IAAI,WAAA,EAAsB,CACzB,OAAO,IAAA,CAAK,YACb,CAEQ,KAIR,CAAA,IAAI,IAA2B,EAAA,CAC9B,OAAO,IAAA,CAAK,KACb,CAEQ,MAIR,CAAA,IAAI,OAA4B,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,cAAA,CAIR,IAAI,aAAA,EAAyB,CAC5B,OAAO,IAAK,CAAA,cACb,CACD","file":"QuestBaseModel.js","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this as any as QuestInterface, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as any as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n","import { QuestProps, StageInterface } from \"../../interface\";\r\nimport QuestStoredClass from \"./QuestStoredClass\";\r\n\r\nexport default class QuestBaseModel extends QuestStoredClass {\r\n\tconstructor(id: string, stages: StageInterface[], props: QuestProps) {\r\n\t\tsuper(id, stages, { onStart: props.onStart, onNextStage: props.onNextStage });\r\n\t\tthis._name = props.name || \"\";\r\n\t\tthis._description = props.description || \"\";\r\n\t\tthis._icon = props.icon;\r\n\t\tthis._image = props.image;\r\n\t\tthis._inDevelopment = props.inDevelopment || false;\r\n\t}\r\n\r\n\tprivate _name: string;\r\n\t/**\r\n\t * The name of the quest.\r\n\t */\r\n\tget name(): string {\r\n\t\treturn this._name;\r\n\t}\r\n\r\n\tprivate _description: string;\r\n\t/**\r\n\t * The description of the quest.\r\n\t */\r\n\tget description(): string {\r\n\t\treturn this._description;\r\n\t}\r\n\r\n\tprivate _icon?: string;\r\n\t/**\r\n\t * Icon of the quest.\r\n\t */\r\n\tget icon(): string | undefined {\r\n\t\treturn this._icon;\r\n\t}\r\n\r\n\tprivate _image?: string;\r\n\t/**\r\n\t * Image of the quest.\r\n\t */\r\n\tget image(): string | undefined {\r\n\t\treturn this._image;\r\n\t}\r\n\r\n\tprivate _inDevelopment: boolean;\r\n\t/**\r\n\t * If the quest is in development.\r\n\t */\r\n\tget inDevelopment(): boolean {\r\n\t\treturn this._inDevelopment;\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts","../../../src/classes/quest/QuestBaseModel.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage","QuestBaseModel","stages"],"mappings":"mDAMA,IAAMA,CAAAA,CAAiB,iBACFC,CAArB,CAAA,cAA8CC,uBAAuD,CACjG,WACIC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,EACN,CAAA,CACE,KAAML,CAAAA,CAAAA,CAAgBG,CAAE,CAAA,CAZP,IAAAC,CAAAA,OAAAA,CAAAA,CAAAA,CAajB,IAAK,CAAA,QAAA,CAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC9B,CAEA,IAAI,MAAA,EAA2B,CAC3B,OAAO,IAAA,CAAK,OAChB,CAEA,IAAI,iBAAA,EAAwC,CACxC,OAAO,IAAA,CAAK,kBAA2B,CAAA,mBAAmB,CAC9D,CACA,IAAY,iBAAA,CAAkBC,CAA2B,CAAA,CACrD,IAAK,CAAA,kBAAA,CAAmB,mBAAqBA,CAAAA,CAAK,EACtD,CAEA,IAAI,YAA2C,EAAA,CAC3C,IAAIC,CAAAA,CAAQ,KAAK,iBACjB,CAAA,GAAI,EAAAA,CAAAA,GAAU,SAAaA,EAAAA,CAAAA,EAAS,KAAK,MAAO,CAAA,MAAA,CAAA,CAGhD,OAAO,IAAA,CAAK,MAAOA,CAAAA,CAAK,CAC5B,CAEA,IAAI,OAAA,EAAmB,CACnB,OAAO,IAAK,CAAA,iBAAA,GAAsB,SACtC,CAEA,IAAI,SAAqB,EAAA,CACrB,OAAI,IAAA,CAAK,iBAAsB,GAAA,SAAA,CACpB,KAEJ,CAAA,IAAA,CAAK,iBAAoB,CAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAS,CACzD,CAEA,IAAI,MAAkB,EAAA,CAClB,OAAO,IAAA,CAAK,kBAA4B,CAAA,QAAQ,CAAK,EA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B,OAAO,IAAA,CAAK,KACb,CAEQ,MAIR,CAAA,IAAI,OAA4B,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,cAAA,CAIR,IAAI,aAAA,EAAyB,CAC5B,OAAO,IAAK,CAAA,cACb,CACD","file":"QuestBaseModel.js","sourcesContent":["import { OnRunProps } from \"@drincs/nqtr\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n constructor(\n id: string,\n private readonly _stages: StageInterface[],\n props: {\n /**\n * The function that will be executed when the quest starts.\n */\n onStart?: (stage: QuestInterface, props: OnRunProps) => void;\n /**\n * The function that will be executed when a stage end in the quest.\n */\n onNextStage?: (stage: QuestInterface, props: OnRunProps) => void;\n } = {}\n ) {\n super(QUEST_CATEGORY, id);\n this._onStart = props.onStart;\n this._onNextStage = props.onNextStage;\n }\n\n get stages(): StageInterface[] {\n return this._stages;\n }\n\n get currentStageIndex(): number | undefined {\n return this.getStorageProperty<number>(\"currentStageIndex\");\n }\n private set currentStageIndex(value: number | undefined) {\n this.setStorageProperty(\"currentStageIndex\", value);\n }\n\n get currentStage(): StageInterface | undefined {\n let index = this.currentStageIndex;\n if (index === undefined || index >= this.stages.length) {\n return undefined;\n }\n return this.stages[index];\n }\n\n get started(): boolean {\n return this.currentStageIndex !== undefined;\n }\n\n get completed(): boolean {\n if (this.currentStageIndex === undefined) {\n return false;\n }\n return this.currentStageIndex > this.stages.length - 1;\n }\n\n get failed(): boolean {\n return this.getStorageProperty<boolean>(\"failed\") || false;\n }\n set failed(value: boolean) {\n this.setStorageProperty(\"failed\", value);\n }\n\n private _onStart?: (stage: QuestInterface, props: OnRunProps) => void;\n get onStart(): undefined | ((stage: QuestInterface, props: OnRunProps) => void) {\n return this._onStart;\n }\n\n private _onNextStage?: (stage: QuestInterface, props: OnRunProps) => void;\n get onNextStage(): undefined | ((stage: QuestInterface, props: OnRunProps) => void) {\n return this._onNextStage;\n }\n\n start(props: OnRunProps): void {\n if (this.started) {\n console.warn(`[NQTR] Quest ${this.id} is already started`);\n return;\n }\n if (this.stages.length === 0) {\n console.error(`[NQTR] Quest ${this.id} has no stages`);\n return;\n }\n this.currentStageIndex = 0;\n let currentStage = this.currentStage;\n if (currentStage && currentStage.start) {\n this.onStart && this.onStart(this as any as QuestInterface, props);\n return currentStage.start(props);\n } else {\n console.error(`[NQTR] Quest ${this.id} has no start stage`);\n }\n }\n\n tryToGoNextStage(props: OnRunProps): boolean {\n if (!this.started) {\n return false;\n }\n if (this.completed) {\n return false;\n }\n let currentStage = this.currentStage;\n if (!currentStage) {\n console.error(`[NQTR] Quest ${this.id} has no current stage`);\n return false;\n }\n if (currentStage.completed) {\n return this.goNextStage(props);\n }\n return false;\n }\n\n completeCurrentStageAndGoNext(props: OnRunProps): boolean {\n let currentStage = this.currentStage;\n if (!currentStage) {\n console.error(`[NQTR] Quest ${this.id} has no current stage`);\n return false;\n }\n currentStage.completed = true;\n return this.goNextStage(props);\n }\n\n goNextStage(props: OnRunProps): boolean {\n if (!this.started) {\n console.warn(`[NQTR] Quest ${this.id} is not started`);\n return false;\n }\n if (this.completed) {\n console.warn(`[NQTR] Quest ${this.id} is already completed`);\n return false;\n }\n let prevStage = this.currentStage;\n let currentStageIndex = this.currentStageIndex;\n if (!prevStage || currentStageIndex === undefined) {\n console.error(`[NQTR] Quest ${this.id} has no current stage`);\n return false;\n }\n this.currentStageIndex = currentStageIndex + 1;\n this.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n if (prevStage && prevStage.onEnd) {\n prevStage.onEnd(prevStage, props);\n }\n let nextCurrentStage = this.currentStage;\n if (nextCurrentStage) {\n (nextCurrentStage as any as StageStoredClass).inizialize();\n if (this.currentStageMustStart) {\n this.startCurrentStage(props);\n }\n }\n\n return true;\n }\n\n get currentStageMustStart(): boolean {\n let currentStage = this.currentStage;\n if (!currentStage) {\n return false;\n }\n return !currentStage.started && currentStage.canStart && !currentStage.completed;\n }\n\n startCurrentStage(props: OnRunProps): void {\n let newCurrentStage = this.currentStage;\n if (newCurrentStage && this.currentStageMustStart) {\n newCurrentStage.start(props);\n } else {\n console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n }\n }\n}\n","import { QuestProps, StageInterface } from \"../../interface\";\r\nimport QuestStoredClass from \"./QuestStoredClass\";\r\n\r\nexport default class QuestBaseModel extends QuestStoredClass {\r\n\tconstructor(id: string, stages: StageInterface[], props: QuestProps) {\r\n\t\tsuper(id, stages, { onStart: props.onStart, onNextStage: props.onNextStage });\r\n\t\tthis._name = props.name || \"\";\r\n\t\tthis._description = props.description || \"\";\r\n\t\tthis._icon = props.icon;\r\n\t\tthis._image = props.image;\r\n\t\tthis._inDevelopment = props.inDevelopment || false;\r\n\t}\r\n\r\n\tprivate _name: string;\r\n\t/**\r\n\t * The name of the quest.\r\n\t */\r\n\tget name(): string {\r\n\t\treturn this._name;\r\n\t}\r\n\r\n\tprivate _description: string;\r\n\t/**\r\n\t * The description of the quest.\r\n\t */\r\n\tget description(): string {\r\n\t\treturn this._description;\r\n\t}\r\n\r\n\tprivate _icon?: string;\r\n\t/**\r\n\t * Icon of the quest.\r\n\t */\r\n\tget icon(): string | undefined {\r\n\t\treturn this._icon;\r\n\t}\r\n\r\n\tprivate _image?: string;\r\n\t/**\r\n\t * Image of the quest.\r\n\t */\r\n\tget image(): string | undefined {\r\n\t\treturn this._image;\r\n\t}\r\n\r\n\tprivate _inDevelopment: boolean;\r\n\t/**\r\n\t * If the quest is in development.\r\n\t */\r\n\tget inDevelopment(): boolean {\r\n\t\treturn this._inDevelopment;\r\n\t}\r\n}\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {StoredClassModel}from'@drincs/pixi-vn';var
|
|
1
|
+
import {StoredClassModel}from'@drincs/pixi-vn';var g="__nqtr-quest__",n=class extends StoredClassModel{constructor(e,t,r={}){super(g,e);this._stages=t;this._onStart=r.onStart,this._onNextStage=r.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===undefined||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==undefined}get completed(){return this.currentStageIndex===undefined?false:this.currentStageIndex>this.stages.length-1}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){console.error(`[NQTR] Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&this.onStart(this,e),t.start(e);console.error(`[NQTR] Quest ${this.id} has no start stage`);}tryToGoNextStage(e){if(!this.started||this.completed)return false;let t=this.currentStage;return t?t.completed?this.goNextStage(e):false:(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}completeCurrentStageAndGoNext(e){let t=this.currentStage;return t?(t.completed=true,this.goNextStage(e)):(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}goNextStage(e){if(!this.started)return console.warn(`[NQTR] Quest ${this.id} is not started`),false;if(this.completed)return console.warn(`[NQTR] Quest ${this.id} is already completed`),false;let t=this.currentStage,r=this.currentStageIndex;if(!t||r===undefined)return console.error(`[NQTR] Quest ${this.id} has no current stage`),false;this.currentStageIndex=r+1,this.onNextStage&&this.onNextStage(this,e),t&&t.onEnd&&t.onEnd(t,e);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var s=class extends n{constructor(a,e,t){super(a,e,{onStart:t.onStart,onNextStage:t.onNextStage}),this._name=t.name||"",this._description=t.description||"",this._icon=t.icon,this._image=t.image,this._inDevelopment=t.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};export{s as default};//# sourceMappingURL=QuestBaseModel.mjs.map
|
|
2
2
|
//# sourceMappingURL=QuestBaseModel.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts","../../../src/classes/quest/QuestBaseModel.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage","QuestBaseModel","stages"],"mappings":"+CAMA,IAAMA,CAAAA,CAAiB,iBACFC,CAArB,CAAA,cAA8CC,gBAAuD,CACpG,WACCC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,EACH,CAAA,CACD,KAAML,CAAAA,CAAAA,CAAgBG,CAAE,CAAA,CAZP,IAAAC,CAAAA,OAAAA,CAAAA,CAAAA,CAajB,IAAK,CAAA,QAAA,CAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC3B,CAEA,IAAI,MAAA,EAA2B,CAC9B,OAAO,IAAA,CAAK,OACb,CAEA,IAAI,iBAAA,EAAwC,CAC3C,OAAO,IAAA,CAAK,kBAA2B,CAAA,mBAAmB,CAC3D,CACA,IAAY,iBAAA,CAAkBC,CAA2B,CAAA,CACxD,IAAK,CAAA,kBAAA,CAAmB,mBAAqBA,CAAAA,CAAK,EACnD,CAEA,IAAI,YAA2C,EAAA,CAC9C,IAAIC,CAAAA,CAAQ,KAAK,iBACjB,CAAA,GAAI,EAAAA,CAAAA,GAAU,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IAAA,EAAQ,EAC3B,CAAA,IAAA,CAAK,aAAeA,CAAM,CAAA,WAAA,EAAe,EACzC,CAAA,IAAA,CAAK,KAAQA,CAAAA,CAAAA,CAAM,KACnB,IAAK,CAAA,MAAA,CAASA,CAAM,CAAA,KAAA,CACpB,IAAK,CAAA,cAAA,CAAiBA,EAAM,aAAiB,EAAA,MAC9C,CAEQ,KAAA,CAIR,IAAI,IAAA,EAAe,CAClB,OAAO,IAAK,CAAA,KACb,CAEQ,YAAA,CAIR,IAAI,WAAA,EAAsB,CACzB,OAAO,IAAA,CAAK,YACb,CAEQ,KAIR,CAAA,IAAI,IAA2B,EAAA,CAC9B,OAAO,IAAA,CAAK,KACb,CAEQ,MAIR,CAAA,IAAI,OAA4B,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,cAAA,CAIR,IAAI,aAAA,EAAyB,CAC5B,OAAO,IAAK,CAAA,cACb,CACD","file":"QuestBaseModel.mjs","sourcesContent":["import { OnStartEndStageQuest } from \"@drincs/nqtr/dist/override\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n\tconstructor(\n\t\tid: string,\n\t\tprivate readonly _stages: StageInterface[],\n\t\tprops: {\n\t\t\t/**\n\t\t\t * The function that will be executed when the quest starts.\n\t\t\t */\n\t\t\tonStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t\t/**\n\t\t\t * The function that will be executed when a stage end in the quest.\n\t\t\t */\n\t\t\tonNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\t\t} = {}\n\t) {\n\t\tsuper(QUEST_CATEGORY, id);\n\t\tthis._onStart = props.onStart;\n\t\tthis._onNextStage = props.onNextStage;\n\t}\n\n\tget stages(): StageInterface[] {\n\t\treturn this._stages;\n\t}\n\n\tget currentStageIndex(): number | undefined {\n\t\treturn this.getStorageProperty<number>(\"currentStageIndex\");\n\t}\n\tprivate set currentStageIndex(value: number | undefined) {\n\t\tthis.setStorageProperty(\"currentStageIndex\", value);\n\t}\n\n\tget currentStage(): StageInterface | undefined {\n\t\tlet index = this.currentStageIndex;\n\t\tif (index === undefined || index >= this.stages.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.stages[index];\n\t}\n\n\tget started(): boolean {\n\t\treturn this.currentStageIndex !== undefined;\n\t}\n\n\tget completed(): boolean {\n\t\tif (this.currentStageIndex === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.currentStageIndex > this.stages.length - 1;\n\t}\n\n\tget failed(): boolean {\n\t\treturn this.getStorageProperty<boolean>(\"failed\") || false;\n\t}\n\tset failed(value: boolean) {\n\t\tthis.setStorageProperty(\"failed\", value);\n\t}\n\n\tprivate _onStart?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onStart(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onStart;\n\t}\n\n\tprivate _onNextStage?: (stage: QuestInterface, props: OnStartEndStageQuest) => void;\n\tget onNextStage(): undefined | ((stage: QuestInterface, props: OnStartEndStageQuest) => void) {\n\t\treturn this._onNextStage;\n\t}\n\n\tstart(props: OnStartEndStageQuest): void {\n\t\tif (this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already started`);\n\t\t\treturn;\n\t\t}\n\t\tif (this.stages.length === 0) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no stages`);\n\t\t\treturn;\n\t\t}\n\t\tthis.currentStageIndex = 0;\n\t\tlet currentStage = this.currentStage;\n\t\tif (currentStage && currentStage.start) {\n\t\t\tthis.onStart && this.onStart(this as any as QuestInterface, props);\n\t\t\treturn currentStage.start(props);\n\t\t} else {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no start stage`);\n\t\t}\n\t}\n\n\ttryToGoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\treturn false;\n\t\t}\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tif (currentStage.completed) {\n\t\t\treturn this.goNextStage(props);\n\t\t}\n\t\treturn false;\n\t}\n\n\tcompleteCurrentStageAndGoNext(props: OnStartEndStageQuest): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tcurrentStage.completed = true;\n\t\treturn this.goNextStage(props);\n\t}\n\n\tgoNextStage(props: OnStartEndStageQuest): boolean {\n\t\tif (!this.started) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is not started`);\n\t\t\treturn false;\n\t\t}\n\t\tif (this.completed) {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} is already completed`);\n\t\t\treturn false;\n\t\t}\n\t\tlet prevStage = this.currentStage;\n\t\tlet currentStageIndex = this.currentStageIndex;\n\t\tif (!prevStage || currentStageIndex === undefined) {\n\t\t\tconsole.error(`[NQTR] Quest ${this.id} has no current stage`);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentStageIndex = currentStageIndex + 1;\n\t\tthis.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n\t\tif (prevStage && prevStage.onEnd) {\n\t\t\tprevStage.onEnd(prevStage, props);\n\t\t}\n\t\tlet nextCurrentStage = this.currentStage;\n\t\tif (nextCurrentStage) {\n\t\t\t(nextCurrentStage as any as StageStoredClass).inizialize();\n\t\t\tif (this.currentStageMustStart) {\n\t\t\t\tthis.startCurrentStage(props);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tget currentStageMustStart(): boolean {\n\t\tlet currentStage = this.currentStage;\n\t\tif (!currentStage) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !currentStage.started && currentStage.canStart && !currentStage.completed;\n\t}\n\n\tstartCurrentStage(props: OnStartEndStageQuest): void {\n\t\tlet newCurrentStage = this.currentStage;\n\t\tif (newCurrentStage && this.currentStageMustStart) {\n\t\t\tnewCurrentStage.start(props);\n\t\t} else {\n\t\t\tconsole.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n\t\t}\n\t}\n}\n","import { QuestProps, StageInterface } from \"../../interface\";\r\nimport QuestStoredClass from \"./QuestStoredClass\";\r\n\r\nexport default class QuestBaseModel extends QuestStoredClass {\r\n\tconstructor(id: string, stages: StageInterface[], props: QuestProps) {\r\n\t\tsuper(id, stages, { onStart: props.onStart, onNextStage: props.onNextStage });\r\n\t\tthis._name = props.name || \"\";\r\n\t\tthis._description = props.description || \"\";\r\n\t\tthis._icon = props.icon;\r\n\t\tthis._image = props.image;\r\n\t\tthis._inDevelopment = props.inDevelopment || false;\r\n\t}\r\n\r\n\tprivate _name: string;\r\n\t/**\r\n\t * The name of the quest.\r\n\t */\r\n\tget name(): string {\r\n\t\treturn this._name;\r\n\t}\r\n\r\n\tprivate _description: string;\r\n\t/**\r\n\t * The description of the quest.\r\n\t */\r\n\tget description(): string {\r\n\t\treturn this._description;\r\n\t}\r\n\r\n\tprivate _icon?: string;\r\n\t/**\r\n\t * Icon of the quest.\r\n\t */\r\n\tget icon(): string | undefined {\r\n\t\treturn this._icon;\r\n\t}\r\n\r\n\tprivate _image?: string;\r\n\t/**\r\n\t * Image of the quest.\r\n\t */\r\n\tget image(): string | undefined {\r\n\t\treturn this._image;\r\n\t}\r\n\r\n\tprivate _inDevelopment: boolean;\r\n\t/**\r\n\t * If the quest is in development.\r\n\t */\r\n\tget inDevelopment(): boolean {\r\n\t\treturn this._inDevelopment;\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/quest/QuestStoredClass.ts","../../../src/classes/quest/QuestBaseModel.ts"],"names":["QUEST_CATEGORY","QuestStoredClass","StoredClassModel","id","_stages","props","value","index","currentStage","prevStage","currentStageIndex","nextCurrentStage","newCurrentStage","QuestBaseModel","stages"],"mappings":"+CAMA,IAAMA,CAAAA,CAAiB,iBACFC,CAArB,CAAA,cAA8CC,gBAAuD,CACjG,WACIC,CAAAA,CAAAA,CACiBC,EACjBC,CASI,CAAA,EACN,CAAA,CACE,KAAML,CAAAA,CAAAA,CAAgBG,CAAE,CAAA,CAZP,IAAAC,CAAAA,OAAAA,CAAAA,CAAAA,CAajB,IAAK,CAAA,QAAA,CAAWC,CAAM,CAAA,OAAA,CACtB,KAAK,YAAeA,CAAAA,CAAAA,CAAM,YAC9B,CAEA,IAAI,MAAA,EAA2B,CAC3B,OAAO,IAAA,CAAK,OAChB,CAEA,IAAI,iBAAA,EAAwC,CACxC,OAAO,IAAA,CAAK,kBAA2B,CAAA,mBAAmB,CAC9D,CACA,IAAY,iBAAA,CAAkBC,CAA2B,CAAA,CACrD,IAAK,CAAA,kBAAA,CAAmB,mBAAqBA,CAAAA,CAAK,EACtD,CAEA,IAAI,YAA2C,EAAA,CAC3C,IAAIC,CAAAA,CAAQ,KAAK,iBACjB,CAAA,GAAI,EAAAA,CAAAA,GAAU,SAAaA,EAAAA,CAAAA,EAAS,KAAK,MAAO,CAAA,MAAA,CAAA,CAGhD,OAAO,IAAA,CAAK,MAAOA,CAAAA,CAAK,CAC5B,CAEA,IAAI,OAAA,EAAmB,CACnB,OAAO,IAAK,CAAA,iBAAA,GAAsB,SACtC,CAEA,IAAI,SAAqB,EAAA,CACrB,OAAI,IAAA,CAAK,iBAAsB,GAAA,SAAA,CACpB,KAEJ,CAAA,IAAA,CAAK,iBAAoB,CAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAS,CACzD,CAEA,IAAI,MAAkB,EAAA,CAClB,OAAO,IAAA,CAAK,kBAA4B,CAAA,QAAQ,CA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,CAC9B,OAAO,IAAA,CAAK,KACb,CAEQ,MAIR,CAAA,IAAI,OAA4B,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,cAAA,CAIR,IAAI,aAAA,EAAyB,CAC5B,OAAO,IAAK,CAAA,cACb,CACD","file":"QuestBaseModel.mjs","sourcesContent":["import { OnRunProps } from \"@drincs/nqtr\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { QuestInterface, StageInterface } from \"../../interface\";\nimport { QuestBaseInternalInterface } from \"../../interface/quest/QuestInterface\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nconst QUEST_CATEGORY = \"__nqtr-quest__\";\nexport default class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {\n constructor(\n id: string,\n private readonly _stages: StageInterface[],\n props: {\n /**\n * The function that will be executed when the quest starts.\n */\n onStart?: (stage: QuestInterface, props: OnRunProps) => void;\n /**\n * The function that will be executed when a stage end in the quest.\n */\n onNextStage?: (stage: QuestInterface, props: OnRunProps) => void;\n } = {}\n ) {\n super(QUEST_CATEGORY, id);\n this._onStart = props.onStart;\n this._onNextStage = props.onNextStage;\n }\n\n get stages(): StageInterface[] {\n return this._stages;\n }\n\n get currentStageIndex(): number | undefined {\n return this.getStorageProperty<number>(\"currentStageIndex\");\n }\n private set currentStageIndex(value: number | undefined) {\n this.setStorageProperty(\"currentStageIndex\", value);\n }\n\n get currentStage(): StageInterface | undefined {\n let index = this.currentStageIndex;\n if (index === undefined || index >= this.stages.length) {\n return undefined;\n }\n return this.stages[index];\n }\n\n get started(): boolean {\n return this.currentStageIndex !== undefined;\n }\n\n get completed(): boolean {\n if (this.currentStageIndex === undefined) {\n return false;\n }\n return this.currentStageIndex > this.stages.length - 1;\n }\n\n get failed(): boolean {\n return this.getStorageProperty<boolean>(\"failed\") || false;\n }\n set failed(value: boolean) {\n this.setStorageProperty(\"failed\", value);\n }\n\n private _onStart?: (stage: QuestInterface, props: OnRunProps) => void;\n get onStart(): undefined | ((stage: QuestInterface, props: OnRunProps) => void) {\n return this._onStart;\n }\n\n private _onNextStage?: (stage: QuestInterface, props: OnRunProps) => void;\n get onNextStage(): undefined | ((stage: QuestInterface, props: OnRunProps) => void) {\n return this._onNextStage;\n }\n\n start(props: OnRunProps): void {\n if (this.started) {\n console.warn(`[NQTR] Quest ${this.id} is already started`);\n return;\n }\n if (this.stages.length === 0) {\n console.error(`[NQTR] Quest ${this.id} has no stages`);\n return;\n }\n this.currentStageIndex = 0;\n let currentStage = this.currentStage;\n if (currentStage && currentStage.start) {\n this.onStart && this.onStart(this as any as QuestInterface, props);\n return currentStage.start(props);\n } else {\n console.error(`[NQTR] Quest ${this.id} has no start stage`);\n }\n }\n\n tryToGoNextStage(props: OnRunProps): boolean {\n if (!this.started) {\n return false;\n }\n if (this.completed) {\n return false;\n }\n let currentStage = this.currentStage;\n if (!currentStage) {\n console.error(`[NQTR] Quest ${this.id} has no current stage`);\n return false;\n }\n if (currentStage.completed) {\n return this.goNextStage(props);\n }\n return false;\n }\n\n completeCurrentStageAndGoNext(props: OnRunProps): boolean {\n let currentStage = this.currentStage;\n if (!currentStage) {\n console.error(`[NQTR] Quest ${this.id} has no current stage`);\n return false;\n }\n currentStage.completed = true;\n return this.goNextStage(props);\n }\n\n goNextStage(props: OnRunProps): boolean {\n if (!this.started) {\n console.warn(`[NQTR] Quest ${this.id} is not started`);\n return false;\n }\n if (this.completed) {\n console.warn(`[NQTR] Quest ${this.id} is already completed`);\n return false;\n }\n let prevStage = this.currentStage;\n let currentStageIndex = this.currentStageIndex;\n if (!prevStage || currentStageIndex === undefined) {\n console.error(`[NQTR] Quest ${this.id} has no current stage`);\n return false;\n }\n this.currentStageIndex = currentStageIndex + 1;\n this.onNextStage && this.onNextStage(this as any as QuestInterface, props);\n if (prevStage && prevStage.onEnd) {\n prevStage.onEnd(prevStage, props);\n }\n let nextCurrentStage = this.currentStage;\n if (nextCurrentStage) {\n (nextCurrentStage as any as StageStoredClass).inizialize();\n if (this.currentStageMustStart) {\n this.startCurrentStage(props);\n }\n }\n\n return true;\n }\n\n get currentStageMustStart(): boolean {\n let currentStage = this.currentStage;\n if (!currentStage) {\n return false;\n }\n return !currentStage.started && currentStage.canStart && !currentStage.completed;\n }\n\n startCurrentStage(props: OnRunProps): void {\n let newCurrentStage = this.currentStage;\n if (newCurrentStage && this.currentStageMustStart) {\n newCurrentStage.start(props);\n } else {\n console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);\n }\n }\n}\n","import { QuestProps, StageInterface } from \"../../interface\";\r\nimport QuestStoredClass from \"./QuestStoredClass\";\r\n\r\nexport default class QuestBaseModel extends QuestStoredClass {\r\n\tconstructor(id: string, stages: StageInterface[], props: QuestProps) {\r\n\t\tsuper(id, stages, { onStart: props.onStart, onNextStage: props.onNextStage });\r\n\t\tthis._name = props.name || \"\";\r\n\t\tthis._description = props.description || \"\";\r\n\t\tthis._icon = props.icon;\r\n\t\tthis._image = props.image;\r\n\t\tthis._inDevelopment = props.inDevelopment || false;\r\n\t}\r\n\r\n\tprivate _name: string;\r\n\t/**\r\n\t * The name of the quest.\r\n\t */\r\n\tget name(): string {\r\n\t\treturn this._name;\r\n\t}\r\n\r\n\tprivate _description: string;\r\n\t/**\r\n\t * The description of the quest.\r\n\t */\r\n\tget description(): string {\r\n\t\treturn this._description;\r\n\t}\r\n\r\n\tprivate _icon?: string;\r\n\t/**\r\n\t * Icon of the quest.\r\n\t */\r\n\tget icon(): string | undefined {\r\n\t\treturn this._icon;\r\n\t}\r\n\r\n\tprivate _image?: string;\r\n\t/**\r\n\t * Image of the quest.\r\n\t */\r\n\tget image(): string | undefined {\r\n\t\treturn this._image;\r\n\t}\r\n\r\n\tprivate _inDevelopment: boolean;\r\n\t/**\r\n\t * If the quest is in development.\r\n\t */\r\n\tget inDevelopment(): boolean {\r\n\t\treturn this._inDevelopment;\r\n\t}\r\n}\r\n"]}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OnRunProps } from '@drincs/nqtr';
|
|
2
2
|
import { StoredClassModel } from '@drincs/pixi-vn';
|
|
3
|
-
import { b as QuestBaseInternalInterface, S as
|
|
3
|
+
import { b as QuestBaseInternalInterface, S as StageInterface, Q as QuestInterface } from '../../StageInterface-DJ7l0ubG.mjs';
|
|
4
4
|
|
|
5
5
|
declare class QuestStoredClass extends StoredClassModel implements QuestBaseInternalInterface {
|
|
6
6
|
private readonly _stages;
|
|
7
|
-
constructor(id: string, _stages:
|
|
7
|
+
constructor(id: string, _stages: StageInterface[], props?: {
|
|
8
8
|
/**
|
|
9
9
|
* The function that will be executed when the quest starts.
|
|
10
10
|
*/
|
|
11
|
-
onStart?: (stage:
|
|
11
|
+
onStart?: (stage: QuestInterface, props: OnRunProps) => void;
|
|
12
12
|
/**
|
|
13
13
|
* The function that will be executed when a stage end in the quest.
|
|
14
14
|
*/
|
|
15
|
-
onNextStage?: (stage:
|
|
15
|
+
onNextStage?: (stage: QuestInterface, props: OnRunProps) => void;
|
|
16
16
|
});
|
|
17
|
-
get stages():
|
|
17
|
+
get stages(): StageInterface[];
|
|
18
18
|
get currentStageIndex(): number | undefined;
|
|
19
19
|
private set currentStageIndex(value);
|
|
20
|
-
get currentStage():
|
|
20
|
+
get currentStage(): StageInterface | undefined;
|
|
21
21
|
get started(): boolean;
|
|
22
22
|
get completed(): boolean;
|
|
23
23
|
get failed(): boolean;
|
|
24
24
|
set failed(value: boolean);
|
|
25
25
|
private _onStart?;
|
|
26
|
-
get onStart(): undefined | ((stage:
|
|
26
|
+
get onStart(): undefined | ((stage: QuestInterface, props: OnRunProps) => void);
|
|
27
27
|
private _onNextStage?;
|
|
28
|
-
get onNextStage(): undefined | ((stage:
|
|
29
|
-
start(props:
|
|
30
|
-
tryToGoNextStage(props:
|
|
31
|
-
completeCurrentStageAndGoNext(props:
|
|
32
|
-
goNextStage(props:
|
|
28
|
+
get onNextStage(): undefined | ((stage: QuestInterface, props: OnRunProps) => void);
|
|
29
|
+
start(props: OnRunProps): void;
|
|
30
|
+
tryToGoNextStage(props: OnRunProps): boolean;
|
|
31
|
+
completeCurrentStageAndGoNext(props: OnRunProps): boolean;
|
|
32
|
+
goNextStage(props: OnRunProps): boolean;
|
|
33
33
|
get currentStageMustStart(): boolean;
|
|
34
|
-
startCurrentStage(props:
|
|
34
|
+
startCurrentStage(props: OnRunProps): void;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export { QuestStoredClass as default };
|