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 20.5 kB
{"version":3,"sources":["../../src/constants.ts","../../src/managers/TimeManagerSettings.ts","../../src/managers/TimeManager.ts","../../src/managers/index.ts","../../src/classes/ActivityStoredClass.ts","../../src/classes/ActivityBaseModel.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","ACTIVITY_CATEGORY","ActivityStoredClass","StoredClassModel","id","_onRun","props","category","ActivityBaseModel","onRun","getFlag"],"mappings":"+DACO,IAAMA,EAAgB,8BCC7B,CAAA,IAAqBC,EAArB,KAAiE,CAC7D,OAAO,WAAA,CAAsB,EAC7B,OAAO,WAAA,CAAsB,GAC7B,OAAO,gBAAA,CAA2B,EAClC,OAAO,SAAA,CAA0B,EAAC,CAClC,OAAO,UAAqB,CAAA,CAAA,CAC5B,OAAO,eAA0B,CAAA,IAAA,CAAK,WAAa,CACnD,CAAA,OAAO,aAA0B,CAAA,EACrC,CCJA,CAAA,IAAqBC,EAArB,KAAiC,CAC7B,WAAWC,CAAwB,CAAA,CAC/B,GAAM,CACF,YAAAC,CAAc,CAAA,CAAA,CACd,YAAAC,CAAc,CAAA,EAAA,CACd,iBAAAC,CAAmB,CAAA,CAAA,CACnB,SAAAC,CAAAA,CAAAA,CAAY,EACZ,CAAA,UAAA,CAAAC,EAAa,CACb,CAAA,eAAA,CAAAC,EAAkBD,CAAa,CAAA,CAAA,CAC/B,aAAAE,CAAAA,CAAAA,CAAgB,EACpB,CAAA,CAAIP,EACJF,CAAoB,CAAA,WAAA,CAAcG,EAClCH,CAAoB,CAAA,WAAA,CAAcI,EAClCJ,CAAoB,CAAA,gBAAA,CAAmBK,EACvCL,CAAoB,CAAA,SAAA,C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,CAAC,CAAA,CACD,IAAK,CAAA,WAAA,CAAcA,EAAM,IAAQ,EAAA,EAAA,CACjC,KAAK,eAAkBA,CAAAA,CAAAA,CAAM,UAAY,KACzC,CAAA,IAAA,CAAK,cAAgBA,CAAM,CAAA,MAAA,EAAU,MACrC,IAAK,CAAA,KAAA,CAAQA,EAAM,WACvB,CAEQ,YAIR,IAAI,IAAA,EAAe,CACf,OAAO,KAAK,kBAA2B,CAAA,MAAM,GAAK,IAAK,CAAA,WAC3D,CACA,IAAI,IAAA,CAAKlB,CAA2B,CAAA,CAChC,KAAK,kBAAmB,CAAA,MAAA,CAAQA,CAAK,EACzC,CAEQ,gBAIR,IAAI,QAAA,EAAoB,CACpB,IAAIA,EAAQ,IAAK,CAAA,kBAAA,CAA4B,UAAU,CAAK,EAAA,IAAA,CAAK,gBACjE,OAAI,OAAOA,GAAU,QACVsB,CAAAA,OAAAA,CAAQtB,CAAK,CAEjBA,CAAAA,CACX,CACA,IAAI,QAAA,CAASA,EAAyB,CAClC,IAAA,CAAK,kBAAmB,CAAA,UAAA,CAAYA,CAAK,EAC7C,CAEQ,cAIR,IAAI,MAAA,EAAkB,CAClB,IAAIA,CAAAA,CAAQ,IAAK,CAAA,kBAAA,CAA4B,QAAQ,CAAK,EAAA,IAAA,CAAK,cAC/D,OAAI,OAAOA,GAAU,QACVsB,CAAAA,OAAAA,CAAQtB,CAAK,CAAA,CAEjBA,CACX,CACA,IAAI,OAAOA,CAAyB,CAAA,CAChC,KAAK,kBAAmB,CAAA,QAAA,CAAUA,CAAK,EAC3C,CAEQ,MAIR,IAAI,IAAA,EAA2B,CAC3B,OAAO,IAAA,CAAK,KAChB,CACJ","file":"ActivityBaseModel.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 { StoredClassModel } from \"@drincs/pixi-vn\";\nimport { ActivityInterface } from \"../interface\";\nimport { ActivityBaseInternalInterface } from \"../interface/ActivityInterface\";\nimport { timeTracker } from \"../managers\";\nimport { OnRunEvent, OnRunProps } from \"../types/OnRunEvent\";\n\nconst ACTIVITY_CATEGORY = \"__nqtr-activity__\";\nexport default class ActivityStoredClass<OnRunEventType = ActivityInterface>\n extends StoredClassModel\n implements ActivityBaseInternalInterface\n{\n constructor(\n id: string,\n private readonly _onRun: OnRunEvent<OnRunEventType>,\n props: {\n fromHour?: number;\n toHour?: number;\n fromDay?: number;\n toDay?: number;\n },\n category: string = ACTIVITY_CATEGORY\n ) {\n super(category, id);\n this._fromHour = props.fromHour;\n this._toHour = props.toHour;\n this._fromDay = props.fromDay;\n this._toDay = props.toDay;\n }\n\n private _fromHour?: number;\n get fromHour(): number | undefined {\n return this._fromHour;\n }\n\n private _toHour?: number;\n get toHour(): number | undefined {\n return this._toHour;\n }\n\n private _fromDay?: number;\n get fromDay(): number | undefined {\n return this._fromDay;\n }\n\n private _toDay?: number;\n get toDay(): number | undefined {\n return this._toDay;\n }\n\n get run(): (props: OnRunProps) => void {\n return (props) => this._onRun(this as any, props);\n }\n\n get expired(): boolean {\n if (this.toDay && this.toDay <= timeTracker.currentDay) {\n return true;\n }\n return false;\n }\n\n get isActive(): boolean {\n if (this.fromDay && this.fromDay > timeTracker.currentDay) {\n return false;\n }\n if (this.toDay && this.toDay < timeTracker.currentDay) {\n return false;\n }\n if (!timeTracker.nowIsBetween(this.fromHour, this.toHour)) {\n return false;\n }\n return true;\n }\n}\n","import { getFlag } from \"@drincs/pixi-vn\";\nimport { ActivityInterface, ActivityProps } from '../interface';\nimport { OnRunEvent } from '../types/OnRunEvent';\nimport ActivityStoredClass from './ActivityStoredClass';\n\n/**\n * The activity model. It is used to create an activity.\n * @example\n * ```tsx\n * export const nap = new ActivityModel(\"nap\",\n * (_, event) => {\n * if (event) {\n * event.navigate(\"/game\")\n * callLabelWithGoNavigationCallBack(napLabel, event)\n * }\n * else {\n * console.error(\"Event is undefined\")\n * }\n * },\n * {\n * name: \"Nap\",\n * fromHour: 5,\n * toHour: 23,\n * icon: \"https://icon.jpg\",\n * }\n * )\n * ```\n */\nexport default class ActivityBaseModel extends ActivityStoredClass<ActivityInterface> {\n /**\n * @param id The activity id, that must be unique.\n * @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.\n * @param props The activity properties.\n */\n constructor(id: string, onRun: OnRunEvent<ActivityInterface>, props: ActivityProps) {\n super(id, onRun, {\n fromHour: props.fromHour,\n toHour: props.toHour,\n fromDay: props.fromDay,\n toDay: props.toDay,\n })\n this.defaultName = props.name || \"\"\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._icon = props.renderIcon\n }\n\n private defaultName: string\n /**\n * The name of the activity.\n */\n get name(): string {\n return this.getStorageProperty<string>(\"name\") || this.defaultName\n }\n set name(value: string | undefined) {\n this.setStorageProperty(\"name\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled. If it is a string, it is a Pixi'VN flag name.\n */\n get disabled(): boolean {\n let value = this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set disabled(value: boolean | string) {\n this.setStorageProperty(\"disabled\", value)\n }\n\n private defaultHidden: boolean | string\n /**\n * Whether is hidden. If it is a string, it is a Pixi'VN flag name.\n */\n get hidden(): boolean {\n let value = this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden\n if (typeof value === \"string\") {\n return getFlag(value)\n }\n return value\n }\n set hidden(value: boolean | string) {\n this.setStorageProperty(\"hidden\", value)\n }\n\n private _icon?: string\n /**\n * The icon of the activity.\n */\n get icon(): string | undefined {\n return this._icon\n }\n}\n"]}