Converted ProfileMeetsTraderLoyaltyLevelToBuyOffer to extension method
This commit is contained in:
@@ -138,7 +138,7 @@ public class TradeController(
|
||||
)
|
||||
{
|
||||
// Skip buying items when player doesn't have needed loyalty
|
||||
if (!PlayerMeetsTraderLoyaltyLevelToBuyOffer(fleaOffer, pmcData))
|
||||
if (!pmcData.PlayerMeetsTraderLoyaltyLevelToBuyOffer(fleaOffer))
|
||||
{
|
||||
var errorMessage =
|
||||
$"Unable to buy item: {fleaOffer.Items[0].Template} from trader: {fleaOffer.User.Id} as loyalty level too low, skipping";
|
||||
@@ -219,30 +219,6 @@ public class TradeController(
|
||||
ragfairServer.ReduceOfferQuantity(fleaOffer.Id, requestOffer.Count ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does Player have necessary trader loyalty to purchase flea offer
|
||||
/// </summary>
|
||||
/// <param name="fleaOffer">Flea offer being bought</param>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <returns>True if player can buy offer</returns>
|
||||
protected bool PlayerMeetsTraderLoyaltyLevelToBuyOffer(RagfairOffer fleaOffer, PmcData pmcData)
|
||||
{
|
||||
if (fleaOffer.LoyaltyLevel == 0)
|
||||
{
|
||||
// No requirement, always passes
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pmcData.TradersInfo.TryGetValue(fleaOffer.User.Id, out var traderInfo))
|
||||
{
|
||||
// Trader exists in profile ,do loyalty level check
|
||||
return traderInfo.LoyaltyLevel >= fleaOffer.LoyaltyLevel;
|
||||
}
|
||||
|
||||
// No trader data on player profile, fail check
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle SellAllFromSavage event
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SPTarkov.Server.Core.Models.Common;
|
||||
using SPTarkov.Server.Core.Models.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Eft.ItemEvent;
|
||||
using SPTarkov.Server.Core.Models.Eft.Ragfair;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Services;
|
||||
|
||||
namespace SPTarkov.Server.Core.Extensions;
|
||||
|
||||
@@ -289,4 +288,28 @@ public static class ProfileExtensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does Player have necessary trader loyalty to purchase flea offer
|
||||
/// </summary>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <param name="fleaOffer">Flea offer being bought</param>
|
||||
/// <returns>True if player can buy offer</returns>
|
||||
public static bool ProfileMeetsTraderLoyaltyLevelToBuyOffer(this PmcData pmcData, RagfairOffer fleaOffer)
|
||||
{
|
||||
if (fleaOffer.LoyaltyLevel == 0)
|
||||
{
|
||||
// No requirement, always passes
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pmcData.TradersInfo.TryGetValue(fleaOffer.User.Id, out var traderInfo))
|
||||
{
|
||||
// Trader exists in profile ,do loyalty level check
|
||||
return traderInfo.LoyaltyLevel >= fleaOffer.LoyaltyLevel;
|
||||
}
|
||||
|
||||
// No trader data on player profile, fail check
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,7 +985,6 @@ public class RagfairOfferHelper(
|
||||
/// <returns>True if has condition</returns>
|
||||
protected bool IsConditionItem(Item item)
|
||||
{
|
||||
// thanks typescript, undefined assertion is not returnable since it
|
||||
// tries to return a multi-type object
|
||||
if (item.Upd is null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user