42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using Fantasy;
|
|
|
|
namespace NBF
|
|
{
|
|
public static class ShopItemHelper
|
|
{
|
|
public static List<TabItemData> ToTabItemData(this List<ShopItemInfo> shopItems)
|
|
{
|
|
List<TabItemData> ret = new List<TabItemData>();
|
|
Dictionary<ItemType, List<ShopItemInfo>> tabDic = new Dictionary<ItemType, List<ShopItemInfo>>();
|
|
|
|
foreach (var shopItemInfo in shopItems)
|
|
{
|
|
var type = shopItemInfo.ItemType;
|
|
if (!tabDic.ContainsKey(type))
|
|
{
|
|
tabDic.Add(type, new List<ShopItemInfo>());
|
|
}
|
|
|
|
tabDic[type].Add(shopItemInfo);
|
|
}
|
|
|
|
foreach (var (key, list) in tabDic)
|
|
{
|
|
list.Sort((x, y) => (int)(y.Price1 - x.Price1));
|
|
}
|
|
|
|
foreach (var (type, list) in tabDic)
|
|
{
|
|
TabItemData tabItem = new TabItemData
|
|
{
|
|
Key = type.ToString()
|
|
};
|
|
tabItem.Items.AddRange(list);
|
|
ret.Add(tabItem);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
}
|
|
} |