2024-05-21 17:59:04 +00:00
|
|
|
import { CustomizationController } from "@spt/controllers/CustomizationController";
|
2024-12-27 13:38:16 +00:00
|
|
|
import type { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
|
|
|
import type { IPmcData } from "@spt/models/eft/common/IPmcData";
|
2024-12-27 15:03:13 +00:00
|
|
|
import type { ICustomisationStorage } from "@spt/models/eft/common/tables/ICustomisationStorage";
|
2024-12-27 13:38:16 +00:00
|
|
|
import type { ISuit } from "@spt/models/eft/common/tables/ITrader";
|
|
|
|
import type { IBuyClothingRequestData } from "@spt/models/eft/customization/IBuyClothingRequestData";
|
|
|
|
import type { IGetSuitsResponse } from "@spt/models/eft/customization/IGetSuitsResponse";
|
|
|
|
import type { IWearClothingRequestData } from "@spt/models/eft/customization/IWearClothingRequestData";
|
|
|
|
import type { ICustomizationSetRequest } from "@spt/models/eft/customization/iCustomizationSetRequest";
|
2024-12-27 15:03:13 +00:00
|
|
|
import type { IHideoutCustomisation } from "@spt/models/eft/hideout/IHideoutCustomisation";
|
2024-12-27 13:38:16 +00:00
|
|
|
import type { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
|
|
|
import type { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
2024-05-21 17:59:04 +00:00
|
|
|
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);
|
|
|
|
}
|
2024-12-26 20:54:19 +00:00
|
|
|
|
2024-12-27 15:03:13 +00:00
|
|
|
/** Handle client/hideout/customization/offer/list */
|
|
|
|
public getHideoutCustomisation(
|
|
|
|
url: string,
|
|
|
|
info: IEmptyRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<IHideoutCustomisation> {
|
2024-12-26 23:02:37 +00:00
|
|
|
return this.httpResponse.getBody(this.customizationController.getHideoutCustomisation(sessionID, info));
|
|
|
|
}
|
|
|
|
|
2024-12-27 15:03:13 +00:00
|
|
|
/** Handle client/customization/storage */
|
|
|
|
public getStorage(
|
|
|
|
url: string,
|
|
|
|
request: IEmptyRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<ICustomisationStorage[]> {
|
2024-12-27 18:53:29 +00:00
|
|
|
return this.httpResponse.getBody(this.customizationController.getCustomisationStorage(sessionID, request));
|
2024-12-26 20:54:19 +00:00
|
|
|
}
|
2024-12-27 00:54:48 +00:00
|
|
|
|
|
|
|
/** Handle CustomizationSet */
|
2024-12-27 15:03:13 +00:00
|
|
|
public setClothing(
|
2024-12-27 13:38:16 +00:00
|
|
|
pmcData: IPmcData,
|
2024-12-27 15:03:13 +00:00
|
|
|
request: ICustomizationSetRequest,
|
2024-12-27 13:38:16 +00:00
|
|
|
sessionID: string,
|
2024-12-27 15:03:13 +00:00
|
|
|
): IItemEventRouterResponse {
|
|
|
|
return this.customizationController.setClothing(sessionID, request, pmcData);
|
2024-12-27 00:54:48 +00:00
|
|
|
}
|
2023-11-15 20:35:05 -05:00
|
|
|
}
|