Added enabled property to events config + wire up

This commit is contained in:
Dev 2024-10-25 11:53:18 +01:00
parent b57a199c8a
commit 731d9f3f0b
3 changed files with 16 additions and 1 deletions

View File

@ -689,6 +689,7 @@
], ],
"events": [ "events": [
{ {
"enabled": true,
"name": "halloween", "name": "halloween",
"type": "HALLOWEEN", "type": "HALLOWEEN",
"startDay": "24", "startDay": "24",
@ -697,6 +698,7 @@
"endMonth": "11" "endMonth": "11"
}, },
{ {
"enabled": true,
"name": "christmas", "name": "christmas",
"type": "CHRISTMAS", "type": "CHRISTMAS",
"startDay": "7", "startDay": "7",
@ -705,6 +707,7 @@
"endMonth": "12" "endMonth": "12"
}, },
{ {
"enabled": true,
"name": "newyears", "name": "newyears",
"type": "NEW_YEARS", "type": "NEW_YEARS",
"startDay": "1", "startDay": "1",
@ -713,6 +716,7 @@
"endMonth": "1" "endMonth": "1"
}, },
{ {
"enabled": true,
"name": "snow", "name": "snow",
"type": "SNOW", "type": "SNOW",
"startDay": "8", "startDay": "8",

View File

@ -14,6 +14,7 @@ export interface ISeasonalEventConfig extends IBaseConfig {
} }
export interface ISeasonalEvent { export interface ISeasonalEvent {
enabled: boolean;
name: string; name: string;
type: SeasonalEventType; type: SeasonalEventType;
startDay: number; startDay: number;

View File

@ -196,7 +196,7 @@ export class SeasonalEventService {
} }
/** /**
* Handle seasonal events * Handle activating seasonal events
*/ */
public enableSeasonalEvents(): void { public enableSeasonalEvents(): void {
if (this.currentlyActiveEvents) { if (this.currentlyActiveEvents) {
@ -207,6 +207,9 @@ export class SeasonalEventService {
} }
} }
/**
* Store active events inside class array property `currentlyActiveEvents` + set class properties: christmasEventActive/halloweenEventActive
*/
protected cacheActiveEvents(): void { protected cacheActiveEvents(): void {
const currentDate = new Date(); const currentDate = new Date();
const seasonalEvents = this.getEventDetails(); const seasonalEvents = this.getEventDetails();
@ -217,6 +220,9 @@ export class SeasonalEventService {
// Current date is between start/end dates // Current date is between start/end dates
if (currentDate >= eventStartDate && currentDate <= eventEndDate) { if (currentDate >= eventStartDate && currentDate <= eventEndDate) {
if (!event.enabled) {
continue;
}
this.currentlyActiveEvents.push(SeasonalEventType[event.type]); this.currentlyActiveEvents.push(SeasonalEventType[event.type]);
if (SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS) { if (SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS) {
@ -230,6 +236,10 @@ export class SeasonalEventService {
} }
} }
/**
* Get the currently active weather season e.g. SUMMER/AUTUMN/WINTER
* @returns Season enum value
*/
public getActiveWeatherSeason(): Season { public getActiveWeatherSeason(): Season {
if (this.weatherConfig.overrideSeason !== null) { if (this.weatherConfig.overrideSeason !== null) {
return this.weatherConfig.overrideSeason; return this.weatherConfig.overrideSeason;