2024-05-21 17:59:04 +00:00
|
|
|
import { CustomizationController } from "@spt/controllers/CustomizationController";
|
|
|
|
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
|
|
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
|
|
|
import { ISuit } from "@spt/models/eft/common/tables/ITrader";
|
|
|
|
import { IBuyClothingRequestData } from "@spt/models/eft/customization/IBuyClothingRequestData";
|
|
|
|
import { IGetSuitsResponse } from "@spt/models/eft/customization/IGetSuitsResponse";
|
|
|
|
import { IWearClothingRequestData } from "@spt/models/eft/customization/IWearClothingRequestData";
|
|
|
|
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
|
|
|
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
|
|
|
import { SaveServer } from "@spt/servers/SaveServer";
|
|
|
|
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
2024-07-23 11:12:53 -04:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
@injectable()
|
2024-07-23 11:12:53 -04:00
|
|
|
export class CustomizationCallbacks {
|
2023-03-03 15:23:46 +00:00
|
|
|
constructor(
|
|
|
|
@inject("CustomizationController") protected customizationController: CustomizationController,
|
|
|
|
@inject("SaveServer") protected saveServer: SaveServer,
|
2023-11-15 20:35:05 -05:00
|
|
|
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
|
2024-07-23 11:12:53 -04:00
|
|
|
) {}
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
/**
|
2023-07-15 10:56:00 +01:00
|
|
|
* Handle client/trading/customization/storage
|
|
|
|
* @returns IGetSuitsResponse
|
2023-03-03 15:23:46 +00:00
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
public getSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetSuitsResponse> {
|
2024-02-02 13:54:07 -05:00
|
|
|
const result: IGetSuitsResponse = { _id: sessionID, suites: this.saveServer.getProfile(sessionID).suits };
|
2023-03-03 15:23:46 +00:00
|
|
|
return this.httpResponse.getBody(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 10:56:00 +01:00
|
|
|
* Handle client/trading/customization
|
2023-03-03 15:23:46 +00:00
|
|
|
* @returns ISuit[]
|
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
public getTraderSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<ISuit[]> {
|
2023-03-03 15:23:46 +00:00
|
|
|
const splittedUrl = url.split("/");
|
2024-09-27 20:41:36 +01:00
|
|
|
const traderID = splittedUrl[splittedUrl.length - 3];
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
return this.httpResponse.getBody(this.customizationController.getTraderSuits(traderID, sessionID));
|
|
|
|
}
|
|
|
|
|
2023-07-15 10:56:00 +01:00
|
|
|
/**
|
|
|
|
* Handle CustomizationWear event
|
|
|
|
*/
|
2024-05-17 15:32:41 -04:00
|
|
|
public wearClothing(
|
|
|
|
pmcData: IPmcData,
|
|
|
|
body: IWearClothingRequestData,
|
|
|
|
sessionID: string,
|
2024-07-23 11:12:53 -04:00
|
|
|
): IItemEventRouterResponse {
|
2023-03-03 15:23:46 +00:00
|
|
|
return this.customizationController.wearClothing(pmcData, body, sessionID);
|
|
|
|
}
|
|
|
|
|
2023-07-15 10:56:00 +01:00
|
|
|
/**
|
|
|
|
* Handle CustomizationBuy event
|
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
public buyClothing(pmcData: IPmcData, body: IBuyClothingRequestData, sessionID: string): IItemEventRouterResponse {
|
2023-03-03 15:23:46 +00:00
|
|
|
return this.customizationController.buyClothing(pmcData, body, sessionID);
|
|
|
|
}
|
2023-11-15 20:35:05 -05:00
|
|
|
}
|