Fix event system not working for events other than halloween and christmas

Allow events to overlap

Rename config property from `enableWinterEvent` to `forceWinterEvent`
This commit is contained in:
Dev 2024-01-06 23:29:42 +00:00
parent ccb658db89
commit bd60cf51e2
6 changed files with 32 additions and 16 deletions

View File

@ -671,7 +671,7 @@
"type": "NEW_YEARS",
"startDay": "1",
"startMonth": "1",
"endDay": "7",
"endDay": "9",
"endMonth": "1"
}
]

View File

@ -1,6 +1,6 @@
{
"acceleration": 7,
"enableWinterEvent": false,
"forceWinterEvent": false,
"weather": {
"clouds": {
"values": [-1.5, -1, 0, 0.5, 1, 1.5],

View File

@ -24,7 +24,12 @@ export class WeatherController
/** Handle client/weather */
public generate(): IWeatherData
{
let result: IWeatherData = { acceleration: 0, time: "", date: "", weather: null, winterEventEnabled: this.weatherConfig.enableWinterEvent };
let result: IWeatherData = {
acceleration: 0,
time: "",
date: "",
weather: null,
winterEventEnabled: this.weatherConfig.forceWinterEvent };
result = this.weatherGenerator.calculateGameTime(result);
result.weather = this.weatherGenerator.generateWeather();

View File

@ -42,7 +42,7 @@ export class WeatherGenerator
data.date = formattedDate;
data.time = this.getBsgFormattedInRaidTime(computedDate);
data.acceleration = this.weatherConfig.acceleration;
data.winterEventEnabled = this.weatherConfig.enableWinterEvent;
data.winterEventEnabled = this.weatherConfig.forceWinterEvent;
return data;
}

View File

@ -7,7 +7,7 @@ export interface IWeatherConfig extends IBaseConfig
kind: "aki-weather";
acceleration: number;
weather: Weather;
enableWinterEvent: boolean;
forceWinterEvent: boolean;
}
export interface Weather

View File

@ -27,8 +27,11 @@ export class SeasonalEventService
protected httpConfig: IHttpConfig;
protected weatherConfig: IWeatherConfig;
protected halloweenEventActive = undefined;
protected christmasEventActive = undefined;
protected halloweenEventActive: boolean = undefined;
protected christmasEventActive: boolean = undefined;
/** All events active at this point in time */
protected currentlyActiveEvents: SeasonalEventType[] = undefined;
constructor(
@inject("WinstonLogger") protected logger: ILogger,
@ -217,14 +220,13 @@ export class SeasonalEventService
public enableSeasonalEvents(sessionId: string): void
{
const globalConfig = this.databaseServer.getTables().globals.config;
if (this.christmasEventActive)
{
this.updateGlobalEvents(sessionId, globalConfig, SeasonalEventType.CHRISTMAS);
}
if (this.halloweenEventActive)
if (this.currentlyActiveEvents)
{
this.updateGlobalEvents(sessionId, globalConfig, SeasonalEventType.HALLOWEEN);
for (const event of this.currentlyActiveEvents)
{
this.updateGlobalEvents(sessionId, globalConfig, event);
}
}
}
@ -241,8 +243,17 @@ export class SeasonalEventService
// Current date is between start/end dates
if (currentDate >= eventStartDate && currentDate <= eventEndDate)
{
this.christmasEventActive = SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS;
this.halloweenEventActive = SeasonalEventType[event.type] === SeasonalEventType.HALLOWEEN;
this.currentlyActiveEvents.push(SeasonalEventType[event.type]);
if (SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS)
{
this.christmasEventActive = true;
}
if (SeasonalEventType[event.type] === SeasonalEventType.HALLOWEEN)
{
this.halloweenEventActive = true;
}
}
}
}
@ -558,6 +569,6 @@ export class SeasonalEventService
public enableSnow(): void
{
this.weatherConfig.enableWinterEvent = true;
this.weatherConfig.forceWinterEvent = true;
}
}