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:
parent
ccb658db89
commit
bd60cf51e2
@ -671,7 +671,7 @@
|
|||||||
"type": "NEW_YEARS",
|
"type": "NEW_YEARS",
|
||||||
"startDay": "1",
|
"startDay": "1",
|
||||||
"startMonth": "1",
|
"startMonth": "1",
|
||||||
"endDay": "7",
|
"endDay": "9",
|
||||||
"endMonth": "1"
|
"endMonth": "1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"acceleration": 7,
|
"acceleration": 7,
|
||||||
"enableWinterEvent": false,
|
"forceWinterEvent": false,
|
||||||
"weather": {
|
"weather": {
|
||||||
"clouds": {
|
"clouds": {
|
||||||
"values": [-1.5, -1, 0, 0.5, 1, 1.5],
|
"values": [-1.5, -1, 0, 0.5, 1, 1.5],
|
||||||
|
@ -24,7 +24,12 @@ export class WeatherController
|
|||||||
/** Handle client/weather */
|
/** Handle client/weather */
|
||||||
public generate(): IWeatherData
|
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 = this.weatherGenerator.calculateGameTime(result);
|
||||||
result.weather = this.weatherGenerator.generateWeather();
|
result.weather = this.weatherGenerator.generateWeather();
|
||||||
|
@ -42,7 +42,7 @@ export class WeatherGenerator
|
|||||||
data.date = formattedDate;
|
data.date = formattedDate;
|
||||||
data.time = this.getBsgFormattedInRaidTime(computedDate);
|
data.time = this.getBsgFormattedInRaidTime(computedDate);
|
||||||
data.acceleration = this.weatherConfig.acceleration;
|
data.acceleration = this.weatherConfig.acceleration;
|
||||||
data.winterEventEnabled = this.weatherConfig.enableWinterEvent;
|
data.winterEventEnabled = this.weatherConfig.forceWinterEvent;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export interface IWeatherConfig extends IBaseConfig
|
|||||||
kind: "aki-weather";
|
kind: "aki-weather";
|
||||||
acceleration: number;
|
acceleration: number;
|
||||||
weather: Weather;
|
weather: Weather;
|
||||||
enableWinterEvent: boolean;
|
forceWinterEvent: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Weather
|
export interface Weather
|
||||||
|
@ -27,8 +27,11 @@ export class SeasonalEventService
|
|||||||
protected httpConfig: IHttpConfig;
|
protected httpConfig: IHttpConfig;
|
||||||
protected weatherConfig: IWeatherConfig;
|
protected weatherConfig: IWeatherConfig;
|
||||||
|
|
||||||
protected halloweenEventActive = undefined;
|
protected halloweenEventActive: boolean = undefined;
|
||||||
protected christmasEventActive = undefined;
|
protected christmasEventActive: boolean = undefined;
|
||||||
|
|
||||||
|
/** All events active at this point in time */
|
||||||
|
protected currentlyActiveEvents: SeasonalEventType[] = undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject("WinstonLogger") protected logger: ILogger,
|
@inject("WinstonLogger") protected logger: ILogger,
|
||||||
@ -217,14 +220,13 @@ export class SeasonalEventService
|
|||||||
public enableSeasonalEvents(sessionId: string): void
|
public enableSeasonalEvents(sessionId: string): void
|
||||||
{
|
{
|
||||||
const globalConfig = this.databaseServer.getTables().globals.config;
|
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
|
// Current date is between start/end dates
|
||||||
if (currentDate >= eventStartDate && currentDate <= eventEndDate)
|
if (currentDate >= eventStartDate && currentDate <= eventEndDate)
|
||||||
{
|
{
|
||||||
this.christmasEventActive = SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS;
|
this.currentlyActiveEvents.push(SeasonalEventType[event.type]);
|
||||||
this.halloweenEventActive = SeasonalEventType[event.type] === SeasonalEventType.HALLOWEEN;
|
|
||||||
|
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
|
public enableSnow(): void
|
||||||
{
|
{
|
||||||
this.weatherConfig.enableWinterEvent = true;
|
this.weatherConfig.forceWinterEvent = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user