diff --git a/project/src/callbacks/RagfairCallbacks.ts b/project/src/callbacks/RagfairCallbacks.ts index 54cde83f..cd8b1d11 100644 --- a/project/src/callbacks/RagfairCallbacks.ts +++ b/project/src/callbacks/RagfairCallbacks.ts @@ -13,6 +13,7 @@ import { IExtendOfferRequestData } from "@spt-aki/models/eft/ragfair/IExtendOffe import { IGetItemPriceResult } from "@spt-aki/models/eft/ragfair/IGetItemPriceResult"; import { IGetMarketPriceRequestData } from "@spt-aki/models/eft/ragfair/IGetMarketPriceRequestData"; import { IGetOffersResult } from "@spt-aki/models/eft/ragfair/IGetOffersResult"; +import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer"; import { IRemoveOfferRequestData } from "@spt-aki/models/eft/ragfair/IRemoveOfferRequestData"; import { ISearchRequestData } from "@spt-aki/models/eft/ragfair/ISearchRequestData"; import { ISendRagfairReportRequestData } from "@spt-aki/models/eft/ragfair/ISendRagfairReportRequestData"; @@ -142,4 +143,10 @@ export class RagfairCallbacks implements OnLoad, OnUpdate this.ragfairTaxService.storeClientOfferTaxValue(sessionId, request); return this.httpResponse.nullResponse(); } + + /** Handle client/ragfair/offer/findbyid */ + public getFleaOfferById(url: string, request: any, sessionID: string): IGetBodyResponseData + { + return this.httpResponse.getBody(this.ragfairController.getOfferById(sessionID, request)); + } } diff --git a/project/src/controllers/RagfairController.ts b/project/src/controllers/RagfairController.ts index 2c4231fc..b2071b98 100644 --- a/project/src/controllers/RagfairController.ts +++ b/project/src/controllers/RagfairController.ts @@ -21,6 +21,7 @@ import { IExtendOfferRequestData } from "@spt-aki/models/eft/ragfair/IExtendOffe import { IGetItemPriceResult } from "@spt-aki/models/eft/ragfair/IGetItemPriceResult"; import { IGetMarketPriceRequestData } from "@spt-aki/models/eft/ragfair/IGetMarketPriceRequestData"; import { IGetOffersResult } from "@spt-aki/models/eft/ragfair/IGetOffersResult"; +import { IGetRagfairOfferByIdRequest } from "@spt-aki/models/eft/ragfair/IGetRagfairOfferByIdRequest"; import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer"; import { ISearchRequestData } from "@spt-aki/models/eft/ragfair/ISearchRequestData"; import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData"; @@ -147,6 +148,20 @@ export class RagfairController return result; } + /** + * Handle client/ragfair/offer/findbyid + * @param sessionId Player id + * @param request Request data + * @returns IRagfairOffer + */ + public getOfferById(sessionId: string, request: IGetRagfairOfferByIdRequest): IRagfairOffer + { + const offers = this.ragfairOfferService.getOffers(); + const offerToReturn = offers.find(x => x.intId === request.id); + + return offerToReturn; + } + /** * Get offers for the client based on type of search being performed * @param searchRequest Client search request data diff --git a/project/src/generators/RagfairOfferGenerator.ts b/project/src/generators/RagfairOfferGenerator.ts index c35ea205..4f8080b6 100644 --- a/project/src/generators/RagfairOfferGenerator.ts +++ b/project/src/generators/RagfairOfferGenerator.ts @@ -34,6 +34,9 @@ export class RagfairOfferGenerator protected ragfairConfig: IRagfairConfig; protected allowedFleaPriceItemsForBarter: { tpl: string; price: number; }[]; + /** Internal counter to ensure each offer created has a unique value for its intId property */ + protected offerCounter = 0; + constructor( @inject("WinstonLogger") protected logger: ILogger, @inject("JsonUtil") protected jsonUtil: JsonUtil, @@ -121,7 +124,7 @@ export class RagfairOfferGenerator const offer: IRagfairOffer = { _id: this.hashUtil.generate(), - intId: 0, + intId: this.offerCounter, user: { id: this.getTraderId(userID), memberType: (userID === "ragfair") @@ -149,6 +152,8 @@ export class RagfairOfferGenerator CurrentItemCount: itemCount, }; + this.offerCounter++; + return offer; } diff --git a/project/src/models/eft/ragfair/IGetRagfairOfferByIdRequest.ts b/project/src/models/eft/ragfair/IGetRagfairOfferByIdRequest.ts new file mode 100644 index 00000000..e25d0d8a --- /dev/null +++ b/project/src/models/eft/ragfair/IGetRagfairOfferByIdRequest.ts @@ -0,0 +1,4 @@ +export interface IGetRagfairOfferByIdRequest +{ + id: number +} \ No newline at end of file diff --git a/project/src/routers/static/RagfairStaticRouter.ts b/project/src/routers/static/RagfairStaticRouter.ts index 05af24b8..5a727270 100644 --- a/project/src/routers/static/RagfairStaticRouter.ts +++ b/project/src/routers/static/RagfairStaticRouter.ts @@ -57,6 +57,14 @@ export class RagfairStaticRouter extends StaticRouter return this.ragfairCallbacks.getFleaPrices(url, info, sessionID); }, ), + new RouteAction( + "/client/ragfair/offer/findbyid", + // eslint-disable-next-line @typescript-eslint/no-unused-vars + (url: string, info: any, sessionID: string, output: string): any => + { + return this.ragfairCallbacks.getFleaOfferById(url, info, sessionID); + }, + ), ]); } }