Fixed items with a stack count > 1 not selling as expected

(cherry picked from commit fd34e7bc8412b0ce0503691b984256b57a14383e)
This commit is contained in:
Dev 2024-07-16 21:08:43 +01:00
parent 59ffc9d886
commit 373f194a25
3 changed files with 14 additions and 8 deletions

View File

@ -499,7 +499,7 @@ export class RagfairController
playerListedPriceInRub,
qualityMultiplier,
);
offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, itemsToListCount);
offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, stackCountTotal);
// Subtract flea market fee from stash
if (this.ragfairConfig.sell.fees)
@ -614,7 +614,7 @@ export class RagfairController
);
// Create array of sell times for items listed
offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, itemsToListCount);
offer.sellResult = this.ragfairSellHelper.rollForSale(75, stackCountTotal);
// Subtract flea market fee from stash
if (this.ragfairConfig.sell.fees)
@ -729,7 +729,7 @@ export class RagfairController
);
// Create array of sell times for items listed + sell all at once as its a pack
offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, itemsToListCount, true);
offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, stackCountTotal, true);
// Subtract flea market fee from stash
if (this.ragfairConfig.sell.fees)

View File

@ -334,7 +334,7 @@ export class RagfairOfferHelper
for (const offer of profileOffers.values())
{
if (offer.sellResult?.length > 0
&& timestamp >= offer.sellResult[0].sellTime)
&& timestamp >= offer.sellResult[0].sellTime) // Checks first item, first is spliced out of array after being processed
{
// Item sold
let totalItemsCount = 1;
@ -353,7 +353,7 @@ export class RagfairOfferHelper
);
this.completeOffer(sessionID, offer, boughtAmount);
offer.sellResult.splice(0, 1);
offer.sellResult.splice(0, 1); // Remove the sell result object now its been processed
}
}

View File

@ -119,15 +119,21 @@ export class RagfairSellHelper
maximumTime = minimumTime + 5;
}
// Sell time will be random between min/max
sellTime += Math.floor(Math.random() * (maximumTime - minimumTime) + minimumTime);
let newSellTime = Math.floor(Math.random() * (maximumTime - minimumTime) + minimumTime);
if (newSellTime === 0)
{
// Ensure all sales dont occur the same exact time
newSellTime += 1;
}
sellTime += newSellTime;
result.push({ sellTime: sellTime, amount: boughtAmount });
this.logger.debug(`Offer will sell at: ${new Date(sellTime * 1000).toLocaleTimeString("en-US")}`);
this.logger.debug(`Offer will sell at: ${new Date(sellTime * 1000).toLocaleTimeString("en-US")}, bought: ${boughtAmount}`);
}
else
{
this.logger.debug("Offer will not sell");
this.logger.debug(`Offer rolled not to sell, item count: ${boughtAmount}`);
}
remainingCount -= boughtAmount;