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

namespace FL.Data
{
    public class DragonEggData : DataSingleton<DragonEggData>, IDisposable
    {
        private Dictionary<int, int> _unlockQualityDic = new Dictionary<int, int>(); // 龙蛋品质解锁条件
        private Dictionary<EQualityLevel, int> _dragonEggDic = new Dictionary<EQualityLevel, int>(); // 龙蛋(品质)数量

        /// <summary>
        /// 当前龙蛋的积分
        /// </summary>
        public int DragonEggSocre
        {
            set; get;
        }
        /// <summary>
        /// 当前龙蛋进度条的最大积分
        /// </summary>
        public int MaxDragonEggSocre
        {
            set; get;
        }

        /// <summary>
        /// 龙蛋等级
        /// </summary>
        public int EggLv
        {
            set; get;
        }

        /// <summary>
        /// 龙蛋数量
        /// </summary>
        public int EggCount { set; get; }

        /// <summary>
        /// 当前龙蛋能量槽激活数量
        /// </summary>
        public int EggEnergy
        {
            set; get;
        }

        /// <summary>
        /// 龙蛋升阶结束时间戳
        /// </summary>
        public long UpgradeEndTime
        {
            set; get;
        }

        /// <summary>
        /// 观看广告加速的结束时间戳
        /// </summary>
        public long AdEndTime
        {
            set; get;
        }

        /// <summary>
        /// 加速道具id
        /// </summary>
        public int AccelerateId
        {
            set; get;
        }

        /// <summary>
        /// 使用1个加速道具减少的时间(秒)
        /// </summary>
        public int ReduceTime
        {
            set; get;
        }

        /// <summary>
        /// 观看广告减少的时间(秒)
        /// </summary>
        public int AdReduceTime
        {
            set; get;
        }

        /// <summary>
        /// 每日观看广告减少升级时间的次数
        /// </summary>
        public int MaxWatchAdCount
        {
            set; get;
        }

        /// <summary>
        /// 当前拥有的观看广告减少时间的次数
        /// </summary>
        public int WatchAdCount
        {
            set; get;
        }

        /// <summary>
        /// 是否已解锁装备分解功能
        /// </summary>
        public bool IsUnLockDecompose
        {
            set; get;
        }

        // 测试今日不再显示出售高战力装备提示
        public bool CheckDayTipsKey
        {
            set; get;
        }

        public void AddUnlockQualityDic(int quality, int globalId)
        {
            if (_unlockQualityDic.ContainsKey(quality))
            {
                _unlockQualityDic[quality] = globalId;
            }
            else
            {
                _unlockQualityDic.Add(quality, globalId);
            }
        }
        public void RemoveUnlockQualityDic(int quality)
        {
            if (_unlockQualityDic.ContainsKey(quality))
            {
                _unlockQualityDic.Remove(quality);
            }
        }
        /// <summary>
        /// 龙蛋品质解锁条件(全局表id)
        /// </summary>
        /// <param name="quality"></param>
        /// <returns></returns>
        public int GetUnlockQuality(int quality)
        {
            if (_unlockQualityDic.ContainsKey(quality))
            {
                return _unlockQualityDic[quality];
            }
            return 0;
        }

        public void OnchangeDragonEgg(EQualityLevel quality, int num)
        {
            if (_dragonEggDic.ContainsKey(quality))
            {
                _dragonEggDic[quality] += num;
            }
            else
            {
                _dragonEggDic.Add(quality, num);
            }
        }
        /// <summary>
        /// 获取龙蛋品质宝箱数量
        /// </summary>
        /// <param name="quality"></param>
        /// <returns></returns>
        public int GetDragonEgg(EQualityLevel quality)
        {
            return _dragonEggDic.ContainsKey(quality) ? _dragonEggDic[quality] : 0;
        }


        void IDisposable.Dispose()
        {
            _unlockQualityDic.Clear();
            _dragonEggDic.Clear();
        }
    }
}
