Added enabled
property to events config + wire up
This commit is contained in:
parent
b57a199c8a
commit
731d9f3f0b
@ -689,6 +689,7 @@
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"enabled": true,
|
||||
"name": "halloween",
|
||||
"type": "HALLOWEEN",
|
||||
"startDay": "24",
|
||||
@ -697,6 +698,7 @@
|
||||
"endMonth": "11"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"name": "christmas",
|
||||
"type": "CHRISTMAS",
|
||||
"startDay": "7",
|
||||
@ -705,6 +707,7 @@
|
||||
"endMonth": "12"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"name": "newyears",
|
||||
"type": "NEW_YEARS",
|
||||
"startDay": "1",
|
||||
@ -713,6 +716,7 @@
|
||||
"endMonth": "1"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"name": "snow",
|
||||
"type": "SNOW",
|
||||
"startDay": "8",
|
||||
|
@ -14,6 +14,7 @@ export interface ISeasonalEventConfig extends IBaseConfig {
|
||||
}
|
||||
|
||||
export interface ISeasonalEvent {
|
||||
enabled: boolean;
|
||||
name: string;
|
||||
type: SeasonalEventType;
|
||||
startDay: number;
|
||||
|
@ -196,7 +196,7 @@ export class SeasonalEventService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle seasonal events
|
||||
* Handle activating seasonal events
|
||||
*/
|
||||
public enableSeasonalEvents(): void {
|
||||
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 {
|
||||
const currentDate = new Date();
|
||||
const seasonalEvents = this.getEventDetails();
|
||||
@ -217,6 +220,9 @@ export class SeasonalEventService {
|
||||
|
||||
// Current date is between start/end dates
|
||||
if (currentDate >= eventStartDate && currentDate <= eventEndDate) {
|
||||
if (!event.enabled) {
|
||||
continue;
|
||||
}
|
||||
this.currentlyActiveEvents.push(SeasonalEventType[event.type]);
|
||||
|
||||
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 {
|
||||
if (this.weatherConfig.overrideSeason !== null) {
|
||||
return this.weatherConfig.overrideSeason;
|
||||
|
Loading…
Reference in New Issue
Block a user