using MessagePack;
using System.Collections.Generic;
using System;
#if GameClient
using GameFramework;
#endif

namespace GameMessage
{
    [Message(MessageCode.JoinRoomRequest)]
    [MessagePackObject()]
    public class JoinRoomRequest : MessageData
    {
        /// <summary>
        /// 房间号
        /// </summary>
        [Key(0)] public int RoomId;

#if GameClient
        public static JoinRoomRequest Create(int roomId)
        {
            JoinRoomRequest request = ReferencePool.Acquire<JoinRoomRequest>();
            request.RoomId = roomId;
            return request;
        }
#endif
    }

    [Message(MessageCode.JoinRoomResponse)]
    [MessagePackObject()]
    public class JoinRoomResponse : MessageData
    {
        /// <summary>
        /// 房间号
        /// </summary>
        [Key(0)] public int RoomId;

        /// <summary>
        /// 房间所属模块Id
        /// </summary>
        [Key(1)] public int ModuleId;
    }

    [MessagePackObject]
    public class FriendRoomRecordInfo
    {
        /// <summary>
        /// ID
        /// </summary>
        [Key(0)] public int Id;

        /// <summary>
        /// 创建人Id
        /// </summary>
        [Key(1)] public int CreateUserId;

        /// <summary>
        /// 玩法id
        /// 从int 改为string  之前也没有使用上。
        /// </summary>
        [Key(2)] public string WayId;

        /// <summary>
        /// 朋友房唯一码
        /// </summary>
        [Key(3)] public string WeiYiMa;

        /// <summary>
        /// 游戏的服务器id
        /// </summary>
        [Key(4)] public int GameSerId;

        /// <summary>
        /// 房间号
        /// </summary>
        [Key(5)] public int RoomNum;

        /// <summary>
        /// 开始时间
        /// </summary>
        [Key(6)] public long StartTime;

        /// <summary>
        /// 结束时间
        /// </summary>
        [Key(7)] public long EndTime;

        /// <summary>
        /// 开战次数
        /// </summary>
        [Key(8)] public int WarCnt;

        /// <summary>
        /// 打完多少盘
        /// </summary>
        [Key(9)] public int OverCnt;

        /// <summary>
        /// 耗卡数量  --xu add
        /// </summary>
        [Key(10)] public int CardNum;

        /// <summary>
        /// 解散原因
        /// </summary>
        [Key(11)] public int DisBankStyle;

        /// <summary>
        /// 分值
        /// </summary>
        [Key(12)] public List<PlayerFightData> Players;

        /// <summary>
        /// 解散玩家id
        /// </summary>
        [Key(13)] public int DisUserId;
    }

    [Message(MessageCode.GetFriendRoomRecordListRequest)]
    [MessagePackObject()]
    public class GetFriendRoomRecordListRequest : MessageData
    {
        /// <summary>
        /// 页码索引
        /// </summary>
        [Key(0)] public int PageIndex;

        /// <summary>
        /// 页码大小
        /// </summary>
        [Key(1)] public int PageSize;

#if GameClient
        public static GetFriendRoomRecordListRequest Create(int pageIndex,int pageSize)
        {
            GetFriendRoomRecordListRequest request = ReferencePool.Acquire<GetFriendRoomRecordListRequest>();
            request.PageIndex = pageIndex;
            request.PageSize = pageSize;
            return request;
        }
#endif
    }

    [Message(MessageCode.GetFriendRoomRecordListResponse)]
    [MessagePackObject()]
    public class GetFriendRoomRecordListResponse : MessageData
    {
        /// <summary>
        /// 战绩列表数据
        /// </summary>
        [Key(0)] public List<WarFriendItemData> Datas;
    }

    [Message(MessageCode.GetFriendRoomFightDataRequest)]
    [MessagePackObject()]
    public class GetFriendRoomFightDataRequest : MessageData
    {
        /// <summary>
        /// 战绩唯一码
        /// </summary>
        [Key(0)] public string WeiYiMa;

        /// <summary>
        /// 第几局
        /// </summary>
        [Key(1)] public int Index;

        /// <summary>
        /// 服务器ID
        /// </summary>
        [Key(2)] public int GameSerId;

        /// <summary>
        /// 回放数据时间
        /// </summary>
        [Key(3)] public DateTime Time;

#if GameClient
        public static GetFriendRoomFightDataRequest Create()
        {
            return ReferencePool.Acquire<GetFriendRoomFightDataRequest>();
        }

        public override void Clear()
        {
            WeiYiMa = null;
            Index = 0;
            GameSerId = 0;
        }
#endif
    }

    [Message(MessageCode.GetFriendRoomFightDataResponse)]
    [MessagePackObject()]
    public class GetFriendRoomFightDataResponse : MessageData
    {
        /// <summary>
        /// 战绩回放数据
        /// </summary>
        [Key(0)] public string JsonPack;
    }
}