using System.Collections.Generic;

namespace Server.Config
{
    public partial class SignConfigCategory
    {
        /// <summary>
        /// 签到礼包奖励天数
        /// </summary>
        public int[] GiftRewardDays
        {
            get;
            private set;
        }

        //签到配置
        public readonly Dictionary<int, SignConfig> SignDataConfig = new Dictionary<int, SignConfig>();
        
        /// <summary>
        /// 签到礼包配置
        /// </summary>
        public readonly Dictionary<int, SignConfig> SignGiftBoxConfig = new Dictionary<int, SignConfig>(); 
        
        partial void PostInit()
        {
            List<int> result = new List<int>();
            for (int i = 0; i < _dataList.Count; i++)
            {
                if (_dataList[i].DataType == 2 && _dataList[i].RewardDay > 0)
                {
                    result.Add(_dataList[i].RewardDay);
                }
            }

            for (int i = 0; i < result.Count; i++)
            {
                int minIdx = i;
                for (int j = i+1; j < result.Count; j++)
                {
                    if (result[j] < result[minIdx])
                    {
                        minIdx = j;
                    }
                }

                if (minIdx != i)
                {
                    (result[i], result[minIdx]) = (result[minIdx], result[i]);
                }
            }
            
            GiftRewardDays = result.ToArray();
            
            for (int i = 0; i < _dataList.Count; i++)
            {
                //签到数据
                if (_dataList[i].DataType == 1)
                {
                    SignDataConfig[_dataList[i].Id] = _dataList[i];
                }
                //礼包数据
                if (_dataList[i].DataType == 2)
                {
                    SignGiftBoxConfig[_dataList[i].RewardDay] = _dataList[i];
                }
            }
            
            
        }
    }
}