mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Improved pack + multi-item player flea offer handling
This commit is contained in:
parent
4e047c48ec
commit
e9d8c02ac2
@ -413,6 +413,8 @@ export class RagfairController
|
|||||||
{
|
{
|
||||||
const output = this.eventOutputHolder.getOutput(sessionID);
|
const output = this.eventOutputHolder.getOutput(sessionID);
|
||||||
const fullProfile = this.saveServer.getProfile(sessionID);
|
const fullProfile = this.saveServer.getProfile(sessionID);
|
||||||
|
const sellAsPack = offerRequest.sellInOnePiece; // a group of items that much be all purchased at once
|
||||||
|
const itemsToListCount = offerRequest.items.length; // Count of root items being sold (no children)
|
||||||
|
|
||||||
const validationMessage = "";
|
const validationMessage = "";
|
||||||
if (!this.isValidPlayerOfferRequest(offerRequest, validationMessage))
|
if (!this.isValidPlayerOfferRequest(offerRequest, validationMessage))
|
||||||
@ -434,7 +436,7 @@ export class RagfairController
|
|||||||
sessionID,
|
sessionID,
|
||||||
offerRequest.requirements,
|
offerRequest.requirements,
|
||||||
this.ragfairHelper.mergeStackable(itemsInInventoryToList),
|
this.ragfairHelper.mergeStackable(itemsInInventoryToList),
|
||||||
offerRequest.sellInOnePiece,
|
sellAsPack,
|
||||||
);
|
);
|
||||||
const rootItem = offer.items[0];
|
const rootItem = offer.items[0];
|
||||||
|
|
||||||
@ -442,26 +444,29 @@ export class RagfairController
|
|||||||
const qualityMultiplier = this.itemHelper.getItemQualityModifierForItems(offer.items, true);
|
const qualityMultiplier = this.itemHelper.getItemQualityModifierForItems(offer.items, true);
|
||||||
let averageOfferPrice = this.ragfairPriceService.getFleaPriceForOfferItems(offer.items);
|
let averageOfferPrice = this.ragfairPriceService.getFleaPriceForOfferItems(offer.items);
|
||||||
|
|
||||||
// Check for and apply item price modifer if it exists
|
// Check for and apply item price modifer if it exists in config
|
||||||
const itemPriceModifer = this.ragfairConfig.dynamic.itemPriceMultiplier[rootItem._tpl];
|
const itemPriceModifer = this.ragfairConfig.dynamic.itemPriceMultiplier[rootItem._tpl];
|
||||||
if (itemPriceModifer)
|
if (itemPriceModifer)
|
||||||
{
|
{
|
||||||
averageOfferPrice *= itemPriceModifer;
|
averageOfferPrice *= itemPriceModifer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply single item price by stack count and quality
|
// Multiply single item price by quality
|
||||||
averageOfferPrice *= rootItem.upd.StackObjectsCount * qualityMultiplier;
|
averageOfferPrice *= qualityMultiplier;
|
||||||
|
|
||||||
const itemStackCount = offerRequest.sellInOnePiece ? 1 : rootItem.upd.StackObjectsCount;
|
// Define packs as a single count item
|
||||||
|
const itemStackCount = sellAsPack
|
||||||
|
? 1
|
||||||
|
: itemsToListCount;
|
||||||
|
|
||||||
// Get averaged price of a single item being listed
|
// Average out price of offer
|
||||||
const averageSingleItemPrice = offerRequest.sellInOnePiece
|
const averageSingleItemPrice = sellAsPack
|
||||||
? averageOfferPrice / rootItem.upd.StackObjectsCount // Packs are a single offer made of many items
|
? averageOfferPrice / itemsToListCount // Packs contains multiple items sold as one
|
||||||
: averageOfferPrice / itemStackCount;
|
: averageOfferPrice / itemStackCount; // Normal offer, single items can be purchased from listing
|
||||||
|
|
||||||
// Get averaged price of listing
|
// Get averaged price of player listing to use when calculating sell chance
|
||||||
const averagePlayerListedPriceInRub = offerRequest.sellInOnePiece
|
const averagePlayerListedPriceInRub = sellAsPack
|
||||||
? playerListedPriceInRub / rootItem.upd.StackObjectsCount
|
? playerListedPriceInRub / itemsToListCount
|
||||||
: playerListedPriceInRub;
|
: playerListedPriceInRub;
|
||||||
|
|
||||||
// Packs are reduced to the average price of a single item in the pack vs the averaged single price of an item
|
// Packs are reduced to the average price of a single item in the pack vs the averaged single price of an item
|
||||||
@ -660,6 +665,11 @@ export class RagfairController
|
|||||||
const formattedItems: Item[] = items.map((item) =>
|
const formattedItems: Item[] = items.map((item) =>
|
||||||
{
|
{
|
||||||
const isChild = items.some((it) => it._id === item.parentId);
|
const isChild = items.some((it) => it._id === item.parentId);
|
||||||
|
if (!isChild && !sellInOnePiece)
|
||||||
|
{
|
||||||
|
// Ensure offer with multiple of an item has its stack count reset
|
||||||
|
item.upd.StackObjectsCount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_id: item._id,
|
_id: item._id,
|
||||||
@ -672,7 +682,10 @@ export class RagfairController
|
|||||||
|
|
||||||
const formattedRequirements: IBarterScheme[] = requirements.map((item) =>
|
const formattedRequirements: IBarterScheme[] = requirements.map((item) =>
|
||||||
{
|
{
|
||||||
return { _tpl: item._tpl, count: item.count, onlyFunctional: item.onlyFunctional };
|
return {
|
||||||
|
_tpl: item._tpl,
|
||||||
|
count: item.count,
|
||||||
|
onlyFunctional: item.onlyFunctional };
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.ragfairOfferGenerator.createAndAddFleaOffer(
|
return this.ragfairOfferGenerator.createAndAddFleaOffer(
|
||||||
|
@ -158,8 +158,8 @@ export class RagfairHelper
|
|||||||
for (let item of items)
|
for (let item of items)
|
||||||
{
|
{
|
||||||
item = this.itemHelper.fixItemStackCount(item);
|
item = this.itemHelper.fixItemStackCount(item);
|
||||||
const isChild = items.some((it) => it._id === item.parentId);
|
|
||||||
|
|
||||||
|
const isChild = items.some((it) => it._id === item.parentId);
|
||||||
if (!isChild)
|
if (!isChild)
|
||||||
{
|
{
|
||||||
if (!rootItem)
|
if (!rootItem)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user