using Fantasy;
using Fantasy.Entitas.Interface;

namespace NB.Game;

public class ItemDestroySystem : DestroySystem<Item>
{
    protected override void Destroy(Item self)
    {
        self.ConfigId = 0;
        self.Count = 0;
        self.IsBind = false;
        self.ExpirationTime = 0;
        self.GetTime = 0;
        self.Abrasion = 0;
    }
}

public static class ItemSystem
{
    public static ItemInfo ToItemInfo(this Item self)
    {
        return new ItemInfo()
        {
            Id = self.Id,
            ConfigId = self.Count,
            Count = self.Count,
            ExpirationTime = self.ExpirationTime,
            GetTime = self.GetTime,
            Abrasion = self.Abrasion
        };
    }

    public static List<ItemInfo> ToItemInfo(this List<Item> items)
    {
        var list = new List<ItemInfo>();
        foreach (var item in items)
        {
            list.Add(item.ToItemInfo());
        }

        return list;
    }

    public static AwardInfo ToAwardInfo(this Item item)
    {
        return new AwardInfo()
        {
            ConfigId = item.ConfigId,
            Count = item.Count
        };
    }

    public static List<AwardInfo> ToAwardInfo(this List<Item> items)
    {
        var list = new List<AwardInfo>();
        foreach (var item in items)
        {
            list.Add(item.ToAwardInfo());
        }

        return list;
    }
    
}