@drincs/nqtr 0.3.1 → 0.3.3

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pixiVn=require('@drincs/pixi-vn');var de=Object.defineProperty;var j=(n,e)=>{for(var t in e)de(n,t,{get:e[t],enumerable:true});};var U={};j(U,{ActivityBaseModel:()=>A,ActivityStoredClass:()=>m,CommitmentBaseModel:()=>Q,LocationBaseModel:()=>E,LocationStoredClass:()=>p,MapBaseModel:()=>N,MapStoredClass:()=>y,Quest:()=>H,RoomBaseModel:()=>C,RoomStoredClass:()=>S,Stage:()=>M});var W={};j(W,{navigator:()=>g,questsNotebook:()=>ce,routine:()=>D,timeTracker:()=>d});var f={};function Y(n){if(Array.isArray(n)){n.forEach(e=>Y(e));return}f[n.id]&&console.warn(`[NQTR] Room id ${n.id} already exists, it will be overwritten`),f[n.id]=n;}function V(n){try{let e=f[n];if(!e){console.error(`[NQTR] Room ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${n}`,e);return}}var Z="___nqtr-current_room_memory___",x=class{get rooms(){return Object.values(f)}get locations(){let e={};return Object.values(f).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(f).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=pixiVn.storage.getVariable(Z);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=V(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!V(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(Z,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(f).forEach(([e,t])=>{t.clearExpiredActivities();});}};var v={};function G(n){if(Array.isArray(n)){n.forEach(e=>G(e));return}v[n.id]&&console.warn(`[NQTR] Quest id ${n.id} already exists, it will be overwritten`),v[n.id]=n;}function ee(n){try{let e=v[n];if(!e){console.error(`[NQTR] Quest ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Quest ${n}`,e);return}}var R=class{get quests(){return Object.values(v)}get startedQuests(){return this.quests.filter(e=>e.started)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return ee(e)}startsStageMustBeStarted(e){Object.values(v).forEach(t=>{t.currentStageMustStart&&t.startCurrentStage(e);});}};var I={},k={};function F(n){if(Array.isArray(n)){n.forEach(e=>F(e));return}I[n.id]&&console.warn(`[NQTR] Commitment id ${n.id} already exists, it will be overwritten`),I[n.id]=n;}function B(n){try{let e=I[n];if(!e){console.error(`[NQTR] Commitment ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${n}`,e);return}}var L="___nqtr-temporary_commitment___",_=class{get fixedRoutine(){return Object.values(k)}set fixedRoutine(e){e.forEach(t=>{k[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),k[t.id]=t;});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(L);return e?e.map(r=>B(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(!B(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(L,t);}find(e){return B(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=pixiVn.storage.getVariable(L);r&&(r=r.filter(i=>!t.includes(i)),pixiVn.storage.setVariable(L,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 g.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var h="___nqtr-time_manager_data___";var u=class{static minDayHours=0;static maxDayHours=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static weekDaysNames=[]};var T=class{initialize(e){let{minDayHours:t=0,maxDayHours:r=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:o=7,weekendStartDay:s=o-1,weekDaysNames:c=[]}=e;u.minDayHours=t,u.maxDayHours=r,u.defaultTimeSpent=i,u.timeSlots=a,u.weekLength=o,s>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${o}, so will be ignored`):u.weekendStartDay=s,c.length!==o?console.warn(`[NQTR] Week days names should be equal to week length ${o}, so will be ignored`):u.weekDaysNames=c;}get minDayHours(){return u.minDayHours}get maxDayHours(){return u.maxDayHours}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get weekDaysNames(){return u.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(h)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(h)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(h,t);}get currentDay(){let e=pixiVn.storage.getVariable(h)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(h)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(h,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 d=new T,g=new x,D=new _,ce=new R;var le="__nqtr-activity__",m=class extends pixiVn.StoredClassModel{constructor(t,r,i,a=le){super(a,t);this._onRun=r;this._fromHour=i.fromHour,this._toHour=i.toHour,this._fromDay=i.fromDay,this._toDay=i.toDay;}_fromHour;get fromHour(){return this._fromHour}_toHour;get toHour(){return this._toHour}_fromDay;get fromDay(){return this._fromDay}_toDay;get toDay(){return this._toDay}get run(){return t=>this._onRun(this,t)}get expired(){return !!(this.toDay&&this.toDay<=d.currentDay)}get isActive(){return !(this.fromDay&&this.fromDay>d.currentDay||this.toDay&&this.toDay<d.currentDay||!d.nowIsBetween(this.fromHour,this.toHour))}};var A=class extends m{constructor(e,t,r){super(e,t,{fromHour:r.fromHour,toHour:r.toHour,fromDay:r.fromDay,toDay:r.toDay}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}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}};var fe="__nqtr-commitment__",P=class extends m{constructor(t,r,i,a,o,s,c){s=s||(()=>{});super(t,s,c,fe);this._characters=r;this._room=i;this.defaultExecutionType=a;this.defaultPriority=o;}get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(t){this.setStorageProperty("executionType",t);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(t){this.setStorageProperty("priority",t);}};var Q=class extends P{constructor(e,t,r,i){super(e,t?Array.isArray(t)?t:[t]:[],r,i.executionType||"interaction",i.priority||0,i.onRun,{fromHour:i.fromHour,toHour:i.toHour,fromDay:i.fromDay,toDay:i.toDay}),this._name=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}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(){if(this.fromDay&&this.fromDay>d.currentDay||!d.nowIsBetween(this.fromHour,this.toHour)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var K={};j(K,{getActivityById:()=>w,newQuest:()=>G,saveActivity:()=>ie,saveCommitment:()=>F,saveRoom:()=>Y});var z={};function ie(n){if(Array.isArray(n)){n.forEach(e=>{z[e.id]=e;});return}z[n.id]=n;}function w(n){try{let e=z[n];if(!e){console.error(`[NQTR] Activity ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${n}`,e);return}}var l=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:a,toDay:o}=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(a===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),o===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),a&&o&&a>=o)throw new Error("[NQTR] The from day must be less than the to day.");if(a&&(s.fromDay=a),o&&(s.toDay=o),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let c=this.additionalActivitiesIds;if(c.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}c.push(t.id),this.setStorageProperty("additionalActivitiesIds",c),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,a={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(a.toDay=i);let o=this.additionalActivitiesIds;if(o.includes(t.id)){if(Object.keys(a).length){this.editExcludedActivityScheduling(t.id,a);return}o=o.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",o);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(a).length){this.editExcludedActivityScheduling(t.id,a);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,a=this.excludedActivitiesIds;i.forEach(o=>{if(o in t){let{toDay:s}=t[o];s&&s<d.currentDay&&(this.removeActivityScheduling(o),i=i.filter(c=>c!==o));}}),a.forEach(o=>{if(o in r){let{toDay:s}=r[o];s&&s<d.currentDay&&(this.removeActivityScheduling(o),a=a.filter(c=>c!==o));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let a=w(r),{fromDay:o=a?.fromDay,fromHour:s=a?.fromHour,toDay:c=a?.toDay,toHour:J=a?.toHour}=i;a&&!(s&&J&&!d.nowIsBetween(s,J))&&!(o&&o>d.currentDay)&&!(c&&c<d.currentDay)&&t.push(a);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let a=w(r);a&&a.isActive&&!(i.toDay&&i.toDay>=d.currentDay)&&t.push(a);}),t}};var he="__nqtr-location__",p=class extends l{constructor(t,r,i=[]){super(he,t,i);this._map=r;}get map(){return this._map}get rooms(){return g.rooms.filter(t=>t.location.id===this.id)}};var E=class extends p{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",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);}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}};var pe="__nqtr-map__",y=class extends l{constructor(e,t=[]){super(pe,e,t);}get locations(){return g.locations.filter(e=>e.map.id===this.id)}};var N=class extends y{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var ye="__nqtr-room__",S=class extends l{constructor(t,r,i=[]){super(ye,t,i);this._location=r;}get routine(){return D.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};var C=class extends S{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 D.currentRoutine.filter(e=>e.room.id===this.id)}};var ve="__nqtr-quest__",O=class extends pixiVn.StoredClassModel{constructor(t,r,i={}){super(ve,t);this._stages=r;this._onStart=i.onStart,this._onNextStage=i.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===undefined||t>=this.stages.length))return this.stages[t]}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(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}start(t){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 r=this.currentStage;if(r&&r.start)return this.onStart&&this.onStart(this,t),r.start(t);console.error(`[NQTR] Quest ${this.id} has no start stage`);}tryToGoNextStage(t){if(!this.started||this.completed)return false;let r=this.currentStage;return r?r.completed?this.goNextStage(t):false:(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}completeCurrentStageAndGoNext(t){let r=this.currentStage;return r?(r.completed=true,this.goNextStage(t)):(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}goNextStage(t){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 r=this.currentStage,i=this.currentStageIndex;if(!r||i===undefined)return console.error(`[NQTR] Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&this.onNextStage(this,t),r&&r.onEnd&&r.onEnd(r,t);let a=this.currentStage;return a&&(a.inizialize(),this.currentStageMustStart&&this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var H=class extends O{constructor(e,t,r){super(e,t,{onStart:r.onStart,onNextStage:r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.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}};var be="__nqtr-stage__",q=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(be,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>d.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=d.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var M=class extends q{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>pixiVn.getFlag(e.flag))?false:super.canStart}};var se={};var ue={};var xe={...U,...K,...se,...W,...ue},er=xe;exports.ActivityBaseModel=A;exports.ActivityStoredClass=m;exports.CommitmentBaseModel=Q;exports.LocationBaseModel=E;exports.LocationStoredClass=p;exports.MapBaseModel=N;exports.MapStoredClass=y;exports.Quest=H;exports.RoomBaseModel=C;exports.RoomStoredClass=S;exports.Stage=M;exports.default=er;exports.getActivityById=w;exports.navigator=g;exports.newQuest=G;exports.questsNotebook=ce;exports.routine=D;exports.saveActivity=ie;exports.saveCommitment=F;exports.saveRoom=Y;exports.timeTracker=d;//# sourceMappingURL=index.js.map
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pixiVn=require('@drincs/pixi-vn');var de=Object.defineProperty;var j=(n,e)=>{for(var t in e)de(n,t,{get:e[t],enumerable:true});};var U={};j(U,{ActivityBaseModel:()=>w,ActivityStoredClass:()=>m,CommitmentBaseModel:()=>E,CommitmentStoredClass:()=>p,LocationBaseModel:()=>N,LocationStoredClass:()=>y,MapBaseModel:()=>O,MapStoredClass:()=>S,Quest:()=>q,QuestStoredClass:()=>I,RoomBaseModel:()=>H,RoomStoredClass:()=>v,Stage:()=>M,StageStoredClass:()=>b});var W={};j(W,{navigator:()=>g,questsNotebook:()=>ce,routine:()=>Q,timeTracker:()=>d});var f={};function Y(n){if(Array.isArray(n)){n.forEach(e=>Y(e));return}f[n.id]&&console.warn(`[NQTR] Room id ${n.id} already exists, it will be overwritten`),f[n.id]=n;}function V(n){try{let e=f[n];if(!e){console.error(`[NQTR] Room ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Room ${n}`,e);return}}var Z="___nqtr-current_room_memory___",T=class{get rooms(){return Object.values(f)}get locations(){let e={};return Object.values(f).forEach(t=>{e[t.location.id]=t.location;}),Object.values(e)}get maps(){let e={};return Object.values(f).forEach(t=>{e[t.location.map.id]=t.location.map;}),Object.values(e)}get currentRoom(){let e=pixiVn.storage.getVariable(Z);if(!e){console.error("[NQTR] The current room has not yet been set");return}let t=V(e);if(!t){console.error(`[NQTR] Current room ${e} not found`);return}return t}set currentRoom(e){if(!V(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(Z,e.id);}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Object.entries(f).forEach(([e,t])=>{t.clearExpiredActivities();});}};var x={};function G(n){if(Array.isArray(n)){n.forEach(e=>G(e));return}x[n.id]&&console.warn(`[NQTR] Quest id ${n.id} already exists, it will be overwritten`),x[n.id]=n;}function ee(n){try{let e=x[n];if(!e){console.error(`[NQTR] Quest ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Quest ${n}`,e);return}}var D=class{get quests(){return Object.values(x)}get startedQuests(){return this.quests.filter(e=>e.started)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return ee(e)}startsStageMustBeStarted(e){Object.values(x).forEach(t=>{t.currentStageMustStart&&t.startCurrentStage(e);});}};var R={},k={};function F(n){if(Array.isArray(n)){n.forEach(e=>F(e));return}R[n.id]&&console.warn(`[NQTR] Commitment id ${n.id} already exists, it will be overwritten`),R[n.id]=n;}function B(n){try{let e=R[n];if(!e){console.error(`[NQTR] Commitment ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Commitment ${n}`,e);return}}var L="___nqtr-temporary_commitment___",A=class{get fixedRoutine(){return Object.values(k)}set fixedRoutine(e){e.forEach(t=>{k[t.id]&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),k[t.id]=t;});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(L);return e?e.map(r=>B(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(!B(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(L,t);}find(e){return B(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(i=>i.id),r=pixiVn.storage.getVariable(L);r&&(r=r.filter(i=>!t.includes(i)),pixiVn.storage.setVariable(L,r));}clearExpiredRoutine(){Object.values(R).forEach(e=>{e.expired&&delete R[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 g.currentRoom?.routine||[]}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var h="___nqtr-time_manager_data___";var u=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:a=[],weekLength:o=7,weekendStartDay:s=o-1,weekDaysNames:c=[]}=e;u.minDayHours=t,u.maxDayHours=r,u.defaultTimeSpent=i,u.timeSlots=a,u.weekLength=o,s>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${o}, so will be ignored`):u.weekendStartDay=s,c.length!==o?console.warn(`[NQTR] Week days names should be equal to week length ${o}, so will be ignored`):u.weekDaysNames=c;}get minDayHours(){return u.minDayHours}get maxDayHours(){return u.maxDayHours}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get weekDaysNames(){return u.weekDaysNames}get currentHour(){let e=pixiVn.storage.getVariable(h)||{};return e.hasOwnProperty("currentHour")&&typeof e.currentHour=="number"?e.currentHour:this.minDayHours}set currentHour(e){let t=pixiVn.storage.getVariable(h)||{};typeof e=="number"?t.currentHour=e:delete t.currentHour,pixiVn.storage.setVariable(h,t);}get currentDay(){let e=pixiVn.storage.getVariable(h)||{};return e.hasOwnProperty("currentDay")&&typeof e.currentDay=="number"?e.currentDay:0}set currentDay(e){let t=pixiVn.storage.getVariable(h)||{};typeof e=="number"?t.currentDay=e:delete t.currentDay,pixiVn.storage.setVariable(h,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 d=new P,g=new T,Q=new A,ce=new D;var le="__nqtr-activity__",m=class extends pixiVn.StoredClassModel{constructor(t,r,i,a=le){super(a,t);this._onRun=r;this._fromHour=i.fromHour,this._toHour=i.toHour,this._fromDay=i.fromDay,this._toDay=i.toDay;}_fromHour;get fromHour(){return this._fromHour}_toHour;get toHour(){return this._toHour}_fromDay;get fromDay(){return this._fromDay}_toDay;get toDay(){return this._toDay}get run(){return t=>this._onRun(this,t)}get expired(){return !!(this.toDay&&this.toDay<=d.currentDay)}get isActive(){return !(this.fromDay&&this.fromDay>d.currentDay||this.toDay&&this.toDay<d.currentDay||!d.nowIsBetween(this.fromHour,this.toHour))}};var w=class extends m{constructor(e,t,r){super(e,t,{fromHour:r.fromHour,toHour:r.toHour,fromDay:r.fromDay,toDay:r.toDay}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}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}};var fe="__nqtr-commitment__",p=class extends m{constructor(t,r,i,a,o,s,c){a=a||(()=>{});super(t,a,c,fe);this._characters=r;this._room=i;this.defaultExecutionType=o;this.defaultPriority=s;}get characters(){return this._characters}get room(){return this._room}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(t){this.setStorageProperty("executionType",t);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(t){this.setStorageProperty("priority",t);}};var E=class extends p{constructor(e,t,r,i){super(e,t?Array.isArray(t)?t:[t]:[],r,i.onRun,i.executionType||"interaction",i.priority||0,{fromHour:i.fromHour,toHour:i.toHour,fromDay:i.fromDay,toDay:i.toDay}),this._name=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}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(){if(this.fromDay&&this.fromDay>d.currentDay||!d.nowIsBetween(this.fromHour,this.toHour)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var K={};j(K,{getActivityById:()=>C,newQuest:()=>G,saveActivity:()=>ie,saveCommitment:()=>F,saveRoom:()=>Y});var z={};function ie(n){if(Array.isArray(n)){n.forEach(e=>{z[e.id]=e;});return}z[n.id]=n;}function C(n){try{let e=z[n];if(!e){console.error(`[NQTR] Activity ${n} not found`);return}return e}catch(e){console.error(`[NQTR] Error while getting Activity ${n}`,e);return}}var l=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:a,toDay:o}=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(a===0&&console.warn("[NQTR] The from day must be greater than 0, so it will be ignored."),o===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),a&&o&&a>=o)throw new Error("[NQTR] The from day must be less than the to day.");if(a&&(s.fromDay=a),o&&(s.toDay=o),this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let c=this.additionalActivitiesIds;if(c.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}c.push(t.id),this.setStorageProperty("additionalActivitiesIds",c),Object.keys(s).length&&this.editActivityScheduling(t.id,s);}revoveActivity(t,r={}){let{toDay:i}=r,a={};i===0&&console.warn("[NQTR] The to day must be greater than 0, so it will be ignored."),i&&(a.toDay=i);let o=this.additionalActivitiesIds;if(o.includes(t.id)){if(Object.keys(a).length){this.editExcludedActivityScheduling(t.id,a);return}o=o.filter(s=>s!==t.id),this.setStorageProperty("additionalActivitiesIds",o);}else if(this.defaultActivitiesIds.includes(t.id)){if(Object.keys(a).length){this.editExcludedActivityScheduling(t.id,a);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,a=this.excludedActivitiesIds;i.forEach(o=>{if(o in t){let{toDay:s}=t[o];s&&s<d.currentDay&&(this.removeActivityScheduling(o),i=i.filter(c=>c!==o));}}),a.forEach(o=>{if(o in r){let{toDay:s}=r[o];s&&s<d.currentDay&&(this.removeActivityScheduling(o),a=a.filter(c=>c!==o));}});}get activities(){let t=[];return Object.entries(this.activeActivityScheduling).forEach(([r,i])=>{let a=C(r),{fromDay:o=a?.fromDay,fromHour:s=a?.fromHour,toDay:c=a?.toDay,toHour:J=a?.toHour}=i;a&&!(s&&J&&!d.nowIsBetween(s,J))&&!(o&&o>d.currentDay)&&!(c&&c<d.currentDay)&&t.push(a);}),Object.entries(this.excludedActivitiesScheduling).forEach(([r,i])=>{let a=C(r);a&&a.isActive&&!(i.toDay&&i.toDay>=d.currentDay)&&t.push(a);}),t}};var he="__nqtr-location__",y=class extends l{constructor(t,r,i=[]){super(he,t,i);this._map=r;}get map(){return this._map}get rooms(){return g.rooms.filter(t=>t.location.id===this.id)}};var N=class extends y{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",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);}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}};var pe="__nqtr-map__",S=class extends l{constructor(e,t=[]){super(pe,e,t);}get locations(){return g.locations.filter(e=>e.map.id===this.id)}};var O=class extends S{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var ye="__nqtr-room__",v=class extends l{constructor(t,r,i=[]){super(ye,t,i);this._location=r;}get routine(){return Q.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}};var H=class extends v{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 Q.currentRoutine.filter(e=>e.room.id===this.id)}};var ve="__nqtr-quest__",I=class extends pixiVn.StoredClassModel{constructor(t,r,i={}){super(ve,t);this._stages=r;this._onStart=i.onStart,this._onNextStage=i.onNextStage;}get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===undefined||t>=this.stages.length))return this.stages[t]}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(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onNextStage;get onNextStage(){return this._onNextStage}start(t){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 r=this.currentStage;if(r&&r.start)return this.onStart&&this.onStart(this,t),r.start(t);console.error(`[NQTR] Quest ${this.id} has no start stage`);}tryToGoNextStage(t){if(!this.started||this.completed)return false;let r=this.currentStage;return r?r.completed?this.goNextStage(t):false:(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}completeCurrentStageAndGoNext(t){let r=this.currentStage;return r?(r.completed=true,this.goNextStage(t)):(console.error(`[NQTR] Quest ${this.id} has no current stage`),false)}goNextStage(t){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 r=this.currentStage,i=this.currentStageIndex;if(!r||i===undefined)return console.error(`[NQTR] Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onNextStage&&this.onNextStage(this,t),r&&r.onEnd&&r.onEnd(r,t);let a=this.currentStage;return a&&(a.inizialize(),this.currentStageMustStart&&this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var q=class extends I{constructor(e,t,r){super(e,t,{onStart:r.onStart,onNextStage:r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.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}};var be="__nqtr-stage__",b=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(be,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._daysRequiredToStart=t.daysRequiredToStart,this._questsRequiredToStart=t.questsRequiredToStart||[];}_onStart;get onStart(){return this._onStart}_onEnd;get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get prevStageEndDay(){return this.getStorageProperty("prevStageEndDay")}set prevStageEndDay(e){this.setStorageProperty("prevStageEndDay",e);}get startDay(){let e=this.prevStageEndDay;if(e!==undefined)return e+this.daysRequiredToStart}get canStart(){let e=this.daysRequiredToStart;if(e>0){let t=this.prevStageEndDay;if(t===undefined||t+e>d.currentDay)return false}return !(this.questsRequiredToStart.length>0&&!this.questsRequiredToStart.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.daysRequiredToStart>0&&(this.prevStageEndDay=d.currentDay,console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`));}start(e){this.canStart?(this.started=true,this.onStart&&this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_daysRequiredToStart;get daysRequiredToStart(){return this._daysRequiredToStart||0}_questsRequiredToStart;get questsRequiredToStart(){return this._questsRequiredToStart||[]}};var M=class extends b{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,daysRequiredToStart:t.daysRequiredToStart,questsRequiredToStart:t.questsRequiredToStart}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequiredToStart=t.flagsRequiredToStart||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequiredToStart;get flagsRequiredToStart(){return this._flagsRequiredToStart}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequiredToStart.length>0&&!this.flagsRequiredToStart.every(e=>pixiVn.getFlag(e.flag))?false:super.canStart}};var se={};var ue={};var xe={...U,...K,...se,...W,...ue},ir=xe;exports.ActivityBaseModel=w;exports.ActivityStoredClass=m;exports.CommitmentBaseModel=E;exports.CommitmentStoredClass=p;exports.LocationBaseModel=N;exports.LocationStoredClass=y;exports.MapBaseModel=O;exports.MapStoredClass=S;exports.Quest=q;exports.QuestStoredClass=I;exports.RoomBaseModel=H;exports.RoomStoredClass=v;exports.Stage=M;exports.StageStoredClass=b;exports.default=ir;exports.getActivityById=C;exports.navigator=g;exports.newQuest=G;exports.questsNotebook=ce;exports.routine=Q;exports.saveActivity=ie;exports.saveCommitment=F;exports.saveRoom=Y;exports.timeTracker=d;//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map