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

namespace FL.Data
{
    public class PlayerData : DataSingleton<PlayerData>, IDisposable
    {
        public int chapterId = 10010101;
        public int[] skillIds = new int[] { 10011 };//13521;200705 , 
        public long UID { get; set; }
        public string Name { get; set; }

        private Attributes _attr;
        public Attributes Attr => _attr ??= ObjectPool.Acquire<Attributes>();

        public string MapAssetName
        {
            get
            {
                var chapter = ChapterTableRepo.Get(chapterId);
                var map = MapTableRepo.Get(chapter.Map);
                return map.AssetName;
            }
        }

        /// <summary>
        /// 角色等级
        /// </summary>
        public int Level
        {
            get; set;
        }

        /// <summary>
        /// 当前经验值
        /// </summary>
        public long Exp
        {
            get; set;
        }

        /// <summary>
        /// 角色称号
        /// </summary>
        public string Title
        {
            get; set;
        }

        void IDisposable.Dispose()
        {
            if (_attr != null)
            {
                ObjectPool.Recycle(_attr);
                _attr = null;
            }
        }

    }
}