@drincs/nqtr 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/{StageInterface-B8NCX3T6.d.mts → StageInterface-DzhX29F-.d.mts} +1 -1
- package/dist/{StageInterface-B8NCX3T6.d.ts → StageInterface-DzhX29F-.d.ts} +1 -1
- package/dist/handlers.cjs +1 -1
- package/dist/handlers.d.mts +2 -2
- package/dist/handlers.d.ts +2 -2
- package/dist/handlers.mjs +1 -1
- package/dist/{index-C2ZYWKtA.d.ts → index-CT-JfKIo.d.mts} +14 -62
- package/dist/{index-CnkqN42W.d.mts → index-DehHTT06.d.ts} +14 -62
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +49 -5
- package/dist/index.d.ts +49 -5
- package/dist/index.mjs +1 -1
- package/dist/registries.d.mts +3 -2
- package/dist/registries.d.ts +3 -2
- package/dist/vite.cjs +2 -2
- package/dist/vite.d.mts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +2 -2
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -22,6 +22,16 @@ To install the NQTR package in an existing JavaScript project, use one of the fo
|
|
|
22
22
|
npm install @drincs/nqtr
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
Use Node.js 20.19.0 or newer to run the tests and use Vite 8. The release build uses `tsup@9` and requires Node.js 22.18.0 or newer. Package metadata does not enforce these versions.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm ci
|
|
31
|
+
npm test
|
|
32
|
+
npm run build
|
|
33
|
+
```
|
|
34
|
+
|
|
25
35
|
## Features
|
|
26
36
|
|
|
27
37
|
NQTR provides the following features (the order is important):
|
|
@@ -31,3 +41,39 @@ NQTR provides the following features (the order is important):
|
|
|
31
41
|
3. [Activity](https://pixi-vn.com/nqtr/activity)
|
|
32
42
|
4. [Routine](https://pixi-vn.com/nqtr/routine)
|
|
33
43
|
5. [Quest system](https://pixi-vn.com/nqtr/quest)
|
|
44
|
+
|
|
45
|
+
## Agent Skills
|
|
46
|
+
|
|
47
|
+
NQTR ships a set of [Agent Skills](https://www.skills.sh/) that teach AI coding assistants how to correctly use each part of the library. When a project uses Pixi’VN with ink, the skills prefer ink (hashtag commands such as `# enter room`, `# wait`, `# start quest`) over TypeScript labels.
|
|
48
|
+
|
|
49
|
+
> In LM Studio Bionic, ask the agent to install skills from `https://github.com/DRincs-Productions/nqtr`, or add the skill files in **Settings → Skills**. To reuse skills installed for Codex or Claude Code, enable **Settings → Skills → Use skills found in other apps**.
|
|
50
|
+
|
|
51
|
+
**Codex**:
|
|
52
|
+
|
|
53
|
+
```npm
|
|
54
|
+
npx skills@latest add DRincs-Productions/nqtr@latest --skill '*' --agent codex -g -y
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Claude Code**:
|
|
58
|
+
|
|
59
|
+
```npm
|
|
60
|
+
npx skills@latest add DRincs-Productions/nqtr@latest --skill '*' --agent claude-code -g -y
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Other agents**:
|
|
64
|
+
|
|
65
|
+
```npm
|
|
66
|
+
npx skills@latest add DRincs-Productions/nqtr@latest --all -y
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Available skills:
|
|
70
|
+
|
|
71
|
+
- `getting-started` (skill `nqtr`) — the index of the skill set: skill map, installation, registries, the Vite plugin, `OnRunProps`, custom classes
|
|
72
|
+
- `ink` — every NQTR hashtag command and quest variable for `.ink` files
|
|
73
|
+
- `navigation` — rooms, locations, maps and `navigator`
|
|
74
|
+
- `time` — `timeTracker`, time slots, `wait`
|
|
75
|
+
- `activity` — player actions linked to rooms
|
|
76
|
+
- `routine` — character commitments (schedules)
|
|
77
|
+
- `quest` — quests, stages and state queries
|
|
78
|
+
|
|
79
|
+
Install them together with the [Pixi’VN](https://github.com/DRincs-Productions/pixi-vn) and [Pixi’VN ink](https://github.com/DRincs-Productions/pixi-vn-ink) skills.
|
|
@@ -379,4 +379,4 @@ interface StageBaseInternalInterface {
|
|
|
379
379
|
readonly questsRequired: QuestsRequiredType[];
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
export type { ActivityInterface as A, CommitmentInterface as C, DateSchedulingInterface as D, ExecutionType as E, LocationInternalInterface as L, MapInterface as M, NavigationAbstractInterface as N, OnRunEvent as O, QuestInterface as Q, RoomInterface as R, StageInterface as S, TimeSchedulingInterface as T, QuestsRequiredType as a,
|
|
382
|
+
export type { ActivityInterface as A, CommitmentInterface as C, DateSchedulingInterface as D, ExecutionType as E, LocationInternalInterface as L, MapInterface as M, NavigationAbstractInterface as N, OnRunEvent as O, QuestInterface as Q, RoomInterface as R, StageInterface as S, TimeSchedulingInterface as T, QuestsRequiredType as a, OnRunProps as b, ActivityBaseInternalInterface as c, ActiveScheduling as d, OnRunAsyncFunction as e, CommitmentBaseInternalInterface as f, MapBaseInternalInterface as g, LocationInterface as h, RoomBaseInternalInterface as i, QuestBaseInternalInterface as j, StageBaseInternalInterface as k, OnRunFunction as l };
|
|
@@ -379,4 +379,4 @@ interface StageBaseInternalInterface {
|
|
|
379
379
|
readonly questsRequired: QuestsRequiredType[];
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
export type { ActivityInterface as A, CommitmentInterface as C, DateSchedulingInterface as D, ExecutionType as E, LocationInternalInterface as L, MapInterface as M, NavigationAbstractInterface as N, OnRunEvent as O, QuestInterface as Q, RoomInterface as R, StageInterface as S, TimeSchedulingInterface as T, QuestsRequiredType as a,
|
|
382
|
+
export type { ActivityInterface as A, CommitmentInterface as C, DateSchedulingInterface as D, ExecutionType as E, LocationInternalInterface as L, MapInterface as M, NavigationAbstractInterface as N, OnRunEvent as O, QuestInterface as Q, RoomInterface as R, StageInterface as S, TimeSchedulingInterface as T, QuestsRequiredType as a, OnRunProps as b, ActivityBaseInternalInterface as c, ActiveScheduling as d, OnRunAsyncFunction as e, CommitmentBaseInternalInterface as f, MapBaseInternalInterface as g, LocationInterface as h, RoomBaseInternalInterface as i, QuestBaseInternalInterface as j, StageBaseInternalInterface as k, OnRunFunction as l };
|
package/dist/handlers.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var storage=require('@drincs/pixi-vn/storage'),registries=require('@drincs/nqtr/registries'),core=require('@drincs/pixi-vn/core');var m="___nqtr-time_manager_data___",
|
|
1
|
+
'use strict';var storage=require('@drincs/pixi-vn/storage'),registries=require('@drincs/nqtr/registries'),core=require('@drincs/pixi-vn/core');var m="___nqtr-time_manager_data___",T="___nqtr-current_room_memory___",v="___nqtr-last_event_memory___";function f(u){storage.storage.set(v,u);}var s;(n=>(n.log=(a,...i)=>console.log(`[NQTR] ${a}`,...i),n.warn=(a,...i)=>console.warn(`[NQTR] ${a}`,...i),n.error=(a,...i)=>console.error(`[NQTR] ${a}`,...i),n.info=(a,...i)=>console.info(`[NQTR] ${a}`,...i)))(s||={});var p=class{get rooms(){return registries.RegisteredRooms.values()}get locations(){return registries.RegisteredLocations.values()}get maps(){return registries.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(T)}get currentRoom(){let e=this.currentRoomId;if(!e){s.error("The current room has not yet been set");return}let t=registries.RegisteredRooms.get(e);if(!t){s.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!registries.RegisteredRooms.get(e)){s.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.storage.get(T);r!==e&&(f({type:"editroom",prev:r,value:e}),storage.storage.set(T,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){registries.RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var l=class{get quests(){return registries.RegisteredQuests.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 registries.RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var E="___nqtr-temporary_commitment___",g=class{get temporaryRoutine(){let e=storage.storage.get(E);if(e){if(Array.isArray(e)){if(e.length>0)throw new core.PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return e}get commitmentsIds(){return [...registries.fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let n=this.temporaryRoutine;e.forEach(a=>{let i=typeof a=="string"?a:a.id;n[i]={id:i,roomId:t,...r};}),storage.storage.set(E,n);}find(e){return registries.RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:s.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.storage.set(E,r);}clearExpiredRoutine(){registries.RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let n=registries.RegisteredCommitments.get(r),a=e[r],i=a?.roomId||registries.fixedCommitments.get(r);return i&&n?.isActive(a)&&(n.characters.length>0?n.characters.every(c=>!t[c.id]||n.priority>t[c.id][0].priority)&&n.characters.forEach(c=>{t[c.id]=[n,i];}):s.error(`The commitment ${n.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){let t=typeof e=="string"?e:e.id;return this.currentRoutine.find(r=>{if(r.characters.map(n=>n.id).includes(t))return r})}};var M={dayStartTime:0,dayEndTime:24,defaultTimeSpent:1,timeSlots:[],weekLength:7,weekendStartDay:6,getDayName:void 0},o=M;var y=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:n=1,timeSlots:a=[],weekLength:i=7,weekendStartDay:I=i-1,getDayName:c}=e;o.dayStartTime=t,o.dayEndTime=r,o.defaultTimeSpent=n,o.timeSlots=a,o.weekLength=i,I>=o.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${i}, so will be ignored`):o.weekendStartDay=I,o.getDayName=c;}get dayStartTime(){return o.dayStartTime}get dayEndTime(){return o.dayEndTime}get defaultTimeSpent(){return o.defaultTimeSpent}get timeSlots(){return o.timeSlots}get weekLength(){return o.weekLength}get weekendStartDay(){return o.weekendStartDay}get getDayName(){return o.getDayName}get currentTime(){let e=storage.storage.get(m)||{};return Object.hasOwn(e,"currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.storage.get(m)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,f({type:"edittime",prev:t,value:r}),storage.storage.set(m,r);}get currentDate(){let e=storage.storage.get(m)||{};return Object.hasOwn(e,"currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.storage.get(m)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,f({type:"edittime",prev:t,value:r}),storage.storage.set(m,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=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,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 oe=new y,se=new p,me=new g,ue=new l;exports.navigator=se;exports.questsNotebook=ue;exports.routine=me;exports.timeTracker=oe;
|
package/dist/handlers.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { n as navigator, q as questsNotebook, r as routine, t as timeTracker } from './index-
|
|
2
|
-
import './StageInterface-
|
|
1
|
+
export { n as navigator, q as questsNotebook, r as routine, t as timeTracker } from './index-CT-JfKIo.mjs';
|
|
2
|
+
import './StageInterface-DzhX29F-.mjs';
|
|
3
3
|
import '@drincs/pixi-vn/storage';
|
|
4
4
|
import '@drincs/nqtr/registries';
|
|
5
5
|
import '@drincs/pixi-vn';
|
package/dist/handlers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { n as navigator, q as questsNotebook, r as routine, t as timeTracker } from './index-
|
|
2
|
-
import './StageInterface-
|
|
1
|
+
export { n as navigator, q as questsNotebook, r as routine, t as timeTracker } from './index-DehHTT06.js';
|
|
2
|
+
import './StageInterface-DzhX29F-.js';
|
|
3
3
|
import '@drincs/pixi-vn/storage';
|
|
4
4
|
import '@drincs/nqtr/registries';
|
|
5
5
|
import '@drincs/pixi-vn';
|
package/dist/handlers.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {storage}from'@drincs/pixi-vn/storage';import {RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,fixedCommitments,RegisteredCommitments}from'@drincs/nqtr/registries';import {PixiError}from'@drincs/pixi-vn/core';var m="___nqtr-time_manager_data___",
|
|
1
|
+
import {storage}from'@drincs/pixi-vn/storage';import {RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,fixedCommitments,RegisteredCommitments}from'@drincs/nqtr/registries';import {PixiError}from'@drincs/pixi-vn/core';var m="___nqtr-time_manager_data___",T="___nqtr-current_room_memory___",v="___nqtr-last_event_memory___";function f(u){storage.set(v,u);}var s;(n=>(n.log=(a,...i)=>console.log(`[NQTR] ${a}`,...i),n.warn=(a,...i)=>console.warn(`[NQTR] ${a}`,...i),n.error=(a,...i)=>console.error(`[NQTR] ${a}`,...i),n.info=(a,...i)=>console.info(`[NQTR] ${a}`,...i)))(s||={});var p=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(T)}get currentRoom(){let e=this.currentRoomId;if(!e){s.error("The current room has not yet been set");return}let t=RegisteredRooms.get(e);if(!t){s.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!RegisteredRooms.get(e)){s.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.get(T);r!==e&&(f({type:"editroom",prev:r,value:e}),storage.set(T,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var l=class{get quests(){return RegisteredQuests.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 RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var E="___nqtr-temporary_commitment___",g=class{get temporaryRoutine(){let e=storage.get(E);if(e){if(Array.isArray(e)){if(e.length>0)throw new PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return e}get commitmentsIds(){return [...fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let n=this.temporaryRoutine;e.forEach(a=>{let i=typeof a=="string"?a:a.id;n[i]={id:i,roomId:t,...r};}),storage.set(E,n);}find(e){return RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:s.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.set(E,r);}clearExpiredRoutine(){RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let n=RegisteredCommitments.get(r),a=e[r],i=a?.roomId||fixedCommitments.get(r);return i&&n?.isActive(a)&&(n.characters.length>0?n.characters.every(c=>!t[c.id]||n.priority>t[c.id][0].priority)&&n.characters.forEach(c=>{t[c.id]=[n,i];}):s.error(`The commitment ${n.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){let t=typeof e=="string"?e:e.id;return this.currentRoutine.find(r=>{if(r.characters.map(n=>n.id).includes(t))return r})}};var M={dayStartTime:0,dayEndTime:24,defaultTimeSpent:1,timeSlots:[],weekLength:7,weekendStartDay:6,getDayName:void 0},o=M;var y=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:n=1,timeSlots:a=[],weekLength:i=7,weekendStartDay:I=i-1,getDayName:c}=e;o.dayStartTime=t,o.dayEndTime=r,o.defaultTimeSpent=n,o.timeSlots=a,o.weekLength=i,I>=o.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${i}, so will be ignored`):o.weekendStartDay=I,o.getDayName=c;}get dayStartTime(){return o.dayStartTime}get dayEndTime(){return o.dayEndTime}get defaultTimeSpent(){return o.defaultTimeSpent}get timeSlots(){return o.timeSlots}get weekLength(){return o.weekLength}get weekendStartDay(){return o.weekendStartDay}get getDayName(){return o.getDayName}get currentTime(){let e=storage.get(m)||{};return Object.hasOwn(e,"currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.get(m)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,f({type:"edittime",prev:t,value:r}),storage.set(m,r);}get currentDate(){let e=storage.get(m)||{};return Object.hasOwn(e,"currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.get(m)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,f({type:"edittime",prev:t,value:r}),storage.set(m,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=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,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 oe=new y,se=new p,me=new g,ue=new l;export{se as navigator,ue as questsNotebook,me as routine,oe as timeTracker};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RoomInterface, h as LocationInterface, M as MapInterface, C as CommitmentInterface,
|
|
2
|
-
import { OnRunProps } from '@drincs/nqtr';
|
|
3
|
-
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
|
|
1
|
+
import { R as RoomInterface, h as LocationInterface, M as MapInterface, C as CommitmentInterface, d as ActiveScheduling, Q as QuestInterface } from './StageInterface-DzhX29F-.mjs';
|
|
4
2
|
import { RoomIdType, CommitmentIdType } from '@drincs/nqtr/registries';
|
|
3
|
+
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
|
|
4
|
+
import { OnRunProps } from '@drincs/nqtr';
|
|
5
5
|
|
|
6
6
|
type TimeSlotInterface = {
|
|
7
7
|
name: string;
|
|
@@ -329,65 +329,11 @@ interface TimeHandlerInterface {
|
|
|
329
329
|
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
declare class QuestHandler implements QuestHandlerInterface {
|
|
333
|
-
get quests(): QuestInterface[];
|
|
334
|
-
get startedQuests(): QuestInterface[];
|
|
335
|
-
get inProgressQuests(): QuestInterface[];
|
|
336
|
-
get completedQuests(): QuestInterface[];
|
|
337
|
-
get failedQuests(): QuestInterface[];
|
|
338
|
-
get notStartedQuests(): QuestInterface[];
|
|
339
|
-
find(id: string): QuestInterface | undefined;
|
|
340
|
-
startsStageMustBeStarted(props: OnRunProps): Promise<void>;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
declare class RoutineHandler implements RoutineHandlerInterface {
|
|
344
|
-
/**
|
|
345
|
-
* Get the temporary commitments by its id.
|
|
346
|
-
* @returns The temporary commitments.
|
|
347
|
-
*/
|
|
348
|
-
private get temporaryRoutine();
|
|
349
|
-
get commitmentsIds(): string[];
|
|
350
|
-
add(commitment: (CommitmentInterface | CommitmentIdType)[] | CommitmentInterface | CommitmentIdType, roomId: string, options?: ActiveScheduling): void;
|
|
351
|
-
find(id: string): CommitmentInterface | undefined;
|
|
352
|
-
remove(commitment: CommitmentInterface | CommitmentIdType, roomId?: string): void;
|
|
353
|
-
clearExpiredRoutine(): void;
|
|
354
|
-
get characterCommitments(): {
|
|
355
|
-
[character: string]: [CommitmentInterface, string];
|
|
356
|
-
};
|
|
357
|
-
get currentRoutine(): CommitmentInterface[];
|
|
358
|
-
get roomCommitments(): {
|
|
359
|
-
[roomId: string]: CommitmentInterface[];
|
|
360
|
-
};
|
|
361
|
-
getCommitmentByCharacter(character: CharacterInterface | CharacterIdType): CommitmentInterface | undefined;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
declare class TimeHandler implements TimeHandlerInterface {
|
|
365
|
-
initialize(settings: TimeSettings): void;
|
|
366
|
-
get dayStartTime(): number;
|
|
367
|
-
get dayEndTime(): number;
|
|
368
|
-
get defaultTimeSpent(): number;
|
|
369
|
-
get timeSlots(): TimeSlotInterface[];
|
|
370
|
-
get weekLength(): number;
|
|
371
|
-
get weekendStartDay(): number;
|
|
372
|
-
get getDayName(): ((weekDayNumber: number) => string) | undefined;
|
|
373
|
-
get currentTime(): number;
|
|
374
|
-
set currentTime(value: number | undefined);
|
|
375
|
-
get currentDate(): number;
|
|
376
|
-
set currentDate(value: number | undefined);
|
|
377
|
-
get isWeekend(): boolean;
|
|
378
|
-
get currentWeekDayNumber(): number;
|
|
379
|
-
get currentDayName(): string;
|
|
380
|
-
get currentTimeSlot(): number;
|
|
381
|
-
increaseTime(delta?: number): number;
|
|
382
|
-
increaseDate(delta?: number, time?: number): number;
|
|
383
|
-
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
332
|
/**
|
|
387
333
|
* The global time manager instance. It handles the current time and date, the week structure
|
|
388
334
|
* (week length, weekend, day names) and the time slots of the day.
|
|
389
335
|
*/
|
|
390
|
-
declare const timeTracker:
|
|
336
|
+
declare const timeTracker: TimeHandlerInterface;
|
|
391
337
|
/**
|
|
392
338
|
* The global navigator instance. It gives access to the registered maps, locations and rooms,
|
|
393
339
|
* and it keeps track of the room where the player currently is (saved and restored with the game state).
|
|
@@ -397,19 +343,25 @@ declare const navigator: NavigatorHandlerInterface;
|
|
|
397
343
|
* The global routine manager instance. It handles the commitments of the characters (fixed or added
|
|
398
344
|
* during the game session), the rooms where they take place and the current routine of each character.
|
|
399
345
|
*/
|
|
400
|
-
declare const routine:
|
|
346
|
+
declare const routine: RoutineHandlerInterface;
|
|
401
347
|
/**
|
|
402
348
|
* The global quests manager instance. It gives access to the registered quests, filtered by their
|
|
403
349
|
* state (not started, in progress, completed, failed), and it starts the stages that must start automatically.
|
|
404
350
|
*/
|
|
405
|
-
declare const questsNotebook:
|
|
351
|
+
declare const questsNotebook: QuestHandlerInterface;
|
|
406
352
|
|
|
407
353
|
declare const handlers_navigator: typeof navigator;
|
|
408
354
|
declare const handlers_questsNotebook: typeof questsNotebook;
|
|
409
355
|
declare const handlers_routine: typeof routine;
|
|
410
356
|
declare const handlers_timeTracker: typeof timeTracker;
|
|
411
357
|
declare namespace handlers {
|
|
412
|
-
export {
|
|
358
|
+
export {
|
|
359
|
+
handlers_navigator as navigator,
|
|
360
|
+
handlers_questsNotebook as questsNotebook,
|
|
361
|
+
handlers_routine as routine,
|
|
362
|
+
handlers_timeTracker as timeTracker,
|
|
363
|
+
};
|
|
413
364
|
}
|
|
414
365
|
|
|
415
|
-
export {
|
|
366
|
+
export { handlers as h, navigator as n, questsNotebook as q, routine as r, timeTracker as t };
|
|
367
|
+
export type { NavigatorHandlerInterface as N, QuestHandlerInterface as Q, RoutineHandlerInterface as R, TimeSlotInterface as T, TimeHandlerInterface as a, TimeSettings as b };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RoomInterface, h as LocationInterface, M as MapInterface, C as CommitmentInterface,
|
|
2
|
-
import { OnRunProps } from '@drincs/nqtr';
|
|
3
|
-
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
|
|
1
|
+
import { R as RoomInterface, h as LocationInterface, M as MapInterface, C as CommitmentInterface, d as ActiveScheduling, Q as QuestInterface } from './StageInterface-DzhX29F-.js';
|
|
4
2
|
import { RoomIdType, CommitmentIdType } from '@drincs/nqtr/registries';
|
|
3
|
+
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
|
|
4
|
+
import { OnRunProps } from '@drincs/nqtr';
|
|
5
5
|
|
|
6
6
|
type TimeSlotInterface = {
|
|
7
7
|
name: string;
|
|
@@ -329,65 +329,11 @@ interface TimeHandlerInterface {
|
|
|
329
329
|
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
declare class QuestHandler implements QuestHandlerInterface {
|
|
333
|
-
get quests(): QuestInterface[];
|
|
334
|
-
get startedQuests(): QuestInterface[];
|
|
335
|
-
get inProgressQuests(): QuestInterface[];
|
|
336
|
-
get completedQuests(): QuestInterface[];
|
|
337
|
-
get failedQuests(): QuestInterface[];
|
|
338
|
-
get notStartedQuests(): QuestInterface[];
|
|
339
|
-
find(id: string): QuestInterface | undefined;
|
|
340
|
-
startsStageMustBeStarted(props: OnRunProps): Promise<void>;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
declare class RoutineHandler implements RoutineHandlerInterface {
|
|
344
|
-
/**
|
|
345
|
-
* Get the temporary commitments by its id.
|
|
346
|
-
* @returns The temporary commitments.
|
|
347
|
-
*/
|
|
348
|
-
private get temporaryRoutine();
|
|
349
|
-
get commitmentsIds(): string[];
|
|
350
|
-
add(commitment: (CommitmentInterface | CommitmentIdType)[] | CommitmentInterface | CommitmentIdType, roomId: string, options?: ActiveScheduling): void;
|
|
351
|
-
find(id: string): CommitmentInterface | undefined;
|
|
352
|
-
remove(commitment: CommitmentInterface | CommitmentIdType, roomId?: string): void;
|
|
353
|
-
clearExpiredRoutine(): void;
|
|
354
|
-
get characterCommitments(): {
|
|
355
|
-
[character: string]: [CommitmentInterface, string];
|
|
356
|
-
};
|
|
357
|
-
get currentRoutine(): CommitmentInterface[];
|
|
358
|
-
get roomCommitments(): {
|
|
359
|
-
[roomId: string]: CommitmentInterface[];
|
|
360
|
-
};
|
|
361
|
-
getCommitmentByCharacter(character: CharacterInterface | CharacterIdType): CommitmentInterface | undefined;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
declare class TimeHandler implements TimeHandlerInterface {
|
|
365
|
-
initialize(settings: TimeSettings): void;
|
|
366
|
-
get dayStartTime(): number;
|
|
367
|
-
get dayEndTime(): number;
|
|
368
|
-
get defaultTimeSpent(): number;
|
|
369
|
-
get timeSlots(): TimeSlotInterface[];
|
|
370
|
-
get weekLength(): number;
|
|
371
|
-
get weekendStartDay(): number;
|
|
372
|
-
get getDayName(): ((weekDayNumber: number) => string) | undefined;
|
|
373
|
-
get currentTime(): number;
|
|
374
|
-
set currentTime(value: number | undefined);
|
|
375
|
-
get currentDate(): number;
|
|
376
|
-
set currentDate(value: number | undefined);
|
|
377
|
-
get isWeekend(): boolean;
|
|
378
|
-
get currentWeekDayNumber(): number;
|
|
379
|
-
get currentDayName(): string;
|
|
380
|
-
get currentTimeSlot(): number;
|
|
381
|
-
increaseTime(delta?: number): number;
|
|
382
|
-
increaseDate(delta?: number, time?: number): number;
|
|
383
|
-
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
332
|
/**
|
|
387
333
|
* The global time manager instance. It handles the current time and date, the week structure
|
|
388
334
|
* (week length, weekend, day names) and the time slots of the day.
|
|
389
335
|
*/
|
|
390
|
-
declare const timeTracker:
|
|
336
|
+
declare const timeTracker: TimeHandlerInterface;
|
|
391
337
|
/**
|
|
392
338
|
* The global navigator instance. It gives access to the registered maps, locations and rooms,
|
|
393
339
|
* and it keeps track of the room where the player currently is (saved and restored with the game state).
|
|
@@ -397,19 +343,25 @@ declare const navigator: NavigatorHandlerInterface;
|
|
|
397
343
|
* The global routine manager instance. It handles the commitments of the characters (fixed or added
|
|
398
344
|
* during the game session), the rooms where they take place and the current routine of each character.
|
|
399
345
|
*/
|
|
400
|
-
declare const routine:
|
|
346
|
+
declare const routine: RoutineHandlerInterface;
|
|
401
347
|
/**
|
|
402
348
|
* The global quests manager instance. It gives access to the registered quests, filtered by their
|
|
403
349
|
* state (not started, in progress, completed, failed), and it starts the stages that must start automatically.
|
|
404
350
|
*/
|
|
405
|
-
declare const questsNotebook:
|
|
351
|
+
declare const questsNotebook: QuestHandlerInterface;
|
|
406
352
|
|
|
407
353
|
declare const handlers_navigator: typeof navigator;
|
|
408
354
|
declare const handlers_questsNotebook: typeof questsNotebook;
|
|
409
355
|
declare const handlers_routine: typeof routine;
|
|
410
356
|
declare const handlers_timeTracker: typeof timeTracker;
|
|
411
357
|
declare namespace handlers {
|
|
412
|
-
export {
|
|
358
|
+
export {
|
|
359
|
+
handlers_navigator as navigator,
|
|
360
|
+
handlers_questsNotebook as questsNotebook,
|
|
361
|
+
handlers_routine as routine,
|
|
362
|
+
handlers_timeTracker as timeTracker,
|
|
363
|
+
};
|
|
413
364
|
}
|
|
414
365
|
|
|
415
|
-
export {
|
|
366
|
+
export { handlers as h, navigator as n, questsNotebook as q, routine as r, timeTracker as t };
|
|
367
|
+
export type { NavigatorHandlerInterface as N, QuestHandlerInterface as Q, RoutineHandlerInterface as R, TimeSlotInterface as T, TimeHandlerInterface as a, TimeSettings as b };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var handlers=require('@drincs/nqtr/handlers'),Qe=require('@drincs/nqtr/registries'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage'),characters=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Qe__namespace=/*#__PURE__*/_interopNamespace(Qe);var ce=Object.defineProperty;var K=(s,e)=>{for(var t in e)ce(s,t,{get:e[t],enumerable:true});};var B={};K(B,{ActivityBaseModel:()=>_,ActivityStoredClass:()=>m,CommitmentBaseModel:()=>A,CommitmentStoredClass:()=>p,LocationBaseModel:()=>b,LocationStoredClass:()=>h,MapBaseModel:()=>C,MapStoredClass:()=>y,QuestBaseModel:()=>P,QuestStoredClass:()=>S,RoomBaseModel:()=>E,RoomStoredClass:()=>v,StageBaseModel:()=>D,StageStoredClass:()=>I});var fe="__nqtr-activity__",m=class extends storage.StoredClassModel{constructor(t,r,i,n=fe){super(n,t);this._onRun=r;this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}_onRun;_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}async addTempHistoryItem(){return await narration.narration.addCurrentStepToHistory()}get run(){return async t=>(await this.addTempHistoryItem(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=handlers.timeTracker.currentDate)}isActive(t={}){let{timeSlot:r=this.timeSlot,dateScheduling:i=this.dateScheduling}=t;if(i?.from!=null&&i.from>handlers.timeTracker.currentDate||i?.to!=null&&i.to<handlers.timeTracker.currentDate)return false;r&&!Array.isArray(r)&&(r=[r]);for(let n of r||[])if(!handlers.timeTracker.nowIsBetween(n?.from,n?.to))return false;return true}};var _=class extends m{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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var u="___nqtr-time_manager_data___",g="___nqtr-current_room_memory___",L="___nqtr-last_event_memory___";function R(s){storage.storage.set(L,s);}function j(){return storage.storage.get(L)}var he="__nqtr-commitment__",p=class extends m{constructor(e,t,r,i){r=r||(()=>{}),super(e,r,i,he),this.defaultExecutionType=i.executionType||"interaction",this.defaultPriority=i.priority,this.characters=t.reduce((n,a)=>{if(typeof a=="string"){let c=characters.RegisteredCharacters.get(a);c?n.push(c):console.warn(`Character with id ${a} not found for commitment ${e}`);}else n.push(a);return n},[]);}defaultExecutionType;defaultPriority;characters;get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}async addTempHistoryItem(){let e=handlers.navigator.currentRoom;if(!e||this.executionType!=="automatic")return await super.addTempHistoryItem();let t=j();switch(t?.type){case "editroom":storage.storage.set(g,t.prev),await super.addTempHistoryItem(),storage.storage.set(g,e.id);break;case "edittime":{let r=storage.storage.get(u)||{};storage.storage.set(u,t.prev),await super.addTempHistoryItem(),storage.storage.set(u,r);break}}}runOptions;get run(){return async(e,t)=>{let r=t?.removeFromRoutine??this.executionType==="automatic";return await this.addTempHistoryItem(),r&&handlers.routine.remove(this.id),await this._onRun(this,e)}}};var A=class extends p{constructor(e,t,r){super(e,t?Array.isArray(t)?t:[t]:[],r.onRun,{executionType:r.executionType,priority:r.priority,timeSlot:r.timeSlot,dateScheduling:r.dateScheduling}),this._name=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var o;(i=>(i.log=(n,...a)=>console.log(`[NQTR] ${n}`,...a),i.warn=(n,...a)=>console.warn(`[NQTR] ${n}`,...a),i.error=(n,...a)=>console.error(`[NQTR] ${n}`,...a),i.info=(n,...a)=>console.info(`[NQTR] ${n}`,...a)))(o||={});var f=class extends storage.StoredClassModel{constructor(e,t,r=[]){super(e,t),this.defaultActivitiesIds=r.map(i=>typeof i=="string"?i:i.id);}defaultActivitiesIds;get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let r=this.excludedActivitiesScheduling;delete r[e],this.setStorageProperty("excludedActivitiesScheduling",r);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.activeActivityScheduling;r[e]=t,this.setStorageProperty("activeActivityScheduling",r);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.excludedActivitiesScheduling;r[e]=t,this.setStorageProperty("excludedActivitiesScheduling",r);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let r=typeof e=="string"?Qe.RegisteredActivities.get(e):e;if(!r)throw o.error(`Activity with id ${e} not found.`),new core.PixiError("unknown_element",`Activity with id ${e} not found.`);let{timeSlot:i,dateScheduling:n}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:l=handlers.timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=l)throw o.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),n?.from!==void 0&&n?.to!==void 0&&n?.from>=n?.to)throw o.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");let a=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(r.id)||a.includes(r.id)?o.info(`Activity with id ${r.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(a.push(r.id),this.setStorageProperty("additionalActivitiesIds",a)),this.excludedActivitiesIds.includes(r.id)&&(this.removeActivityScheduling(r.id),o.log(`Activity with id ${r.id} was excluded from the ${this.id}, but now it will be added again with the new scheduling options. So it will be removed from the excluded activities list.`)),(i||n)&&this.editActivityScheduling(r.id,{timeSlot:i,dateScheduling:n});}removeActivity(e){let t=typeof e=="string"?e:e.id,r=this.additionalActivitiesIds;if(r.includes(t))r=r.filter(i=>i!==t),this.setStorageProperty("additionalActivitiesIds",r);else if(this.defaultActivitiesIds.includes(t)){let i=this.excludedActivitiesIds;i.push(t),this.setStorageProperty("excludedActivitiesIds",i);}else o.warn(`Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,r=this.additionalActivitiesIds,i=this.excludedActivitiesIds;r.forEach(n=>{if(n in e){let{to:a}=e[n].dateScheduling||{};a&&a<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(n),r=r.filter(c=>c!==n));}}),i.forEach(n=>{n in t&&t[n]&&(this.removeActivityScheduling(n),i=i.filter(a=>a!==n));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let r=Qe.RegisteredActivities.get(t);return r?.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(r),e},[])}};var Se="__nqtr-location__",h=class extends f{constructor(t,r,i=[]){super(Se,t,i);this._map=r;}_map;get map(){return this._map}get rooms(){return handlers.navigator.rooms.filter(t=>t.location.id===this.id)}};var b=class extends h{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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Te="__nqtr-map__",y=class extends f{constructor(e,t=[]){super(Te,e,t);}get locations(){return handlers.navigator.locations.filter(e=>e.map.id===this.id)}};var C=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 te="__nqtr-room__",v=class extends f{_location;constructor(e,t,r=[]){Array.isArray(r)?super(te,e,r):(super(te,e,r.activities),r.routine.forEach(i=>{let n=typeof i=="string"?i:i.id;Qe.fixedCommitments.set(n,e);})),this._location=t;}get routine(){return handlers.routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:r,dateScheduling:i}=t;if(r&&!Array.isArray(r)&&(r=[r]),r?.forEach(n=>{let{to:a=handlers.timeTracker.dayEndTime+1}=n||{};if(n&&n.from>=a)throw o.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw o.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");handlers.routine.add(e,this.id,{timeSlot:r,dateScheduling:i});}removeCommitment(e){handlers.routine.remove(e,this.id);}get location(){return this._location}get characters(){return this.routine.reduce((e,t)=>(e.push(...t.characters),e),[])}get automaticFunctions(){return this.routine.reduce((e,t)=>{if(t.executionType==="automatic"&&t.run){let r=async i=>{await t.run(i);};e.push(r);}return e},[])}};var E=class extends v{constructor(e,t,r={}){super(e,t,{activities:r.activities||[],routine:r.routine||[]}),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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ae="__nqtr-quest__",S=class extends storage.StoredClassModel{constructor(t,r,i={}){super(Ae,t);this._stages=r;this._onStart=i.onStart,this._onContinue=i.onContinue||i.onNextStage;}_stages;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}_onContinue;get onContinue(){return this._onContinue}get onNextStage(){return this._onContinue}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){o.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r?.start)return this.onStart&&await this.onStart(this,t),await r.start(t);o.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(t){return await this.advanceIfCompleted(t)}async advanceIfCompleted(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.advanceUnconditionally(t):false:(o.error(`Quest ${this.id} has no current stage`),false)}async goNext(t){return await this.continue(t)}async continue(t){let r=this.currentStage;return r?(r.completed=true,await this.advanceUnconditionally(t)):(o.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(t){return await this.advanceUnconditionally(t)}async advanceUnconditionally(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,i=this.currentStageIndex;if(!r||i===void 0)return o.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onContinue&&await this.onContinue(this,t),r?.onEnd&&await r.onEnd(r,t);let n=this.currentStage;return n&&(n.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 P=class extends S{constructor(e,t,r){super(e,t,{onStart:r.onStart,onContinue:r.onContinue||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 Ce="__nqtr-stage__",I=class extends storage.StoredClassModel{constructor(e,t={}){super(Ce,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>handlers.timeTracker.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=handlers.timeTracker.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 D=class extends I{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=>storage.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.storage.getFlag(e.flag))?false:super.canStart}};var ae={};var oe={};var G={};K(G,{navigator:()=>qe,questsNotebook:()=>Ne,routine:()=>Me,timeTracker:()=>Oe});var w=class{get rooms(){return Qe.RegisteredRooms.values()}get locations(){return Qe.RegisteredLocations.values()}get maps(){return Qe.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(g)}get currentRoom(){let e=this.currentRoomId;if(!e){o.error("The current room has not yet been set");return}let t=Qe.RegisteredRooms.get(e);if(!t){o.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!Qe.RegisteredRooms.get(e)){o.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.storage.get(g);r!==e&&(R({type:"editroom",prev:r,value:e}),storage.storage.set(g,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){Qe.RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var O=class{get quests(){return Qe.RegisteredQuests.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 Qe.RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var z="___nqtr-temporary_commitment___",q=class{get temporaryRoutine(){let e=storage.storage.get(z);if(e){if(Array.isArray(e)){if(e.length>0)throw new core.PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return e}get commitmentsIds(){return [...Qe.fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let i=this.temporaryRoutine;e.forEach(n=>{let a=typeof n=="string"?n:n.id;i[a]={id:a,roomId:t,...r};}),storage.storage.set(z,i);}find(e){return Qe.RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:o.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.storage.set(z,r);}clearExpiredRoutine(){Qe.RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let i=Qe.RegisteredCommitments.get(r),n=e[r],a=n?.roomId||Qe.fixedCommitments.get(r);return a&&i?.isActive(n)&&(i.characters.length>0?i.characters.every(l=>!t[l.id]||i.priority>t[l.id][0].priority)&&i.characters.forEach(l=>{t[l.id]=[i,a];}):o.error(`The commitment ${i.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){let t=typeof e=="string"?e:e.id;return this.currentRoutine.find(r=>{if(r.characters.map(i=>i.id).includes(t))return r})}};var we={dayStartTime:0,dayEndTime:24,defaultTimeSpent:1,timeSlots:[],weekLength:7,weekendStartDay:6,getDayName:void 0},d=we;var M=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:n=[],weekLength:a=7,weekendStartDay:c=a-1,getDayName:l}=e;d.dayStartTime=t,d.dayEndTime=r,d.defaultTimeSpent=i,d.timeSlots=n,d.weekLength=a,c>=d.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${a}, so will be ignored`):d.weekendStartDay=c,d.getDayName=l;}get dayStartTime(){return d.dayStartTime}get dayEndTime(){return d.dayEndTime}get defaultTimeSpent(){return d.defaultTimeSpent}get timeSlots(){return d.timeSlots}get weekLength(){return d.weekLength}get weekendStartDay(){return d.weekendStartDay}get getDayName(){return d.getDayName}get currentTime(){let e=storage.storage.get(u)||{};return Object.hasOwn(e,"currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.storage.get(u)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,R({type:"edittime",prev:t,value:r}),storage.storage.set(u,r);}get currentDate(){let e=storage.storage.get(u)||{};return Object.hasOwn(e,"currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.storage.get(u)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,R({type:"edittime",prev:t,value:r}),storage.storage.set(u,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=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,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 Oe=new M,qe=new w,Me=new q,Ne=new O;var Le={...B,...ae,...oe,handlers:G,registries:Qe__namespace},wr=Le;Object.defineProperty(exports,"RegisteredActivities",{enumerable:true,get:function(){return Qe.RegisteredActivities}});Object.defineProperty(exports,"RegisteredCommitments",{enumerable:true,get:function(){return Qe.RegisteredCommitments}});Object.defineProperty(exports,"RegisteredLocations",{enumerable:true,get:function(){return Qe.RegisteredLocations}});Object.defineProperty(exports,"RegisteredMaps",{enumerable:true,get:function(){return Qe.RegisteredMaps}});Object.defineProperty(exports,"RegisteredQuests",{enumerable:true,get:function(){return Qe.RegisteredQuests}});Object.defineProperty(exports,"RegisteredRooms",{enumerable:true,get:function(){return Qe.RegisteredRooms}});exports.ActivityBaseModel=_;exports.ActivityStoredClass=m;exports.CommitmentBaseModel=A;exports.CommitmentStoredClass=p;exports.LocationBaseModel=b;exports.LocationStoredClass=h;exports.MapBaseModel=C;exports.MapStoredClass=y;exports.QuestBaseModel=P;exports.QuestStoredClass=S;exports.RoomBaseModel=E;exports.RoomStoredClass=v;exports.StageBaseModel=D;exports.StageStoredClass=I;exports.default=wr;Object.keys(handlers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return handlers[k]}})});
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var handlers=require('@drincs/nqtr/handlers'),tt=require('@drincs/nqtr/registries'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage'),characters=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var tt__namespace=/*#__PURE__*/_interopNamespace(tt);var Ce=Object.defineProperty;var te=(s,e)=>{for(var t in e)Ce(s,t,{get:e[t],enumerable:true});};function k(s,e,t){if(!s.has(e))throw new Error(`NQTR testing: unknown ${t} "${e}".`);let r=s.get(e);if(!r)throw new Error(`NQTR testing: unavailable ${t} "${e}".`);return r}function Pe(){let s={},e={},t,r=a=>k(tt.RegisteredRooms,a,"room"),i=a=>k(tt.RegisteredActivities,a,"activity"),n=a=>k(tt.RegisteredCommitments,a,"commitment"),o=a=>k(tt.RegisteredQuests,a,"quest"),u={async goToRoom(a){handlers.navigator.currentRoom=r(a);},async increaseTime(a){handlers.timeTracker.increaseTime(a);},async increaseDate(a,p){handlers.timeTracker.increaseDate(a,p);},async addActivity(a,p){r(a).addActivity(i(p));},async removeActivity(a,p){r(a).removeActivity(i(p));},async addCommitment(a,p){r(a).addCommitment(n(p));},async removeRoutine(a){handlers.routine.remove(n(a));},async runActivity(a){return await i(a).run(s)},async runCommitment(a){return await n(a).run(s)},async startQuest(a){await o(a).start(s);},async continueQuest(a){return await o(a).continue(s)}},f={getCurrentRoom:()=>handlers.navigator.currentRoomId?handlers.navigator.currentRoom:void 0,getRooms:()=>tt.RegisteredRooms.values(),getActivities:()=>tt.RegisteredActivities.values(),getCommitments:()=>tt.RegisteredCommitments.values(),getRoutine:()=>[...new Set(handlers.routine.currentRoutine)],getQuests:()=>tt.RegisteredQuests.values()};function X(){if(t&&typeof window<"u"){let a=window;a[t.key]===t.api&&delete a[t.key];}t=void 0;}function _e(a){X();let $={...Object.fromEntries(Object.entries(u).map(([ee,xe])=>[ee,(...be)=>Promise.resolve().then(()=>(e[ee]??xe)(...be))])),...f},Z=a?.windowKey??"nqtr";return typeof window<"u"&&(window[Z]=$),t={key:Z,api:$},$}return {setProps(a){s=a;},setActions(a){e={...a};},enable:_e,disable:X,isEnabled:()=>t!==void 0}}var F=Pe();var G={};te(G,{ActivityBaseModel:()=>_,ActivityStoredClass:()=>l,CommitmentBaseModel:()=>C,CommitmentStoredClass:()=>y,LocationBaseModel:()=>P,LocationStoredClass:()=>v,MapBaseModel:()=>w,MapStoredClass:()=>I,QuestBaseModel:()=>D,QuestStoredClass:()=>T,RoomBaseModel:()=>E,RoomStoredClass:()=>S,StageBaseModel:()=>q,StageStoredClass:()=>R});var De="__nqtr-activity__",l=class extends storage.StoredClassModel{constructor(t,r,i,n=De){super(n,t);this._onRun=r;this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}_onRun;_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}async addTempHistoryItem(){return await narration.narration.addCurrentStepToHistory()}get run(){return async t=>(await this.addTempHistoryItem(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=handlers.timeTracker.currentDate)}isActive(t={}){let{timeSlot:r=this.timeSlot,dateScheduling:i=this.dateScheduling}=t;if(i?.from!=null&&i.from>handlers.timeTracker.currentDate||i?.to!=null&&i.to<handlers.timeTracker.currentDate)return false;r&&!Array.isArray(r)&&(r=[r]);for(let n of r||[])if(!handlers.timeTracker.nowIsBetween(n?.from,n?.to))return false;return true}};var _=class extends l{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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var m="___nqtr-time_manager_data___",h="___nqtr-current_room_memory___",Y="___nqtr-last_event_memory___";function x(s){storage.storage.set(Y,s);}function ue(){return storage.storage.get(Y)}var Qe="__nqtr-commitment__",y=class extends l{constructor(e,t,r,i){r=r||(()=>{}),super(e,r,i,Qe),this.defaultExecutionType=i.executionType||"interaction",this.defaultPriority=i.priority,this.characters=t.reduce((n,o)=>{if(typeof o=="string"){let u=characters.RegisteredCharacters.get(o);u?n.push(u):console.warn(`Character with id ${o} not found for commitment ${e}`);}else n.push(o);return n},[]);}defaultExecutionType;defaultPriority;characters;get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}async addTempHistoryItem(){let e=handlers.navigator.currentRoom;if(!e||this.executionType!=="automatic")return await super.addTempHistoryItem();let t=ue();switch(t?.type){case "editroom":storage.storage.set(h,t.prev),await super.addTempHistoryItem(),storage.storage.set(h,e.id);break;case "edittime":{let r=storage.storage.get(m)||{};storage.storage.set(m,t.prev),await super.addTempHistoryItem(),storage.storage.set(m,r);break}}}runOptions;get run(){return async(e,t)=>{let r=t?.removeFromRoutine??this.executionType==="automatic";return await this.addTempHistoryItem(),r&&handlers.routine.remove(this.id),await this._onRun(this,e)}}};var C=class extends y{constructor(e,t,r){super(e,t?Array.isArray(t)?t:[t]:[],r.onRun,{executionType:r.executionType,priority:r.priority,timeSlot:r.timeSlot,dateScheduling:r.dateScheduling}),this._name=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var d;(i=>(i.log=(n,...o)=>console.log(`[NQTR] ${n}`,...o),i.warn=(n,...o)=>console.warn(`[NQTR] ${n}`,...o),i.error=(n,...o)=>console.error(`[NQTR] ${n}`,...o),i.info=(n,...o)=>console.info(`[NQTR] ${n}`,...o)))(d||={});var g=class extends storage.StoredClassModel{constructor(e,t,r=[]){super(e,t),this.defaultActivitiesIds=r.map(i=>typeof i=="string"?i:i.id);}defaultActivitiesIds;get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let r=this.excludedActivitiesScheduling;delete r[e],this.setStorageProperty("excludedActivitiesScheduling",r);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.activeActivityScheduling;r[e]=t,this.setStorageProperty("activeActivityScheduling",r);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.excludedActivitiesScheduling;r[e]=t,this.setStorageProperty("excludedActivitiesScheduling",r);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let r=typeof e=="string"?tt.RegisteredActivities.get(e):e;if(!r)throw d.error(`Activity with id ${e} not found.`),new core.PixiError("unknown_element",`Activity with id ${e} not found.`);let{timeSlot:i,dateScheduling:n}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(u=>{let{to:f=handlers.timeTracker.dayEndTime+1}=u||{};if(u&&u.from>=f)throw d.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),n?.from!==void 0&&n?.to!==void 0&&n?.from>=n?.to)throw d.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");let o=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(r.id)||o.includes(r.id)?d.info(`Activity with id ${r.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(o.push(r.id),this.setStorageProperty("additionalActivitiesIds",o)),this.excludedActivitiesIds.includes(r.id)&&(this.removeActivityScheduling(r.id),d.log(`Activity with id ${r.id} was excluded from the ${this.id}, but now it will be added again with the new scheduling options. So it will be removed from the excluded activities list.`)),(i||n)&&this.editActivityScheduling(r.id,{timeSlot:i,dateScheduling:n});}removeActivity(e){let t=typeof e=="string"?e:e.id,r=this.additionalActivitiesIds;if(r.includes(t))r=r.filter(i=>i!==t),this.setStorageProperty("additionalActivitiesIds",r);else if(this.defaultActivitiesIds.includes(t)){let i=this.excludedActivitiesIds;i.push(t),this.setStorageProperty("excludedActivitiesIds",i);}else d.warn(`Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,r=this.additionalActivitiesIds,i=this.excludedActivitiesIds;r.forEach(n=>{if(n in e){let{to:o}=e[n].dateScheduling||{};o&&o<handlers.timeTracker.currentDate&&(this.removeActivityScheduling(n),r=r.filter(u=>u!==n));}}),i.forEach(n=>{n in t&&t[n]&&(this.removeActivityScheduling(n),i=i.filter(o=>o!==n));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let r=tt.RegisteredActivities.get(t);return r?.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(r),e},[])}};var Le="__nqtr-location__",v=class extends g{constructor(t,r,i=[]){super(Le,t,i);this._map=r;}_map;get map(){return this._map}get rooms(){return handlers.navigator.rooms.filter(t=>t.location.id===this.id)}};var P=class extends v{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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var $e="__nqtr-map__",I=class extends g{constructor(e,t=[]){super($e,e,t);}get locations(){return handlers.navigator.locations.filter(e=>e.map.id===this.id)}};var w=class extends I{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 he="__nqtr-room__",S=class extends g{_location;constructor(e,t,r=[]){Array.isArray(r)?super(he,e,r):(super(he,e,r.activities),r.routine.forEach(i=>{let n=typeof i=="string"?i:i.id;tt.fixedCommitments.set(n,e);})),this._location=t;}get routine(){return handlers.routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:r,dateScheduling:i}=t;if(r&&!Array.isArray(r)&&(r=[r]),r?.forEach(n=>{let{to:o=handlers.timeTracker.dayEndTime+1}=n||{};if(n&&n.from>=o)throw d.error("The from time must be less than the to time."),new core.PixiError("invalid_usage","The from time must be less than the to time.")}),i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw d.error("The from day/date must be less than the to day/date."),new core.PixiError("invalid_usage","The from day/date must be less than the to day/date.");handlers.routine.add(e,this.id,{timeSlot:r,dateScheduling:i});}removeCommitment(e){handlers.routine.remove(e,this.id);}get location(){return this._location}get characters(){return this.routine.reduce((e,t)=>(e.push(...t.characters),e),[])}get automaticFunctions(){return this.routine.reduce((e,t)=>{if(t.executionType==="automatic"&&t.run){let r=async i=>{await t.run(i);};e.push(r);}return e},[])}};var E=class extends S{constructor(e,t,r={}){super(e,t,{activities:r.activities||[],routine:r.routine||[]}),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"?storage.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"?storage.storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var ze="__nqtr-quest__",T=class extends storage.StoredClassModel{constructor(t,r,i={}){super(ze,t);this._stages=r;this._onStart=i.onStart,this._onContinue=i.onContinue||i.onNextStage;}_stages;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}_onContinue;get onContinue(){return this._onContinue}get onNextStage(){return this._onContinue}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){d.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r?.start)return this.onStart&&await this.onStart(this,t),await r.start(t);d.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(t){return await this.advanceIfCompleted(t)}async advanceIfCompleted(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.advanceUnconditionally(t):false:(d.error(`Quest ${this.id} has no current stage`),false)}async goNext(t){return await this.continue(t)}async continue(t){let r=this.currentStage;return r?(r.completed=true,await this.advanceUnconditionally(t)):(d.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(t){return await this.advanceUnconditionally(t)}async advanceUnconditionally(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,i=this.currentStageIndex;if(!r||i===void 0)return d.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onContinue&&await this.onContinue(this,t),r?.onEnd&&await r.onEnd(r,t);let n=this.currentStage;return n&&(n.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 D=class extends T{constructor(e,t,r){super(e,t,{onStart:r.onStart,onContinue:r.onContinue||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 Ge="__nqtr-stage__",R=class extends storage.StoredClassModel{constructor(e,t={}){super(Ge,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>handlers.timeTracker.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=handlers.timeTracker.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 q=class extends R{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=>storage.storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.storage.getFlag(e.flag))?false:super.canStart}};var Se={};var Te={};var J={};te(J,{navigator:()=>Xe,questsNotebook:()=>et,routine:()=>Ze,timeTracker:()=>Je});var O=class{get rooms(){return tt.RegisteredRooms.values()}get locations(){return tt.RegisteredLocations.values()}get maps(){return tt.RegisteredMaps.values()}get currentRoomId(){return storage.storage.get(h)}get currentRoom(){let e=this.currentRoomId;if(!e){d.error("The current room has not yet been set");return}let t=tt.RegisteredRooms.get(e);if(!t){d.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!tt.RegisteredRooms.get(e)){d.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.storage.get(h);r!==e&&(x({type:"editroom",prev:r,value:e}),storage.storage.set(h,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){tt.RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var N=class{get quests(){return tt.RegisteredQuests.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 tt.RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var V="___nqtr-temporary_commitment___",Q=class{get temporaryRoutine(){let e=storage.storage.get(V);if(e){if(Array.isArray(e)){if(e.length>0)throw new core.PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return e}get commitmentsIds(){return [...tt.fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let i=this.temporaryRoutine;e.forEach(n=>{let o=typeof n=="string"?n:n.id;i[o]={id:o,roomId:t,...r};}),storage.storage.set(V,i);}find(e){return tt.RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:d.warn(`The commitment ${e} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.storage.set(V,r);}clearExpiredRoutine(){tt.RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let i=tt.RegisteredCommitments.get(r),n=e[r],o=n?.roomId||tt.fixedCommitments.get(r);return o&&i?.isActive(n)&&(i.characters.length>0?i.characters.every(f=>!t[f.id]||i.priority>t[f.id][0].priority)&&i.characters.forEach(f=>{t[f.id]=[i,o];}):d.error(`The commitment ${i.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){let t=typeof e=="string"?e:e.id;return this.currentRoutine.find(r=>{if(r.characters.map(i=>i.id).includes(t))return r})}};var Ve={dayStartTime:0,dayEndTime:24,defaultTimeSpent:1,timeSlots:[],weekLength:7,weekendStartDay:6,getDayName:void 0},c=Ve;var M=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:n=[],weekLength:o=7,weekendStartDay:u=o-1,getDayName:f}=e;c.dayStartTime=t,c.dayEndTime=r,c.defaultTimeSpent=i,c.timeSlots=n,c.weekLength=o,u>=c.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${o}, so will be ignored`):c.weekendStartDay=u,c.getDayName=f;}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=storage.storage.get(m)||{};return Object.hasOwn(e,"currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.storage.get(m)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,x({type:"edittime",prev:t,value:r}),storage.storage.set(m,r);}get currentDate(){let e=storage.storage.get(m)||{};return Object.hasOwn(e,"currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.storage.get(m)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,x({type:"edittime",prev:t,value:r}),storage.storage.set(m,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=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,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 Je=new M,Xe=new O,Ze=new Q,et=new N;var rt={testing:F,...G,...Se,...Te,handlers:J,registries:tt__namespace},ti=rt;Object.defineProperty(exports,"RegisteredActivities",{enumerable:true,get:function(){return tt.RegisteredActivities}});Object.defineProperty(exports,"RegisteredCommitments",{enumerable:true,get:function(){return tt.RegisteredCommitments}});Object.defineProperty(exports,"RegisteredLocations",{enumerable:true,get:function(){return tt.RegisteredLocations}});Object.defineProperty(exports,"RegisteredMaps",{enumerable:true,get:function(){return tt.RegisteredMaps}});Object.defineProperty(exports,"RegisteredQuests",{enumerable:true,get:function(){return tt.RegisteredQuests}});Object.defineProperty(exports,"RegisteredRooms",{enumerable:true,get:function(){return tt.RegisteredRooms}});exports.ActivityBaseModel=_;exports.ActivityStoredClass=l;exports.CommitmentBaseModel=C;exports.CommitmentStoredClass=y;exports.LocationBaseModel=P;exports.LocationStoredClass=v;exports.MapBaseModel=w;exports.MapStoredClass=I;exports.QuestBaseModel=D;exports.QuestStoredClass=T;exports.RoomBaseModel=E;exports.RoomStoredClass=S;exports.StageBaseModel=q;exports.StageStoredClass=R;exports.default=ti;exports.testing=F;Object.keys(handlers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return handlers[k]}})});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, E as ExecutionType, O as OnRunEvent, A as ActivityInterface, Q as QuestInterface, a as QuestsRequiredType, S as StageInterface, R as RoomInterface, b as OnRunProps, c as ActivityBaseInternalInterface, d as ActiveScheduling, e as OnRunAsyncFunction, f as CommitmentBaseInternalInterface, N as NavigationAbstractInterface, L as LocationInternalInterface, M as MapInterface, g as MapBaseInternalInterface, h as LocationInterface, i as RoomBaseInternalInterface, j as QuestBaseInternalInterface, k as StageBaseInternalInterface } from './StageInterface-DzhX29F-.mjs';
|
|
2
|
+
export { l as OnRunFunction } from './StageInterface-DzhX29F-.mjs';
|
|
1
3
|
export * from '@drincs/nqtr/handlers';
|
|
2
4
|
import * as registries from '@drincs/nqtr/registries';
|
|
3
5
|
import { ActivityIdType, CommitmentIdType } from '@drincs/nqtr/registries';
|
|
4
6
|
export { ActivityIdType, CommitmentIdType, LocationIdType, MapIdType, NqtrActivityIds, NqtrCommitmentIds, NqtrLocationIds, NqtrMapIds, NqtrQuestIds, NqtrRoomIds, QuestIdType, RegisteredActivities, RegisteredCommitments, RegisteredLocations, RegisteredMaps, RegisteredQuests, RegisteredRooms, RoomIdType } from '@drincs/nqtr/registries';
|
|
5
|
-
import { T as TimeSchedulingInterface, D as DateSchedulingInterface, C as CommitmentInterface, E as ExecutionType, O as OnRunEvent, A as ActivityInterface, Q as QuestInterface, a as QuestsRequiredType, S as StageInterface, b as ActivityBaseInternalInterface, c as ActiveScheduling, d as OnRunAsyncFunction, e as CommitmentBaseInternalInterface, f as OnRunProps, N as NavigationAbstractInterface, L as LocationInternalInterface, M as MapInterface, R as RoomInterface, g as MapBaseInternalInterface, h as LocationInterface, i as RoomBaseInternalInterface, j as QuestBaseInternalInterface, k as StageBaseInternalInterface } from './StageInterface-B8NCX3T6.mjs';
|
|
6
|
-
export { l as OnRunFunction } from './StageInterface-B8NCX3T6.mjs';
|
|
7
7
|
import { StoredClassModel } from '@drincs/pixi-vn/storage';
|
|
8
8
|
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn/characters';
|
|
9
9
|
import { CharacterInterface as CharacterInterface$1, CharacterIdType as CharacterIdType$1 } from '@drincs/pixi-vn';
|
|
10
|
-
import { h as handlers$1 } from './index-
|
|
11
|
-
export { T as ITimeStlot, N as NavigatorHandlerInterface, Q as QuestHandlerInterface, R as RoutineHandlerInterface, a as TimeHandlerInterface, b as TimeSettings } from './index-
|
|
10
|
+
import { h as handlers$1 } from './index-CT-JfKIo.mjs';
|
|
11
|
+
export { T as ITimeStlot, N as NavigatorHandlerInterface, Q as QuestHandlerInterface, R as RoutineHandlerInterface, a as TimeHandlerInterface, b as TimeSettings } from './index-CT-JfKIo.mjs';
|
|
12
12
|
import '@drincs/nqtr';
|
|
13
13
|
|
|
14
14
|
interface ActivityProps {
|
|
@@ -290,6 +290,40 @@ interface StageProps {
|
|
|
290
290
|
onEnd?: OnRunEvent<StageInterface>;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
/** Actions applications can replace with their UI-aware implementations. */
|
|
294
|
+
interface NqtrTestingActions {
|
|
295
|
+
goToRoom(roomId: string): Promise<void>;
|
|
296
|
+
increaseTime(amount: number): Promise<void>;
|
|
297
|
+
increaseDate(days: number, hour?: number): Promise<void>;
|
|
298
|
+
addActivity(roomId: string, activityId: string): Promise<void>;
|
|
299
|
+
removeActivity(roomId: string, activityId: string): Promise<void>;
|
|
300
|
+
addCommitment(roomId: string, commitmentId: string): Promise<void>;
|
|
301
|
+
removeRoutine(commitmentId: string): Promise<void>;
|
|
302
|
+
runActivity(activityId: string): Promise<unknown>;
|
|
303
|
+
runCommitment(commitmentId: string): Promise<unknown>;
|
|
304
|
+
startQuest(questId: string): Promise<void>;
|
|
305
|
+
continueQuest(questId: string): Promise<boolean>;
|
|
306
|
+
}
|
|
307
|
+
/** Direct reads return registered domain objects; no React hook or cache is involved. */
|
|
308
|
+
interface NqtrTestingAPI extends NqtrTestingActions {
|
|
309
|
+
getCurrentRoom(): RoomInterface | undefined;
|
|
310
|
+
getRooms(): RoomInterface[];
|
|
311
|
+
getActivities(): ActivityInterface[];
|
|
312
|
+
getCommitments(): CommitmentInterface[];
|
|
313
|
+
getRoutine(): CommitmentInterface[];
|
|
314
|
+
getQuests(): QuestInterface[];
|
|
315
|
+
}
|
|
316
|
+
/** Opt-in browser testing bridge. Keep props and overrides fresh in the application. */
|
|
317
|
+
declare const testing: {
|
|
318
|
+
setProps(value: OnRunProps): void;
|
|
319
|
+
setActions(value: Partial<NqtrTestingActions>): void;
|
|
320
|
+
enable: (options?: {
|
|
321
|
+
windowKey?: string;
|
|
322
|
+
}) => NqtrTestingAPI;
|
|
323
|
+
disable: () => void;
|
|
324
|
+
isEnabled: () => boolean;
|
|
325
|
+
};
|
|
326
|
+
|
|
293
327
|
interface ActivityStoredClassProps extends ActiveScheduling {
|
|
294
328
|
}
|
|
295
329
|
declare class ActivityStoredClass<OnRunEventType = ActivityInterface> extends StoredClassModel implements ActivityBaseInternalInterface {
|
|
@@ -827,6 +861,16 @@ declare const nqtr: {
|
|
|
827
861
|
QuestStoredClass: typeof QuestStoredClass;
|
|
828
862
|
StageBaseModel: typeof StageBaseModel;
|
|
829
863
|
StageStoredClass: typeof StageStoredClass;
|
|
864
|
+
testing: {
|
|
865
|
+
setProps(value: OnRunProps): void;
|
|
866
|
+
setActions(value: Partial<NqtrTestingActions>): void;
|
|
867
|
+
enable: (options?: {
|
|
868
|
+
windowKey?: string;
|
|
869
|
+
}) => NqtrTestingAPI;
|
|
870
|
+
disable: () => void;
|
|
871
|
+
isEnabled: () => boolean;
|
|
872
|
+
};
|
|
830
873
|
};
|
|
831
874
|
|
|
832
|
-
export { ActiveScheduling, ActivityBaseModel, ActivityInterface,
|
|
875
|
+
export { ActiveScheduling, ActivityBaseModel, ActivityInterface, ActivityStoredClass, CommitmentBaseModel, CommitmentInterface, CommitmentStoredClass, DateSchedulingInterface, ExecutionType, LocationBaseModel, LocationInterface, LocationStoredClass, MapBaseModel, MapInterface, MapStoredClass, OnRunAsyncFunction, OnRunEvent, OnRunProps, QuestBaseModel, QuestInterface, QuestStoredClass, QuestsRequiredType, RoomBaseModel, RoomInterface, RoomStoredClass, StageBaseModel, StageInterface, StageStoredClass, TimeSchedulingInterface, nqtr as default, testing };
|
|
876
|
+
export type { ActivityProps, ActivityStoredClassProps, CommitmentInfo, CommitmentProps, CommitmentStoredClassProps, LocationBaseModelProps, MapBaseModelProps, NqtrTestingAPI, NqtrTestingActions, QuestProps, QuestStoredClassProps, RoomBaseModelProps, StageProps, StageStoredClassProps };
|