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

namespace GameMessage
{
    /// <summary>
    /// 服务器配置请求
    /// </summary>
    [Message(MessageCode.ServerConfigRequest)]
    [MessagePackObject()]
    public class ServerConfigRequest : MessageData
    {
        [Key(0)] public int Ver;
    }

    [Message(MessageCode.ServerConfigResponse)]
    [MessagePackObject()]
    public class ServerConfigResponse : MessageData
    {
        [Key(0)] public string AllServerConfig;
    }
    
    [Message(MessageCode.ServerConfigRequestV2)]
    [MessagePackObject()]
    public class ServerConfigRequestV2 : MessageData
    {
        /// <summary>
        /// 版本
        /// </summary>
        [Key(0)]
        public long Ver;

#if GameClient
        public static ServerConfigRequestV2 Create(long ver)
        {
            ServerConfigRequestV2 requestV2 = ReferencePool.Acquire<ServerConfigRequestV2>();
            requestV2.Ver = ver;
            return requestV2;
        }
#endif
    }
    
    [Message(MessageCode.ServerConfigResponseV2)]
    [MessagePackObject()]
    public class ServerConfigResponseV2 : MessageData
    {
        /// <summary>
        /// 版本
        /// </summary>
        [Key(0)]
        public long Ver;
        
        /// <summary>
        /// 俱乐部配置
        /// </summary>
        [Key(1)]
        public ClubConfig ClubConfig;

        /// <summary>
        /// 游戏配置
        /// </summary>
        [Key(2)]
        public List<GameConfig> GameConfigs;
    }
    
    [MessagePackObject]
    public class ClubConfig
    {
        /// <summary>
        /// 域名地址
        /// </summary>
        [Key(0)]
        public string Url;
    }

    [MessagePackObject()]
    public class GameConfig
    {
        /// <summary>
        /// 服务器ID
        /// </summary>
        [Key(0)]
        public int ServerId;

        /// <summary>
        /// 客户端ID
        /// </summary>
        [Key(1)]
        public int ClientId;

        /// <summary>
        /// 模块ID
        /// </summary>
        [Key(2)]
        public int ModuleId;

        /// <summary>
        /// 开放朋友场
        /// </summary>
        [Key(3)]
        public bool OpenFriend;

        /// <summary>
        /// 开放金币场
        /// </summary>
        [Key(4)]
        public bool OpenGold;

        /// <summary>
        /// 开放回放
        /// </summary>
        [Key(5)]
        public bool OpenPlayBack;

        /// <summary>
        /// 开放平台 null 表示所有都开启  012 表示开放0桌面 1安卓 2苹果
        /// </summary>
        [Key(6)]
        public string OpenPlat;

        /// <summary>
        /// 游戏类型 0牌类 1麻将类
        /// </summary>
        [Key(7)]
        public int GameStyle;

        /// <summary>
        /// 排序图片
        /// </summary>
        [Key(8)]
        public int SortNum;
        
        /// <summary>
        /// 0表示去自身游戏iD 的图片  大于0表示去指定ID的图片
        /// </summary>
        [Key(9)]
        public int ImgNum;

        /// <summary>
        /// 活动状态 0 表示不开放 1表示正常 2表示有活动 3表示最新 4表示最热
        /// </summary>
        [Key(10)]
        public int Active;

        /// <summary>
        /// 朋友房规则
        /// </summary>
        [Key(11)]
        public string FriendRule;

        /// <summary>
        /// WebSocket 端口
        /// </summary>
        [Key(12)]
        public int WebPort;

        /// <summary>
        /// ip 地址
        /// </summary>
        [Key(13)]
        public string Ip;
    }
}