using XGame.Database;
namespace FL.Data.Items
{
public class EquipItemBase : IItemBase
{
///
/// 装备唯一id
///
public int Id { get; private set; }
private EquipmentTable _table;
private ItemTable _itemTable;
///
/// 装备表格id
///
public int TableId => _table.Id;
public EItemType ItemType => EItemType.Equip;
///
/// 装备部位
///
public EEquipType EquipType => _table.Part;
public EQualityLevel Quality => _table.Quality;
public string Name => _table.Name;
public int Level { get; set; }
///
/// 装备属性转化的战斗力
///
public long FightingPower { get; set; }
public string Description { get; set; }
public string Icon => _itemTable?.Icon;
///
/// 根据uid从装备背包获取装备信息
///
///
public void InitById(int id)
{
var attr = EquipData.Instance.GetBagEquipItem(id);
XGame.Framework.Assert.IsNotNull(attr, $"装备信息不存在,id:{id}");
Id = id;
Level = attr.Level;
var tableId = attr.TableId;
_table = EquipmentTableRepo.Get(tableId);
XGame.Framework.Assert.IsNotNull(_table, $"装备表不存在,id:{tableId}");
_itemTable = ItemTableRepo.Get(tableId);
XGame.Framework.Assert.IsNotNull(_itemTable, $"道具表不存在,id:{tableId}");
}
///
/// 根据装备部位从身上穿戴的装备获取装备信息
///
///
public void InitByEquipPart(EEquipType equipPart)
{
var attr = EquipData.Instance.GetWearEquipData(equipPart);
XGame.Framework.Assert.IsNotNull(attr, $"装备信息不存在,部位id:{equipPart}");
Id = 0;
Level = attr.Level;
var tableId = attr.TableId;
_table = EquipmentTableRepo.Get(tableId);
XGame.Framework.Assert.IsNotNull(_table, $"装备表不存在,id:{tableId}");
_itemTable = ItemTableRepo.Get(tableId);
XGame.Framework.Assert.IsNotNull(_itemTable, $"道具表不存在,id:{tableId}");
}
}
}