Improved import consistency + comment improvements

Moved `IGenerateEquipmentProperties` into own file
This commit is contained in:
Dev 2024-06-19 11:11:28 +01:00
parent f7e42cae5d
commit 43a09c29c2
27 changed files with 67 additions and 65 deletions

View File

@ -15,6 +15,8 @@ import { BaseClasses } from "@spt/models/enums/BaseClasses";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { ModSpawn } from "@spt/models/enums/ModSpawn";
import { IChooseRandomCompatibleModResult } from "@spt/models/spt/bots/IChooseRandomCompatibleModResult";
import { IFilterPlateModsForSlotByLevelResult, Result } from "@spt/models/spt/bots/IFilterPlateModsForSlotByLevelResult";
import { IGenerateEquipmentProperties } from "@spt/models/spt/bots/IGenerateEquipmentProperties";
import { IGenerateWeaponRequest } from "@spt/models/spt/bots/IGenerateWeaponRequest";
import { IModToSpawnRequest } from "@spt/models/spt/bots/IModToSpawnRequest";
import { EquipmentFilterDetails, EquipmentFilters, IBotConfig } from "@spt/models/spt/config/IBotConfig";
@ -30,8 +32,6 @@ import { LocalisationService } from "@spt/services/LocalisationService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { HashUtil } from "@spt/utils/HashUtil";
import { RandomUtil } from "@spt/utils/RandomUtil";
import { IFilterPlateModsForSlotByLevelResult, Result } from "../models/spt/bots/IFilterPlateModsForSlotByLevelResult";
import { IGenerateEquipmentProperties } from "./BotInventoryGenerator";
@injectable()
export class BotEquipmentModGenerator
@ -159,7 +159,7 @@ export class BotEquipmentModGenerator
// Find random mod and check its compatible
let modTpl: string | undefined;
let found = false;
const exhaustableModPool = new ExhaustableArray(modPoolToChooseFrom, this.randomUtil, this.cloner);
const exhaustableModPool = new ExhaustableArray<string>(modPoolToChooseFrom, this.randomUtil, this.cloner);
while (exhaustableModPool.hasValues())
{
modTpl = exhaustableModPool.getRandomValue();

View File

@ -7,17 +7,16 @@ import { BotHelper } from "@spt/helpers/BotHelper";
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { WeightedRandomHelper } from "@spt/helpers/WeightedRandomHelper";
import { Inventory as PmcInventory } from "@spt/models/eft/common/tables/IBotBase";
import { Chances, Generation, IBotType, Inventory, Mods } from "@spt/models/eft/common/tables/IBotType";
import { Chances, Equipment, Generation, IBotType, Inventory } from "@spt/models/eft/common/tables/IBotType";
import { ITemplateItem } from "@spt/models/eft/common/tables/ITemplateItem";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { EquipmentSlots } from "@spt/models/enums/EquipmentSlots";
import { GameEditions } from "@spt/models/enums/GameEditions";
import { ItemTpl } from "@spt/models/enums/ItemTpl";
import { IGenerateEquipmentProperties } from "@spt/models/spt/bots/IGenerateEquipmentProperties";
import {
EquipmentFilterDetails,
EquipmentFilters,
IBotConfig,
RandomisationDetails,
} from "@spt/models/spt/config/IBotConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer";
@ -253,14 +252,14 @@ export class BotInventoryGenerator
if (botEquipConfig.forceOnlyArmoredRigWhenNoArmor && !hasArmorVest)
{
// Filter rigs down to only those with armor
this.filterRigsToThoseWithProtection(templateInventory);
this.filterRigsToThoseWithProtection(templateInventory.equipment);
}
// Optimisation - Remove armored rigs from pool
if (hasArmorVest)
{
// Filter rigs down to only those with armor
this.filterRigsToThoseWithoutProtection(templateInventory);
this.filterRigsToThoseWithoutProtection(templateInventory.equipment);
}
this.generateEquipment({
@ -278,44 +277,44 @@ export class BotInventoryGenerator
/**
* Remove non-armored rigs from parameter data
* @param templateInventory
* @param templateEquipment Equpiment to filter TacticalVest of
*/
protected filterRigsToThoseWithProtection(templateInventory: Inventory): void
protected filterRigsToThoseWithProtection(templateEquipment: Equipment): void
{
const tacVestsWithArmor = Object.entries(templateInventory.equipment.TacticalVest).reduce(
const tacVestsWithArmor = Object.entries(templateEquipment.TacticalVest).reduce(
(newVestDictionary, [tplKey]) =>
{
if (this.itemHelper.itemHasSlots(tplKey))
{
newVestDictionary[tplKey] = templateInventory.equipment.TacticalVest[tplKey];
newVestDictionary[tplKey] = templateEquipment.TacticalVest[tplKey];
}
return newVestDictionary;
},
{},
);
templateInventory.equipment.TacticalVest = tacVestsWithArmor;
templateEquipment.TacticalVest = tacVestsWithArmor;
}
/**
* Remove armored rigs from parameter data
* @param templateInventory
* @param templateEquipment Equpiment to filter TacticalVest of
*/
protected filterRigsToThoseWithoutProtection(templateInventory: Inventory): void
protected filterRigsToThoseWithoutProtection(templateEquipment: Equipment): void
{
const tacVestsWithoutArmor = Object.entries(templateInventory.equipment.TacticalVest).reduce(
const tacVestsWithoutArmor = Object.entries(templateEquipment.TacticalVest).reduce(
(newVestDictionary, [tplKey]) =>
{
if (!this.itemHelper.itemHasSlots(tplKey))
{
newVestDictionary[tplKey] = templateInventory.equipment.TacticalVest[tplKey];
newVestDictionary[tplKey] = templateEquipment.TacticalVest[tplKey];
}
return newVestDictionary;
},
{},
);
templateInventory.equipment.TacticalVest = tacVestsWithoutArmor;
templateEquipment.TacticalVest = tacVestsWithoutArmor;
}
/**
@ -480,8 +479,8 @@ export class BotInventoryGenerator
* @param botInventory Inventory to add weapons to
* @param botRole assault/pmcBot/bossTagilla etc
* @param isPmc Is the bot being generated as a pmc
* @param botLevel level of bot having weapon generated
* @param itemGenerationLimitsMinMax Limits for items the bot can have
* @param botLevel level of bot having weapon generated
*/
protected generateAndAddWeaponsToBot(
templateInventory: Inventory,
@ -584,24 +583,3 @@ export class BotInventoryGenerator
);
}
}
export interface IGenerateEquipmentProperties
{
/** Root Slot being generated */
rootEquipmentSlot: string
/** Equipment pool for root slot being generated */
rootEquipmentPool: Record<string, number>
modPool: Mods
/** Dictionary of mod items and their chance to spawn for this bot type */
spawnChances: Chances
/** Role being generated for */
botRole: string
/** Level of bot being generated */
botLevel: number
inventory: PmcInventory
botEquipmentConfig: EquipmentFilters
/** Settings from bot.json to adjust how item is generated */
randomisationDetails: RandomisationDetails
/** OPTIONAL - Do not generate mods for tpls in this array */
generateModsBlacklist?: string[]
}

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { InventoryHelper } from "@spt/helpers/InventoryHelper";
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { QuestHelper } from "@spt/helpers/QuestHelper";
import { IPmcData, IPostRaidPmcData } from "@spt/models/eft/common/IPmcData";
import { IQuestStatus, TraderInfo } from "@spt/models/eft/common/tables/IBotBase";
@ -22,7 +23,6 @@ import { ProfileFixerService } from "@spt/services/ProfileFixerService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { RandomUtil } from "@spt/utils/RandomUtil";
import { TimeUtil } from "@spt/utils/TimeUtil";
import { ProfileHelper } from "./ProfileHelper";
@injectable()
export class InRaidHelper

View File

@ -1,9 +1,9 @@
import { inject, injectable } from "tsyringe";
import { ItemHelper } from "@spt/helpers/ItemHelper";
import { IPreset } from "@spt/models/eft/common/IGlobals";
import { BaseClasses } from "@spt/models/enums/BaseClasses";
import { DatabaseService } from "@spt/services/DatabaseService";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { ItemHelper } from "./ItemHelper";
@injectable()
export class PresetHelper

View File

@ -4,6 +4,7 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
import { PaymentHelper } from "@spt/helpers/PaymentHelper";
import { PresetHelper } from "@spt/helpers/PresetHelper";
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
import { QuestHelper } from "@spt/helpers/QuestHelper";
import { RagfairHelper } from "@spt/helpers/RagfairHelper";
import { RagfairServerHelper } from "@spt/helpers/RagfairServerHelper";
import { RagfairSortHelper } from "@spt/helpers/RagfairSortHelper";
@ -34,7 +35,6 @@ import { RagfairOfferService } from "@spt/services/RagfairOfferService";
import { RagfairRequiredItemsService } from "@spt/services/RagfairRequiredItemsService";
import { HashUtil } from "@spt/utils/HashUtil";
import { TimeUtil } from "@spt/utils/TimeUtil";
import { QuestHelper } from "./QuestHelper";
@injectable()
export class RagfairOfferHelper

View File

@ -460,7 +460,7 @@ export class TraderHelper
*/
public getAccountTypeAdjustedTraderPurchaseLimit(buyRestrictionMax: number, gameVersion: string): number
{
if ([GameEditions.EDGE_OF_DARKNESS, GameEditions.UNHEARD].includes(<any>gameVersion))
if (([GameEditions.EDGE_OF_DARKNESS, GameEditions.UNHEARD] as string[]).includes(gameVersion))
{
return Math.floor(buyRestrictionMax * 1.2);
}

View File

@ -1,4 +1,4 @@
import { IMagazineTemplateAmmoItem } from "../profile/ISptProfile";
import { IMagazineTemplateAmmoItem } from "@spt/models/eft/profile/ISptProfile";
export interface ISetMagazineRequest
{

View File

@ -1,7 +1,7 @@
import { Exit, ILocationBase } from "@spt/models/eft/common/ILocationBase";
import { ILooseLoot } from "@spt/models/eft/common/ILooseLoot";
import { Ixyz } from "./Ixyz";
import { Item } from "./tables/IItem";
import { Ixyz } from "@spt/models/eft/common/Ixyz";
import { Item } from "@spt/models/eft/common/tables/IItem";
export interface ILocation
{

View File

@ -1,4 +1,4 @@
import { IQuestConditionTypes, IQuestRewards } from "./IQuest";
import { IQuestConditionTypes, IQuestRewards } from "@spt/models/eft/common/tables/IQuest";
export interface IAchievement
{

View File

@ -1,4 +1,4 @@
import { IQuest, IQuestConditionTypes, IQuestRewards } from "./IQuest";
import { IQuest, IQuestConditionTypes, IQuestRewards } from "@spt/models/eft/common/tables/IQuest";
export interface IRepeatableQuest extends IQuest
{

View File

@ -1,4 +1,4 @@
import { Item } from "../common/tables/IItem";
import { Item } from "@spt/models/eft/common/tables/IItem";
export interface IItemDeliveryRequestData
{

View File

@ -1,4 +1,4 @@
import { Item } from "../common/tables/IItem";
import { Item } from "@spt/models/eft/common/tables/IItem";
export interface IAddItemDirectRequest
{

View File

@ -1,4 +1,4 @@
import { Item } from "../common/tables/IItem";
import { Item } from "@spt/models/eft/common/tables/IItem";
export interface IAddItemsDirectRequest
{

View File

@ -1,4 +1,4 @@
import { IInventoryBaseActionRequestData } from "./IInventoryBaseActionRequestData";
import { IInventoryBaseActionRequestData } from "@spt/models/eft/inventory/IInventoryBaseActionRequestData";
export interface IRedeemProfileRequestData extends IInventoryBaseActionRequestData
{

View File

@ -1,4 +1,4 @@
import { IInventoryBaseActionRequestData } from "./IInventoryBaseActionRequestData";
import { IInventoryBaseActionRequestData } from "@spt/models/eft/inventory/IInventoryBaseActionRequestData";
export interface ISetFavoriteItems extends IInventoryBaseActionRequestData
{

View File

@ -1,4 +1,4 @@
import { IAchievement } from "../common/tables/IAchievement";
import { IAchievement } from "@spt/models/eft/common/tables/IAchievement";
export interface IGetAchievementsResponse
{

View File

@ -1,6 +1,6 @@
import { IGroupCharacter } from "@spt/models/eft/match/IGroupCharacter";
import { Message } from "@spt/models/eft/profile/ISptProfile";
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
import { IGroupCharacter } from "../match/IGroupCharacter";
export interface IWsChatMessageReceived extends IWsNotificationEvent
{

View File

@ -1,5 +1,5 @@
import { IGroupCharacter } from "@spt/models/eft/match/IGroupCharacter";
import { IWsNotificationEvent } from "@spt/models/eft/ws/IWsNotificationEvent";
import { IGroupCharacter } from "../match/IGroupCharacter";
export interface IWsGroupMatchInviteAccept extends IWsNotificationEvent, IGroupCharacter
{}

View File

@ -0,0 +1,24 @@
import { Inventory as PmcInventory } from "@spt/models/eft/common/tables/IBotBase";
import { Chances, Mods } from "@spt/models/eft/common/tables/IBotType";
import { EquipmentFilters, RandomisationDetails } from "@spt/models/spt/config/IBotConfig";
export interface IGenerateEquipmentProperties
{
/** Root Slot being generated */
rootEquipmentSlot: string
/** Equipment pool for root slot being generated */
rootEquipmentPool: Record<string, number>
modPool: Mods
/** Dictionary of mod items and their chance to spawn for this bot type */
spawnChances: Chances
/** Role being generated for */
botRole: string
/** Level of bot being generated */
botLevel: number
inventory: PmcInventory
botEquipmentConfig: EquipmentFilters
/** Settings from bot.json to adjust how item is generated */
randomisationDetails: RandomisationDetails
/** OPTIONAL - Do not generate mods for tpls in this array */
generateModsBlacklist?: string[]
}

View File

@ -1,5 +1,5 @@
import { MinMax } from "@spt/models/common/MinMax";
import { IBaseConfig } from "./IBaseConfig";
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
export interface IBTRConfig extends IBaseConfig
{

View File

@ -4,7 +4,7 @@ import { GiftSenderType } from "@spt/models/enums/GiftSenderType";
import { SeasonalEventType } from "@spt/models/enums/SeasonalEventType";
import { Traders } from "@spt/models/enums/Traders";
import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig";
import { IProfileChangeEvent } from "../dialog/ISendMessageDetails";
import { IProfileChangeEvent } from "@spt/models/spt/dialog/ISendMessageDetails";
export interface IGiftsConfig extends IBaseConfig
{

View File

@ -4,11 +4,11 @@ import { ISptProfile, Info } from "@spt/models/eft/profile/ISptProfile";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer";
import { LocalisationService } from "@spt/services/LocalisationService";
import { HashUtil } from "@spt/utils/HashUtil";
import { JsonUtil } from "@spt/utils/JsonUtil";
import { VFS } from "@spt/utils/VFS";
import { ConfigServer } from "./ConfigServer";
@injectable()
export class SaveServer

View File

@ -3,10 +3,10 @@ import { inject, injectAll, injectable } from "tsyringe";
import { WebSocket, Server } from "ws";
import { HttpServerHelper } from "@spt/helpers/HttpServerHelper";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { IWebSocketConnectionHandler } from "@spt/servers/ws/IWebSocketConnectionHandler";
import { LocalisationService } from "@spt/services/LocalisationService";
import { JsonUtil } from "@spt/utils/JsonUtil";
import { RandomUtil } from "@spt/utils/RandomUtil";
import { IWebSocketConnectionHandler } from "./ws/IWebSocketConnectionHandler";
@injectable()
export class WebSocketServer

View File

@ -9,9 +9,9 @@ import { IHttpConfig } from "@spt/models/spt/config/IHttpConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer";
import { IWebSocketConnectionHandler } from "@spt/servers/ws/IWebSocketConnectionHandler";
import { ISptWebSocketMessageHandler } from "@spt/servers/ws/message/ISptWebSocketMessageHandler";
import { LocalisationService } from "@spt/services/LocalisationService";
import { JsonUtil } from "@spt/utils/JsonUtil";
import { ISptWebSocketMessageHandler } from "./message/ISptWebSocketMessageHandler";
@injectable()
export class SptWebSocketConnectionHandler implements IWebSocketConnectionHandler

View File

@ -20,7 +20,7 @@ import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
import { ITemplates } from "@spt/models/spt/templates/ITemplates";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { DatabaseServer } from "@spt/servers/DatabaseServer";
import { LocalisationService } from "./LocalisationService";
import { LocalisationService } from "@spt/services/LocalisationService";
@injectable()
export class DatabaseService

View File

@ -1,4 +1,4 @@
import { LinkedListNode } from "./Nodes";
import { LinkedListNode } from "@spt/utils/collections/lists/Nodes";
export class LinkedList<T>
{

View File

@ -1,4 +1,4 @@
import { LinkedList } from "../lists/LinkedList";
import { LinkedList } from "@spt/utils/collections/lists/LinkedList";
export class Queue<T>
{