2024-10-23 00:08:52 +02:00
|
|
|
|
using EFT.InventoryLogic;
|
2024-11-08 21:17:10 +01:00
|
|
|
|
using LootValueEX.Extensions;
|
|
|
|
|
using SPT.Reflection.Utils;
|
2024-10-23 00:08:52 +02:00
|
|
|
|
|
|
|
|
|
namespace LootValueEX.Utils
|
|
|
|
|
{
|
2024-11-23 01:30:48 +01:00
|
|
|
|
internal static class ItemUtils
|
2024-10-23 00:08:52 +02:00
|
|
|
|
{
|
2024-11-26 06:35:35 +01:00
|
|
|
|
internal static float GetArmorDurability(IEnumerable<RepairableComponent> repairableComponents) => repairableComponents.Sum(x => x.Durability);
|
2024-11-08 21:17:10 +01:00
|
|
|
|
|
2024-11-23 01:30:48 +01:00
|
|
|
|
internal static Task<Structs.TradeOfferStruct> GetBestTraderValueAsync(Item item)
|
2024-11-08 21:17:10 +01:00
|
|
|
|
{
|
|
|
|
|
Structs.TradeOfferStruct bestOffer = new();
|
|
|
|
|
item = item.UnstackItem();
|
|
|
|
|
foreach (TraderClass trader in ClientAppUtils.GetMainApp().GetClientBackEndSession().DisplayableTraders)
|
|
|
|
|
{
|
|
|
|
|
Structs.TradeOfferStruct currentOffer = EconomyUtils.GetTraderItemOffer(trader, item);
|
|
|
|
|
|
|
|
|
|
if (currentOffer.Equals(default) || currentOffer.Price <= 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (currentOffer.PriceInRouble > bestOffer.PriceInRouble)
|
|
|
|
|
bestOffer = currentOffer;
|
|
|
|
|
}
|
|
|
|
|
return Task.FromResult(bestOffer);
|
|
|
|
|
}
|
|
|
|
|
public static Structs.TradeOfferStruct GetBestTraderValue(Item item) => Task.Run(() => GetBestTraderValueAsync(item)).Result;
|
2024-10-23 00:08:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|