Fixed item sell prices not varying per trader - client/items/prices/TRADERID
endpoint requires prices to be altered by the traders sell coef (which is based on player loyalty level with said trader)
This commit is contained in:
parent
88a430a724
commit
3a3a7b1026
@ -122,5 +122,6 @@
|
|||||||
"category": [],
|
"category": [],
|
||||||
"id_list": []
|
"id_list": []
|
||||||
},
|
},
|
||||||
"unlockedByDefault": true
|
"unlockedByDefault": true,
|
||||||
|
"refreshTraderRagfairOffers": false
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { HideoutController } from "@spt/controllers/HideoutController";
|
import { HideoutController } from "@spt/controllers/HideoutController";
|
||||||
import { RagfairController } from "@spt/controllers/RagfairController";
|
import { TraderController } from "@spt/controllers/TraderController";
|
||||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||||
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
||||||
import { IGlobals } from "@spt/models/eft/common/IGlobals";
|
import { IGlobals } from "@spt/models/eft/common/IGlobals";
|
||||||
@ -11,7 +11,6 @@ import { IHideoutProductionData } from "@spt/models/eft/hideout/IHideoutProducti
|
|||||||
import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase";
|
import { IHideoutScavCase } from "@spt/models/eft/hideout/IHideoutScavCase";
|
||||||
import { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase";
|
import { IHideoutSettingsBase } from "@spt/models/eft/hideout/IHideoutSettingsBase";
|
||||||
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
||||||
import { Money } from "@spt/models/enums/Money";
|
|
||||||
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
import { ISettingsBase } from "@spt/models/spt/server/ISettingsBase";
|
||||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||||
@ -28,7 +27,7 @@ export class DataCallbacks {
|
|||||||
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||||
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
||||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||||
@inject("RagfairController") protected ragfairController: RagfairController,
|
@inject("TraderController") protected traderController: TraderController,
|
||||||
@inject("HideoutController") protected hideoutController: HideoutController,
|
@inject("HideoutController") protected hideoutController: HideoutController,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -184,7 +183,6 @@ export class DataCallbacks {
|
|||||||
/**
|
/**
|
||||||
* Handle client/items/prices/
|
* Handle client/items/prices/
|
||||||
* Called when viewing a traders assorts
|
* Called when viewing a traders assorts
|
||||||
* TODO - fully implement this
|
|
||||||
*/
|
*/
|
||||||
public getItemPrices(
|
public getItemPrices(
|
||||||
url: string,
|
url: string,
|
||||||
@ -193,20 +191,6 @@ export class DataCallbacks {
|
|||||||
): IGetBodyResponseData<IGetItemPricesResponse> {
|
): IGetBodyResponseData<IGetItemPricesResponse> {
|
||||||
const traderId = url.replace("/client/items/prices/", "");
|
const traderId = url.replace("/client/items/prices/", "");
|
||||||
|
|
||||||
// All traders share same item prices, unknown how to tell what items are shown for each trader
|
return this.httpResponse.getBody(this.traderController.getItemPrices(sessionID, traderId));
|
||||||
// Shown items listed are likely linked to traders items_buy/category array
|
|
||||||
const handbookPrices = this.ragfairController.getStaticPrices();
|
|
||||||
|
|
||||||
const response: IGetItemPricesResponse = {
|
|
||||||
supplyNextTime: this.traderHelper.getNextUpdateTimestamp(traderId),
|
|
||||||
prices: handbookPrices,
|
|
||||||
currencyCourses: {
|
|
||||||
"5449016a4bdc2d6f028b456f": handbookPrices[Money.ROUBLES],
|
|
||||||
"569668774bdc2da2298b4568": handbookPrices[Money.EUROS],
|
|
||||||
"5696686a4bdc2da3298b456a": handbookPrices[Money.DOLLARS],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.httpResponse.getBody(response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,16 @@ import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
|||||||
import { TraderAssortHelper } from "@spt/helpers/TraderAssortHelper";
|
import { TraderAssortHelper } from "@spt/helpers/TraderAssortHelper";
|
||||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||||
import { ITraderAssort, ITraderBase } from "@spt/models/eft/common/tables/ITrader";
|
import { ITraderAssort, ITraderBase } from "@spt/models/eft/common/tables/ITrader";
|
||||||
|
import { IGetItemPricesResponse } from "@spt/models/eft/game/IGetItemPricesResponse";
|
||||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
|
import { Money } from "@spt/models/enums/Money";
|
||||||
import { Traders } from "@spt/models/enums/Traders";
|
import { Traders } from "@spt/models/enums/Traders";
|
||||||
import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig";
|
import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig";
|
||||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||||
import { FenceService } from "@spt/services/FenceService";
|
import { FenceService } from "@spt/services/FenceService";
|
||||||
|
import { RagfairPriceService } from "@spt/services/RagfairPriceService";
|
||||||
import { TraderAssortService } from "@spt/services/TraderAssortService";
|
import { TraderAssortService } from "@spt/services/TraderAssortService";
|
||||||
import { TraderPurchasePersisterService } from "@spt/services/TraderPurchasePersisterService";
|
import { TraderPurchasePersisterService } from "@spt/services/TraderPurchasePersisterService";
|
||||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||||
@ -28,6 +31,7 @@ export class TraderController {
|
|||||||
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||||
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
||||||
@inject("TraderAssortService") protected traderAssortService: TraderAssortService,
|
@inject("TraderAssortService") protected traderAssortService: TraderAssortService,
|
||||||
|
@inject("RagfairPriceService") protected ragfairPriceService: RagfairPriceService,
|
||||||
@inject("TraderPurchasePersisterService")
|
@inject("TraderPurchasePersisterService")
|
||||||
protected traderPurchasePersisterService: TraderPurchasePersisterService,
|
protected traderPurchasePersisterService: TraderPurchasePersisterService,
|
||||||
@inject("FenceService") protected fenceService: FenceService,
|
@inject("FenceService") protected fenceService: FenceService,
|
||||||
@ -161,4 +165,28 @@ export class TraderController {
|
|||||||
public getAssort(sessionId: string, traderId: string): ITraderAssort {
|
public getAssort(sessionId: string, traderId: string): ITraderAssort {
|
||||||
return this.traderAssortHelper.getAssort(sessionId, traderId);
|
return this.traderAssortHelper.getAssort(sessionId, traderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Handle client/items/prices/TRADERID */
|
||||||
|
public getItemPrices(sessionId: string, traderId: string): IGetItemPricesResponse {
|
||||||
|
const pmcData = this.profileHelper.getPmcProfile(sessionId);
|
||||||
|
const traderDetails = this.traderHelper.getLoyaltyLevel(traderId, pmcData);
|
||||||
|
const traderItemSellMultipler = 1 - traderDetails.buy_price_coef / 100;
|
||||||
|
|
||||||
|
// Clone handbook prices so we can apply the coef multipler to every item
|
||||||
|
const handbookPrices = this.ragfairPriceService.getAllStaticPrices();
|
||||||
|
const handbookPricesClone = this.cloner.clone(handbookPrices);
|
||||||
|
for (const handbookItemKey in handbookPricesClone) {
|
||||||
|
handbookPricesClone[handbookItemKey] = handbookPricesClone[handbookItemKey] * traderItemSellMultipler;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
supplyNextTime: this.traderHelper.getNextUpdateTimestamp(traderId),
|
||||||
|
prices: handbookPricesClone,
|
||||||
|
currencyCourses: {
|
||||||
|
"5449016a4bdc2d6f028b456f": handbookPrices[Money.ROUBLES],
|
||||||
|
"569668774bdc2da2298b4568": handbookPrices[Money.EUROS],
|
||||||
|
"5696686a4bdc2da3298b456a": handbookPrices[Money.DOLLARS],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user