@drincs/nqtr 1.0.3 → 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 +47 -1
- package/dist/{StageInterface-BN_O8nDA.d.mts → StageInterface-DzhX29F-.d.mts} +20 -1
- package/dist/{StageInterface-BN_O8nDA.d.ts → StageInterface-DzhX29F-.d.ts} +20 -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-CT-JfKIo.d.mts +367 -0
- package/dist/index-DehHTT06.d.ts +367 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +51 -7
- package/dist/index.d.ts +51 -7
- 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 +13 -10
- package/dist/index-CtxMgD9N.d.ts +0 -270
- package/dist/index-D0T0L2IE.d.mts +0 -270
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Navigation Quest Time Routine (NQTR)
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://www.npmjs.com/package/@drincs/nqtr" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/@drincs/nqtr?label=version" alt="npm version"></a>
|
|
@@ -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.
|
|
@@ -43,6 +43,25 @@ interface ActiveScheduling {
|
|
|
43
43
|
|
|
44
44
|
type ExecutionType = "automatic" | "interaction";
|
|
45
45
|
|
|
46
|
+
/** biome-ignore-all lint/suspicious/noEmptyInterface: <explanation> */
|
|
47
|
+
/**
|
|
48
|
+
* Object passed to the functions triggered by the system (e.g. {@link OnRunEvent}),
|
|
49
|
+
* allowing you to customize and access properties inside them.
|
|
50
|
+
*
|
|
51
|
+
* By default it is an empty interface. You can override it in your `.d.ts` file
|
|
52
|
+
* (module augmentation) to specify the required properties.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts title="nqtr.d.ts"
|
|
56
|
+
* import "@drincs/nqtr";
|
|
57
|
+
*
|
|
58
|
+
* declare module "@drincs/nqtr" {
|
|
59
|
+
* interface OnRunProps {
|
|
60
|
+
* navigate: (route: string) => void;
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
46
65
|
interface OnRunProps {
|
|
47
66
|
}
|
|
48
67
|
/**
|
|
@@ -360,4 +379,4 @@ interface StageBaseInternalInterface {
|
|
|
360
379
|
readonly questsRequired: QuestsRequiredType[];
|
|
361
380
|
}
|
|
362
381
|
|
|
363
|
-
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 };
|
|
@@ -43,6 +43,25 @@ interface ActiveScheduling {
|
|
|
43
43
|
|
|
44
44
|
type ExecutionType = "automatic" | "interaction";
|
|
45
45
|
|
|
46
|
+
/** biome-ignore-all lint/suspicious/noEmptyInterface: <explanation> */
|
|
47
|
+
/**
|
|
48
|
+
* Object passed to the functions triggered by the system (e.g. {@link OnRunEvent}),
|
|
49
|
+
* allowing you to customize and access properties inside them.
|
|
50
|
+
*
|
|
51
|
+
* By default it is an empty interface. You can override it in your `.d.ts` file
|
|
52
|
+
* (module augmentation) to specify the required properties.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts title="nqtr.d.ts"
|
|
56
|
+
* import "@drincs/nqtr";
|
|
57
|
+
*
|
|
58
|
+
* declare module "@drincs/nqtr" {
|
|
59
|
+
* interface OnRunProps {
|
|
60
|
+
* navigate: (route: string) => void;
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
46
65
|
interface OnRunProps {
|
|
47
66
|
}
|
|
48
67
|
/**
|
|
@@ -360,4 +379,4 @@ interface StageBaseInternalInterface {
|
|
|
360
379
|
readonly questsRequired: QuestsRequiredType[];
|
|
361
380
|
}
|
|
362
381
|
|
|
363
|
-
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};
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { R as RoomInterface, h as LocationInterface, M as MapInterface, C as CommitmentInterface, d as ActiveScheduling, Q as QuestInterface } from './StageInterface-DzhX29F-.mjs';
|
|
2
|
+
import { RoomIdType, CommitmentIdType } from '@drincs/nqtr/registries';
|
|
3
|
+
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
|
|
4
|
+
import { OnRunProps } from '@drincs/nqtr';
|
|
5
|
+
|
|
6
|
+
type TimeSlotInterface = {
|
|
7
|
+
name: string;
|
|
8
|
+
startTime: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Time Settings, which can be set using {@link timeTracker.editSettings}
|
|
12
|
+
*/
|
|
13
|
+
type TimeSettings = {
|
|
14
|
+
/**
|
|
15
|
+
* Minimum time of the day
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
dayStartTime?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum time of the day
|
|
21
|
+
* @default 24
|
|
22
|
+
*/
|
|
23
|
+
dayEndTime?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Default time spent
|
|
26
|
+
* @default 1
|
|
27
|
+
*/
|
|
28
|
+
defaultTimeSpent?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Time slots
|
|
31
|
+
* @default []
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* [
|
|
35
|
+
* { name: 'Morning', startTime: 5 },
|
|
36
|
+
* { name: 'Afternoon', startTime: 12 },
|
|
37
|
+
* { name: 'Evening', startTime: 18 },
|
|
38
|
+
* { name: 'Night', startTime: 22 }
|
|
39
|
+
* ]
|
|
40
|
+
*/
|
|
41
|
+
timeSlots?: TimeSlotInterface[];
|
|
42
|
+
/**
|
|
43
|
+
* Week length
|
|
44
|
+
* @default 7
|
|
45
|
+
*/
|
|
46
|
+
weekLength?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Weekend start day. For example, if the real life weekend starts on Saturday, then the value should be 6
|
|
49
|
+
* @default weekLength - 1
|
|
50
|
+
*/
|
|
51
|
+
weekendStartDay?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Week days name
|
|
54
|
+
* @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
|
|
55
|
+
* @returns The name of the week day.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* (weekDayNumber: number) => {
|
|
59
|
+
* const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
60
|
+
* return weekDaysNames[weekDayNumber];
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
getDayName?: (weekDayNumber: number) => string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Handler that manages the navigation system: it gives access to all the registered
|
|
69
|
+
* rooms, locations and maps, and keeps track of the room where the player currently is.
|
|
70
|
+
*/
|
|
71
|
+
interface NavigatorHandlerInterface {
|
|
72
|
+
/**
|
|
73
|
+
* All the registered rooms.
|
|
74
|
+
*/
|
|
75
|
+
readonly rooms: RoomInterface[];
|
|
76
|
+
/**
|
|
77
|
+
* All the registered locations.
|
|
78
|
+
*/
|
|
79
|
+
readonly locations: LocationInterface[];
|
|
80
|
+
/**
|
|
81
|
+
* All the registered maps.
|
|
82
|
+
*/
|
|
83
|
+
readonly maps: MapInterface[];
|
|
84
|
+
/**
|
|
85
|
+
* The id of the room where the player currently is, read from the game storage.
|
|
86
|
+
* It is `undefined` if the current room has not been set yet.
|
|
87
|
+
*/
|
|
88
|
+
readonly currentRoomId: string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* The room where the player currently is.
|
|
91
|
+
* Getting it returns `undefined` (and logs an error) if the current room has not been set
|
|
92
|
+
* or if it is not registered.
|
|
93
|
+
*
|
|
94
|
+
* Setting it accepts a room or a room id. If the room is not registered, an error is logged
|
|
95
|
+
* and nothing changes. If it is already the current room, nothing happens; otherwise
|
|
96
|
+
* the change is stored and tracked as the last event.
|
|
97
|
+
*/
|
|
98
|
+
get currentRoom(): RoomInterface | undefined;
|
|
99
|
+
set currentRoom(room: RoomInterface | RoomIdType);
|
|
100
|
+
/**
|
|
101
|
+
* The location that contains the current room, or `undefined` if there is no current room.
|
|
102
|
+
*/
|
|
103
|
+
readonly currentLocation: LocationInterface | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* The map that contains the current location, or `undefined` if there is no current room.
|
|
106
|
+
*/
|
|
107
|
+
readonly currentMap: MapInterface | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Clear all the expired activities from every registered room.
|
|
110
|
+
*/
|
|
111
|
+
clearExpiredActivities(): void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Handler that manages the routine of the characters: the commitments (fixed or added during the
|
|
116
|
+
* game session) and the rooms where they take place.
|
|
117
|
+
*/
|
|
118
|
+
interface RoutineHandlerInterface {
|
|
119
|
+
/**
|
|
120
|
+
* The ids of all the commitments: the fixed ones and the ones added during the game session.
|
|
121
|
+
*/
|
|
122
|
+
readonly commitmentsIds: string[];
|
|
123
|
+
/**
|
|
124
|
+
* The commitments that are currently active, grouped by character id.
|
|
125
|
+
* Each value is a tuple with the commitment and the id of the room where it takes place.
|
|
126
|
+
* If a character has two or more commitments at the same time, only the one with the highest priority is kept.
|
|
127
|
+
*/
|
|
128
|
+
readonly characterCommitments: {
|
|
129
|
+
[character: string]: [CommitmentInterface, string];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* The current commitments. The hidden commitments are not included.
|
|
133
|
+
* In case there is a character who has two or more commitments at the same time, will be selected the commitment with the highest priority.
|
|
134
|
+
* Higher priority commitments are calculated using the following steps:
|
|
135
|
+
* 1. The commitments that have Commitments BaseModel.priority set to a higher value will be selected first.
|
|
136
|
+
* 2. If there are commitments with the same priority, the commitments that are not fixed will be selected first.
|
|
137
|
+
* 3. If there are commitments with the same priority and the same fixed status, priority will be given to the commitment with a lower index.
|
|
138
|
+
*/
|
|
139
|
+
readonly currentRoutine: CommitmentInterface[];
|
|
140
|
+
/**
|
|
141
|
+
* The current commitments grouped by the id of the room where they take place.
|
|
142
|
+
*/
|
|
143
|
+
readonly roomCommitments: {
|
|
144
|
+
[roomId: string]: CommitmentInterface[];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Add commitments during the game session.
|
|
148
|
+
* @param commitment The commitment or commitments (or their ids) to add.
|
|
149
|
+
* @param roomId The id of the room where the commitment is.
|
|
150
|
+
* @param options The scheduling options of the commitment (e.g. when it starts and ends).
|
|
151
|
+
*/
|
|
152
|
+
add(commitment: (CommitmentInterface | CommitmentIdType)[] | CommitmentInterface | CommitmentIdType, roomId: string, options?: ActiveScheduling): void;
|
|
153
|
+
/**
|
|
154
|
+
* Get a registered commitment by its id.
|
|
155
|
+
* @param id The id of the commitment.
|
|
156
|
+
* @returns The commitment or undefined if not found.
|
|
157
|
+
*/
|
|
158
|
+
find(id: string): CommitmentInterface | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Remove a commitment added during the game session. Fixed commitments can't be removed.
|
|
161
|
+
* @param commitment The commitment or commitment id to remove.
|
|
162
|
+
* @param roomId If set, the commitment is removed only if it was added to this room.
|
|
163
|
+
*/
|
|
164
|
+
remove(commitment: CommitmentInterface | CommitmentIdType, roomId?: string): void;
|
|
165
|
+
/**
|
|
166
|
+
* Clear all the expired commitments.
|
|
167
|
+
*/
|
|
168
|
+
clearExpiredRoutine(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Get the current commitment of a character.
|
|
171
|
+
* @param character The character or the character id.
|
|
172
|
+
* @returns The commitment or undefined if not found.
|
|
173
|
+
*/
|
|
174
|
+
getCommitmentByCharacter(character: CharacterInterface | CharacterIdType): CommitmentInterface | undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Handler that manages the quests registered in the game.
|
|
179
|
+
*/
|
|
180
|
+
interface QuestHandlerInterface {
|
|
181
|
+
/**
|
|
182
|
+
* The quests registered in the game.
|
|
183
|
+
*/
|
|
184
|
+
readonly quests: QuestInterface[];
|
|
185
|
+
/**
|
|
186
|
+
* The quests that are started, so they are in progress or completed or failed.
|
|
187
|
+
*/
|
|
188
|
+
readonly startedQuests: QuestInterface[];
|
|
189
|
+
/**
|
|
190
|
+
* The quests that are in progress.
|
|
191
|
+
*/
|
|
192
|
+
readonly inProgressQuests: QuestInterface[];
|
|
193
|
+
/**
|
|
194
|
+
* The quests that are completed.
|
|
195
|
+
*/
|
|
196
|
+
readonly completedQuests: QuestInterface[];
|
|
197
|
+
/**
|
|
198
|
+
* The quests that are failed.
|
|
199
|
+
*/
|
|
200
|
+
readonly failedQuests: QuestInterface[];
|
|
201
|
+
/**
|
|
202
|
+
* The quests that are not started.
|
|
203
|
+
*/
|
|
204
|
+
readonly notStartedQuests: QuestInterface[];
|
|
205
|
+
/**
|
|
206
|
+
* Get the quest by the id.
|
|
207
|
+
* @param id The id of the quest.
|
|
208
|
+
* @returns The quest with the id, or `undefined` if not found.
|
|
209
|
+
*/
|
|
210
|
+
find(id: string): QuestInterface | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Start the current stage of every quest whose current stage must be started automatically.
|
|
213
|
+
* @param props The props passed to the functions triggered by the stages. See {@link OnRunProps}.
|
|
214
|
+
*/
|
|
215
|
+
startsStageMustBeStarted(props: OnRunProps): Promise<void>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Handler that manages the time of the game: the current time and date, the day/week structure
|
|
220
|
+
* and the time slots.
|
|
221
|
+
*/
|
|
222
|
+
interface TimeHandlerInterface {
|
|
223
|
+
/**
|
|
224
|
+
* Set the time settings. Omitted values fall back to their defaults.
|
|
225
|
+
* @param settings The time settings.
|
|
226
|
+
*/
|
|
227
|
+
initialize(settings: TimeSettings): void;
|
|
228
|
+
/**
|
|
229
|
+
* The time at which a day starts.
|
|
230
|
+
*/
|
|
231
|
+
readonly dayStartTime: number;
|
|
232
|
+
/**
|
|
233
|
+
* The time at which a day ends. When the time reaches it, the date increases.
|
|
234
|
+
*/
|
|
235
|
+
readonly dayEndTime: number;
|
|
236
|
+
/**
|
|
237
|
+
* The default time spent by {@link increaseTime} when no delta is given.
|
|
238
|
+
*/
|
|
239
|
+
readonly defaultTimeSpent: number;
|
|
240
|
+
/**
|
|
241
|
+
* The time slots of a day (e.g. morning, afternoon, evening).
|
|
242
|
+
*/
|
|
243
|
+
readonly timeSlots: TimeSlotInterface[];
|
|
244
|
+
/**
|
|
245
|
+
* The number of days in a week.
|
|
246
|
+
*/
|
|
247
|
+
readonly weekLength: number;
|
|
248
|
+
/**
|
|
249
|
+
* The week day (starting from 0) from which the weekend starts.
|
|
250
|
+
*/
|
|
251
|
+
readonly weekendStartDay: number;
|
|
252
|
+
/**
|
|
253
|
+
* Week days name
|
|
254
|
+
* @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
|
|
255
|
+
* @returns The name of the week day.
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* (weekDayNumber: number) => {
|
|
259
|
+
* const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
260
|
+
* return weekDaysNames[weekDayNumber];
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
readonly getDayName: ((weekDayNumber: number) => string) | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* The current time. Time is a numeric variable used to determine and manage time during a day/date.
|
|
267
|
+
* It's recommended to use currentTime as if it were the current time. If you also want to manage minutes, you can use a float value.
|
|
268
|
+
* Setting it to `undefined` resets it to {@link dayStartTime}.
|
|
269
|
+
*/
|
|
270
|
+
get currentTime(): number;
|
|
271
|
+
set currentTime(value: number | undefined);
|
|
272
|
+
/**
|
|
273
|
+
* The current date. Date is a numeric variable used to determine and manage the number of days passed.
|
|
274
|
+
* It's recommended to use currentDate as if it were the current day.
|
|
275
|
+
* Setting it to `undefined` resets it to 0.
|
|
276
|
+
*/
|
|
277
|
+
get currentDate(): number;
|
|
278
|
+
set currentDate(value: number | undefined);
|
|
279
|
+
/**
|
|
280
|
+
* If the current day is greater than or equal to the weekend start day, then it will return true.
|
|
281
|
+
*/
|
|
282
|
+
readonly isWeekend: boolean;
|
|
283
|
+
/**
|
|
284
|
+
* The current week day number (from: 1 - to: {@link weekLength}).
|
|
285
|
+
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
|
|
286
|
+
*/
|
|
287
|
+
readonly currentWeekDayNumber: number;
|
|
288
|
+
/**
|
|
289
|
+
* The current week day name. If the week days names are not defined, then it will return an empty string.
|
|
290
|
+
* For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
|
|
291
|
+
* @default ""
|
|
292
|
+
*/
|
|
293
|
+
readonly currentDayName: string;
|
|
294
|
+
/**
|
|
295
|
+
* The index of the current time slot in {@link timeSlots}.
|
|
296
|
+
* You can use this property to create "Image that changes based on the time period":
|
|
297
|
+
* @example
|
|
298
|
+
* ```tsx
|
|
299
|
+
* import { timeTracker } from '@drincs/nqtr';
|
|
300
|
+
*
|
|
301
|
+
* function changeBackground() {
|
|
302
|
+
* return (
|
|
303
|
+
* <img src={`background-${timeTracker.currentTimeSlot}.png`} />
|
|
304
|
+
* )
|
|
305
|
+
* }
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
readonly currentTimeSlot: number;
|
|
309
|
+
/**
|
|
310
|
+
* Increase the current time by the given time spent.
|
|
311
|
+
* If the new time is greater than or equal to {@link dayEndTime}, then it will increase the day and set the new time.
|
|
312
|
+
* @param delta The time spent (default: {@link defaultTimeSpent}).
|
|
313
|
+
* @returns The new current time.
|
|
314
|
+
*/
|
|
315
|
+
increaseTime(delta?: number): number;
|
|
316
|
+
/**
|
|
317
|
+
* Increase the current date by the given delta.
|
|
318
|
+
* @param delta The number of days to increase (default: 1).
|
|
319
|
+
* @param time The time of the new day (default: {@link dayStartTime}).
|
|
320
|
+
* @returns The new current date.
|
|
321
|
+
*/
|
|
322
|
+
increaseDate(delta?: number, time?: number): number;
|
|
323
|
+
/**
|
|
324
|
+
* Check if the current time is between the given times.
|
|
325
|
+
* @param fromTime The starting time. If the {@link currentTime} is equal to this time, the function will return true. If undefined, the day start is used.
|
|
326
|
+
* @param toTime The ending time. If undefined, the day end is used.
|
|
327
|
+
* @returns true if the current time is between the given times, otherwise false.
|
|
328
|
+
*/
|
|
329
|
+
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The global time manager instance. It handles the current time and date, the week structure
|
|
334
|
+
* (week length, weekend, day names) and the time slots of the day.
|
|
335
|
+
*/
|
|
336
|
+
declare const timeTracker: TimeHandlerInterface;
|
|
337
|
+
/**
|
|
338
|
+
* The global navigator instance. It gives access to the registered maps, locations and rooms,
|
|
339
|
+
* and it keeps track of the room where the player currently is (saved and restored with the game state).
|
|
340
|
+
*/
|
|
341
|
+
declare const navigator: NavigatorHandlerInterface;
|
|
342
|
+
/**
|
|
343
|
+
* The global routine manager instance. It handles the commitments of the characters (fixed or added
|
|
344
|
+
* during the game session), the rooms where they take place and the current routine of each character.
|
|
345
|
+
*/
|
|
346
|
+
declare const routine: RoutineHandlerInterface;
|
|
347
|
+
/**
|
|
348
|
+
* The global quests manager instance. It gives access to the registered quests, filtered by their
|
|
349
|
+
* state (not started, in progress, completed, failed), and it starts the stages that must start automatically.
|
|
350
|
+
*/
|
|
351
|
+
declare const questsNotebook: QuestHandlerInterface;
|
|
352
|
+
|
|
353
|
+
declare const handlers_navigator: typeof navigator;
|
|
354
|
+
declare const handlers_questsNotebook: typeof questsNotebook;
|
|
355
|
+
declare const handlers_routine: typeof routine;
|
|
356
|
+
declare const handlers_timeTracker: typeof timeTracker;
|
|
357
|
+
declare namespace handlers {
|
|
358
|
+
export {
|
|
359
|
+
handlers_navigator as navigator,
|
|
360
|
+
handlers_questsNotebook as questsNotebook,
|
|
361
|
+
handlers_routine as routine,
|
|
362
|
+
handlers_timeTracker as timeTracker,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
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 };
|