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

namespace GameMessage
{
    /// <summary>
    /// 玩家自身的俱乐部信息请求
    /// </summary>
    [Message(MessageCode.ClubPlayerSelfRequest)]
    [MessagePackObject]
    public class ClubPlayerSelfRequest : MessageData
    {
#if GameClient
        public static ClubPlayerSelfRequest Create()
        {
            return ReferencePool.Acquire<ClubPlayerSelfRequest>();
        }
#endif
    }

    /// <summary>
    /// 玩家自身的俱乐部信息响应
    /// </summary>
    [Message(MessageCode.ClubPlayerSelfResponse)]
    [MessagePackObject]
    public class ClubPlayerSelfResponse : MessageData
    {
        [Key(0)]
        public ClubPlayerInfo PlayerInfo;
    }
    
    /// <summary>
    /// 搜索俱乐部玩家请求
    /// </summary>
    [Message(MessageCode.SearchClubPlayerRequest)]
    [MessagePackObject]
    public class SearchClubPlayerRequest : MessageData
    {
        [Key(0)] public int ClubId;

        /// <summary>
        /// 搜索关键字 (ID、名称、 备注)
        /// </summary>
        [Key(1)] public string SearchKey;
        
        /// <summary>
        /// 全局搜索 (如果是联盟会搜索所有子俱乐部得玩家)
        /// </summary>
        [Key(2)] public bool IsGlobalSearch;
        
        /// <summary>
        /// 详细搜索
        /// </summary>
        [Key(3)] public bool IsDetailSearch;
        
#if GameClient
        public static SearchClubPlayerRequest Create(int clubId, string searchKey, bool isGlobalSearch, bool isDetailSearch)
        {
            var req = ReferencePool.Acquire<SearchClubPlayerRequest>();
            req.ClubId = clubId;
            req.SearchKey = searchKey;
            req.IsGlobalSearch = isGlobalSearch;
            req.IsDetailSearch = isDetailSearch;
            return req;
        }
#endif
    }
    
    /// <summary>
    /// 搜索俱乐部玩家响应
    /// </summary>
    [Message(MessageCode.SearchClubPlayerResponse)]
    [MessagePackObject]
    public class SearchClubPlayerResponse : MessageData
    {
        [Key(0)] public int ClubId;
        [Key(1)] public List<ClubPlayerSampleInfo> List;
    }
    
    /// <summary>
    /// 搜索俱乐部玩家请求
    /// </summary>
    [Message(MessageCode.SearchGamePlayerRequest)]
    [MessagePackObject]
    public class SearchGamePlayerRequest : MessageData
    {
        [Key(0)] public int ClubId;

        /// <summary>
        /// 搜索关键字 (ID)
        /// </summary>
        [Key(1)] public string SearchKey;
        
#if GameClient
        public static SearchGamePlayerRequest Create(int clubId, string searchKey)
        {
            var req = ReferencePool.Acquire<SearchGamePlayerRequest>();
            req.ClubId = clubId;
            req.SearchKey = searchKey;
            return req;
        }
#endif
    }
    
    /// <summary>
    /// 搜索俱乐部玩家响应
    /// </summary>
    [Message(MessageCode.SearchGamePlayerResponse)]
    [MessagePackObject]
    public class SearchGamePlayerResponse : MessageData
    {
        [Key(0)] public int ClubId;
        [Key(1)] public List<GamePlayerSampleInfo> List;
    }

    [MessagePackObject]
    public class GamePlayerSampleInfo
    {
        /// <summary>
        /// 玩家Id
        /// </summary>
        [Key(0)]public int UserId;

        /// <summary>
        /// 玩家昵称
        /// </summary>
        [Key(1)]public string NickName;

        /// <summary>
        /// 玩家性别
        /// </summary>
        [Key(2)]public int Sex;

        /// <summary>
        /// 玩家是否加入了该俱乐部
        /// </summary>
        [Key(3)]public bool IsInClub;

        /// <summary>
        /// 玩家加入的亲友房数量
        /// </summary>
        [Key(4)]public int JoinCount;
    }

    [MessagePackObject]
    public class ClubPlayerSampleInfo
    {
        [Key(0)]
        public int UserId;
        
        [Key(1)]
        public string NickName;
        
        [Key(2)]
        public int Sex;
        
        /// <summary>
        /// 俱乐部信息
        /// </summary>
        [Key(3)] public PlayerClubInfo ClubInfo;
    }

    /// <summary>
    /// 俱乐部的玩家信息
    /// </summary>
    [MessagePackObject]
    public class ClubPlayerInfo
    {
        [Key(0)]
        public ulong Ver;

        [Key(1)]
        public int UserId;

        [Key(2)]
        public int Sex;

        [Key(3)]
        public List<int> FightRecordIds;

        [Key(4)]
        public string NickName;

        [Key(5)]
        public List<PlayerClubInfo> MyClubs;

        [Key(6)]
        public List<PlayerClubInfo> JoinClubs;
    }

    /// <summary>
    /// 玩家的俱乐部信息
    /// </summary>
    [MessagePackObject]
    public class PlayerClubInfo
    {
        [Key(0)]
        public int ClubId;

        [Key(1)]
        public long JoinTime;

        [Key(2)]
        public int Position;

        [Key(3)]
        public int InGame;

        [Key(4)]
        public string Remark;

        [Key(5)]
        public int Permission;

        [Key(6)]
        public int PartnerId;
    }
}