@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 • 23.6 kB
Source Map (JSON)
{"version":3,"sources":["../../../src/constants.ts","../../../src/managers/TimeManagerSettings.ts","../../../src/managers/TimeManager.ts","../../../src/managers/index.ts","../../../src/classes/quest/StageStoredClass.ts","../../../src/classes/quest/StageBaseModel.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","STAGE_CATEGORY","StageStoredClass","StoredClassModel","id","options","prevStageEndDay","daysRequired","q","props","StageBaseModel","flag","getFlag"],"mappings":"+DACO,IAAMA,EAAgB,8BCC7B,CAAA,IAAqBC,EAArB,KAAiE,CAC7D,OAAO,WAAsB,CAAA,CAAA,CAC7B,OAAO,WAAsB,CAAA,EAAA,CAC7B,OAAO,gBAA2B,CAAA,CAAA,CAClC,OAAO,SAAA,CAA0B,EAAC,CAClC,OAAO,UAAqB,CAAA,CAAA,CAC5B,OAAO,eAA0B,CAAA,IAAA,CAAK,WAAa,CACnD,CAAA,OAAO,cAA0B,EACrC,ECJA,IAAqBC,CAAAA,CAArB,KAAiC,CAC7B,UAAA,CAAWC,EAAwB,CAC/B,GAAM,CACF,WAAA,CAAAC,CAAc,CAAA,CAAA,CACd,YAAAC,CAAc,CAAA,EAAA,CACd,iBAAAC,CAAmB,CAAA,CAAA,CACnB,UAAAC,CAAY,CAAA,GACZ,UAAAC,CAAAA,CAAAA,CAAa,EACb,eAAAC,CAAAA,CAAAA,CAAkBD,EAAa,CAC/B,CAAA,aAAA,CAAAE,EAAgB,EACpB,CAAIP,CAAAA,CAAAA,CACJF,CAAoB,CAAA,WAAA,CAAcG,EAClCH,CAAoB,CAAA,WAAA,CAAcI,EAClCJ,CAAoB,CAAA,gBAAA,CAAmB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AqB,EACrD,CAAA,IAAA,CAAK,OAASA,CAAM,CAAA,KAAA,CACpB,KAAK,qBAAwBA,CAAAA,CAAAA,CAAM,sBAAwB,EAAC,CAC5D,KAAK,0BAA6BA,CAAAA,CAAAA,CAAM,2BAA6B,GACtE,CAEQ,MAIR,IAAI,IAAA,EAAe,CAClB,OAAO,IAAA,CAAK,KACb,CAEQ,YAIR,CAAA,IAAI,aAAsB,CACzB,OAAO,KAAK,YACb,CAEQ,mBAIR,IAAI,iBAAA,EAA4B,CAC/B,OAAO,IAAA,CAAK,kBACb,CAEQ,MAAA,CAIR,IAAI,KAA4B,EAAA,CAC/B,OAAO,IAAK,CAAA,MACb,CAEQ,MAIR,CAAA,IAAI,OAAsB,CACzB,OAAO,KAAK,MACb,CAEQ,sBAIR,IAAI,oBAAA,EAAqC,CACxC,OAAO,IAAA,CAAK,qBACb,CAEQ,0BAAA,CAIR,IAAI,yBAAoC,EAAA,CACvC,OAAO,IAAK,CAAA,0BACb,CAEA,IAAa,SAAqB,EAAA,CACjC,OAAI,KAAM,CAAA,SAAA,CACF,KAEJ,IAAK,CAAA,KAAA,CAAM,OAAS,CAClB,CAAA,CAAA,CAAA,IAAA,CAAK,MAAM,KAAOE,CAAAA,CAAAA,EAASC,QAAQD,CAAK,CAAA,IAAI,CAAC,CAK5C,CAAA,KACR,CACA,IAAa,SAAA,CAAUvB,CAAgB,CAAA,CACtC,KAAM,CAAA,SAAA,CAAYA,EACnB,CACA,IAAa,UAAoB,CAChC,OAAI,KAAK,oBAAqB,CAAA,MAAA,CAAS,GAAK,CAAC,IAAA,CAAK,qBAAqB,KAAOuB,CAAAA,CAAAA,EAASC,QAAQD,CAAK,CAAA,IAAI,CAAC,CACjG,CAAA,KAAA,CAED,KAAM,CAAA,QACd,CACD","file":"StageBaseModel.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","import { getFlag } from \"@drincs/pixi-vn\";\nimport { StageProps } from \"../../interface\";\nimport StageFlags from \"../../interface/quest/StageFlags\";\nimport StageStoredClass from \"./StageStoredClass\";\n\nexport default class StageBaseModel extends StageStoredClass {\n\tconstructor(id: string, props: StageProps) {\n\t\tsuper(id, {\n\t\t\tonStart: props.onStart,\n\t\t\tonEnd: props.onEnd,\n\t\t\tdaysRequiredToStart: props.daysRequiredToStart,\n\t\t\tquestsRequiredToStart: props.questsRequiredToStart,\n\t\t});\n\t\tthis._name = props.name || \"\";\n\t\tthis._flags = props.flags || [];\n\t\tthis._description = props.description || \"\";\n\t\tthis._adviceDescription = props.adviceDescription || \"\";\n\t\tthis._image = props.image;\n\t\tthis._flagsRequiredToStart = props.flagsRequiredToStart || [];\n\t\tthis._requestDescriptionToStart = props.requestDescriptionToStart || \"\";\n\t}\n\n\tprivate _name: string;\n\t/**\n\t * The name of the stage.\n\t */\n\tget name(): string {\n\t\treturn this._name;\n\t}\n\n\tprivate _description: string;\n\t/**\n\t * The description of the stage.\n\t */\n\tget description(): string {\n\t\treturn this._description;\n\t}\n\n\tprivate _adviceDescription: string;\n\t/**\n\t * The advice description of the stage.\n\t */\n\tget adviceDescription(): string {\n\t\treturn this._adviceDescription;\n\t}\n\n\tprivate _image?: string;\n\t/**\n\t * The image of the stage.\n\t */\n\tget image(): string | undefined {\n\t\treturn this._image;\n\t}\n\n\tprivate _flags: StageFlags[];\n\t/**\n\t * The list of flags that the player must complete to finish the stage.\n\t */\n\tget flags(): StageFlags[] {\n\t\treturn this._flags;\n\t}\n\n\tprivate _flagsRequiredToStart: StageFlags[];\n\t/**\n\t * The list of flags required to start the stage.\n\t */\n\tget flagsRequiredToStart(): StageFlags[] {\n\t\treturn this._flagsRequiredToStart;\n\t}\n\n\tprivate _requestDescriptionToStart: string;\n\t/**\n\t * The description of the request to start the stage.\n\t */\n\tget requestDescriptionToStart(): string {\n\t\treturn this._requestDescriptionToStart;\n\t}\n\n\toverride get completed(): boolean {\n\t\tif (super.completed) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.flags.length > 0) {\n\t\t\tif (!this.flags.every((flag) => getFlag(flag.flag))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\toverride set completed(value: boolean) {\n\t\tsuper.completed = value;\n\t}\n\toverride get canStart(): boolean {\n\t\tif (this.flagsRequiredToStart.length > 0 && !this.flagsRequiredToStart.every((flag) => getFlag(flag.flag))) {\n\t\t\treturn false;\n\t\t}\n\t\treturn super.canStart;\n\t}\n}\n"]}