using MessagePack;
#if GameClient
using GameFramework;
#endif

namespace GameMessage
{
    /// <summary>
    /// 俱乐部比赛信息请求
    /// </summary>
    [Message(MessageCode.ClubMatchScoreRequest)]
    [MessagePackObject]
    public class ClubMatchScoreRequest : MessageData
    {
        /// <summary>
        /// 俱乐部id
        /// </summary>
        [Key(0)]
        public int ClubId;

#if GameClient
        public static ClubMatchScoreRequest Create(int clubId)
        {
            ClubMatchScoreRequest request = ReferencePool.Acquire<ClubMatchScoreRequest>();
            request.ClubId = clubId;
            return request;
        }
#endif
    }
    
    /// <summary>
    /// 俱乐部比赛信息响应
    /// </summary>
    [Message(MessageCode.ClubMatchScoreResponse)]
    [MessagePackObject]
    public class ClubMatchScoreResponse : MessageData
    {
        /// <summary>
        /// 俱乐部id
        /// </summary>
        [Key(0)]
        public int ClubId;
        
        /// <summary>
        /// 是否开启比赛
        /// </summary>
        [Key(1)]
        public bool IsOpenMatch;

        /// <summary>
        /// 比赛积分。开始了才有值
        /// </summary>
        [Key(2)]
        public double Score;

        /// <summary>
        /// 淘汰分
        /// </summary>
        [Key(3)]
        public double ScoreBak;

        /// <summary>
        /// 0 不是联赛 其他值是联赛俱乐部id
        /// </summary>
        [Key(4)]
        public int LeagueClubId;

        /// <summary>
        /// 比赛结束时间
        /// </summary>
        [Key(5)]
        public long MatchEndTime;

        /// <summary>
        /// 是否显示淘汰分 1显示 0不显示(默认)
        /// </summary>
        [Key(6)]
        public byte IsVisibleScoreBak;

        /// <summary>
        /// 是否是联赛管理员
        /// </summary>
        [Key(7)]
        public bool IsLeagueAdmin;
    }

    /// <summary>
    /// 修改玩家俱乐部积分请求
    /// </summary>
    [Message(MessageCode.EditorClubMatchScoreRequest)]
    [MessagePackObject]
    public class EditorClubMatchScoreRequest : MessageData
    {
        /// <summary>
        /// 俱乐部id
        /// </summary>
        [Key(0)]
        public int ClubId;
        
        /// <summary>
        /// 玩家积分信息
        /// </summary>
        [Key(1)]
        public UserScorePack[] UserScores;

#if GameClient
        public static EditorClubMatchScoreRequest Create(int clubId)
        {
            EditorClubMatchScoreRequest request = ReferencePool.Acquire<EditorClubMatchScoreRequest>();
            request.ClubId = clubId;
            return request;
        }

        public override void Clear()
        {
            UserScores = null;
        }
#endif
    }
    
    /// <summary>
    /// 修改玩家俱乐部积分响应
    /// </summary>
    [Message(MessageCode.EditorClubMatchScoreResponse)]
    [MessagePackObject]
    public class EditorClubMatchScoreResponse : MessageData
    {
        /// <summary>
        /// 俱乐部id
        /// </summary>
        [Key(0)]
        public int ClubId;
        
        /// <summary>
        /// 结果码
        /// </summary>
        [Key(1)]
        public int ResultCode;

        /// <summary>
        /// 操作的玩家积分信息
        /// </summary>
        [Key(2)]
        public UserScorePack[] UserScores;
    }

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

        /// <summary>
        /// 加多少分值，减多少
        /// </summary>
        [Key(1)]
        public double Score;
    }

    /// <summary>
    /// 玩家比赛积分请求
    /// </summary>
    [Message(MessageCode.PlayerMatchScoreRequest)]
    [MessagePackObject]
    public class PlayerMatchScoreRequest : MessageData
    {
        /// <summary>
        /// 玩家的UserId
        /// </summary>
        [Key(0)]
        public int PlayerUserId;

        /// <summary>
        /// 玩家
        /// </summary>
        [Key(1)]
        public int ClubId;
        
        #if GameClient
        public static PlayerMatchScoreRequest Create(int playerUserId, int clubId)
        {
            PlayerMatchScoreRequest request = ReferencePool.Acquire<PlayerMatchScoreRequest>();
            request.PlayerUserId = playerUserId;
            request.ClubId = clubId;
            return request;
        }
        #endif
    }
    
    /// <summary>
    /// 玩家比赛积分响应
    /// </summary>
    [Message(MessageCode.PlayerMatchScoreResponse)]
    [MessagePackObject]
    public class PlayerMatchScoreResponse : MessageData
    {
        [Key(0)]
        public int PlayerUserId;

        [Key(1)]
        public int ClubId;

        [Key(2)]
        public double Score;
    }
}