using GameMessage;
using MessagePack;

#if Server
using Server.Core;
#else
using GameFramework;
#endif

namespace UnityGame
{
    [Message(MessageCode.AdGiftRandomDataRequest)]
    [MessagePackObject]
    public class AdGiftRandomDataRequest : MessageData
    {
    }

    [Message(MessageCode.AdGiftRandomDataResponse)]
    [MessagePackObject]
    public class AdGiftRandomDataResponse : MessageData
    {
        [Key(0)] public int DayReceiveCnt;

#if Server
        public static AdGiftRandomDataResponse Create(int receiveCnt)
        {
            AdGiftRandomDataResponse response = ReferencePool.Fetch<AdGiftRandomDataResponse>();
            response.DayReceiveCnt = receiveCnt;
            return response;
        }

        public override void Dispose()
        {
            ReferencePool.Recycle(this);
        }
#endif
    }

    [Message(MessageCode.AdGiftRandomRequest)]
    [MessagePackObject]
    public class AdGiftRandomRequest : MessageData
    {
        /// <summary>
        /// 奖励数额
        /// </summary>
        [Key(0)] public int Reward;

#if GameClient
        public static AdGiftRandomRequest Create(int reward)
        {
            AdGiftRandomRequest self = ReferencePool.Acquire<AdGiftRandomRequest>();
            self.Reward = reward;
            return self;
        }
#endif
    }

    [Message(MessageCode.AdGiftRandomResponse)]
    [MessagePackObject]
    public class AdGiftRandomResponse : MessageData
    {
        /// <summary>
        /// 今日领取次数
        /// </summary>
        [Key(0)] public int DayReceiveCnt;

        /// <summary>
        /// 奖励
        /// </summary>
        [Key(1)] public int Reward;

#if Server
        public static AdGiftRandomResponse Create(int receiveCnt, int reward)
        {
            AdGiftRandomResponse response = ReferencePool.Fetch<AdGiftRandomResponse>();
            response.DayReceiveCnt = receiveCnt;
            response.Reward = reward;
            return response;
        }

        public override void Dispose()
        {
            ReferencePool.Recycle(this);
        }
#endif
    }
}