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

namespace GameMessage
{
    /// <summary>
    /// 俱乐部信息请求
    /// </summary>
    [Message(MessageCode.ClubMatchInfoRequest)]
    [MessagePackObject]
    public class ClubMatchInfoRequest : MessageData
    {
        /// <summary>
        /// 俱乐部ID
        /// </summary>
        [Key(0)]
        public int ClubId;
        
        #if GameClient
        public static ClubMatchInfoRequest Create(int clubId)
        {
            ClubMatchInfoRequest request = ReferencePool.Acquire<ClubMatchInfoRequest>();
            request.ClubId = clubId;
            return request;
        }
        #endif
    }

    /// <summary>
    /// 俱乐部信息响应
    /// </summary>
    [Message(MessageCode.ClubMatchInfoResponse)]
    [MessagePackObject]
    public class ClubMatchInfoResponse : MessageData
    {
        /// <summary>
        /// 所属公会ID
        /// </summary>
        [Key(0)]
        public int ClubId;

        /// <summary>
        /// 比赛开始时间
        /// </summary>
        [Key(1)]
        public long MatchStartTime;
        
        /// <summary>
        /// 比赛结束时间
        /// </summary>
        [Key(2)]
        public long MatchEndTime;
        
        /// <summary>
        /// 比赛名称    可以为空。
        /// </summary>
        [Key(3)]
        public string MatchInfoName;
        
        /// <summary>
        /// 比赛频率
        /// </summary>
        [Key(4)]
        public int MatchRate;

        /// <summary>
        /// 淘汰分值
        /// </summary>
        [Key(5)]
        public int DieOutNum;

        /// <summary>
        /// 是否自动开启下一场比赛
        /// </summary>
        [Key(6)]
        public bool AutoOpen;

        /// <summary>
        /// 该值表示是否是联赛，小于0是联赛，该值存储了联赛的ClubId
        /// </summary>
        [Key(7)]
        public int LeagueClubId;

        /// <summary>
        /// 普通成员显示的桌子数量
        /// </summary>
        [Key(8)]
        public int VisibleDesk;
        
        /// <summary>
        /// 是否只显示自己俱乐部的桌子--只有联赛才会能体现出这个设置
        /// 1不是 0是显示自己俱乐部的桌子
        /// </summary>
        [Key(9)]
        public byte IsOnlyVisibleMyClub;
        
        /// <summary>
        /// 关联的玩法
        /// </summary>
        [Key(10)]
        public List<MatchPlayWayInfo> MatchPlayWayInfos;

        /// <summary>
        /// 是否显示淘汰分
        /// </summary>
        [Key(11)]
        public byte IsVisibleScoreBak;
        
        /// <summary>
        /// 每轮比赛开始积分是否 1清零 0不清零
        /// </summary>
        [Key(12)]
        public byte IsScoreReset;
        
        /// <summary>
        /// 联赛账号，只用于展示和进入联赛时用。其他获取比赛数据不能使用
        /// </summary>
        [Key(13)]
        public int LeagueUserNameNumber;
    }

    [MessagePackObject]
    public class MatchPlayWayInfo
    {
        /// <summary>
        /// 玩法的唯一码
        /// </summary>
        [Key(0)]
        public string WeiYiMa;

        /// <summary>
        /// 最低分数限制
        /// </summary>
        [Key(1)]
        public int MinScore;

        /// <summary>
        /// 桌费数值，每人消耗    AA
        /// </summary>
        [Key(2)]
        public int DeskCost;

        /// <summary>
        /// 消耗方式 1AA 2大赢家
        /// </summary>
        [Key(3)]
        public int TypeMode;

        /// <summary>
        /// 最低分值免收桌费，大赢家低于免消耗    AA
        /// </summary>
        [Key(4)]
        public int MinFreeDeskCostNum;

        /// <summary>
        /// 是否第一局结束前解散不计房费  true是不计  false 否计算
        /// </summary>
        [Key(5)]
        public bool IsFirstCalcDeskCost;

        /// <summary>
        /// 小局低于多少分解散桌子
        /// </summary>
        [Key(6)]
        public int BuresMinScore;

        /// <summary>
        /// 是否开启小局低于多少分解散房间
        /// </summary>
        [Key(7)]
        public bool IsBuresMin;

        /// <summary>
        /// 是否开启 解散房间按实际局数计算比赛消耗
        /// </summary>
        [Key(8)]
        public bool IsRealCalcScore;

        /// <summary>
        /// 大赢家消耗规则
        /// </summary>
        [Key(9)]
        public List<MatchMaxWinnerScoreRange> MaxWinnerScoreRanges;

        /// <summary>
        /// 每次比赛联赛活跃积分,联赛使用 联盟长可以设置，群主只能看，成员不可见
        /// </summary>
        [Key(10)]
        public double LeagueDeskScore;
    }

    [MessagePackObject]
    public class MatchMaxWinnerScoreRange
    {
        [Key(0)]
        public int MaxWinnerMinScore;

        [Key(1)]
        public int DeskScore;
    }
}