@drincs/nqtr 0.5.2 → 0.5.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/{RoomInterface--jctVS2T.d.mts → RoomInterface-B6ryEuU-.d.mts} +2 -2
- package/dist/{RoomInterface-BfsHYFLJ.d.ts → RoomInterface-C_Dbpef2.d.ts} +2 -2
- package/dist/classes/index.cjs +1 -1
- package/dist/classes/index.cjs.map +1 -1
- package/dist/classes/index.d.mts +5 -3
- package/dist/classes/index.d.ts +5 -3
- package/dist/classes/index.mjs +1 -1
- package/dist/classes/index.mjs.map +1 -1
- package/dist/decorators/index.d.mts +1 -1
- package/dist/decorators/index.d.ts +1 -1
- package/dist/{index-B1y3qV-4.d.ts → index-DgRUEShD.d.ts} +1 -1
- package/dist/{index-D7Oi8Goi.d.mts → index-DnY50udK.d.mts} +1 -1
- package/dist/{index-CoygDiva.d.mts → index-DuUQHHHa.d.mts} +1 -1
- package/dist/{index-BjAF_78_.d.ts → index-Q2x0LXsj.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interface/index.d.mts +2 -2
- package/dist/interface/index.d.ts +2 -2
- package/dist/managers/index.cjs +1 -1
- package/dist/managers/index.cjs.map +1 -1
- package/dist/managers/index.d.mts +2 -2
- package/dist/managers/index.d.ts +2 -2
- package/dist/managers/index.mjs +1 -1
- package/dist/managers/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface
|
|
1
|
+
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface-B6ryEuU-.mjs';
|
|
2
2
|
import { Q as QuestInterface } from '../StageInterface-C1Zfcpk3.mjs';
|
|
3
3
|
import '@drincs/nqtr';
|
|
4
4
|
import '@drincs/pixi-vn';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface-
|
|
1
|
+
import { A as ActivityInterface, C as CommitmentInterface, L as LocationInterface, M as MapInterface, R as RoomInterface } from '../RoomInterface-C_Dbpef2.js';
|
|
2
2
|
import { Q as QuestInterface } from '../StageInterface-C1Zfcpk3.js';
|
|
3
3
|
import '@drincs/nqtr';
|
|
4
4
|
import '@drincs/pixi-vn';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface-
|
|
1
|
+
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface-C_Dbpef2.js';
|
|
2
2
|
import { OnRunProps } from '@drincs/nqtr';
|
|
3
3
|
import { Q as QuestInterface } from './StageInterface-C1Zfcpk3.js';
|
|
4
4
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, A as ActivityInterface } from './RoomInterface
|
|
1
|
+
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, A as ActivityInterface } from './RoomInterface-B6ryEuU-.mjs';
|
|
2
2
|
import { E as ExecutionType, a as OnRunEvent, Q as QuestInterface, d as QuestsRequiredType, S as StageInterface } from './StageInterface-C1Zfcpk3.mjs';
|
|
3
3
|
|
|
4
4
|
interface ActivityProps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface
|
|
1
|
+
import { C as CommitmentInterface, R as RoomInterface, L as LocationInterface, M as MapInterface } from './RoomInterface-B6ryEuU-.mjs';
|
|
2
2
|
import { OnRunProps } from '@drincs/nqtr';
|
|
3
3
|
import { Q as QuestInterface } from './StageInterface-C1Zfcpk3.mjs';
|
|
4
4
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, A as ActivityInterface } from './RoomInterface-
|
|
1
|
+
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, A as ActivityInterface } from './RoomInterface-C_Dbpef2.js';
|
|
2
2
|
import { E as ExecutionType, a as OnRunEvent, Q as QuestInterface, d as QuestsRequiredType, S as StageInterface } from './StageInterface-C1Zfcpk3.js';
|
|
3
3
|
|
|
4
4
|
interface ActivityProps {
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pixiVn=require('@drincs/pixi-vn');var Te=Object.defineProperty;var X=(o,e)=>{for(var t in e)Te(o,t,{get:e[t],enumerable:true});};var ae={};X(ae,{ActivityBaseModel:()=>B,ActivityStoredClass:()=>f,CommitmentBaseModel:()=>k,CommitmentStoredClass:()=>I,LocationBaseModel:()=>z,LocationStoredClass:()=>x,MapBaseModel:()=>Y,MapStoredClass:()=>R,QuestBaseModel:()=>V,QuestStoredClass:()=>T,RoomBaseModel:()=>F,RoomStoredClass:()=>_,StageBaseModel:()=>H,StageStoredClass:()=>b});var l="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",Z="___nqtr-last_event_memory___";var ie={};X(ie,{navigator:()=>y,questsNotebook:()=>Ce,routine:()=>re,timeTracker:()=>u});var ee={};X(ee,{RegisteredActivities:()=>C,RegisteredCommitments:()=>h,RegisteredLocations:()=>E,RegisteredMaps:()=>P,RegisteredQuests:()=>M,RegisteredRooms:()=>S});var s;(n=>(n.log=(i,...a)=>console.log(`[NQTR] ${i}`,...a),n.warn=(i,...a)=>console.warn(`[NQTR] ${i}`,...a),n.error=(i,...a)=>console.error(`[NQTR] ${i}`,...a),n.info=(i,...a)=>console.info(`[NQTR] ${i}`,...a)))(s||={});var G=new pixiVn.CachedMap({cacheSize:20}),se;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}G.set(i.id,i);}n.add=o;function e(i){try{let a=G.get(i);if(!a){console.warn(`[NQTR] Activity ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Activity ${i}`,a);return}}n.get=e;function t(){return Array.from(G.values())}n.values=t;function r(i){return G.has(i)}n.has=r;})(se||={});var C=se;var A=new pixiVn.CachedMap({cacheSize:20}),K=new pixiVn.CachedMap({cacheSize:20}),ue;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}console.warn(`[NQTR] Registering commitment ${i.id}`,i),A.set(i.id,i);}n.add=o;function e(i){try{let a=A.get(i);if(!a){console.warn(`[NQTR] Commitment ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Commitment ${i}`,a);return}}n.get=e;function t(){return Array.from(A.values())}n.values=t;function r(i){return A.has(i)}n.has=r;})(ue||={});var h=ue;var w=new pixiVn.CachedMap({cacheSize:20}),ce;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>o(a));return}w.has(i.id)&&console.warn(`[NQTR] Location id ${i.id} already exists, it will be overwritten`),w.set(i.id,i);}n.add=o;function e(i){try{let a=w.get(i);if(!a){console.warn(`[NQTR] Location ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Location ${i}`,a);return}}n.get=e;function t(){return Array.from(w.values())}n.values=t;function r(i){return w.has(i)}n.has=r;})(ce||={});var E=ce;var Q=new pixiVn.CachedMap({cacheSize:20}),le;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>o(a));return}Q.has(i.id)&&console.warn(`[NQTR] Map id ${i.id} already exists, it will be overwritten`),Q.set(i.id,i);}n.add=o;function e(i){try{let a=Q.get(i);if(!a){console.warn(`[NQTR] Map ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Map ${i}`,a);return}}n.get=e;function t(){return Array.from(Q.values())}n.values=t;function r(i){return Q.has(i)}n.has=r;})(le||={});var P=le;var W=new pixiVn.CachedMap({cacheSize:5}),me;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}W.set(i.id,i);}n.add=o;function e(i){try{let a=W.get(i);if(!a){console.warn(`[NQTR] Quest ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Quest ${i}`,a);return}}n.get=e;function t(){return Array.from(W.values())}n.values=t;function r(i){return W.has(i)}n.has=r;})(me||={});var M=me;var U=new pixiVn.CachedMap({cacheSize:20}),fe;(n=>{function o(i){if(Array.isArray(i)){i.forEach(m=>o(m));return}U.set(i.id,i);let a=i.location;E.add(a);let d=a?.map;d&&P.add(d);}n.add=o;function e(i){try{let a=U.get(i);if(!a){console.warn(`[NQTR] Room ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Room ${i}`,a);return}}n.get=e;function t(){return Array.from(U.values())}n.values=t;function r(i){return U.has(i)}n.has=r;})(fe||={});var S=fe;var N=class{get rooms(){return S.values()}get locations(){return E.values()}get maps(){return P.values()}get currentRoomId(){return pixiVn.storage.getVariable(p)}get currentRoom(){let e=this.currentRoomId;if(!e){s.error("The current room has not yet been set");return}let t=S.get(e);if(!t){s.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!S.get(e)){s.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=pixiVn.storage.getVariable(p);r!==e&&(q({type:"editroom",prev:r,value:e}),pixiVn.storage.setVariable(p,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){S.values().forEach(e=>{e.clearExpiredActivities();});}};var O=class{get quests(){return M.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}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 M.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var J="___nqtr-temporary_commitment___",L=class{get fixedRoutine(){return [...K.values()]}set fixedRoutine(e){e.forEach(t=>{K.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),K.set(t.id,t);});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(J);return e?e.map(r=>h.get(r)).filter(r=>r!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!h.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);pixiVn.storage.setVariable(J,t);}find(e){return h.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(n=>n.id),r=pixiVn.storage.getVariable(J);r&&(r=r.filter(n=>!t.includes(n)),pixiVn.storage.setVariable(J,r));}clearExpiredRoutine(){h.values().forEach(e=>{e.expired&&A.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(n=>!e[n.id]||t.priority>e[n.id].priority)&&t.characters.forEach(n=>{e[n.id]=t;}):s.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var c=class{static dayStartTime=0;static dayEndTime=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static getDayName};var $=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:n=1,timeSlots:i=[],weekLength:a=7,weekendStartDay:d=a-1,getDayName:m}=e;c.dayStartTime=t,c.dayEndTime=r,c.defaultTimeSpent=n,c.timeSlots=i,c.weekLength=a,d>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${a}, so will be ignored`):c.weekendStartDay=d,c.getDayName=m;}get dayStartTime(){return c.dayStartTime}get dayEndTime(){return c.dayEndTime}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get getDayName(){return c.getDayName}get currentTime(){let e=pixiVn.storage.getVariable(l)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=pixiVn.storage.getVariable(l)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,q({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(l,r);}get currentDate(){let e=pixiVn.storage.getVariable(l)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=pixiVn.storage.getVariable(l)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,q({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(l,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}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.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=this.dayStartTime,t=1){let r=this.currentDate+t;return this.currentDate=r,this.currentTime=e,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var u=new $,y=new N,re=new L,Ce=new O;function q(o){pixiVn.storage.setVariable(Z,o);}function we(){return pixiVn.storage.getVariable(Z)}function ge(){let o=we(),e=y.currentRoom;if(!e||!e.automaticFunction){pixiVn.narration.addCurrentStepToHistory();return}switch(o?.type){case "editroom":pixiVn.storage.setVariable(p,o.prev),pixiVn.narration.addCurrentStepToHistory(),pixiVn.storage.setVariable(p,e.id);break;case "edittime":let t=pixiVn.storage.getVariable(l)||{};pixiVn.storage.setVariable(l,o.prev),pixiVn.narration.addCurrentStepToHistory(),pixiVn.storage.setVariable(l,t);break}}var Me="__nqtr-activity__",f=class extends pixiVn.StoredClassModel{constructor(t,r,n,i=Me){super(i,t);this._onRun=r;this._timeSlot=n.timeSlot,this._dateScheduling=n.dateScheduling;}_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}get run(){return async t=>(ge(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=u.currentDate)}get isActive(){return !(this.dateScheduling?.from&&this.dateScheduling.from>u.currentDate||this.dateScheduling?.to&&this.dateScheduling.to<u.currentDate||!u.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to))}};var B=class extends f{constructor(e,t,r){super(e,t,{dateScheduling:r.dateScheduling,timeSlot:r.timeSlot}),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.storage.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.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ne="__nqtr-commitment__",I=class extends f{constructor(t,r,n,i,a){i=i||(()=>{});super(t,i,a,Ne);this._characters=r;this._room=n;this.defaultExecutionType=a.executionType||"interaction",this.defaultPriority=a.priority;}defaultExecutionType;defaultPriority;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 k=class extends I{constructor(e,t,r,n){super(e,t?Array.isArray(t)?t:[t]:[],r,n.onRun,{executionType:n.executionType,priority:n.priority,timeSlot:n.timeSlot,dateScheduling:n.dateScheduling}),this._name=n.name||"",this._image=n.image,this.defaultDisabled=n.disabled||false,this.defaultHidden=n.hidden||false,this._icon=n.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.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.dateScheduling?.from&&this.dateScheduling.from>u.currentDate||!u.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var g=class extends pixiVn.StoredClassModel{constructor(t,r,n=[]){super(t,r);this.defaultActivities=n;}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 n=this.excludedActivitiesScheduling;delete n[t],this.setStorageProperty("excludedActivitiesScheduling",n);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let n=this.activeActivityScheduling;n[t]=r,this.setStorageProperty("activeActivityScheduling",n);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let n=this.excludedActivitiesScheduling;n[t]=r,this.setStorageProperty("excludedActivitiesScheduling",n);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{timeSlot:n,dateScheduling:i}=r,{to:a=u.dayEndTime+1}=n||{};if(n&&n.from>=a)throw new Error("[NQTR] The from time must be less than the to time.");if(i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let d=this.additionalActivitiesIds;d.includes(t.id)?console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`):(d.push(t.id),this.setStorageProperty("additionalActivitiesIds",d)),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.`)),(n||i)&&this.editActivityScheduling(t.id,{timeSlot:n,dateScheduling:i});}removeActivity(t,r={}){let{to:n}=r,i=typeof t=="string"?t:t.id,a=this.additionalActivitiesIds;if(a.includes(i)){if(n!==void 0){this.editExcludedActivityScheduling(i,{dateScheduling:{to:n}});return}a=a.filter(d=>d!==i),this.setStorageProperty("additionalActivitiesIds",a),this.removeActivityScheduling(i);}else if(this.defaultActivitiesIds.includes(i)){if(n!==void 0){this.editExcludedActivityScheduling(i,{dateScheduling:{to:n}});return}let d=this.excludedActivitiesIds;d.push(i),this.setStorageProperty("excludedActivitiesIds",d);}else console.warn(`[NQTR] Activity with id ${i} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,n=this.additionalActivitiesIds,i=this.excludedActivitiesIds;n.forEach(a=>{if(a in t){let{to:d}=t[a].dateScheduling||{};d&&d<u.currentDate&&(this.removeActivityScheduling(a),n=n.filter(m=>m!==a));}}),i.forEach(a=>{if(a in r){let{to:d}=r[a].dateScheduling||{};d&&d<u.currentDate&&(this.removeActivityScheduling(a),i=i.filter(m=>m!==a));}});}get activities(){let t=[],r=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(n=>{let i=C.get(n),{dateScheduling:a,timeSlot:d}=r[n]||{},{from:m=i?.dateScheduling?.from,to:oe=i?.dateScheduling?.to}=a||{},{from:Re=i?.timeSlot?.from,to:_e=i?.timeSlot?.to}=d||{};i&&u.nowIsBetween(Re,_e)&&!(m&&m>u.currentDate)&&!(oe&&oe<u.currentDate)&&t.push(i);}),Object.entries(this.excludedActivitiesScheduling).forEach(([n,i])=>{let a=C.get(n);a&&a.isActive&&!(i.dateScheduling&&i.dateScheduling.to!==void 0&&i.dateScheduling.to>=u.currentDate)&&t.push(a);}),this.defaultActivities.forEach(n=>{n.isActive&&!t.find(i=>i.id===n.id)&&t.push(n);}),t}};var Oe="__nqtr-location__",x=class extends g{constructor(t,r,n=[]){super(Oe,t,n);this._map=r;}get map(){return this._map}get rooms(){return y.rooms.filter(t=>t.location.id===this.id)}};var z=class extends x{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.storage.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.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Le="__nqtr-map__",R=class extends g{constructor(e,t=[]){super(Le,e,t);}get locations(){return y.locations.filter(e=>e.map.id===this.id)}};var Y=class extends R{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 $e="__nqtr-room__",_=class extends g{constructor(t,r,n=[]){super($e,t,n);this._location=r;}get routine(){return re.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}get characters(){let t=[];return this.routine.forEach(r=>{t.push(...r.characters);}),t}get automaticFunction(){let t=this.routine.find(r=>r.executionType==="automatic")?.run;if(t)return async r=>{await t(r);}}};var F=class extends _{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.storage.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.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var ke="__nqtr-quest__",T=class extends pixiVn.StoredClassModel{constructor(t,r,n={}){super(ke,t);this._stages=r;this._onStart=n.onStart,this._onNextStage=n.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===void 0||t>=this.stages.length))return this.stages[t]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}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}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){s.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r&&r.start)return this.onStart&&await this.onStart(this,t),await r.start(t);s.error(`Quest ${this.id} has no start stage`);}async tryToGoNextStage(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.goNextStage(t):false:(s.error(`Quest ${this.id} has no current stage`),false)}async completeCurrentStageAndGoNext(t){let r=this.currentStage;return r?(r.completed=true,await this.goNextStage(t)):(s.error(`Quest ${this.id} has no current stage`),false)}async goNextStage(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,n=this.currentStageIndex;if(!r||n===void 0)return s.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=n+1,this.onNextStage&&await this.onNextStage(this,t),r&&r.onEnd&&await r.onEnd(r,t);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var V=class extends T{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 Ye="__nqtr-stage__",b=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(Ye,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}_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 inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>u.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=u.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_deltaDateRequired;get deltaDateRequired(){return this._deltaDateRequired||0}_questsRequired;get questsRequired(){return this._questsRequired||[]}};var H=class extends b{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],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}_flagsRequired;get flagsRequired(){return this._flagsRequired}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>pixiVn.storage.getFlag(e.flag))?false:super.canStart}};var Ie={};var xe={};var Fe={...ae,...ee,...Ie,...ie,...xe},ri=Fe;exports.ActivityBaseModel=B;exports.ActivityStoredClass=f;exports.CommitmentBaseModel=k;exports.CommitmentStoredClass=I;exports.LocationBaseModel=z;exports.LocationStoredClass=x;exports.MapBaseModel=Y;exports.MapStoredClass=R;exports.QuestBaseModel=V;exports.QuestStoredClass=T;exports.RegisteredActivities=C;exports.RegisteredCommitments=h;exports.RegisteredLocations=E;exports.RegisteredMaps=P;exports.RegisteredQuests=M;exports.RegisteredRooms=S;exports.RoomBaseModel=F;exports.RoomStoredClass=_;exports.StageBaseModel=H;exports.StageStoredClass=b;exports.default=ri;exports.navigator=y;exports.questsNotebook=Ce;exports.routine=re;exports.timeTracker=u;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var pixiVn=require('@drincs/pixi-vn');var Te=Object.defineProperty;var X=(o,e)=>{for(var t in e)Te(o,t,{get:e[t],enumerable:true});};var ne={};X(ne,{ActivityBaseModel:()=>$,ActivityStoredClass:()=>f,CommitmentBaseModel:()=>k,CommitmentStoredClass:()=>v,LocationBaseModel:()=>z,LocationStoredClass:()=>I,MapBaseModel:()=>Y,MapStoredClass:()=>x,QuestBaseModel:()=>V,QuestStoredClass:()=>_,RoomBaseModel:()=>F,RoomStoredClass:()=>R,StageBaseModel:()=>H,StageStoredClass:()=>T});var ie={};X(ie,{navigator:()=>y,questsNotebook:()=>Ce,routine:()=>re,timeTracker:()=>u});var l="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",Z="___nqtr-last_event_memory___";var ee={};X(ee,{RegisteredActivities:()=>D,RegisteredCommitments:()=>h,RegisteredLocations:()=>A,RegisteredMaps:()=>E,RegisteredQuests:()=>Q,RegisteredRooms:()=>S});var s;(n=>(n.log=(i,...a)=>console.log(`[NQTR] ${i}`,...a),n.warn=(i,...a)=>console.warn(`[NQTR] ${i}`,...a),n.error=(i,...a)=>console.error(`[NQTR] ${i}`,...a),n.info=(i,...a)=>console.info(`[NQTR] ${i}`,...a)))(s||={});var G=new pixiVn.CachedMap({cacheSize:20}),oe;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}G.set(i.id,i);}n.add=o;function e(i){try{let a=G.get(i);if(!a){console.warn(`[NQTR] Activity ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Activity ${i}`,a);return}}n.get=e;function t(){return Array.from(G.values())}n.values=t;function r(i){return G.has(i)}n.has=r;})(oe||={});var D=oe;var b=new pixiVn.CachedMap({cacheSize:20}),K=new pixiVn.CachedMap({cacheSize:20}),de;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}console.warn(`[NQTR] Registering commitment ${i.id}`,i),b.set(i.id,i);}n.add=o;function e(i){try{let a=b.get(i);if(!a){console.warn(`[NQTR] Commitment ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Commitment ${i}`,a);return}}n.get=e;function t(){return Array.from(b.values())}n.values=t;function r(i){return b.has(i)}n.has=r;})(de||={});var h=de;var C=new pixiVn.CachedMap({cacheSize:20}),ue;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>o(a));return}C.has(i.id)&&console.warn(`[NQTR] Location id ${i.id} already exists, it will be overwritten`),C.set(i.id,i);}n.add=o;function e(i){try{let a=C.get(i);if(!a){console.warn(`[NQTR] Location ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Location ${i}`,a);return}}n.get=e;function t(){return Array.from(C.values())}n.values=t;function r(i){return C.has(i)}n.has=r;})(ue||={});var A=ue;var w=new pixiVn.CachedMap({cacheSize:20}),ce;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>o(a));return}w.has(i.id)&&console.warn(`[NQTR] Map id ${i.id} already exists, it will be overwritten`),w.set(i.id,i);}n.add=o;function e(i){try{let a=w.get(i);if(!a){console.warn(`[NQTR] Map ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Map ${i}`,a);return}}n.get=e;function t(){return Array.from(w.values())}n.values=t;function r(i){return w.has(i)}n.has=r;})(ce||={});var E=ce;var W=new pixiVn.CachedMap({cacheSize:5}),le;(n=>{function o(i){if(Array.isArray(i)){i.forEach(a=>n.add(a));return}W.set(i.id,i);}n.add=o;function e(i){try{let a=W.get(i);if(!a){console.warn(`[NQTR] Quest ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Quest ${i}`,a);return}}n.get=e;function t(){return Array.from(W.values())}n.values=t;function r(i){return W.has(i)}n.has=r;})(le||={});var Q=le;var U=new pixiVn.CachedMap({cacheSize:20}),me;(n=>{function o(i){if(Array.isArray(i)){i.forEach(m=>o(m));return}U.set(i.id,i);let a=i.location;A.add(a);let d=a?.map;d&&E.add(d);}n.add=o;function e(i){try{let a=U.get(i);if(!a){console.warn(`[NQTR] Room ${i} not found, you should register it first`);return}return a}catch(a){s.error(`Error while getting Room ${i}`,a);return}}n.get=e;function t(){return Array.from(U.values())}n.values=t;function r(i){return U.has(i)}n.has=r;})(me||={});var S=me;function M(o){pixiVn.storage.setVariable(Z,o);}function ge(){return pixiVn.storage.getVariable(Z)}var N=class{get rooms(){return S.values()}get locations(){return A.values()}get maps(){return E.values()}get currentRoomId(){return pixiVn.storage.getVariable(p)}get currentRoom(){let e=this.currentRoomId;if(!e){s.error("The current room has not yet been set");return}let t=S.get(e);if(!t){s.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!S.get(e)){s.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=pixiVn.storage.getVariable(p);r!==e&&(M({type:"editroom",prev:r,value:e}),pixiVn.storage.setVariable(p,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){S.values().forEach(e=>{e.clearExpiredActivities();});}};var q=class{get quests(){return Q.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}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 Q.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var J="___nqtr-temporary_commitment___",O=class{get fixedRoutine(){return [...K.values()]}set fixedRoutine(e){e.forEach(t=>{K.has(t.id)&&console.warn(`[NQTR] Commitment id ${t.id} already exists, it will be overwritten`),K.set(t.id,t);});}get temporaryRoutine(){let e=pixiVn.storage.getVariable(J);return e?e.map(r=>h.get(r)).filter(r=>r!==void 0):[]}get allRoutine(){return [...this.fixedRoutine,...this.temporaryRoutine]}add(e){Array.isArray(e)||(e=[e]);let t=e.map(r=>{if(!h.get(r.id)){console.warn(`[NQTR] Commitment ${r.id} not found, it will be ignored`);return}return r.id}).filter(r=>r!==void 0);pixiVn.storage.setVariable(J,t);}find(e){return h.get(e)}remove(e){Array.isArray(e)||(e=[e]);let t=e.map(n=>n.id),r=pixiVn.storage.getVariable(J);r&&(r=r.filter(n=>!t.includes(n)),pixiVn.storage.setVariable(J,r));}clearExpiredRoutine(){h.values().forEach(e=>{e.expired&&b.delete(e.id);});}get currentRoutine(){let e={};return [...this.fixedRoutine,...this.temporaryRoutine].forEach(t=>{t.isActive&&(t.characters.length>0?t.characters.every(n=>!e[n.id]||t.priority>e[n.id].priority)&&t.characters.forEach(n=>{e[n.id]=t;}):s.error(`The commitment ${t.id} has no characters assigned`));}),Object.values(e)}getCommitmentByCharacter(e){this.currentRoutine.forEach(t=>{if(t.characters.map(r=>r.id).includes(e.id))return t});}};var c=class{static dayStartTime=0;static dayEndTime=24;static defaultTimeSpent=1;static timeSlots=[];static weekLength=7;static weekendStartDay=this.weekLength-1;static getDayName};var L=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:n=1,timeSlots:i=[],weekLength:a=7,weekendStartDay:d=a-1,getDayName:m}=e;c.dayStartTime=t,c.dayEndTime=r,c.defaultTimeSpent=n,c.timeSlots=i,c.weekLength=a,d>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${a}, so will be ignored`):c.weekendStartDay=d,c.getDayName=m;}get dayStartTime(){return c.dayStartTime}get dayEndTime(){return c.dayEndTime}get defaultTimeSpent(){return c.defaultTimeSpent}get timeSlots(){return c.timeSlots}get weekLength(){return c.weekLength}get weekendStartDay(){return c.weekendStartDay}get getDayName(){return c.getDayName}get currentTime(){let e=pixiVn.storage.getVariable(l)||{};return e.hasOwnProperty("currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=pixiVn.storage.getVariable(l)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,M({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(l,r);}get currentDate(){let e=pixiVn.storage.getVariable(l)||{};return e.hasOwnProperty("currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=pixiVn.storage.getVariable(l)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,M({type:"edittime",prev:t,value:r}),pixiVn.storage.setVariable(l,r);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}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.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=this.dayStartTime,t=1){let r=this.currentDate+t;return this.currentDate=r,this.currentTime=e,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var u=new L,y=new N,re=new O,Ce=new q;var Me="__nqtr-activity__",f=class extends pixiVn.StoredClassModel{constructor(t,r,n,i=Me){super(i,t);this._onRun=r;this._timeSlot=n.timeSlot,this._dateScheduling=n.dateScheduling;}_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){pixiVn.narration.addCurrentStepToHistory();}get run(){return async t=>(this.addTempHistoryItem(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=u.currentDate)}get isActive(){return !(this.dateScheduling?.from&&this.dateScheduling.from>u.currentDate||this.dateScheduling?.to&&this.dateScheduling.to<u.currentDate||!u.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to))}};var $=class extends f{constructor(e,t,r){super(e,t,{dateScheduling:r.dateScheduling,timeSlot:r.timeSlot}),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.storage.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.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ne="__nqtr-commitment__",v=class extends f{constructor(t,r,n,i,a){i=i||(()=>{});super(t,i,a,Ne);this._characters=r;this._room=n;this.defaultExecutionType=a.executionType||"interaction",this.defaultPriority=a.priority;}defaultExecutionType;defaultPriority;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);}addTempHistoryItem(){let t=y.currentRoom;if(!t||this.executionType!=="automatic")return super.addTempHistoryItem();let r=ge();switch(r?.type){case "editroom":pixiVn.storage.setVariable(p,r.prev),super.addTempHistoryItem(),pixiVn.storage.setVariable(p,t.id);break;case "edittime":let n=pixiVn.storage.getVariable(l)||{};pixiVn.storage.setVariable(l,r.prev),super.addTempHistoryItem(),pixiVn.storage.setVariable(l,n);break}}};var k=class extends v{constructor(e,t,r,n){super(e,t?Array.isArray(t)?t:[t]:[],r,n.onRun,{executionType:n.executionType,priority:n.priority,timeSlot:n.timeSlot,dateScheduling:n.dateScheduling}),this._name=n.name||"",this._image=n.image,this.defaultDisabled=n.disabled||false,this.defaultHidden=n.hidden||false,this._icon=n.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.storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){if(this.dateScheduling?.from&&this.dateScheduling.from>u.currentDate||!u.nowIsBetween(this.timeSlot?.from,this.timeSlot?.to)||!this.expired)return true;let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?pixiVn.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var g=class extends pixiVn.StoredClassModel{constructor(t,r,n=[]){super(t,r);this.defaultActivities=n;}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 n=this.excludedActivitiesScheduling;delete n[t],this.setStorageProperty("excludedActivitiesScheduling",n);}editActivityScheduling(t,r){this.removeActivityScheduling(t);let n=this.activeActivityScheduling;n[t]=r,this.setStorageProperty("activeActivityScheduling",n);}editExcludedActivityScheduling(t,r){this.removeActivityScheduling(t);let n=this.excludedActivitiesScheduling;n[t]=r,this.setStorageProperty("excludedActivitiesScheduling",n);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}addActivity(t,r={}){let{timeSlot:n,dateScheduling:i}=r,{to:a=u.dayEndTime+1}=n||{};if(n&&n.from>=a)throw new Error("[NQTR] The from time must be less than the to time.");if(i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw new Error("[NQTR] The from day/date must be less than the to day/date.");if(this.defaultActivitiesIds.includes(t.id)){console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`);return}let d=this.additionalActivitiesIds;d.includes(t.id)?console.warn(`[NQTR] Activity with id ${t.id} already exists, so it will be ignored.`):(d.push(t.id),this.setStorageProperty("additionalActivitiesIds",d)),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.`)),(n||i)&&this.editActivityScheduling(t.id,{timeSlot:n,dateScheduling:i});}removeActivity(t,r={}){let{to:n}=r,i=typeof t=="string"?t:t.id,a=this.additionalActivitiesIds;if(a.includes(i)){if(n!==void 0){this.editExcludedActivityScheduling(i,{dateScheduling:{to:n}});return}a=a.filter(d=>d!==i),this.setStorageProperty("additionalActivitiesIds",a),this.removeActivityScheduling(i);}else if(this.defaultActivitiesIds.includes(i)){if(n!==void 0){this.editExcludedActivityScheduling(i,{dateScheduling:{to:n}});return}let d=this.excludedActivitiesIds;d.push(i),this.setStorageProperty("excludedActivitiesIds",d);}else console.warn(`[NQTR] Activity with id ${i} not found, so it will be ignored.`);}clearExpiredActivities(){let t=this.activeActivityScheduling,r=this.excludedActivitiesScheduling,n=this.additionalActivitiesIds,i=this.excludedActivitiesIds;n.forEach(a=>{if(a in t){let{to:d}=t[a].dateScheduling||{};d&&d<u.currentDate&&(this.removeActivityScheduling(a),n=n.filter(m=>m!==a));}}),i.forEach(a=>{if(a in r){let{to:d}=r[a].dateScheduling||{};d&&d<u.currentDate&&(this.removeActivityScheduling(a),i=i.filter(m=>m!==a));}});}get activities(){let t=[],r=this.activeActivityScheduling;return this.additionalActivitiesIds.concat(this.defaultActivitiesIds).forEach(n=>{let i=D.get(n),{dateScheduling:a,timeSlot:d}=r[n]||{},{from:m=i?.dateScheduling?.from,to:ae=i?.dateScheduling?.to}=a||{},{from:Re=i?.timeSlot?.from,to:_e=i?.timeSlot?.to}=d||{};i&&u.nowIsBetween(Re,_e)&&!(m&&m>u.currentDate)&&!(ae&&ae<u.currentDate)&&t.push(i);}),Object.entries(this.excludedActivitiesScheduling).forEach(([n,i])=>{let a=D.get(n);a&&a.isActive&&!(i.dateScheduling&&i.dateScheduling.to!==void 0&&i.dateScheduling.to>=u.currentDate)&&t.push(a);}),this.defaultActivities.forEach(n=>{n.isActive&&!t.find(i=>i.id===n.id)&&t.push(n);}),t}};var Oe="__nqtr-location__",I=class extends g{constructor(t,r,n=[]){super(Oe,t,n);this._map=r;}get map(){return this._map}get rooms(){return y.rooms.filter(t=>t.location.id===this.id)}};var z=class extends I{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.storage.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.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Le="__nqtr-map__",x=class extends g{constructor(e,t=[]){super(Le,e,t);}get locations(){return y.locations.filter(e=>e.map.id===this.id)}};var Y=class extends x{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 $e="__nqtr-room__",R=class extends g{constructor(t,r,n=[]){super($e,t,n);this._location=r;}get routine(){return re.currentRoutine.filter(t=>t.room.id===this.id)}get location(){return this._location}get characters(){let t=[];return this.routine.forEach(r=>{t.push(...r.characters);}),t}get automaticFunctions(){return this.routine.filter(t=>t.executionType==="automatic"&&t.run).map(t=>async n=>{await t.run(n);})}};var F=class extends R{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.storage.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.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var ke="__nqtr-quest__",_=class extends pixiVn.StoredClassModel{constructor(t,r,n={}){super(ke,t);this._stages=r;this._onStart=n.onStart,this._onNextStage=n.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===void 0||t>=this.stages.length))return this.stages[t]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}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}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){s.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r&&r.start)return this.onStart&&await this.onStart(this,t),await r.start(t);s.error(`Quest ${this.id} has no start stage`);}async tryToGoNextStage(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.goNextStage(t):false:(s.error(`Quest ${this.id} has no current stage`),false)}async completeCurrentStageAndGoNext(t){let r=this.currentStage;return r?(r.completed=true,await this.goNextStage(t)):(s.error(`Quest ${this.id} has no current stage`),false)}async goNextStage(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,n=this.currentStageIndex;if(!r||n===void 0)return s.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=n+1,this.onNextStage&&await this.onNextStage(this,t),r&&r.onEnd&&await r.onEnd(r,t);let i=this.currentStage;return i&&(i.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var V=class extends _{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 Ye="__nqtr-stage__",T=class extends pixiVn.StoredClassModel{constructor(e,t={}){super(Ye,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}_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 inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>u.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=u.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}_deltaDateRequired;get deltaDateRequired(){return this._deltaDateRequired||0}_questsRequired;get questsRequired(){return this._questsRequired||[]}};var H=class extends T{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired}),this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],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}_flagsRequired;get flagsRequired(){return this._flagsRequired}_requestDescriptionToStart;get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>pixiVn.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>pixiVn.storage.getFlag(e.flag))?false:super.canStart}};var Ie={};var xe={};var Fe={...ne,...ee,...Ie,...ie,...xe},ai=Fe;exports.ActivityBaseModel=$;exports.ActivityStoredClass=f;exports.CommitmentBaseModel=k;exports.CommitmentStoredClass=v;exports.LocationBaseModel=z;exports.LocationStoredClass=I;exports.MapBaseModel=Y;exports.MapStoredClass=x;exports.QuestBaseModel=V;exports.QuestStoredClass=_;exports.RegisteredActivities=D;exports.RegisteredCommitments=h;exports.RegisteredLocations=A;exports.RegisteredMaps=E;exports.RegisteredQuests=Q;exports.RegisteredRooms=S;exports.RoomBaseModel=F;exports.RoomStoredClass=R;exports.StageBaseModel=H;exports.StageStoredClass=T;exports.default=ai;exports.navigator=y;exports.questsNotebook=Ce;exports.routine=re;exports.timeTracker=u;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|