@drincs/nqtr
Version:
A complete system introducing the concepts of location, time and event, producing the framework of a not-quite-point-and-click adventure game.
271 lines (262 loc) • 10.2 kB
TypeScript
import { R as RoomInterface, h as LocationInterface, M as MapInterface, Q as QuestInterface, C as CommitmentInterface, c as ActiveScheduling } from './StageInterface-BN_O8nDA.js';
import { RoomIdType, CommitmentIdType } from '@drincs/nqtr/registries';
import { OnRunProps } from '@drincs/nqtr';
import { CharacterInterface, CharacterIdType } from '@drincs/pixi-vn';
type TimeSlotInterface = {
name: string;
startTime: number;
};
/**
* Time Settings, which can be set using {@link timeTracker.editSettings}
*/
type TimeSettings = {
/**
* Minimum time of the day
* @default 0
*/
dayStartTime?: number;
/**
* Maximum time of the day
* @default 24
*/
dayEndTime?: number;
/**
* Default time spent
* @default 1
*/
defaultTimeSpent?: number;
/**
* Time slots
* @default []
* @example
* ```ts
* [
* { name: 'Morning', startTime: 5 },
* { name: 'Afternoon', startTime: 12 },
* { name: 'Evening', startTime: 18 },
* { name: 'Night', startTime: 22 }
* ]
*/
timeSlots?: TimeSlotInterface[];
/**
* Week length
* @default 7
*/
weekLength?: number;
/**
* Weekend start day. For example, if the real life weekend starts on Saturday, then the value should be 6
* @default weekLength - 1
*/
weekendStartDay?: number;
/**
* Week days name
* @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
* @returns The name of the week day.
* @example
* ```ts
* (weekDayNumber: number) => {
* const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
* return weekDaysNames[weekDayNumber];
* }
* ```
*/
getDayName?: (weekDayNumber: number) => string;
};
declare class NavigatorHandler {
get rooms(): RoomInterface[];
get locations(): LocationInterface[];
get maps(): MapInterface[];
get currentRoomId(): string | undefined;
get currentRoom(): RoomInterface | undefined;
set currentRoom(room: RoomInterface | RoomIdType);
get currentLocation(): LocationInterface | undefined;
get currentMap(): MapInterface | undefined;
/**
* Clear all the expired activities.
*/
clearExpiredActivities(): void;
}
declare class QuestHandler {
/**
* The quests registered in the game.
*/
get quests(): QuestInterface[];
/**
* The quests that are started, so they are in progress or completed or failed.
*/
get startedQuests(): QuestInterface[];
/**
* The quests that are in progress.
*/
get inProgressQuests(): QuestInterface[];
/**
* The quests that are completed.
*/
get completedQuests(): QuestInterface[];
/**
* The quests that are failed.
*/
get failedQuests(): QuestInterface[];
/**
* The quests that are not started.
*/
get notStartedQuests(): QuestInterface[];
/**
* Get the quest by the id.
* @param id The id of the quest.
* @returns The quest with the id.
*/
find(id: string): QuestInterface | undefined;
/**
* Start the quests that must start on the current stage.
*/
startsStageMustBeStarted(props: OnRunProps): Promise<void>;
}
declare class RoutineHandler {
/**
* Get the temporary commitments by its id.
* @returns The temporary commitments.
*/
private get temporaryRoutine();
get commitmentsIds(): string[];
/**
* This feature adds the commitments during the game session.
* @param commitment The commitment or commitments to add.
* @param roomId The id of the room where the commitment is.
*/
add(commitment: (CommitmentInterface | CommitmentIdType)[] | CommitmentInterface | CommitmentIdType, roomId: string, options?: ActiveScheduling): void;
/**
* Get the commitments added during the game session.
* @param id The id of the commitment.
* @returns The commitment or undefined if not found.
*/
find(id: string): CommitmentInterface | undefined;
/**
* Remove the commitments added during the game session.
* @param commitment The commitment or commitment id to remove.
* @param roomId The id of the room where the commitment is.
*/
remove(commitment: CommitmentInterface | CommitmentIdType, roomId?: string): void;
/**
* Clear all the expired commitments.
*/
clearExpiredRoutine(): void;
get characterCommitments(): {
[character: string]: [CommitmentInterface, string];
};
/**
* Get the current commitments. The hidden commitments are not included.
* 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.
* Higher priority commitments are calculated using the following steps:
* 1. The commitments that have Commitments BaseModel.priority set to a higher value will be selected first.
* 2. If there are commitments with the same priority, the commitments that are not fixed will be selected first.
* 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.
* @returns The current commitments.
*/
get currentRoutine(): CommitmentInterface[];
get roomCommitments(): {
[roomId: string]: CommitmentInterface[];
};
/**
* Get the character commitment.
* @param character The character.
* @returns The commitment or undefined if not found.
*/
getCommitmentByCharacter(character: CharacterInterface | CharacterIdType): CommitmentInterface | undefined;
}
declare class TimeHandler {
initialize(settings: TimeSettings): void;
get dayStartTime(): number;
get dayEndTime(): number;
get defaultTimeSpent(): number;
get timeSlots(): TimeSlotInterface[];
get weekLength(): number;
get weekendStartDay(): number;
/**
* Week days name
* @param weekDayNumber The current week day number (from: 0 - to: {@link weekLength} - 1).
* @returns The name of the week day.
* @example
* ```ts
* (weekDayNumber: number) => {
* const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
* return weekDaysNames[weekDayNumber];
* }
* ```
*/
get getDayName(): ((weekDayNumber: number) => string) | undefined;
/**
* Get the current time. Time is a numeric variable used to determine and manage time during a day/date.
* 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.
*/
get currentTime(): number;
set currentTime(value: number | undefined);
/**
* Get the current date. Date is a numeric variable used to determine and manage the number of days passed.
* It's recommended to use currentDate as if it were the current day.
*/
get currentDate(): number;
set currentDate(value: number | undefined);
/**
* If the current day is greater than or equal to the weekend start day, then it will return true.
*/
get isWeekend(): boolean;
/**
* Get the current week day number (from: 1 - to: {@link weekLength}).
* For example, if the week length is 7 and the current day is 10, then the result will be 4.
*/
get currentWeekDayNumber(): number;
/**
* Get the current week day name. If the week days names are not defined, then it will return undefined.
* 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'.
* @default ""
*/
get currentDayName(): string;
/**
* Get the current {@link timeSlots} index.
* You can use this property to create "Image that changes based on the time period":
* @example
* ```tsx
* import { weekLength } from '@drincs/nqtr';
*
* function changeBackground() {
* return (
* <img src={`background-currentTimeSlot.currentTimeSlot.png`} />
* )
* }
*/
get currentTimeSlot(): number;
/**
* This function will increase the current time by the given time spent.
* If the new time is greater than or equal to the max day times, then it will increase the day and set the new time.
* @param delta is the time spent in times (default: {@link defaultTimeSpent})
* @returns currentTimeSlot.currentTime
*/
increaseTime(delta?: number): number;
/**
* This function will increase the current date by the given delta.
* @param delta is the number of days to increase (default: 1)
* @param time is the time of the new day (default: {@link dayStartTime})
* @returns timeTracker.currentDate
*/
increaseDate(delta?: number, time?: number): number;
/**
* This function will check if the current time is between the given times.
* @param fromTime the starting time. If the {@link currentTime} is equal to this time, the function will return true.
* @param toTime the ending time.
* @returns true if the current time is between the given times, otherwise false.
*/
nowIsBetween(fromTime: number | undefined, toTime: number | undefined): boolean;
}
declare const timeTracker: TimeHandler;
declare const navigator: NavigatorHandler;
declare const routine: RoutineHandler;
declare const questsNotebook: QuestHandler;
declare const handlers_navigator: typeof navigator;
declare const handlers_questsNotebook: typeof questsNotebook;
declare const handlers_routine: typeof routine;
declare const handlers_timeTracker: typeof timeTracker;
declare namespace handlers {
export { handlers_navigator as navigator, handlers_questsNotebook as questsNotebook, handlers_routine as routine, handlers_timeTracker as timeTracker };
}
export { type TimeSlotInterface as T, type TimeSettings as a, handlers as h, navigator as n, questsNotebook as q, routine as r, timeTracker as t };