Fixed preset builder showing items from locked traders
This commit is contained in:
@@ -324,4 +324,16 @@ public static class ProfileExtensions
|
||||
// No trader data on player profile, fail check
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Ids of traders with an unlocked status of "false"
|
||||
/// </summary>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <returns>Hashset of Trader ids</returns>
|
||||
public static HashSet<MongoId> GetLockedTraderIds(this PmcData pmcData)
|
||||
{
|
||||
return pmcData.TradersInfo?
|
||||
.Where(trader => trader.Value.Unlocked == false)
|
||||
.Select(t => t.Key).ToHashSet() ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +237,7 @@ public class RagfairOfferHelper(
|
||||
? cloner.Clone(searchRequest.BuildItems.Keys.ToDictionary(key => key, ragfairOfferService.GetOffersOfType))
|
||||
: searchRequest.BuildItems.Keys.ToDictionary(key => key, ragfairOfferService.GetOffersOfType);
|
||||
|
||||
var lockedTraders = pmcData.GetLockedTraderIds();
|
||||
foreach (var (desiredItemTpl, matchingOffers) in buildItems)
|
||||
{
|
||||
if (matchingOffers is null)
|
||||
@@ -266,6 +267,12 @@ public class RagfairOfferHelper(
|
||||
|
||||
if (offer.IsTraderOffer())
|
||||
{
|
||||
// Player hasn't unlocked trader selling this offer, skip
|
||||
if (lockedTraders.Contains(offer.User.Id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TraderBuyRestrictionReached(offer))
|
||||
{
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user