From 37b7712602f89de7ed077f3a3cf098a58798b84d Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 1 Nov 2023 11:35:05 +0000 Subject: [PATCH] Rename function `getAllSeasonalEventItems()` to `getInactiveSeasonalEventItems()` --- project/src/generators/BotGenerator.ts | 3 +-- .../generators/FenceBaseAssortGenerator.ts | 2 +- project/src/generators/LocationGenerator.ts | 6 +++--- project/src/generators/PMCLootGenerator.ts | 6 +++--- .../src/generators/RagfairAssortGenerator.ts | 2 +- project/src/services/SeasonalEventService.ts | 21 ++++++++++--------- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index 15f99a65..36db7cff 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -152,8 +152,7 @@ export class BotGenerator bot.Info.Nickname = this.generateBotNickname(botJsonTemplate, botGenerationDetails.isPlayerScav, botRole, sessionId); - const skipChristmasItems = !this.seasonalEventService.christmasEventEnabled(); - if (skipChristmasItems) + if (!this.seasonalEventService.christmasEventEnabled()) { this.seasonalEventService.removeChristmasItemsFromBotInventory(botJsonTemplate.inventory, botGenerationDetails.role); } diff --git a/project/src/generators/FenceBaseAssortGenerator.ts b/project/src/generators/FenceBaseAssortGenerator.ts index 8a3b4810..3e0e43a2 100644 --- a/project/src/generators/FenceBaseAssortGenerator.ts +++ b/project/src/generators/FenceBaseAssortGenerator.ts @@ -38,7 +38,7 @@ export class FenceBaseAssortGenerator */ public generateFenceBaseAssorts(): void { - const blockedSeasonalItems = this.seasonalEventService.getAllSeasonalEventItems(); + const blockedSeasonalItems = this.seasonalEventService.getInactiveSeasonalEventItems(); const baseFenceAssort = this.databaseServer.getTables().traders[Traders.FENCE].assort; diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 8dfab184..e8f6e9b3 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -431,7 +431,7 @@ export class LocationGenerator protected getPossibleLootItemsForContainer(containerTypeId: string, staticLootDist: Record): ProbabilityObjectArray { const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled(); - const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems(); + const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems(); const itemDistribution = new ProbabilityObjectArray(this.mathUtil, this.jsonUtil); for (const icd of staticLootDist[containerTypeId].itemDistribution) @@ -533,7 +533,7 @@ export class LocationGenerator // Iterate over spawnpoints const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled(); - const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems(); + const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems(); for (const spawnPoint of chosenSpawnpoints) { if (!spawnPoint.template) @@ -623,7 +623,7 @@ export class LocationGenerator } const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled(); - const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems(); + const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems(); // Add remaining forced loot to array for (const forcedLootItem of forcedSpawnPoints) { diff --git a/project/src/generators/PMCLootGenerator.ts b/project/src/generators/PMCLootGenerator.ts index 52b48f40..2e146d44 100644 --- a/project/src/generators/PMCLootGenerator.ts +++ b/project/src/generators/PMCLootGenerator.ts @@ -53,7 +53,7 @@ export class PMCLootGenerator if (!this.seasonalEventService.seasonalEventEnabled()) { // Blacklist seasonal items - itemBlacklist.push(...this.seasonalEventService.getAllSeasonalEventItems()); + itemBlacklist.push(...this.seasonalEventService.getInactiveSeasonalEventItems()); } const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent) @@ -89,7 +89,7 @@ export class PMCLootGenerator if (!this.seasonalEventService.seasonalEventEnabled()) { // Blacklist seasonal items - itemBlacklist.push(...this.seasonalEventService.getAllSeasonalEventItems()); + itemBlacklist.push(...this.seasonalEventService.getInactiveSeasonalEventItems()); } const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent) @@ -134,7 +134,7 @@ export class PMCLootGenerator if (!this.seasonalEventService.seasonalEventEnabled()) { // Blacklist seasonal items - itemBlacklist.push(...this.seasonalEventService.getAllSeasonalEventItems()); + itemBlacklist.push(...this.seasonalEventService.getInactiveSeasonalEventItems()); } const itemsToAdd = Object.values(items).filter(item => allowedItemTypes.includes(item._parent) diff --git a/project/src/generators/RagfairAssortGenerator.ts b/project/src/generators/RagfairAssortGenerator.ts index 19855ebb..2da09e56 100644 --- a/project/src/generators/RagfairAssortGenerator.ts +++ b/project/src/generators/RagfairAssortGenerator.ts @@ -76,7 +76,7 @@ export class RagfairAssortGenerator ]; const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled(); - const seasonalItemTplBlacklist = this.seasonalEventService.getAllSeasonalEventItems(); + const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems(); for (const item of items) { if (!this.itemHelper.isValidItem(item._id, ragfairItemInvalidBaseTypes)) diff --git a/project/src/services/SeasonalEventService.ts b/project/src/services/SeasonalEventService.ts index 68b52644..67791335 100644 --- a/project/src/services/SeasonalEventService.ts +++ b/project/src/services/SeasonalEventService.ts @@ -105,11 +105,12 @@ export class SeasonalEventService } /** - * Get an array of items that appear during a seasonal event - * returns multiple seasonal event items if they are both active + * Get an array of seasonal items that should not appear + * e.g. if halloween is active, only return christmas items + * or, if halloween and christmas are inactive, return both sets of items * @returns array of tpl strings */ - public getAllSeasonalEventItems(): string[] + public getInactiveSeasonalEventItems(): string[] { const items = []; if (!this.christmasEventEnabled()) @@ -237,10 +238,10 @@ export class SeasonalEventService /** * Iterate through bots inventory and loot to find and remove christmas items (as defined in SeasonalEventService) - * @param nodeInventory Bots inventory to iterate over + * @param botInventory Bots inventory to iterate over * @param botRole the role of the bot being processed */ - public removeChristmasItemsFromBotInventory(nodeInventory: Inventory, botRole: string): void + public removeChristmasItemsFromBotInventory(botInventory: Inventory, botRole: string): void { const christmasItems = this.getChristmasEventItems(); const equipmentSlotsToFilter = ["FaceCover", "Headwear", "Backpack", "TacticalVest"]; @@ -249,25 +250,25 @@ export class SeasonalEventService // Remove christmas related equipment for (const equipmentSlotKey of equipmentSlotsToFilter) { - if (!nodeInventory.equipment[equipmentSlotKey]) + if (!botInventory.equipment[equipmentSlotKey]) { this.logger.warning(this.localisationService.getText("seasonal-missing_equipment_slot_on_bot", {equipmentSlot: equipmentSlotKey, botRole: botRole})); } - const equipment: Record = nodeInventory.equipment[equipmentSlotKey]; + const equipment: Record = botInventory.equipment[equipmentSlotKey]; // eslint-disable-next-line @typescript-eslint/no-unused-vars - nodeInventory.equipment[equipmentSlotKey] = Object.fromEntries(Object.entries(equipment).filter(([index]) => !christmasItems.includes(index))); + botInventory.equipment[equipmentSlotKey] = Object.fromEntries(Object.entries(equipment).filter(([index]) => !christmasItems.includes(index))); } // Remove christmas related loot from loot containers for (const lootContainerKey of lootContainersToFilter) { - if (!nodeInventory.items[lootContainerKey]) + if (!botInventory.items[lootContainerKey]) { this.logger.warning(this.localisationService.getText("seasonal-missing_loot_container_slot_on_bot", {lootContainer: lootContainerKey, botRole: botRole})); } - nodeInventory.items[lootContainerKey] = nodeInventory.items[lootContainerKey].filter((x: string) => !christmasItems.includes(x)); + botInventory.items[lootContainerKey] = botInventory.items[lootContainerKey].filter((x: string) => !christmasItems.includes(x)); } }