using System;
using System.Collections.Generic;
using MessagePack;

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

namespace GameMessage
{
    /// <summary>
    /// 道具数据请求
    /// </summary>
    [Message(MessageCode.PropDataRequest)]
    [MessagePackObject()]
    [Obsolete("PropDataRequest is deprecated, use new PropDataRequest2 instead")]
    public class PropDataRequest : MessageData
    {
#if GameClient
        public static PropDataRequest Create()
        {
            return ReferencePool.Acquire<PropDataRequest>();
        }

        public override void Clear()
        {
        }
#endif
    }

    /// <summary>
    /// 道具数据响应
    /// </summary>
    [Message(MessageCode.PropDataResponse)]
    [MessagePackObject()]
    [Obsolete("PropDataResponse is deprecated, use new PropDataResponse2 instead")]
    public class PropDataResponse : MessageData
    {
        /// <summary>
        /// 用户id
        /// </summary>
        [Key(0)] public int Userid;

        /// <summary>
        /// 参赛券
        /// </summary>
        [Key(1)] public int CanSaiJuan;

        /// <summary>
        /// 门票
        /// </summary>
        [Key(2)] public int MenPiao;

        /// <summary>
        /// 复活卡
        /// </summary>
        [Key(3)] public int FuHuoKa;

        /// <summary>
        /// 公会令
        /// </summary>
        [Key(4)] public int ClubToken;

        /// <summary>
        /// 总公会令
        /// </summary>
        [Key(5)] public int ClubSuperToken;
    }

    [Message(MessageCode.PropDataRequestV2)]
    [MessagePackObject]
    public class PropDataRequestV2 : MessageData
    {
#if GameClient
        public static PropDataRequestV2 Create()
        {
            PropDataRequestV2 request = ReferencePool.Acquire<PropDataRequestV2>();
            return request;
        }
#endif
    }

    [Message(MessageCode.PropDataResponseV2)]
    [MessagePackObject]
    public class PropDataResponseV2 : MessageData
    {
        /// <summary>
        /// 玩家的UserId
        /// </summary>
        [Key(0)]
        public int UserId;
        
        /// <summary>
        /// 道具的道具
        /// </summary>
        [Key(1)]
        public Dictionary<int, int> PropData;
        
        #if Server
        public static PropDataResponseV2 Create(int userId, Dictionary<int, int> propData)
        {
            PropDataResponseV2 response = new PropDataResponseV2();
            response.UserId = userId;
            response.PropData = propData;
            return response;
        }

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

    /// <summary>
    /// 红包卷请求
    /// </summary>
    [Message(MessageCode.HongBaoJuanRequest)]
    [MessagePackObject()]
    public class HongBaoJuanRequest : MessageData
    {
#if GameClient
        public static HongBaoJuanRequest Create()
        {
            return ReferencePool.Acquire<HongBaoJuanRequest>();
        }
#endif
    }

    /// <summary>
    /// 红包卷响应
    /// </summary>
    [Message(MessageCode.HongBaoJuanResponse)]
    [MessagePackObject()]
    public class HongBaoJuanResponse : MessageData
    {
        /// <summary>
        /// 用户UserId
        /// </summary>
        [Key(0)] public int UserId;

        /// <summary>
        /// 红包卷数量
        /// </summary>
        [Key(1)] public int HongBaoJuanNum;
    }

    /// <summary>
    /// 兑换房卡请求
    /// </summary>
    [Message(MessageCode.DiamondExChangeFangKaRequest)]
    [MessagePackObject()]
    public class DiamondExChangeFangKaRequest : MessageData
    {
        /// <summary>
        /// 兑换的数值
        /// </summary>
        [Key(0)] public int ExchangeValue;

#if GameClient
        public static DiamondExChangeFangKaRequest Create()
        {
            return new DiamondExChangeFangKaRequest();
        }
#endif
    }

    /// <summary>
    /// 兑换房卡响应
    /// </summary>
    [Message(MessageCode.DiamondExChangeFangKaResponse)]
    [MessagePackObject()]
    public class DiamondExChangeFangKaResponse : MessageData
    {
        /// <summary>
        /// 兑换的数值
        /// </summary>
        [Key(0)] public int ExchangeValue;

        /// <summary>
        /// 玩家当前房卡数量
        /// </summary>
        [Key(1)] public int FangKaNum;

        /// <summary>
        /// 玩家当前钻石数量
        /// </summary>
        [Key(2)] public int DiamondNum;

        /// <summary>
        /// 结果
        /// </summary>
        [Key(3)] public int ResultCode;
    }

    // 赠送道具
    /// <summary>
    /// 道具数据请求
    /// </summary>
    [Message(MessageCode.PropDataGiveRequest)]
    [MessagePackObject()]
    public class PropDataGiveRequest : MessageData
    {
        /// <summary>
        /// 接受的用户
        /// </summary>
        [Key(0)] public int ReceiveUserId;

        /// <summary>
        /// 道具ID
        /// </summary>
        [Key(1)] public int PropId;

        /// <summary>
        /// 道具数量
        /// </summary>
        [Key(2)] public int PropNum;

#if GameClient
        public static PropDataGiveRequest Create(int receiveUserId, int propId, int propNum)
        {
            PropDataGiveRequest request = ReferencePool.Acquire<PropDataGiveRequest>();
            request.ReceiveUserId = receiveUserId;
            request.PropId = propId;
            request.PropNum = propNum;
            return request;
        }
#endif
    }

    /// <summary>
    /// 道具数据响应
    /// </summary>
    [Message(MessageCode.PropDataGiveResponse)]
    [MessagePackObject()]
    public class PropDataGiveResponse : MessageData
    {
        /// <summary>
        /// 状态码
        /// </summary>
        [Key(0)] public int StatusCode;
    }
}