using System;
using XGame.Database;
using XGame.Framework;


namespace FL.Data.Items
{
    public struct ChangeEquipParam
    {
        public EEquipType equipType;
        public long equipUid;    // 当前要穿戴的装备唯一id
        public long replacedUid; // 被替换下来的装备唯一id
    }

    public class EquipItem : IItem, IDisposable
    {
        private Attributes _attributes;
        public Attributes Attributes => _attributes ??= (_attributes = ObjectPool.Acquire<Attributes>());

        /// <summary>
        /// 装备唯一id
        /// </summary>
        public long Id { get; private set; }
        public EquipmentTable Table { get; private set; }
        /// <summary>
        /// 装备表格id
        /// </summary>
        public int TableId => Table.Id;

        public EItemType ItemType => EItemType.Equip;

        /// <summary>
        /// 装备部位
        /// </summary>
        public EEquipType EquipType => Table.Part;

        public EQualityLevel Quality => Table.Quality;

        public string Name => Table.Name;

        string IItem.Icon => Table.Icon;

        public int Level { get; set; }
        /// <summary>
        /// 装备属性转化的战斗力
        /// </summary>
        public long FightingPower { get; set; }
        public string Count { get; set; }

        public string Description { get; set; }

        public void Init(EquipmentTable table, long id)
        {
            Table = table;
            Id = id;
        }

        public void Dispose()
        {
            if (_attributes != null)
            {
                ObjectPool.Recycle(_attributes);
            }
        }
    }
}
