From ed3e16a94f4c74b3960f0499df469e15958643e6 Mon Sep 17 00:00:00 2001 From: Tyfon Date: Sat, 20 Jul 2024 21:45:42 +0000 Subject: [PATCH] Add support for flea market dogtag barter requirements (!378) Trader offers with dogtag barter requirements are currently missing the `level` and `side` properties necessary to qualify them. This data already exists in the assorts, just needed to be sent along with the offer. I considered updating the `side` property of `Requirement` in `IAddOfferRequestData.ts`, but that field is never used, and the client appears to pass 0 for both (even though 0 is not a valid `side`). Not sure if this should be going to `master` or `310-dev`? Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/378 Co-authored-by: Tyfon Co-committed-by: Tyfon (cherry picked from commit ec76a8897fda32ab938bd758025bafdad1e956da) --- .../src/generators/RagfairOfferGenerator.ts | 22 ++++++++++++++----- .../src/models/eft/common/tables/ITrader.ts | 3 +++ .../src/models/eft/ragfair/IRagfairOffer.ts | 3 +++ .../src/models/enums/DogtagExchangeSide.ts | 6 +++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 project/src/models/enums/DogtagExchangeSide.ts diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index 0d470edf..30f2446a 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -115,11 +115,23 @@ export class RagfairOfferGenerator { const isTrader = this.ragfairServerHelper.isTrader(userID); - const offerRequirements = barterScheme.map((barter) => ({ - _tpl: barter._tpl, - count: +barter.count.toFixed(2), - onlyFunctional: barter.onlyFunctional ?? false, - } as OfferRequirement)); + const offerRequirements = barterScheme.map((barter) => + { + const offerRequirement: OfferRequirement = { + _tpl: barter._tpl, + count: +barter.count.toFixed(2), + onlyFunctional: barter.onlyFunctional ?? false, + }; + + // Dogtags define level and side + if (barter.level !== undefined) + { + offerRequirement.level = barter.level; + offerRequirement.side = barter.side; + } + + return offerRequirement; + }); // Clone to avoid modifying original array const itemsClone = this.cloner.clone(items); diff --git a/project/src/models/eft/common/tables/ITrader.ts b/project/src/models/eft/common/tables/ITrader.ts index 53e449e2..6d874ead 100644 --- a/project/src/models/eft/common/tables/ITrader.ts +++ b/project/src/models/eft/common/tables/ITrader.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { Item } from "@spt/models/eft/common/tables/IItem"; +import { DogtagExchangeSide } from "@spt/models/enums/DogtagExchangeSide"; import { ITraderServiceModel } from "@spt/models/spt/services/ITraderServiceModel"; export interface ITrader @@ -95,6 +96,8 @@ export interface IBarterScheme _tpl: string onlyFunctional?: boolean sptQuestLocked?: boolean + level?: number + side?: DogtagExchangeSide } export interface ISuit diff --git a/project/src/models/eft/ragfair/IRagfairOffer.ts b/project/src/models/eft/ragfair/IRagfairOffer.ts index e2937694..6c6cc7a2 100644 --- a/project/src/models/eft/ragfair/IRagfairOffer.ts +++ b/project/src/models/eft/ragfair/IRagfairOffer.ts @@ -1,4 +1,5 @@ import { Item } from "@spt/models/eft/common/tables/IItem"; +import { DogtagExchangeSide } from "@spt/models/enums/DogtagExchangeSide"; import { MemberCategory } from "@spt/models/enums/MemberCategory"; export interface IRagfairOffer @@ -33,6 +34,8 @@ export interface OfferRequirement _tpl: string count: number onlyFunctional: boolean + level?: number + side?: DogtagExchangeSide } export interface IRagfairOfferUser diff --git a/project/src/models/enums/DogtagExchangeSide.ts b/project/src/models/enums/DogtagExchangeSide.ts new file mode 100644 index 00000000..425827a5 --- /dev/null +++ b/project/src/models/enums/DogtagExchangeSide.ts @@ -0,0 +1,6 @@ +export enum DogtagExchangeSide +{ + USEC = "Usec", + BEAR = "Bear", + ANY = "Any", +}