using GameMessage;
using MessagePack;

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

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

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

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

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

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

        /// <summary>
        /// 领取类型
        /// </summary>
        [Key(1)] public int ReceiveType;
        
        #if GameClient
        public static GeneralAdGiftRequest Create(int reward, int receiveType)
        {
            GeneralAdGiftRequest self = ReferencePool.Acquire<GeneralAdGiftRequest>();
            self.Reward = reward;
            self.ReceiveType = receiveType;
            return self;
        }
#endif
    }

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

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

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

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