52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using Dalamud.Plugin.Services;
|
|
using LLib.Shop.Model;
|
|
using LLib.Shop.Searchers;
|
|
|
|
namespace LLib.Shop;
|
|
|
|
public sealed class VendorResolver
|
|
{
|
|
private readonly GilShopSearcher _gilShopSearcher;
|
|
|
|
private readonly SpecialShopSearcher _specialShopSearcher;
|
|
|
|
private readonly GCShopSearcher _gcShopSearcher;
|
|
|
|
public VendorResolver(IDataManager dataManager, NpcPositionCache positionCache)
|
|
{
|
|
_gilShopSearcher = new GilShopSearcher(dataManager, positionCache);
|
|
_specialShopSearcher = new SpecialShopSearcher(dataManager, positionCache);
|
|
_gcShopSearcher = new GCShopSearcher(dataManager, positionCache);
|
|
}
|
|
|
|
public IReadOnlyList<ShopSearchResult> FindVendorsForItem(uint itemId)
|
|
{
|
|
List<ShopSearchResult> list = new List<ShopSearchResult>();
|
|
list.AddRange(_gilShopSearcher.Search(itemId));
|
|
list.AddRange(_specialShopSearcher.Search(itemId));
|
|
list.AddRange(_gcShopSearcher.Search(itemId));
|
|
return list;
|
|
}
|
|
|
|
public IReadOnlyList<ShopSearchResult> FindVendorsForItem(uint itemId, EShopType shopType)
|
|
{
|
|
return shopType switch
|
|
{
|
|
EShopType.GilShop => _gilShopSearcher.Search(itemId),
|
|
EShopType.SpecialShop => _specialShopSearcher.Search(itemId),
|
|
EShopType.GCShop => _gcShopSearcher.Search(itemId),
|
|
_ => new List<ShopSearchResult>(),
|
|
};
|
|
}
|
|
|
|
public ShopSearchResult? FindGilVendor(uint itemId)
|
|
{
|
|
List<ShopSearchResult> list = _gilShopSearcher.Search(itemId);
|
|
if (list.Count <= 0)
|
|
{
|
|
return null;
|
|
}
|
|
return list[0];
|
|
}
|
|
}
|