using System.Collections.Generic;
using MessagePack;

#if Server
using Server.Core;
#endif

namespace GameMessage
{
    [Message(MessageCode.PrizeWheelDataRequest)]
    [MessagePackObject]
    public class PrizeWheelDataRequest : MessageData
    {
    }

    [Message(MessageCode.PrizeWheelDataResponse)]
    [MessagePackObject]
    public class PrizeWheelDataResponse : MessageData
    {
        /// <summary>
        /// 时间戳
        /// </summary>
        [Key(0)]
        public long DateTimestamp;
        
        /// <summary>
        /// 转盘数据 key转盘类型 value 进行转的次数
        /// </summary>
        [Key(1)] public Dictionary<int, int> PrizeWheelData = new Dictionary<int, int>();

#if Server
        public static PrizeWheelDataResponse Create()
        {
            PrizeWheelDataResponse response = ReferencePool.Fetch<PrizeWheelDataResponse>();
            return response;
        }

        public override void Dispose()
        {
            PrizeWheelData = null;
            ReferencePool.Recycle(this);
        }

#endif
    }

    [Message(MessageCode.PrizeWheelRewardRequest)]
    [MessagePackObject]
    public class PrizeWheelRewardRequest : MessageData
    {
        /// <summary>
        /// 转盘版本
        /// </summary>
        [Key(0)] public int Version;

        /// <summary>
        /// 转盘类型
        /// </summary>
        [Key(1)] public int PrizeWheelType;

        /// <summary>
        /// 转盘转到的奖励ID
        /// </summary>
        [Key(2)] public int RewardId;

        /// <summary>
        /// 消耗类型 0免费 1看广告 2分享
        /// </summary>
        [Key(3)]
        public int ConsumeType;
    }

    [Message(MessageCode.PrizeWheelRewardResponse)]
    [MessagePackObject]
    public class PrizeWheelRewardResponse : MessageData
    {
        /// <summary>
        /// 结果
        /// </summary>
        [Key(0)] public int ResultCode;

        /// <summary>
        /// 转盘类型
        /// </summary>
        [Key(1)]
        public int PrizeWheelType;
        
        /// <summary>
        /// 转盘奖励ID
        /// </summary>
        [Key(2)]
        public int RewardId;
        
        /// <summary>
        /// 消耗类型
        /// </summary>
        [Key(3)]
        public int ConsumeType;
        
        /// <summary>
        /// 转盘数据
        /// </summary>
        [Key(4)] public PrizeWheelDataResponse PrizeWheelDataResponse;

#if Server
        public static PrizeWheelRewardResponse Create(PrizeWheelDataResponse prizeWheelDataResponse = null)
        {
            PrizeWheelRewardResponse self = ReferencePool.Fetch<PrizeWheelRewardResponse>();
            self.PrizeWheelDataResponse = prizeWheelDataResponse;
            return self;
        }

        public override void Dispose()
        {
            if (PrizeWheelDataResponse != null)
            {
                PrizeWheelDataResponse.Dispose();
                PrizeWheelDataResponse = null;
            }
            ReferencePool.Recycle(this);
        }
#endif
    }
}