@drincs/nqtr 0.1.9 → 0.1.10
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/dist/classes/Activity.js +10 -12
- package/dist/classes/Activity.js.map +1 -1
- package/dist/classes/Activity.mjs +10 -12
- package/dist/classes/Activity.mjs.map +1 -1
- package/dist/classes/Commitment.js +5 -6
- package/dist/classes/Commitment.js.map +1 -1
- package/dist/classes/Commitment.mjs +5 -6
- package/dist/classes/Commitment.mjs.map +1 -1
- package/dist/classes/index.js +10 -12
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +10 -12
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/navigation/ActivityRoom.js +5 -6
- package/dist/classes/navigation/ActivityRoom.js.map +1 -1
- package/dist/classes/navigation/ActivityRoom.mjs +5 -6
- package/dist/classes/navigation/ActivityRoom.mjs.map +1 -1
- package/dist/classes/navigation/Location.js +5 -6
- package/dist/classes/navigation/Location.js.map +1 -1
- package/dist/classes/navigation/Location.mjs +5 -6
- package/dist/classes/navigation/Location.mjs.map +1 -1
- package/dist/classes/navigation/Map.js +5 -6
- package/dist/classes/navigation/Map.js.map +1 -1
- package/dist/classes/navigation/Map.mjs +5 -6
- package/dist/classes/navigation/Map.mjs.map +1 -1
- package/dist/classes/navigation/Room.js +15 -18
- package/dist/classes/navigation/Room.js.map +1 -1
- package/dist/classes/navigation/Room.mjs +15 -18
- package/dist/classes/navigation/Room.mjs.map +1 -1
- package/dist/classes/navigation/index.js +25 -30
- package/dist/classes/navigation/index.js.map +1 -1
- package/dist/classes/navigation/index.mjs +25 -30
- package/dist/classes/navigation/index.mjs.map +1 -1
- package/dist/functions/ActivityFunctions.js.map +1 -1
- package/dist/functions/ActivityFunctions.mjs.map +1 -1
- package/dist/functions/NavigationFunctions.js +5 -6
- package/dist/functions/NavigationFunctions.js.map +1 -1
- package/dist/functions/NavigationFunctions.mjs +5 -6
- package/dist/functions/NavigationFunctions.mjs.map +1 -1
- package/dist/functions/index.js +5 -6
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +5 -6
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.js +35 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/classes/Activity.js
CHANGED
|
@@ -349,17 +349,16 @@ var ActivityStoredAbstract = class {
|
|
|
349
349
|
* The function for rendering the icon of the activity.
|
|
350
350
|
*/
|
|
351
351
|
get renderIcon() {
|
|
352
|
-
|
|
352
|
+
let render = this._renderIcon;
|
|
353
|
+
if (render === void 0) {
|
|
353
354
|
return void 0;
|
|
354
355
|
}
|
|
355
|
-
if (typeof
|
|
356
|
-
return (props) => this._renderIcon;
|
|
357
|
-
}
|
|
358
|
-
if (this._renderIcon !== void 0) {
|
|
356
|
+
if (typeof render === "function") {
|
|
359
357
|
return (props) => {
|
|
360
|
-
return
|
|
358
|
+
return render(this, props);
|
|
361
359
|
};
|
|
362
360
|
}
|
|
361
|
+
return (props) => render;
|
|
363
362
|
}
|
|
364
363
|
/**
|
|
365
364
|
* The function that is called when the activity is runned.
|
|
@@ -476,17 +475,16 @@ var ActivityModel = class {
|
|
|
476
475
|
* The function for rendering the icon of the activity.
|
|
477
476
|
*/
|
|
478
477
|
get renderIcon() {
|
|
479
|
-
|
|
478
|
+
let render = this._renderIcon;
|
|
479
|
+
if (render === void 0) {
|
|
480
480
|
return void 0;
|
|
481
481
|
}
|
|
482
|
-
if (typeof
|
|
483
|
-
return (props) => this._renderIcon;
|
|
484
|
-
}
|
|
485
|
-
if (this._renderIcon !== void 0) {
|
|
482
|
+
if (typeof render === "function") {
|
|
486
483
|
return (props) => {
|
|
487
|
-
return
|
|
484
|
+
return render(this, props);
|
|
488
485
|
};
|
|
489
486
|
}
|
|
487
|
+
return (props) => render;
|
|
490
488
|
}
|
|
491
489
|
/**
|
|
492
490
|
* The function that is called when the activity is runned.
|
|
@@ -1 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,EAMA,IAAI,QAA8C;AAC9C,WAAO,CAAC,UAAU,KAAK,OAAO,MAAM,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAsB;AAClB,QAAI,KAAK,SAAS,KAAK,SAAS,YAAY,YAAY;AACpD,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAwB;AACpB,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,IACrB;AAAA,EACJ;AACJ","sourcesContent":["import { GraphicItemType, OnRenderGraphicItemProps, OnRunActivityProps } from '@drincs/nqtr/dist/override';\nimport { getFlag } from \"@drincs/pixi-vn\";\nimport TimeManager from \"../managers/TimeManager\";\n\nexport interface ActivityProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n * If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n * If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n /**\n * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem\n * @default undefined\n */\n renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n}\n\n/**\n * The function that is called when the activity is runned.\n */\nexport type OnRunActivityEvent<T> = (activity: T, props?: OnRunActivityProps) => void\n\nexport abstract class ActivityStoredAbstract {\n /**\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(onRun: OnRunActivityEvent<ActivityStoredAbstract>, props: ActivityProps) {\n this.defaultName = props.name\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n abstract setStorageProperty<T>(propertyName: string, value: T | undefined): void;\n abstract getStorageProperty<T>(propertyName: string): T | undefined;\n abstract get id(): string\n\n private defaultName?: string\n /**\n * The name\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 defaultFromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled.\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 the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (!this._renderIcon) {\n return undefined\n }\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n private _onRun: (activity: ActivityStoredAbstract, props?: OnRunActivityProps) => void\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this.getStorageProperty<string>(\"name\") || this.defaultName,\n fromHour: this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour,\n toHour: this.getStorageProperty<number>(\"toHour\") || this.defaultToHour,\n fromDay: this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay,\n toDay: this.getStorageProperty<number>(\"toDay\") || this.defaultToDay,\n disabled: this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled,\n hidden: this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden,\n renderIcon: this._renderIcon\n }\n }\n}\n\n/**\n * The activity model.\n */\nexport default class ActivityModel {\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: OnRunActivityEvent<ActivityModel>, props: ActivityProps) {\n this._id = id\n this._name = props.name\n this._fromHour = props.fromHour\n this._toHour = props.toHour\n this._fromDay = props.fromDay\n this._toDay = props.toDay\n this._disabled = props.disabled || false\n this._hidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n private _id: string\n /**\n * The activity id, that is unique.\n */\n get id(): string {\n return this._id\n }\n\n private _name?: string\n /**\n * The name\n */\n get name(): string | undefined {\n return this._name\n }\n\n private _fromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number | undefined {\n return this._fromHour\n }\n\n private _toHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number | undefined {\n return this._toHour\n }\n\n private _fromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this._fromDay\n }\n\n private _toDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this._toDay\n }\n\n private _disabled?: boolean | string\n /**\n * Whether is disabled.\n */\n get disabled(): boolean | undefined {\n if (typeof this._disabled === \"string\") {\n return getFlag(this._disabled)\n }\n return this._disabled\n }\n\n private _hidden: boolean | string\n /**\n * Whether is hidden. If the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!this.isDeadline) {\n return true\n }\n if (typeof this._hidden === \"string\") {\n return getFlag(this._hidden)\n }\n return this._hidden\n }\n\n private _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (!this._renderIcon) {\n return undefined\n }\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n private _onRun: OnRunActivityEvent<ActivityModel>\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isDeadline(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this._name,\n fromHour: this._fromHour,\n toHour: this._toHour,\n fromDay: this._fromDay,\n toDay: this._toDay,\n disabled: this._disabled,\n hidden: this._hidden,\n renderIcon: this._renderIcon,\n }\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.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 static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.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 static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.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: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.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: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.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 TimeManager.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 static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/classes/Activity.ts","../../src/managers/TimeManager.ts"],"names":["props"],"mappings":";AACA,SAAS,eAAe;;;ACDxB,SAAS,0BAA0B;AAGnC,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AAOtB,IAAqB,cAArB,MAAqB,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AK;AAAA,MACX,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,IACrB;AAAA,EACJ;AACJ","sourcesContent":["import { GraphicItemType, OnRenderGraphicItemProps, OnRunActivityProps } from '@drincs/nqtr/dist/override';\nimport { getFlag } from \"@drincs/pixi-vn\";\nimport TimeManager from \"../managers/TimeManager\";\n\nexport interface ActivityProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n * If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n * If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n /**\n * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem\n * @default undefined\n */\n renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n}\n\n/**\n * The function that is called when the activity is runned.\n */\nexport type OnRunActivityEvent<T> = (activity: T, props?: OnRunActivityProps) => void\n\nexport abstract class ActivityStoredAbstract {\n /**\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(onRun: OnRunActivityEvent<ActivityStoredAbstract>, props: ActivityProps) {\n this.defaultName = props.name\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n abstract setStorageProperty<T>(propertyName: string, value: T | undefined): void;\n abstract getStorageProperty<T>(propertyName: string): T | undefined;\n abstract get id(): string\n\n private defaultName?: string\n /**\n * The name\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 defaultFromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled.\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 the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n let render = this._renderIcon\n if (render === undefined) {\n return undefined\n }\n if (typeof render === \"function\") {\n return (props?: OnRenderGraphicItemProps) => {\n return render(this, props)\n }\n }\n return (props?: OnRenderGraphicItemProps) => render\n }\n\n private _onRun: (activity: ActivityStoredAbstract, props?: OnRunActivityProps) => void\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this.getStorageProperty<string>(\"name\") || this.defaultName,\n fromHour: this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour,\n toHour: this.getStorageProperty<number>(\"toHour\") || this.defaultToHour,\n fromDay: this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay,\n toDay: this.getStorageProperty<number>(\"toDay\") || this.defaultToDay,\n disabled: this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled,\n hidden: this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden,\n renderIcon: this._renderIcon\n }\n }\n}\n\n/**\n * The activity model.\n */\nexport default class ActivityModel {\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: OnRunActivityEvent<ActivityModel>, props: ActivityProps) {\n this._id = id\n this._name = props.name\n this._fromHour = props.fromHour\n this._toHour = props.toHour\n this._fromDay = props.fromDay\n this._toDay = props.toDay\n this._disabled = props.disabled || false\n this._hidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n private _id: string\n /**\n * The activity id, that is unique.\n */\n get id(): string {\n return this._id\n }\n\n private _name?: string\n /**\n * The name\n */\n get name(): string | undefined {\n return this._name\n }\n\n private _fromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number | undefined {\n return this._fromHour\n }\n\n private _toHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number | undefined {\n return this._toHour\n }\n\n private _fromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this._fromDay\n }\n\n private _toDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this._toDay\n }\n\n private _disabled?: boolean | string\n /**\n * Whether is disabled.\n */\n get disabled(): boolean | undefined {\n if (typeof this._disabled === \"string\") {\n return getFlag(this._disabled)\n }\n return this._disabled\n }\n\n private _hidden: boolean | string\n /**\n * Whether is hidden. If the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!this.isDeadline) {\n return true\n }\n if (typeof this._hidden === \"string\") {\n return getFlag(this._hidden)\n }\n return this._hidden\n }\n\n private _renderIcon?: GraphicItemType | ((activity: ActivityModel, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n let render = this._renderIcon\n if (render === undefined) {\n return undefined\n }\n if (typeof render === \"function\") {\n return (props?: OnRenderGraphicItemProps) => {\n return render(this, props)\n }\n }\n return (props?: OnRenderGraphicItemProps) => render\n }\n\n private _onRun: OnRunActivityEvent<ActivityModel>\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isDeadline(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this._name,\n fromHour: this._fromHour,\n toHour: this._toHour,\n fromDay: this._fromDay,\n toDay: this._toDay,\n disabled: this._disabled,\n hidden: this._hidden,\n renderIcon: this._renderIcon,\n }\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.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 static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.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 static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.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: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.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: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.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 TimeManager.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 static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n"]}
|
|
@@ -345,17 +345,16 @@ var ActivityStoredAbstract = class {
|
|
|
345
345
|
* The function for rendering the icon of the activity.
|
|
346
346
|
*/
|
|
347
347
|
get renderIcon() {
|
|
348
|
-
|
|
348
|
+
let render = this._renderIcon;
|
|
349
|
+
if (render === void 0) {
|
|
349
350
|
return void 0;
|
|
350
351
|
}
|
|
351
|
-
if (typeof
|
|
352
|
-
return (props) => this._renderIcon;
|
|
353
|
-
}
|
|
354
|
-
if (this._renderIcon !== void 0) {
|
|
352
|
+
if (typeof render === "function") {
|
|
355
353
|
return (props) => {
|
|
356
|
-
return
|
|
354
|
+
return render(this, props);
|
|
357
355
|
};
|
|
358
356
|
}
|
|
357
|
+
return (props) => render;
|
|
359
358
|
}
|
|
360
359
|
/**
|
|
361
360
|
* The function that is called when the activity is runned.
|
|
@@ -472,17 +471,16 @@ var ActivityModel = class {
|
|
|
472
471
|
* The function for rendering the icon of the activity.
|
|
473
472
|
*/
|
|
474
473
|
get renderIcon() {
|
|
475
|
-
|
|
474
|
+
let render = this._renderIcon;
|
|
475
|
+
if (render === void 0) {
|
|
476
476
|
return void 0;
|
|
477
477
|
}
|
|
478
|
-
if (typeof
|
|
479
|
-
return (props) => this._renderIcon;
|
|
480
|
-
}
|
|
481
|
-
if (this._renderIcon !== void 0) {
|
|
478
|
+
if (typeof render === "function") {
|
|
482
479
|
return (props) => {
|
|
483
|
-
return
|
|
480
|
+
return render(this, props);
|
|
484
481
|
};
|
|
485
482
|
}
|
|
483
|
+
return (props) => render;
|
|
486
484
|
}
|
|
487
485
|
/**
|
|
488
486
|
* The function that is called when the activity is runned.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/classes/Activity.ts","../../src/managers/TimeManager.ts"],"names":["props"],"mappings":";AACA,SAAS,eAAe;;;ACDxB,SAAS,0BAA0B;AAGnC,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AAOtB,IAAqB,cAArB,MAAqB,aAAY;AAAA,EACrB,cAAc;AAAA,EAAE;AAAA,EACxB,OAAe,aAAa,UAAwB;AAChD,QAAI,OAAY,CAAC;AACjB,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,kBAAkB,IAAI,SAAS;AAAA,IACxC;AACA,QAAI,MAAM,QAAQ,SAAS,SAAS,GAAG;AACnC,WAAK,WAAW,IAAI,SAAS;AAAA,IACjC;AACA,QAAI,OAAO,SAAS,eAAe,UAAU;AACzC,WAAK,YAAY,IAAI,SAAS;AAAA,IAClC;AACA,QAAI,OAAO,SAAS,oBAAoB,UAAU;AAC9C,UAAI,aAAa,SAAS,cAAc,aAAY;AACpD,UAAI,SAAS,mBAAmB,YAAY;AACxC,gBAAQ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AY,UAAU;AAClC,aAAO,QAAQ,KAAK,OAAO;AAAA,IAC/B;AACA,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAkF;AAClF,QAAI,CAAC,KAAK,aAAa;AACnB,aAAO;AAAA,IACX;AACA,QAAI,OAAO,KAAK,gBAAgB,YAAY;AACxC,aAAO,CAAC,UAAqC,KAAK;AAAA,IACtD;AACA,QAAI,KAAK,gBAAgB,QAAW;AAChC,aAAO,CAAC,UAAqC;AACzC,eAAQ,KAAK,YAAoB,MAAM,KAAK;AAAA,MAChD;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAA8C;AAC9C,WAAO,CAAC,UAAU,KAAK,OAAO,MAAM,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAsB;AAClB,QAAI,KAAK,SAAS,KAAK,SAAS,YAAY,YAAY;AACpD,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAwB;AACpB,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,IACrB;AAAA,EACJ;AACJ","sourcesContent":["import { GraphicItemType, OnRenderGraphicItemProps, OnRunActivityProps } from '@drincs/nqtr/dist/override';\nimport { getFlag } from \"@drincs/pixi-vn\";\nimport TimeManager from \"../managers/TimeManager\";\n\nexport interface ActivityProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n * If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n * If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n /**\n * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem\n * @default undefined\n */\n renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n}\n\n/**\n * The function that is called when the activity is runned.\n */\nexport type OnRunActivityEvent<T> = (activity: T, props?: OnRunActivityProps) => void\n\nexport abstract class ActivityStoredAbstract {\n /**\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(onRun: OnRunActivityEvent<ActivityStoredAbstract>, props: ActivityProps) {\n this.defaultName = props.name\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n abstract setStorageProperty<T>(propertyName: string, value: T | undefined): void;\n abstract getStorageProperty<T>(propertyName: string): T | undefined;\n abstract get id(): string\n\n private defaultName?: string\n /**\n * The name\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 defaultFromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled.\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 the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (!this._renderIcon) {\n return undefined\n }\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n private _onRun: (activity: ActivityStoredAbstract, props?: OnRunActivityProps) => void\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this.getStorageProperty<string>(\"name\") || this.defaultName,\n fromHour: this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour,\n toHour: this.getStorageProperty<number>(\"toHour\") || this.defaultToHour,\n fromDay: this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay,\n toDay: this.getStorageProperty<number>(\"toDay\") || this.defaultToDay,\n disabled: this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled,\n hidden: this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden,\n renderIcon: this._renderIcon\n }\n }\n}\n\n/**\n * The activity model.\n */\nexport default class ActivityModel {\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: OnRunActivityEvent<ActivityModel>, props: ActivityProps) {\n this._id = id\n this._name = props.name\n this._fromHour = props.fromHour\n this._toHour = props.toHour\n this._fromDay = props.fromDay\n this._toDay = props.toDay\n this._disabled = props.disabled || false\n this._hidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n private _id: string\n /**\n * The activity id, that is unique.\n */\n get id(): string {\n return this._id\n }\n\n private _name?: string\n /**\n * The name\n */\n get name(): string | undefined {\n return this._name\n }\n\n private _fromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number | undefined {\n return this._fromHour\n }\n\n private _toHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number | undefined {\n return this._toHour\n }\n\n private _fromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this._fromDay\n }\n\n private _toDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this._toDay\n }\n\n private _disabled?: boolean | string\n /**\n * Whether is disabled.\n */\n get disabled(): boolean | undefined {\n if (typeof this._disabled === \"string\") {\n return getFlag(this._disabled)\n }\n return this._disabled\n }\n\n private _hidden: boolean | string\n /**\n * Whether is hidden. If the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!this.isDeadline) {\n return true\n }\n if (typeof this._hidden === \"string\") {\n return getFlag(this._hidden)\n }\n return this._hidden\n }\n\n private _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (!this._renderIcon) {\n return undefined\n }\n if (typeof this._renderIcon !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderIcon as GraphicItemType\n }\n if (this._renderIcon !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this._renderIcon as any)(this, props)\n }\n }\n }\n\n private _onRun: OnRunActivityEvent<ActivityModel>\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isDeadline(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this._name,\n fromHour: this._fromHour,\n toHour: this._toHour,\n fromDay: this._fromDay,\n toDay: this._toDay,\n disabled: this._disabled,\n hidden: this._hidden,\n renderIcon: this._renderIcon,\n }\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.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 static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.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 static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.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: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.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: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.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 TimeManager.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 static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/classes/Activity.ts","../../src/managers/TimeManager.ts"],"names":["props"],"mappings":";AACA,SAAS,eAAe;;;ACDxB,SAAS,0BAA0B;AAGnC,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AAOtB,IAAqB,cAArB,MAAqB,aAAY;AAAA,EACrB,cAAc;AAAA,EAAE;AAAA,EACxB,OAAe,aAAa,UAAwB;AAChD,QAAI,OAAY,CAAC;AACjB,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,kBAAkB,IAAI,SAAS;AAAA,IACxC;AACA,QAAI,MAAM,QAAQ,SAAS,SAAS,GAAG;AACnC,WAAK,WAAW,IAAI,SAAS;AAAA,IACjC;AACA,QAAI,OAAO,SAAS,eAAe,UAAU;AACzC,WAAK,YAAY,IAAI,SAAS;AAAA,IAClC;AACA,QAAI,OAAO,SAAS,oBAAoB,UAAU;AAC9C,UAAI,aAAa,SAAS,cAAc,aAAY;AACpD,UAAI,SAAS,mBAAmB,YAAY;AACxC,gBAAQ,KAAK,4DAA4D,UAAU,EAAE;AAAA,MACzF;AACA,WAAK,iBAAiB,IAAI,SAAS;AAAA,IACvC;AACA,QAAI,MAAM,QAAQ,SAAS,aAAa,GAAG;AACvC,UAAI,aAAa,SAAS,cAAc,aAAY;AACpD,UAAI,SAAS,cAAc,WAAW,YAAY;AA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AAqC;AACzC,eAAO,OAAO,MAAM,KAAK;AAAA,MAC7B;AAAA,IACJ;AACA,WAAO,CAAC,UAAqC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAA8C;AAC9C,WAAO,CAAC,UAAU,KAAK,OAAO,MAAM,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAsB;AAClB,QAAI,KAAK,SAAS,KAAK,SAAS,YAAY,YAAY;AACpD,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAwB;AACpB,WAAO;AAAA,MACH,MAAM,KAAK;AAAA,MACX,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,IACrB;AAAA,EACJ;AACJ","sourcesContent":["import { GraphicItemType, OnRenderGraphicItemProps, OnRunActivityProps } from '@drincs/nqtr/dist/override';\nimport { getFlag } from \"@drincs/pixi-vn\";\nimport TimeManager from \"../managers/TimeManager\";\n\nexport interface ActivityProps {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n * If you set 3, the activity will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n * If you set 3, the activity will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n * If you set 3, the activity will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n /**\n * The icon element. Can be a string or an Element or a Pixi'VN CanvasItem\n * @default undefined\n */\n renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n}\n\n/**\n * The function that is called when the activity is runned.\n */\nexport type OnRunActivityEvent<T> = (activity: T, props?: OnRunActivityProps) => void\n\nexport abstract class ActivityStoredAbstract {\n /**\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(onRun: OnRunActivityEvent<ActivityStoredAbstract>, props: ActivityProps) {\n this.defaultName = props.name\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n abstract setStorageProperty<T>(propertyName: string, value: T | undefined): void;\n abstract getStorageProperty<T>(propertyName: string): T | undefined;\n abstract get id(): string\n\n private defaultName?: string\n /**\n * The name\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 defaultFromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled.\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 the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 _renderIcon?: GraphicItemType | ((activity: ActivityStoredAbstract, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n let render = this._renderIcon\n if (render === undefined) {\n return undefined\n }\n if (typeof render === \"function\") {\n return (props?: OnRenderGraphicItemProps) => {\n return render(this, props)\n }\n }\n return (props?: OnRenderGraphicItemProps) => render\n }\n\n private _onRun: (activity: ActivityStoredAbstract, props?: OnRunActivityProps) => void\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this.getStorageProperty<string>(\"name\") || this.defaultName,\n fromHour: this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour,\n toHour: this.getStorageProperty<number>(\"toHour\") || this.defaultToHour,\n fromDay: this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay,\n toDay: this.getStorageProperty<number>(\"toDay\") || this.defaultToDay,\n disabled: this.getStorageProperty<boolean>(\"disabled\") || this.defaultDisabled,\n hidden: this.getStorageProperty<boolean>(\"hidden\") || this.defaultHidden,\n renderIcon: this._renderIcon\n }\n }\n}\n\n/**\n * The activity model.\n */\nexport default class ActivityModel {\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: OnRunActivityEvent<ActivityModel>, props: ActivityProps) {\n this._id = id\n this._name = props.name\n this._fromHour = props.fromHour\n this._toHour = props.toHour\n this._fromDay = props.fromDay\n this._toDay = props.toDay\n this._disabled = props.disabled || false\n this._hidden = props.hidden || false\n this._renderIcon = props.renderIcon\n this._onRun = (props) => onRun(this, props)\n }\n\n private _id: string\n /**\n * The activity id, that is unique.\n */\n get id(): string {\n return this._id\n }\n\n private _name?: string\n /**\n * The name\n */\n get name(): string | undefined {\n return this._name\n }\n\n private _fromHour?: number\n /**\n * The hour when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromHour(): number | undefined {\n return this._fromHour\n }\n\n private _toHour?: number\n /**\n * The hour when the activity ends. If the activity is ended yet, it will be hidden.\n */\n get toHour(): number | undefined {\n return this._toHour\n }\n\n private _fromDay?: number\n /**\n * The day when the activity starts. If the activity is not started yet, it will be hidden.\n */\n get fromDay(): number | undefined {\n return this._fromDay\n }\n\n private _toDay?: number\n /**\n * The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.\n */\n get toDay(): number | undefined {\n return this._toDay\n }\n\n private _disabled?: boolean | string\n /**\n * Whether is disabled.\n */\n get disabled(): boolean | undefined {\n if (typeof this._disabled === \"string\") {\n return getFlag(this._disabled)\n }\n return this._disabled\n }\n\n private _hidden: boolean | string\n /**\n * Whether is hidden. If the activity is not started yet, it will be hidden.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!this.isDeadline) {\n return true\n }\n if (typeof this._hidden === \"string\") {\n return getFlag(this._hidden)\n }\n return this._hidden\n }\n\n private _renderIcon?: GraphicItemType | ((activity: ActivityModel, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the icon of the activity.\n */\n get renderIcon(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n let render = this._renderIcon\n if (render === undefined) {\n return undefined\n }\n if (typeof render === \"function\") {\n return (props?: OnRenderGraphicItemProps) => {\n return render(this, props)\n }\n }\n return (props?: OnRenderGraphicItemProps) => render\n }\n\n private _onRun: OnRunActivityEvent<ActivityModel>\n /**\n * The function that is called when the activity is runned.\n */\n get onRun(): (props?: OnRunActivityProps) => void {\n return (props) => this._onRun(this, props)\n }\n\n /**\n * Whether the activity is a deadline.\n * @returns Whether the activity is a deadline.\n */\n isDeadline(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n\n /**\n * Export the activity properties.\n * @returns The activity properties.\n */\n export(): ActivityProps {\n return {\n name: this._name,\n fromHour: this._fromHour,\n toHour: this._toHour,\n fromDay: this._fromDay,\n toDay: this._toDay,\n disabled: this._disabled,\n hidden: this._hidden,\n renderIcon: this._renderIcon,\n }\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.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 static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.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 static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.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: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.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: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.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 TimeManager.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 static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n"]}
|
|
@@ -332,17 +332,16 @@ var CommitmentBaseModel = class extends pixiVn.StoredClassModel {
|
|
|
332
332
|
* The function for rendering the image of the room.
|
|
333
333
|
*/
|
|
334
334
|
get renderImage() {
|
|
335
|
-
|
|
335
|
+
let render = this._renderImage;
|
|
336
|
+
if (render === void 0) {
|
|
336
337
|
return void 0;
|
|
337
338
|
}
|
|
338
|
-
if (typeof
|
|
339
|
-
return (props) => this._renderImage;
|
|
340
|
-
}
|
|
341
|
-
if (this.renderImage !== void 0) {
|
|
339
|
+
if (typeof render === "function") {
|
|
342
340
|
return (props) => {
|
|
343
|
-
return
|
|
341
|
+
return render(this, props);
|
|
344
342
|
};
|
|
345
343
|
}
|
|
344
|
+
return (props) => render;
|
|
346
345
|
}
|
|
347
346
|
/**
|
|
348
347
|
* Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/classes/Commitment.ts","../../src/managers/TimeManager.ts"],"names":[],"mappings":";AACA,SAA6B,SAAS,wBAAwB;;;ACD9D,SAAS,0BAA0B;AAGnC,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AAOtB,IAAqB,cAArB,MAAqB,aAAY;AAAA,EACrB,cAAc;AAAA,EAAE;AAAA,EACxB,OAAe,aAAa,UAAwB;AAChD,QAAI,OAAY,CAAC;AACjB,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,kBAAkB,IAAI,SAAS;AAAA,IACxC;AACA,QAAI,MAAM,QAAQ,SAAS,SAAS,GAAG;AACnC,WAAK,WAAW,IAAI,SAAS;AAAA,IACjC;AACA,QAAI,OAAO,SAAS,eAAe,UAAU;AACzC,WAAK,YAAY,IAAI,SAAS;AAAA,IAClC;AACA,QAAI,OAAO,SAAS,oBAAoB,UAAU;AAC9C,UAAI,aAAa,SAAS,cAAc,aAAY;AACpD,UAAI,SAAS,mBAAmB,YAAY;AACxC,gBAAQ,KAAK,4DA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raphicItemProps } from \"@drincs/nqtr/dist/override\";\nimport { CharacterBaseModel, getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { ExecutionTypeEnum } from \"../enums/ExecutionTypeEnum\";\nimport TimeManager from \"../managers/TimeManager\";\nimport { RoomBaseModel } from \"./navigation\";\n\nconst COMMITMENT_CATEGORY = \"__nqtr-commitment__\"\n\nexport interface CommitmentBaseModelProps<TCharacter extends CharacterBaseModel = CharacterBaseModel, TRoom extends RoomBaseModel = RoomBaseModel> {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set 3, the commitment will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the commitment ends. If the commitment is ended yet, it will be hidden.\n * If you set 3, the commitment will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set 3, the commitment will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.\n * If you set 3, the commitment will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\n /**\n * The image. It can be a string, an Element or a Pixi'VN Canvas Item.\n * Or an object to manage multiple image types. For example to have a image based on time.\n * @example\n * ```ts\n * {\n * \"morning\": \"morning-background.jpg\",\n * \"afternoon\": \"afternoon-background.jpg\",\n * \"evening\": \"evening-background.jpg\",\n * \"night\": \"night-background.jpg\"\n * }\n * ```\n * @default undefined\n */\n renderImage?: GraphicItemType | ((commitment: CommitmentBaseModel<TCharacter, TRoom>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * Execution type. If is \"automatic\" the onRun() runned automatically when the palayer is in the room. If is \"interaction\" the player must interact with the character to run the onRun() function.\n * @default ExecutionTypeEnum.INTERACTION\n */\n executionType?: ExecutionTypeEnum\n /**\n * Is a function that is called when the player interacts with the character.\n * @param commitment \n * @returns \n * @default undefined\n */\n onRun?: (commitment: CommitmentBaseModel) => void\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * If it is disabled this commitment will not be taken into consideration. So the characters will not be in the room, but will be busy with other commitments.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n}\n\n/**\n * The base model of a commitment. I suggest you extend this class to create your own commitment model.\n * You must use the saveRoom function to save the commitment in the registered commitments.\n * @example\n * ```ts\n * export const mcRoom = new CommitmentBaseModel(\"test\", character, room, {\n * name: \"Test\",\n * image: \"https://image.jpg\",\n * executionType: ExecutionTypeEnum.INTERACTION,\n * onRun: (commitment) => {\n * // Do something\n * }\n})\n * saveCommitment(mcRoom)\n * ```\n */\nexport default class CommitmentBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel, TRoom extends RoomBaseModel = RoomBaseModel> extends StoredClassModel {\n /**\n * @param id The id of the commitment, it must be unique.\n * @param character The character or characters that are in the commitment and so in the room.\n * @param room The room where the commitment is.\n * @param props The properties of the commitment.\n */\n constructor(id: string, character: TCharacter | TCharacter[] | undefined, room: TRoom, props: CommitmentBaseModelProps<TCharacter, TRoom>) {\n super(COMMITMENT_CATEGORY, id)\n this._characters = character ? Array.isArray(character) ? character : [character] : []\n this._room = room\n this._name = props.name || \"\"\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this._renderImage = props.renderImage\n this._executionType = props.executionType || ExecutionTypeEnum.INTERACTION\n this._onRun = props.onRun\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n }\n\n private _characters: TCharacter[]\n /**\n * The character or characters that are in the commitment and so in the room.\n */\n get characters(): TCharacter[] {\n return this._characters\n }\n\n private _room: TRoom\n /**\n * The room where the commitment is.\n */\n get room(): TRoom {\n return this._room\n }\n\n private _name: string\n /**\n * The name\n */\n get name(): string {\n return this._name\n }\n\n private defaultFromHour?: number\n /**\n * The hour when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set undefined, it will return the initial value of fromHour.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the commitment ends. If the commitment is ended yet, it will be hidden.\n * If you set undefined, it will return the initial value of toHour.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set undefined, it will return the initial value of fromDay.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.\n * If you set undefined, it will return the initial value of toDay.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private _renderImage?: GraphicItemType | ((commitment: CommitmentBaseModel<TCharacter, TRoom>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the image of the room.\n */\n get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n if (!this._renderImage) {\n return undefined\n }\n if (typeof this._renderImage !== \"function\") {\n return (props?: OnRenderGraphicItemProps) => this._renderImage as GraphicItemType\n }\n if (this.renderImage !== undefined) {\n return (props?: OnRenderGraphicItemProps) => {\n return (this.renderImage as any)(this, props)\n }\n }\n }\n\n private _executionType: ExecutionTypeEnum\n /**\n * Execution type. If is \"automatic\" the onRun() runned automatically when the palayer is in the room. If is \"interaction\" the player must interact with the character to run the onRun() function.\n */\n get executionType(): ExecutionTypeEnum {\n return this._executionType\n }\n\n private _onRun?: (commitment: CommitmentBaseModel) => void\n /**\n * Is a function that is called when the player interacts with the character.\n */\n onRun() {\n if (!this._onRun) {\n console.warn(\"[NQTR] onRun() is not defined for commitmen, so it will not run.\", this)\n }\n else {\n this._onRun(this)\n }\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled. You can also pass 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. You can also pass a Pixi'VN flag name.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 /**\n * Whether the commitment is expired.\n * @returns Whether the commitment is expired.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.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 static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.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 static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.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: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.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: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.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 TimeManager.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 static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/classes/Commitment.ts","../../src/managers/TimeManager.ts"],"names":[],"mappings":";AACA,SAA6B,SAAS,wBAAwB;;;ACD9D,SAAS,0BAA0B;AAGnC,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AAOtB,IAAqB,cAArB,MAAqB,aAAY;AAAA,EACrB,cAAc;AAAA,EAAE;AAAA,EACxB,OAAe,aAAa,UAAwB;AAChD,QAAI,OAAY,CAAC;AACjB,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAgB,UAAU;AAC1C,WAAK,aAAa,IAAI,SAAS;AAAA,IACnC;AACA,QAAI,OAAO,SAAS,gBAAg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aAAO,QAAQ,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACX;AAAA,EACA,IAAI,OAAO,OAAyB;AAChC,SAAK,mBAAmB,UAAU,KAAK;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAqB;AACjB,QAAI,KAAK,SAAS,KAAK,SAAS,YAAY,YAAY;AACpD,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AACJ","sourcesContent":["import { GraphicItemType, OnRenderGraphicItemProps } from \"@drincs/nqtr/dist/override\";\nimport { CharacterBaseModel, getFlag, StoredClassModel } from \"@drincs/pixi-vn\";\nimport { ExecutionTypeEnum } from \"../enums/ExecutionTypeEnum\";\nimport TimeManager from \"../managers/TimeManager\";\nimport { RoomBaseModel } from \"./navigation\";\n\nconst COMMITMENT_CATEGORY = \"__nqtr-commitment__\"\n\nexport interface CommitmentBaseModelProps<TCharacter extends CharacterBaseModel = CharacterBaseModel, TRoom extends RoomBaseModel = RoomBaseModel> {\n /**\n * The name\n * @default \"\"\n */\n name?: string\n /**\n * The hour when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set 3, the commitment will be hidden into hours 1 and 2, and will be shown from hour 3.\n * @default TimeManager.minDayHours\n */\n fromHour?: number\n /**\n * The hour when the commitment ends. If the commitment is ended yet, it will be hidden.\n * If you set 3, the commitment will be shown into hours 1 and 2 and will be hidden from hour 3.\n * @default TimeManager.maxDayHours + 1\n */\n toHour?: number\n /**\n * The day when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set 3, the commitment will be hidden into days 1 and 2, and will be shown from day 3.\n * @default undefined\n */\n fromDay?: number\n /**\n * The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.\n * If you set 3, the commitment will be shown into days 1 and 2 and will be deleted or hidden from day 3.\n * @default undefined\n */\n toDay?: number\n /**\n * The image. It can be a string, an Element or a Pixi'VN Canvas Item.\n * Or an object to manage multiple image types. For example to have a image based on time.\n * @example\n * ```ts\n * {\n * \"morning\": \"morning-background.jpg\",\n * \"afternoon\": \"afternoon-background.jpg\",\n * \"evening\": \"evening-background.jpg\",\n * \"night\": \"night-background.jpg\"\n * }\n * ```\n * @default undefined\n */\n renderImage?: GraphicItemType | ((commitment: CommitmentBaseModel<TCharacter, TRoom>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * Execution type. If is \"automatic\" the onRun() runned automatically when the palayer is in the room. If is \"interaction\" the player must interact with the character to run the onRun() function.\n * @default ExecutionTypeEnum.INTERACTION\n */\n executionType?: ExecutionTypeEnum\n /**\n * Is a function that is called when the player interacts with the character.\n * @param commitment \n * @returns \n * @default undefined\n */\n onRun?: (commitment: CommitmentBaseModel) => void\n /**\n * Whether is disabled. You can also pass a Pixi'VN flag name.\n * If it is disabled this commitment will not be taken into consideration. So the characters will not be in the room, but will be busy with other commitments.\n * @default false\n */\n disabled?: boolean | string\n /**\n * Whether is hidden. You can also pass a Pixi'VN flag name.\n * @default false\n */\n hidden?: boolean | string\n}\n\n/**\n * The base model of a commitment. I suggest you extend this class to create your own commitment model.\n * You must use the saveRoom function to save the commitment in the registered commitments.\n * @example\n * ```ts\n * export const mcRoom = new CommitmentBaseModel(\"test\", character, room, {\n * name: \"Test\",\n * image: \"https://image.jpg\",\n * executionType: ExecutionTypeEnum.INTERACTION,\n * onRun: (commitment) => {\n * // Do something\n * }\n})\n * saveCommitment(mcRoom)\n * ```\n */\nexport default class CommitmentBaseModel<TCharacter extends CharacterBaseModel = CharacterBaseModel, TRoom extends RoomBaseModel = RoomBaseModel> extends StoredClassModel {\n /**\n * @param id The id of the commitment, it must be unique.\n * @param character The character or characters that are in the commitment and so in the room.\n * @param room The room where the commitment is.\n * @param props The properties of the commitment.\n */\n constructor(id: string, character: TCharacter | TCharacter[] | undefined, room: TRoom, props: CommitmentBaseModelProps<TCharacter, TRoom>) {\n super(COMMITMENT_CATEGORY, id)\n this._characters = character ? Array.isArray(character) ? character : [character] : []\n this._room = room\n this._name = props.name || \"\"\n this.defaultFromHour = props.fromHour\n this.defaultToHour = props.toHour\n this.defaultFromDay = props.fromDay\n this.defaultToDay = props.toDay\n this._renderImage = props.renderImage\n this._executionType = props.executionType || ExecutionTypeEnum.INTERACTION\n this._onRun = props.onRun\n this.defaultDisabled = props.disabled || false\n this.defaultHidden = props.hidden || false\n }\n\n private _characters: TCharacter[]\n /**\n * The character or characters that are in the commitment and so in the room.\n */\n get characters(): TCharacter[] {\n return this._characters\n }\n\n private _room: TRoom\n /**\n * The room where the commitment is.\n */\n get room(): TRoom {\n return this._room\n }\n\n private _name: string\n /**\n * The name\n */\n get name(): string {\n return this._name\n }\n\n private defaultFromHour?: number\n /**\n * The hour when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set undefined, it will return the initial value of fromHour.\n */\n get fromHour(): number {\n return this.getStorageProperty<number>(\"fromHour\") || this.defaultFromHour || TimeManager.minDayHours\n }\n set fromHour(value: number | undefined) {\n this.setStorageProperty(\"fromHour\", value)\n }\n\n private defaultToHour?: number\n /**\n * The hour when the commitment ends. If the commitment is ended yet, it will be hidden.\n * If you set undefined, it will return the initial value of toHour.\n */\n get toHour(): number {\n return this.getStorageProperty<number>(\"toHour\") || this.defaultToHour || (TimeManager.maxDayHours + 1)\n }\n set toHour(value: number | undefined) {\n this.setStorageProperty(\"toHour\", value)\n }\n\n private defaultFromDay?: number\n /**\n * The day when the commitment starts. If the commitment is not started yet, it will be hidden.\n * If you set undefined, it will return the initial value of fromDay.\n */\n get fromDay(): number | undefined {\n return this.getStorageProperty<number>(\"fromDay\") || this.defaultFromDay\n }\n set fromDay(value: number | undefined) {\n this.setStorageProperty(\"fromDay\", value)\n }\n\n private defaultToDay?: number\n /**\n * The day when the commitment ends. If the commitment is ended yet, it will be deleted or hidden.\n * If you set undefined, it will return the initial value of toDay.\n */\n get toDay(): number | undefined {\n return this.getStorageProperty<number>(\"toDay\") || this.defaultToDay\n }\n set toDay(value: number | undefined) {\n this.setStorageProperty(\"toDay\", value)\n }\n\n private _renderImage?: GraphicItemType | ((commitment: CommitmentBaseModel<TCharacter, TRoom>, props?: OnRenderGraphicItemProps) => GraphicItemType)\n /**\n * The function for rendering the image of the room.\n */\n get renderImage(): ((props?: OnRenderGraphicItemProps) => GraphicItemType) | undefined {\n let render = this._renderImage\n if (render === undefined) {\n return undefined\n }\n if (typeof render === \"function\") {\n return (props?: OnRenderGraphicItemProps) => {\n return render(this, props)\n }\n }\n return (props?: OnRenderGraphicItemProps) => render\n }\n\n private _executionType: ExecutionTypeEnum\n /**\n * Execution type. If is \"automatic\" the onRun() runned automatically when the palayer is in the room. If is \"interaction\" the player must interact with the character to run the onRun() function.\n */\n get executionType(): ExecutionTypeEnum {\n return this._executionType\n }\n\n private _onRun?: (commitment: CommitmentBaseModel) => void\n /**\n * Is a function that is called when the player interacts with the character.\n */\n onRun() {\n if (!this._onRun) {\n console.warn(\"[NQTR] onRun() is not defined for commitmen, so it will not run.\", this)\n }\n else {\n this._onRun(this)\n }\n }\n\n private defaultDisabled: boolean | string\n /**\n * Whether is disabled. You can also pass 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. You can also pass a Pixi'VN flag name.\n */\n get hidden(): boolean {\n if (this.fromDay && this.fromDay > TimeManager.currentDay) {\n return true\n }\n if (!TimeManager.nowIsBetween(this.fromHour, this.toHour)) {\n return true\n }\n if (!this.isExpired) {\n return true\n }\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 /**\n * Whether the commitment is expired.\n * @returns Whether the commitment is expired.\n */\n isExpired(): boolean {\n if (this.toDay && this.toDay <= TimeManager.currentDay) {\n return true\n }\n return false\n }\n}\n","import { GameStorageManager } from \"@drincs/pixi-vn\";\nimport { ITimeStlot, TimeSettings } from \"../types/TimeSettings\";\n\nconst TIME_SETTINGS_KEY = '___nqtr-time_manager_settings___';\nconst TIME_DATA_KEY = '___nqtr-time_manager_data___';\n\ntype ITimeData = {\n currentHour?: number\n currentDay?: number\n}\n\nexport default class TimeManager {\n private constructor() { }\n private static editSettings(settings: TimeSettings) {\n let data: any = {}\n if (typeof settings.minDayHours === 'number') {\n data['minDayHours'] = settings.minDayHours\n }\n if (typeof settings.maxDayHours === 'number') {\n data['maxDayHours'] = settings.maxDayHours\n }\n if (typeof settings.minDayHours === 'number') {\n data['defaultTimeSpent'] = settings.defaultTimeSpent\n }\n if (Array.isArray(settings.timeSlots)) {\n data['timeSlots'] = settings.timeSlots\n }\n if (typeof settings.weekLength === 'number') {\n data['weekLength'] = settings.weekLength\n }\n if (typeof settings.weekendStartDay === 'number') {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekendStartDay >= weekLength) {\n console.warn(`[NQTR] Weekend start day should be less than week length ${weekLength}`)\n }\n data['weekendStartDay'] = settings.weekendStartDay\n }\n if (Array.isArray(settings.weekDaysNames)) {\n let weekLength = settings.weekLength || TimeManager.weekLength\n if (settings.weekDaysNames.length !== weekLength) {\n console.warn(`[NQTR] Week days names should be equal to week length ${weekLength}`)\n }\n data['weekDaysNames'] = settings.weekDaysNames\n }\n GameStorageManager.setVariable(TIME_SETTINGS_KEY, data)\n }\n /**\n * Get time settings\n * @default {}\n */\n static get settings(): TimeSettings {\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY) || {}\n return settings\n }\n /**\n * Set time settings, Is very important to set the settings before using the nqtr library, bacause more of the features are based on the time settings.\n */\n static set settings(value: TimeSettings) {\n TimeManager.editSettings(value)\n }\n static get minDayHours(): number {\n let result = 0\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('minDayHours')) {\n result = settings.minDayHours || 0\n }\n return result\n }\n static get maxDayHours(): number {\n let result = 24\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('maxDayHours')) {\n result = settings.maxDayHours || 24\n }\n return result\n }\n static get defaultTimeSpent(): number {\n let result = 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('defaultTimeSpent')) {\n result = settings.defaultTimeSpent || 1\n }\n return result\n }\n static get timeSlots(): ITimeStlot[] {\n let result: ITimeStlot[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('timeSlots')) {\n result = settings.timeSlots || []\n }\n return result\n }\n static get weekLength(): number {\n let result = 7\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekLength')) {\n result = settings.weekLength || 7\n }\n return result\n }\n static get weekendStartDay(): number {\n let result = TimeManager.weekLength - 1\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekendStartDay')) {\n result = settings.weekendStartDay || TimeManager.weekLength - 1\n }\n return result\n }\n static get weekDaysNames(): string[] {\n let result: string[] = []\n let settings = GameStorageManager.getVariable<TimeSettings>(TIME_SETTINGS_KEY)\n if (settings && settings.hasOwnProperty('weekDaysNames')) {\n result = settings.weekDaysNames || result\n }\n return result\n }\n\n /**\n * Get the current hour\n */\n static get currentHour(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentHour') && typeof data.currentHour === 'number') {\n return data.currentHour\n }\n return TimeManager.minDayHours\n }\n static set currentHour(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentHour = value\n } else {\n delete data.currentHour\n }\n GameStorageManager.setVariable(TIME_DATA_KEY, data)\n }\n /**\n * Get the current day\n */\n static get currentDay(): number {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (data.hasOwnProperty('currentDay') && typeof data.currentDay === 'number') {\n return data.currentDay\n }\n return 0\n }\n static set currentDay(value: number | undefined) {\n let data = GameStorageManager.getVariable<ITimeData>(TIME_DATA_KEY) || {}\n if (typeof value === 'number') {\n data.currentDay = value\n }\n else {\n delete data.currentDay\n }\n GameStorageManager.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 static get isWeekend(): boolean {\n return TimeManager.currentWeekDayNumber >= TimeManager.weekendStartDay\n }\n /**\n * Get the current week day number (1-TimeManager.weekLength).\n * For example, if the week length is 7 and the current day is 10, then the result will be 4.\n */\n static get currentWeekDayNumber(): number {\n let result = TimeManager.currentDay % TimeManager.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 static get currentDayName(): string {\n let weekDayNumber = TimeManager.currentWeekDayNumber - 1\n if (weekDayNumber >= TimeManager.weekDaysNames.length) {\n console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, TimeManager.weekDaysNames)\n return \"\"\n }\n return TimeManager.weekDaysNames[weekDayNumber]\n }\n /**\n * Get the current TimeManager.timeSlots index.\n * You can use this property to create \"Image that changes based on the time period\":\n * @example\n * ```ts\n * import { TimeManager } from '@drincs/nqtr';\n * \n * function changeBackground() {\n * return (\n * <img src={`background-${TimeManager.currentTimeSlot}.png`} />\n * )\n * }\n */\n static get currentTimeSlot(): number {\n if (TimeManager.timeSlots.length === 0) {\n console.warn('[NQTR] Time slots are not defined')\n return 0\n }\n for (let index = 0; index < TimeManager.timeSlots.length; index++) {\n let slot = TimeManager.timeSlots[index]\n if (TimeManager.timeSlots.length > index + 1) {\n if (TimeManager.nowIsBetween(slot.startHour, TimeManager.timeSlots[index + 1].startHour)) {\n return index\n }\n }\n }\n return TimeManager.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: TimeManager.defaultTimeSpent)\n * @returns TimeManager.currentHour\n */\n static increaseHour(timeSpent: number = TimeManager.defaultTimeSpent): number {\n let newHour = TimeManager.currentHour + timeSpent\n if (newHour >= TimeManager.maxDayHours) {\n TimeManager.increaseDay()\n newHour = TimeManager.minDayHours + (newHour - TimeManager.maxDayHours)\n }\n TimeManager.currentHour = newHour\n return TimeManager.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: TimeManager.minDayHours)\n * @param days is the number of days to increase (default: 1)\n * @returns TimeManager.currentDay\n */\n static increaseDay(newDayHour: number = TimeManager.minDayHours, days: number = 1): number {\n let newDay = TimeManager.currentDay + days\n TimeManager.currentDay = newDay\n TimeManager.currentHour = newDayHour\n return TimeManager.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 TimeManager.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 static nowIsBetween(fromHour: number, toHour: number): boolean {\n let currentHour = TimeManager.currentHour\n if (fromHour < toHour) {\n return currentHour >= fromHour && currentHour < toHour\n }\n return currentHour >= fromHour || currentHour < toHour\n }\n}\n"]}
|
|
@@ -330,17 +330,16 @@ var CommitmentBaseModel = class extends StoredClassModel {
|
|
|
330
330
|
* The function for rendering the image of the room.
|
|
331
331
|
*/
|
|
332
332
|
get renderImage() {
|
|
333
|
-
|
|
333
|
+
let render = this._renderImage;
|
|
334
|
+
if (render === void 0) {
|
|
334
335
|
return void 0;
|
|
335
336
|
}
|
|
336
|
-
if (typeof
|
|
337
|
-
return (props) => this._renderImage;
|
|
338
|
-
}
|
|
339
|
-
if (this.renderImage !== void 0) {
|
|
337
|
+
if (typeof render === "function") {
|
|
340
338
|
return (props) => {
|
|
341
|
-
return
|
|
339
|
+
return render(this, props);
|
|
342
340
|
};
|
|
343
341
|
}
|
|
342
|
+
return (props) => render;
|
|
344
343
|
}
|
|
345
344
|
/**
|
|
346
345
|
* Execution type. If is "automatic" the onRun() runned automatically when the palayer is in the room. If is "interaction" the player must interact with the character to run the onRun() function.
|