Fixed seasonal event items not appearing on flea during event
Don't rely on globals event value for event check, store event bools on SeasonaleventService class construction Remove dupe function `getSeasonalEventItemsToBlock(), rely on `getAllSeasonalEventItems()`
This commit is contained in:
parent
11b885539d
commit
5a0e16634e
@ -211,7 +211,7 @@ export class GameController
|
|||||||
|
|
||||||
if (this.seasonalEventService.isAutomaticEventDetectionEnabled())
|
if (this.seasonalEventService.isAutomaticEventDetectionEnabled())
|
||||||
{
|
{
|
||||||
this.seasonalEventService.checkForAndEnableSeasonalEvents(sessionID);
|
this.seasonalEventService.enableSeasonalEvents(sessionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmcProfile?.Skills?.Common)
|
if (pmcProfile?.Skills?.Common)
|
||||||
|
@ -38,7 +38,7 @@ export class FenceBaseAssortGenerator
|
|||||||
*/
|
*/
|
||||||
public generateFenceBaseAssorts(): void
|
public generateFenceBaseAssorts(): void
|
||||||
{
|
{
|
||||||
const blockedSeasonalItems = this.seasonalEventService.getSeasonalEventItemsToBlock();
|
const blockedSeasonalItems = this.seasonalEventService.getAllSeasonalEventItems();
|
||||||
|
|
||||||
const baseFenceAssort = this.databaseServer.getTables().traders[Traders.FENCE].assort;
|
const baseFenceAssort = this.databaseServer.getTables().traders[Traders.FENCE].assort;
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ export class LocationGenerator
|
|||||||
protected getPossibleLootItemsForContainer(containerTypeId: string, staticLootDist: Record<string, IStaticLootDetails>): ProbabilityObjectArray<string, number>
|
protected getPossibleLootItemsForContainer(containerTypeId: string, staticLootDist: Record<string, IStaticLootDetails>): ProbabilityObjectArray<string, number>
|
||||||
{
|
{
|
||||||
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
||||||
const seasonalItemTplBlacklist = this.seasonalEventService.getSeasonalEventItemsToBlock();
|
const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems();
|
||||||
|
|
||||||
const itemDistribution = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
const itemDistribution = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
||||||
for (const icd of staticLootDist[containerTypeId].itemDistribution)
|
for (const icd of staticLootDist[containerTypeId].itemDistribution)
|
||||||
@ -535,7 +535,7 @@ export class LocationGenerator
|
|||||||
|
|
||||||
// Iterate over spawnpoints
|
// Iterate over spawnpoints
|
||||||
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
||||||
const seasonalItemTplBlacklist = this.seasonalEventService.getSeasonalEventItemsToBlock();
|
const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems();
|
||||||
for (const spawnPoint of chosenSpawnpoints)
|
for (const spawnPoint of chosenSpawnpoints)
|
||||||
{
|
{
|
||||||
const itemArray = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
const itemArray = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
||||||
@ -611,7 +611,7 @@ export class LocationGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
||||||
const seasonalItemTplBlacklist = this.seasonalEventService.getSeasonalEventItemsToBlock();
|
const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems();
|
||||||
// Add remaining forced loot to array
|
// Add remaining forced loot to array
|
||||||
for (const forcedLootItem of forcedSpawnPoints)
|
for (const forcedLootItem of forcedSpawnPoints)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ export class PMCLootGenerator
|
|||||||
if (!this.seasonalEventService.seasonalEventEnabled())
|
if (!this.seasonalEventService.seasonalEventEnabled())
|
||||||
{
|
{
|
||||||
// Blacklist seasonal items
|
// Blacklist seasonal items
|
||||||
itemBlacklist.push(...this.seasonalEventService.getSeasonalEventItemsToBlock());
|
itemBlacklist.push(...this.seasonalEventService.getAllSeasonalEventItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent)
|
const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent)
|
||||||
@ -89,7 +89,7 @@ export class PMCLootGenerator
|
|||||||
if (!this.seasonalEventService.seasonalEventEnabled())
|
if (!this.seasonalEventService.seasonalEventEnabled())
|
||||||
{
|
{
|
||||||
// Blacklist seasonal items
|
// Blacklist seasonal items
|
||||||
itemBlacklist.push(...this.seasonalEventService.getSeasonalEventItemsToBlock());
|
itemBlacklist.push(...this.seasonalEventService.getAllSeasonalEventItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent)
|
const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent)
|
||||||
@ -134,7 +134,7 @@ export class PMCLootGenerator
|
|||||||
if (!this.seasonalEventService.seasonalEventEnabled())
|
if (!this.seasonalEventService.seasonalEventEnabled())
|
||||||
{
|
{
|
||||||
// Blacklist seasonal items
|
// Blacklist seasonal items
|
||||||
itemBlacklist.push(...this.seasonalEventService.getSeasonalEventItemsToBlock());
|
itemBlacklist.push(...this.seasonalEventService.getAllSeasonalEventItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent)
|
const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent)
|
||||||
|
@ -76,7 +76,7 @@ export class RagfairAssortGenerator
|
|||||||
];
|
];
|
||||||
|
|
||||||
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
|
||||||
const seasonalItemTplBlacklist = this.seasonalEventService.getSeasonalEventItemsToBlock();
|
const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems();
|
||||||
for (const item of items)
|
for (const item of items)
|
||||||
{
|
{
|
||||||
if (!this.itemHelper.isValidItem(item._id, ragfairItemInvalidBaseTypes))
|
if (!this.itemHelper.isValidItem(item._id, ragfairItemInvalidBaseTypes))
|
||||||
|
@ -24,6 +24,9 @@ export class SeasonalEventService
|
|||||||
protected questConfig: IQuestConfig;
|
protected questConfig: IQuestConfig;
|
||||||
protected httpConfig: IHttpConfig;
|
protected httpConfig: IHttpConfig;
|
||||||
|
|
||||||
|
protected halloweenEventActive = undefined;
|
||||||
|
protected christmasEventActive = undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject("WinstonLogger") protected logger: ILogger,
|
@inject("WinstonLogger") protected logger: ILogger,
|
||||||
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
||||||
@ -38,6 +41,8 @@ export class SeasonalEventService
|
|||||||
this.seasonalEventConfig = this.configServer.getConfig(ConfigTypes.SEASONAL_EVENT);
|
this.seasonalEventConfig = this.configServer.getConfig(ConfigTypes.SEASONAL_EVENT);
|
||||||
this.questConfig = this.configServer.getConfig(ConfigTypes.QUEST);
|
this.questConfig = this.configServer.getConfig(ConfigTypes.QUEST);
|
||||||
this.httpConfig = this.configServer.getConfig(ConfigTypes.HTTP);
|
this.httpConfig = this.configServer.getConfig(ConfigTypes.HTTP);
|
||||||
|
|
||||||
|
this.cacheActiveEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get christmasEventItems(): string[]
|
protected get christmasEventItems(): string[]
|
||||||
@ -107,28 +112,6 @@ export class SeasonalEventService
|
|||||||
public getAllSeasonalEventItems(): string[]
|
public getAllSeasonalEventItems(): string[]
|
||||||
{
|
{
|
||||||
const items = [];
|
const items = [];
|
||||||
|
|
||||||
if (!this.christmasEventEnabled())
|
|
||||||
{
|
|
||||||
items.push(...this.christmasEventItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.halloweenEventEnabled())
|
|
||||||
{
|
|
||||||
items.push(...this.halloweenEventItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an array of seasonal items that should be blocked as season is not currently active
|
|
||||||
* @returns Array of tpl strings
|
|
||||||
*/
|
|
||||||
public getSeasonalEventItemsToBlock(): string[]
|
|
||||||
{
|
|
||||||
const items = [];
|
|
||||||
|
|
||||||
if (!this.christmasEventEnabled())
|
if (!this.christmasEventEnabled())
|
||||||
{
|
{
|
||||||
items.push(...this.christmasEventItems);
|
items.push(...this.christmasEventItems);
|
||||||
@ -148,26 +131,25 @@ export class SeasonalEventService
|
|||||||
*/
|
*/
|
||||||
public seasonalEventEnabled(): boolean
|
public seasonalEventEnabled(): boolean
|
||||||
{
|
{
|
||||||
return this.databaseServer.getTables().globals.config.EventType.includes(SeasonalEventType.CHRISTMAS) ||
|
return this.christmasEventEnabled() || this.halloweenEventEnabled();
|
||||||
this.databaseServer.getTables().globals.config.EventType.includes(SeasonalEventType.HALLOWEEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is christmas event active (Globals eventtype array contains even name)
|
* Is christmas event active
|
||||||
* @returns true if active
|
* @returns true if active
|
||||||
*/
|
*/
|
||||||
public christmasEventEnabled(): boolean
|
public christmasEventEnabled(): boolean
|
||||||
{
|
{
|
||||||
return this.databaseServer.getTables().globals.config.EventType.includes(SeasonalEventType.CHRISTMAS);
|
return this.christmasEventActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* is halloween event active (Globals eventtype array contains even name)
|
* is halloween event active
|
||||||
* @returns true if active
|
* @returns true if active
|
||||||
*/
|
*/
|
||||||
public halloweenEventEnabled(): boolean
|
public halloweenEventEnabled(): boolean
|
||||||
{
|
{
|
||||||
return this.databaseServer.getTables().globals.config.EventType.includes(SeasonalEventType.HALLOWEEN);
|
return this.halloweenEventActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -216,12 +198,25 @@ export class SeasonalEventService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if current date falls inside any of the seasons events pased in, if so, handle them
|
* Handle seasonal events
|
||||||
* @param sessionId Players id
|
* @param sessionId Players id
|
||||||
*/
|
*/
|
||||||
public checkForAndEnableSeasonalEvents(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)
|
||||||
|
{
|
||||||
|
this.updateGlobalEvents(sessionId, globalConfig, SeasonalEventType.HALLOWEEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected cacheActiveEvents(): void
|
||||||
|
{
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
const seasonalEvents = this.getEventDetails();
|
const seasonalEvents = this.getEventDetails();
|
||||||
|
|
||||||
@ -234,7 +229,8 @@ export class SeasonalEventService
|
|||||||
if (currentDate >= eventStartDate
|
if (currentDate >= eventStartDate
|
||||||
&& currentDate <= eventEndDate)
|
&& currentDate <= eventEndDate)
|
||||||
{
|
{
|
||||||
this.updateGlobalEvents(sessionId, globalConfig, event.type);
|
this.christmasEventActive = (SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS);
|
||||||
|
this.halloweenEventActive = (SeasonalEventType[event.type] === SeasonalEventType.HALLOWEEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,6 +391,8 @@ export class SeasonalEventService
|
|||||||
assaultBackpack.push("634959225289190e5e773b3b");
|
assaultBackpack.push("634959225289190e5e773b3b");
|
||||||
assaultBackpack.push("634959225289190e5e773b3b");
|
assaultBackpack.push("634959225289190e5e773b3b");
|
||||||
assaultBackpack.push("634959225289190e5e773b3b");
|
assaultBackpack.push("634959225289190e5e773b3b");
|
||||||
|
assaultBackpack.push("634959225289190e5e773b3b");
|
||||||
|
assaultBackpack.push("634959225289190e5e773b3b");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user