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

This commit is contained in:
Dev 2024-07-16 21:08:43 +01:00
parent fcdf537c3b
commit fd34e7bc84
3 changed files with 14 additions and 8 deletions

View File

@ -490,7 +490,7 @@ export class RagfairController
playerListedPriceInRub, playerListedPriceInRub,
qualityMultiplier, qualityMultiplier,
); );
offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, itemsToListCount); offer.sellResult = this.ragfairSellHelper.rollForSale(sellChancePercent, stackCountTotal);
// Subtract flea market fee from stash // Subtract flea market fee from stash
if (this.ragfairConfig.sell.fees) if (this.ragfairConfig.sell.fees)
@ -595,7 +595,7 @@ export class RagfairController
); );
// Create array of sell times for items listed // 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 // Subtract flea market fee from stash
if (this.ragfairConfig.sell.fees) if (this.ragfairConfig.sell.fees)
@ -700,7 +700,7 @@ export class RagfairController
); );
// Create array of sell times for items listed + sell all at once as its a pack // 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 // Subtract flea market fee from stash
if (this.ragfairConfig.sell.fees) if (this.ragfairConfig.sell.fees)

View File

@ -334,7 +334,7 @@ export class RagfairOfferHelper
for (const offer of profileOffers.values()) for (const offer of profileOffers.values())
{ {
if (offer.sellResult?.length > 0 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 // Item sold
let totalItemsCount = 1; let totalItemsCount = 1;
@ -353,7 +353,7 @@ export class RagfairOfferHelper
); );
this.completeOffer(sessionID, offer, boughtAmount); 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; maximumTime = minimumTime + 5;
} }
// Sell time will be random between min/max // 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 }); 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 else
{ {
this.logger.debug("Offer will not sell"); this.logger.debug(`Offer rolled not to sell, item count: ${boughtAmount}`);
} }
remainingCount -= boughtAmount; remainingCount -= boughtAmount;