UNPKG

@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.

1 lines 19.6 kB
{"version":3,"sources":["../../../src/constants.ts","../../../src/managers/TimeManagerSettings.ts","../../../src/managers/TimeManager.ts","../../../src/managers/index.ts","../../../src/classes/quest/StageStoredClass.ts"],"names":["TIME_DATA_KEY","TimeManagerSettings","TimeManager","settings","minDayHours","maxDayHours","defaultTimeSpent","timeSlots","weekLength","weekendStartDay","weekDaysNames","data","storage","value","weekDayNumber","index","slot","timeSpent","newHour","newDayHour","days","newDay","fromHour","toHour","currentHour","timeTracker","navigator","STAGE_CATEGORY","StageStoredClass","StoredClassModel","id","options","prevStageEndDay","daysRequired","q","props"],"mappings":"uDACO,IAAMA,CAAAA,CAAgB,+BCC7B,IAAqBC,CAAAA,CAArB,KAAiE,CAC7D,OAAO,WAAsB,CAAA,CAAA,CAC7B,OAAO,WAAsB,CAAA,EAAA,CAC7B,OAAO,gBAA2B,CAAA,CAAA,CAClC,OAAO,SAA0B,CAAA,EACjC,CAAA,OAAO,WAAqB,CAC5B,CAAA,OAAO,gBAA0B,IAAK,CAAA,UAAA,CAAa,EACnD,OAAO,aAAA,CAA0B,EACrC,ECJA,IAAqBC,CAAAA,CAArB,KAAiC,CAC7B,UAAA,CAAWC,EAAwB,CAC/B,GAAM,CACF,WAAA,CAAAC,EAAc,CACd,CAAA,WAAA,CAAAC,EAAc,EACd,CAAA,gBAAA,CAAAC,EAAmB,CACnB,CAAA,SAAA,CAAAC,CAAY,CAAA,GACZ,UAAAC,CAAAA,CAAAA,CAAa,EACb,eAAAC,CAAAA,CAAAA,CAAkBD,EAAa,CAC/B,CAAA,aAAA,CAAAE,CAAgB,CAAA,EACpB,CAAIP,CAAAA,CAAAA,CACJF,EAAoB,WAAcG,CAAAA,CAAAA,CAClCH,EAAoB,WAAcI,CAAAA,CAAAA,CAClCJ,CAAoB,CAAA,gBAAA,CAAmBK,EACvCL,CAAoB,CAAA,SAAA,CAA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AY,CAAA,UAAA,CAC7C,OAAO,MAEf,CACA,OACI,EAAK,IAAA,CAAA,qBAAA,CAAsB,OAAS,CACpC,EAAA,CAAC,IAAK,CAAA,qBAAA,CAAsB,MACvBS,CAAMA,EAAAA,CAAAA,CAAE,MAAM,iBAAqBA,EAAAA,CAAAA,CAAE,MAAM,iBAAqBA,EAAAA,CAAAA,CAAE,WACvE,CAAA,CAKR,CAEA,UAAa,EAAA,CACL,KAAK,mBAAsB,CAAA,CAAA,GAC3B,KAAK,eAAkBT,CAAAA,CAAAA,CAAY,UACnC,CAAA,OAAA,CAAQ,IAAI,CAAgB,aAAA,EAAA,IAAA,CAAK,EAAE,CAAsB,mBAAA,EAAA,IAAA,CAAK,QAAQ,CAAE,CAAA,CAAA,EAEhF,CAEA,KAAA,CAAMU,EAAmB,CACjB,IAAA,CAAK,UACL,IAAK,CAAA,OAAA,CAAU,KACX,IAAK,CAAA,OAAA,EACL,IAAK,CAAA,OAAA,CAAQ,KAA+BA,CAAK,CAAA,EAGrD,QAAQ,IAAK,CAAA,CAAA,aAAA,EAAgB,KAAK,EAAE,CAAA,YAAA,CAAc,EAE1D,CAEQ,qBACR,IAAI,mBAAA,EAA8B,CAC9B,OAAO,IAAA,CAAK,sBAAwB,CACxC,CAEQ,sBACR,CAAA,IAAI,uBAA8C,CAC9C,OAAO,KAAK,sBAA0B,EAAA,EAC1C,CACJ","file":"StageStoredClass.mjs","sourcesContent":["export const TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nexport const TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\n","import { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nexport default class TimeManagerSettings implements TimeSettings {\n static minDayHours: number = 0\n static maxDayHours: number = 24\n static defaultTimeSpent: number = 1\n static timeSlots: ITimeStlot[] = []\n static weekLength: number = 7\n static weekendStartDay: number = this.weekLength - 1\n static weekDaysNames: string[] = []\n}\n","import { storage } from \"@drincs/pixi-vn\";\nimport { TIME_DATA_KEY } from \"../constants\";\nimport TimeDataType from \"../types/TimeDataType\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\nimport TimeManagerSettings from \"./TimeManagerSettings\";\n\nexport default class TimeManager {\n initialize(settings: TimeSettings) {\n const {\n minDayHours = 0,\n maxDayHours = 24,\n defaultTimeSpent = 1,\n timeSlots = [],\n weekLength = 7,\n weekendStartDay = weekLength - 1,\n weekDaysNames = [],\n } = settings;\n TimeManagerSettings.minDayHours = minDayHours;\n TimeManagerSettings.maxDayHours = maxDayHours;\n TimeManagerSettings.defaultTimeSpent = defaultTimeSpent;\n TimeManagerSettings.timeSlots = timeSlots;\n TimeManagerSettings.weekLength = weekLength;\n if (weekendStartDay >= TimeManagerSettings.weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}, so will be ignored`);\n } else {\n TimeManagerSettings.weekendStartDay = weekendStartDay;\n }\n if (weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}, so will be ignored`);\n } else {\n TimeManagerSettings.weekDaysNames = weekDaysNames;\n }\n }\n get minDayHours(): number {\n return TimeManagerSettings.minDayHours;\n }\n get maxDayHours(): number {\n return TimeManagerSettings.maxDayHours;\n }\n get defaultTimeSpent(): number {\n return TimeManagerSettings.defaultTimeSpent;\n }\n get timeSlots(): ITimeStlot[] {\n return TimeManagerSettings.timeSlots;\n }\n get weekLength(): number {\n return TimeManagerSettings.weekLength;\n }\n get weekendStartDay(): number {\n return TimeManagerSettings.weekendStartDay;\n }\n get weekDaysNames(): string[] {\n return TimeManagerSettings.weekDaysNames;\n }\n\n /**\n * Get the current hour\n */\n get currentHour(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {};\n if (data.hasOwnProperty(\"currentHour\") && typeof data.currentHour === \"number\") {\n return data.currentHour;\n }\n return this.minDayHours;\n }\n set currentHour(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {};\n if (typeof value === \"number\") {\n data.currentHour = value;\n } else {\n delete data.currentHour;\n }\n storage.setVariable(TIME_DATA_KEY, data);\n }\n /**\n * Get the current day\n */\n get currentDay(): number {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {};\n if (data.hasOwnProperty(\"currentDay\") && typeof data.currentDay === \"number\") {\n return data.currentDay;\n }\n return 0;\n }\n set currentDay(value: number | undefined) {\n let data = storage.getVariable<TimeDataType>(TIME_DATA_KEY) || {};\n if (typeof value === \"number\") {\n data.currentDay = value;\n } else {\n delete data.currentDay;\n }\n storage.setVariable(TIME_DATA_KEY, data);\n }\n /**\n * If the current day is greater than or equal to the weekend start day, then it will return true.\n */\n get isWeekend(): boolean {\n return this.currentWeekDayNumber >= this.weekendStartDay;\n }\n /**\n * Get the current week day number (1 - {@link weekLength}).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n get currentWeekDayNumber(): number {\n let result = this.currentDay % this.weekLength;\n return result + 1;\n }\n /**\n * Get the current week day name. If the week days names are not defined, then it will return undefined.\n * 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'.\n * @default \"\"\n */\n get currentDayName(): string {\n let weekDayNumber = this.currentWeekDayNumber - 1;\n if (weekDayNumber >= this.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, this.weekDaysNames);\n return \"\";\n }\n return this.weekDaysNames[weekDayNumber];\n }\n /**\n * Get the current {@link timeSlots} index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```tsx\n * import { weekLength } from '@drincs/nqtr';\n *\n * function changeBackground() {\n * return (\n * <img src={`background-currentTimeSlot.currentTimeSlot.png`} />\n * )\n * }\n */\n get currentTimeSlot(): number {\n if (this.timeSlots.length === 0) {\n console.warn(\"[NQTR] Time slots are not defined\");\n return 0;\n }\n for (let index = 0; index < this.timeSlots.length; index++) {\n let slot = this.timeSlots[index];\n if (this.timeSlots.length > index + 1) {\n if (this.nowIsBetween(slot.startHour, this.timeSlots[index + 1].startHour)) {\n return index;\n }\n }\n }\n return this.timeSlots.length - 1;\n }\n\n /**\n * This function will increase the current hour by the given time spent.\n * If the new hour is greater than or equal to the max day hours, then it will increase the day and set the new hour.\n * @param timeSpent is the time spent in hours (default: {@link defaultTimeSpent})\n * @returns currentTimeSlot.currentHour\n */\n increaseHour(timeSpent: number = this.defaultTimeSpent): number {\n let newHour = this.currentHour + timeSpent;\n if (newHour >= this.maxDayHours) {\n this.increaseDay();\n newHour = this.minDayHours + (newHour - this.maxDayHours);\n }\n this.currentHour = newHour;\n return this.currentHour;\n }\n\n /**\n * This function will increase the current day by the given days.\n * @param newDayHour is the hour of the new day (default: {@link minDayHours})\n * @param days is the number of days to increase (default: 1)\n * @returns timeTracker.currentDay\n */\n increaseDay(newDayHour: number = this.minDayHours, days: number = 1): number {\n let newDay = this.currentDay + days;\n this.currentDay = newDay;\n this.currentHour = newDayHour;\n return this.currentDay;\n }\n\n /**\n * This function will check if the current hour is between the given hours.\n * @param fromHour the starting hour. If the {@link currentHour} is equal to this hour, the function will return true.\n * @param toHour the ending hour.\n * @returns true if the current hour is between the given hours, otherwise false.\n */\n nowIsBetween(fromHour: number | undefined, toHour: number | undefined): boolean {\n if (fromHour === undefined) {\n fromHour = this.minDayHours - 1;\n }\n if (toHour === undefined) {\n toHour = this.maxDayHours + 1;\n }\n let currentHour = this.currentHour;\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour;\n }\n return currentHour >= fromHour || currentHour < toHour;\n }\n}\n","import NavigatorManager from \"./NavigatorManager\";\nimport QuestManager from \"./QuestManager\";\nimport RoutineManager from \"./RoutineManager\";\nimport { default as TimeManager } from \"./TimeManager\";\n\nconst timeTracker = new TimeManager();\nconst navigator = new NavigatorManager();\nconst routine = new RoutineManager();\nconst questsNotebook = new QuestManager();\n\nexport { navigator, questsNotebook, routine, timeTracker };\n","import { OnRunProps } from \"@drincs/nqtr\";\nimport { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { StageInterface } from \"../../interface\";\nimport { StageBaseInternalInterface } from \"../../interface/quest/StageInterface\";\nimport { timeTracker } from \"../../managers\";\nimport { QuestsRequiredType } from \"../../types\";\n\nconst STAGE_CATEGORY = \"__nqtr-stage__\";\nexport default class StageStoredClass extends StoredClassModel implements StageBaseInternalInterface {\n constructor(\n id: string,\n options: {\n /**\n * The function that will be executed when the stage starts.\n */\n onStart?: (stage: StageInterface, props: OnRunProps) => void;\n /**\n * The function that will be executed when the stage ends.\n */\n onEnd?: (stage: StageInterface, props: OnRunProps) => void;\n /**\n * The day required to start the stage.\n * @example If the value is 3, and the previous stage ends on day 1, the stage will start on day 4.\n */\n daysRequiredToStart?: number;\n /**\n * The quests required to start the stage.\n * @default []\n */\n questsRequiredToStart?: QuestsRequiredType[];\n } = {}\n ) {\n super(STAGE_CATEGORY, id);\n this._onStart = options.onStart;\n this._onEnd = options.onEnd;\n this._daysRequiredToStart = options.daysRequiredToStart;\n this._questsRequiredToStart = options.questsRequiredToStart || [];\n }\n\n private _onStart?: (stage: StageInterface, props: OnRunProps) => void;\n get onStart(): undefined | ((stage: StageInterface, props: OnRunProps) => void) {\n return this._onStart;\n }\n\n private _onEnd?: (stage: StageInterface, props: OnRunProps) => void;\n get onEnd(): undefined | ((stage: StageInterface, props: OnRunProps) => void) {\n return this._onEnd;\n }\n\n get completed(): boolean {\n return this.getStorageProperty<boolean>(\"completed\") || false;\n }\n set completed(value: boolean) {\n this.setStorageProperty(\"completed\", value);\n }\n\n get started(): boolean {\n return this.getStorageProperty<boolean>(\"started\") || false;\n }\n set started(value: boolean) {\n this.setStorageProperty(\"started\", value);\n }\n\n private get prevStageEndDay(): number | undefined {\n return this.getStorageProperty<number>(\"prevStageEndDay\");\n }\n private set prevStageEndDay(value: number | undefined) {\n this.setStorageProperty(\"prevStageEndDay\", value);\n }\n\n get startDay(): number | undefined {\n let prevStageEndDay = this.prevStageEndDay;\n if (prevStageEndDay === undefined) {\n return undefined;\n }\n return prevStageEndDay + this.daysRequiredToStart;\n }\n\n get canStart(): boolean {\n let daysRequired = this.daysRequiredToStart;\n if (daysRequired > 0) {\n let prevStageEndDay = this.prevStageEndDay;\n if (prevStageEndDay === undefined) {\n return false;\n }\n if (prevStageEndDay + daysRequired > timeTracker.currentDay) {\n return false;\n }\n }\n if (\n this.questsRequiredToStart.length > 0 &&\n !this.questsRequiredToStart.every(\n (q) => q.quest.currentStageIndex && q.quest.currentStageIndex >= q.stageNumber\n )\n ) {\n return false;\n }\n return true;\n }\n\n inizialize() {\n if (this.daysRequiredToStart > 0) {\n this.prevStageEndDay = timeTracker.currentDay;\n console.log(`[NQTR] Stage ${this.id} will start on day ${this.startDay}`);\n }\n }\n\n start(props: OnRunProps) {\n if (this.canStart) {\n this.started = true;\n if (this.onStart) {\n this.onStart(this as any as StageInterface, props);\n }\n } else {\n console.warn(`[NQTR] Stage ${this.id} can't start`);\n }\n }\n\n private _daysRequiredToStart?: number;\n get daysRequiredToStart(): number {\n return this._daysRequiredToStart || 0;\n }\n\n private _questsRequiredToStart: QuestsRequiredType[];\n get questsRequiredToStart(): QuestsRequiredType[] {\n return this._questsRequiredToStart || [];\n }\n}\n"]}