using System;
using System.Collections.Generic;
using MessagePack;

#if GameClient
using GameFramework;
#endif

#if Server
using Server.Core;
#endif

namespace GameMessage
{
    /// <summary>
    /// 比赛报名请求
    /// </summary>
    [Message(MessageCode.JianCaiRaceCompetitionRequest)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionRequest : MessageData
    {
        /// <summary>
        /// 报名信息
        /// </summary>
        [Key(0)] public JianCaiRaceCompetitionInfo CompetitionInfo;

        /// <summary>
        /// 验证码
        /// </summary>
        [Key(1)] public string VerifyCode;

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

        public override void Clear()
        {
            CompetitionInfo = null;
            VerifyCode = null;
        }
#endif
    }

    /// <summary>
    /// 报名结果响应
    /// </summary>
    [Message(MessageCode.JianCaiRaceCompetitionResponse)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionResponse : MessageData
    {
        /// <summary>
        /// 报名结果错误码
        /// </summary>
        [Key(0)] public int ResultCode;

        /// <summary>
        /// 报名信息
        /// </summary>
        [Key(1)] public JianCaiRaceCompetitionInfo CompetitionInfo;

        /// <summary>
        /// 奖励
        /// </summary>
        [Key(2)] public ResData[] Reward;

#if Server
        public static JianCaiRaceCompetitionResponse Create()
        {
            JianCaiRaceCompetitionResponse self = ReferencePool.Fetch<JianCaiRaceCompetitionResponse>();
            self.ResultCode = 0;
            self.Reward = null;
            return self;
        }

        public override void Dispose()
        {
            ResultCode = 0;
            CompetitionInfo = null;
            Reward = null;
            ReferencePool.Recycle(this);
        }
#endif
    }

    /// <summary>
    /// 报名信息查询请求
    /// </summary>
    [Message(MessageCode.JianCaiRaceCompetitionInfoRequest)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfoRequest : MessageData
    {
        /// <summary>
        /// 查询的用户UserId，查询自己填0
        /// </summary>
        [Key(0)] public int UserId;

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

        public override void Clear()
        {
            UserId = 0;
        }
#endif
    }

    /// <summary>
    /// 报名信息查询响应
    /// </summary>
    [Message(MessageCode.JianCaiRaceCompetitionInfoResponse)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfoResponse : MessageData
    {
        /// <summary>
        /// 查询的用户UserId
        /// </summary>
        [Key(0)] public int UserId;

        [Key(1)] public int ResultCode;

        /// <summary>
        /// 自己的报名信息
        /// </summary>
        [Key(2)] public JianCaiRaceCompetitionInfo Self;

        /// <summary>
        /// 队友的报名信息
        /// </summary>
        [Key(3)] public JianCaiRaceCompetitionInfo Friend;

        /// <summary>
        /// 队友的游戏信息
        /// </summary>
        [Key(4)] public RaceGameInfo FriendGameInfo;

#if Server
        public static JianCaiRaceCompetitionInfoResponse Create(int userId)
        {
            JianCaiRaceCompetitionInfoResponse self = ReferencePool.Fetch<JianCaiRaceCompetitionInfoResponse>();
            self.ResultCode = 0;
            self.UserId = userId;
            return self;
        }

        public override void Dispose()
        {
            UserId = 0;
            Self = null;
            Friend = null;
            FriendGameInfo = null;

            ReferencePool.Recycle(this);
        }
#endif
    }

    [Message(MessageCode.JianCaiRaceCompetitionInfoByRaceIdRequest)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfoByRaceIdRequest : MessageData
    {
        [Key(0)] public string Tag;

        [Key(1)] public int RaceId;

#if GameClient
        public static JianCaiRaceCompetitionInfoByRaceIdRequest Create(string tag, int raceId)
        {
            JianCaiRaceCompetitionInfoByRaceIdRequest self =
                ReferencePool.Acquire<JianCaiRaceCompetitionInfoByRaceIdRequest>();
            self.Tag = tag;
            self.RaceId = raceId;
            return self;
        }

        public override void Clear()
        {
        }

#endif
    }

    [Message(MessageCode.JianCaiRaceCompetitionInfoByRaceIdResponse)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfoByRaceIdResponse : MessageData
    {
        [Key(0)] public string Tag;

        /// <summary>
        /// 自己的报名信息
        /// </summary>
        [Key(1)] public JianCaiRaceCompetitionInfo info;

        [Key(2)] public int UserId;

#if Server
        public static JianCaiRaceCompetitionInfoByRaceIdResponse Create(string tag)
        {
            JianCaiRaceCompetitionInfoByRaceIdResponse self =
                ReferencePool.Fetch<JianCaiRaceCompetitionInfoByRaceIdResponse>();
            self.Tag = tag;
            self.info = null;
            self.UserId = 0;
            return self;
        }

        public override void Dispose()
        {
            Tag = null;
            info = null;
            ReferencePool.Recycle(this);
        }
#endif
    }

    /// <summary>
    /// 建材比赛报名信息查询
    /// </summary>
    [Message(MessageCode.JianCaiRaceCompetitionInfoByPhoneRequest)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfoByPhoneRequest : MessageData
    {
        /// <summary>
        /// 手机号
        /// </summary>
        [Key(0)] public string PhoneNumber;
    }

    [Message(MessageCode.JianCaiRaceCompetitionInfoByPhoneResponse)]
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfoByPhoneResponse : MessageData
    {
        [Key(0)] public int ResultCode;

        /// <summary>
        /// 自己的报名信息
        /// </summary>
        [Key(1)] public JianCaiRaceCompetitionInfo Self;

        /// <summary>
        /// 队友的游戏信息
        /// </summary>
        [Key(2)] public RaceGameInfo FriendGameInfo;

#if Server
        public static JianCaiRaceCompetitionInfoByPhoneResponse Create()
        {
            JianCaiRaceCompetitionInfoByPhoneResponse self =
                ReferencePool.Fetch<JianCaiRaceCompetitionInfoByPhoneResponse>();
            self.ResultCode = 0;
            return self;
        }

        public override void Dispose()
        {
            this.Self = null;
            this.FriendGameInfo = null;

            ReferencePool.Recycle(this);
        }
#endif
    }

    /// <summary>
    /// 注册成为建材比赛的用户
    /// </summary>
    [Message(MessageCode.RegisterJianCaiBiSaiRequest)]
    [MessagePackObject]
    public class RegisterJianCaiBiSaiRequest : MessageData
    {
#if GameClient
        public static RegisterJianCaiBiSaiRequest Create()
        {
            RegisterJianCaiBiSaiRequest self = ReferencePool.Acquire<RegisterJianCaiBiSaiRequest>();
            return self;
        }

        public override void Clear()
        {
        }
#endif
    }

    /// <summary>
    /// 注册成为建材比赛用户的响应
    /// </summary>
    [Message(MessageCode.RegisterJianCaiBiSaiResponse)]
    [MessagePackObject]
    public class RegisterJianCaiBiSaiResponse : MessageData
    {
        /// <summary>
        /// 注册结果
        /// </summary>
        [Key(0)] public int ResultCode;

        /// <summary>
        /// 是否是注册
        /// </summary>
        [Key(1)] public bool IsRegister;

#if Server
        public static RegisterJianCaiBiSaiResponse Create()
        {
            RegisterJianCaiBiSaiResponse self = ReferencePool.Fetch<RegisterJianCaiBiSaiResponse>();
            self.IsRegister = false;
            return self;
        }

        public override void Dispose()
        {
            ReferencePool.Recycle(this);
        }

#endif
    }

    [Message(MessageCode.JianCaiGetTeammateApplyRequest)]
    [MessagePackObject]
    public class JianCaiGetTeammateApplyRequest : MessageData
    {
        /// <summary>
        /// 队友的比赛ID
        /// </summary>
        [Key(0)] public int FriendRaceId;

#if GameClient
        public static JianCaiGetTeammateApplyRequest Create(int friendRaceId)
        {
            JianCaiGetTeammateApplyRequest self = ReferencePool.Acquire<JianCaiGetTeammateApplyRequest>();
            self.FriendRaceId = friendRaceId;
            return self;
        }
#endif
    }

    [Message(MessageCode.JianCaiGetTeammateApplyResponse)]
    [MessagePackObject]
    public class JianCaiGetTeammateApplyResponse : MessageData
    {
        /// <summary>
        /// 成为队友信息结果
        /// </summary>
        [Key(0)] public int ResultCode;

        /// <summary>
        /// 队友的报名信息
        /// </summary>
        [Key(1)] public JianCaiRaceCompetitionInfo Friend;

        /// <summary>
        /// 队友的游戏信息
        /// </summary>
        [Key(2)] public RaceGameInfo FriendGameInfo;

#if Server
        public static JianCaiGetTeammateApplyResponse Create()
        {
            JianCaiGetTeammateApplyResponse self = ReferencePool.Fetch<JianCaiGetTeammateApplyResponse>();
            return self;
        }

        public override void Dispose()
        {
            Friend = null;
            FriendGameInfo = null;
            ReferencePool.Recycle(this);
        }
#endif
    }

    [Message(MessageCode.UnbindTeammateRequest)]
    [MessagePackObject]
    public class UnbindTeammateRequest : MessageData
    {
    }

    [Message(MessageCode.UnbindTeammateResponse)]
    [MessagePackObject]
    public class UnbindTeammateResponse : MessageData
    {
        /// <summary>
        /// 解除队友绑定
        /// </summary>
        [Key(0)] public int ResultCode;

#if Server
        public static UnbindTeammateResponse Create()
        {
            UnbindTeammateResponse self = ReferencePool.Fetch<UnbindTeammateResponse>();
            self.ResultCode = 0;
            return self;
        }

        public override void Dispose()
        {
            ReferencePool.Recycle(this);
        }
#endif
    }

    /// <summary>
    /// 建材比赛所有轮的信息
    /// </summary>
    [MessagePackObject]
    [Message(MessageCode.JianCaiRoundInfosRequest)]
    public class JianCaiRoundInfosRequest : MessageData
    {
    }

    [MessagePackObject]
    [Message(MessageCode.JianCaiRoundInfosResponse)]
    public class JianCaiRoundInfosResponse : MessageData
    {
        /// <summary>
        /// 轮次信息
        /// </summary>
        [Key(0)] public JianCaiRoundInfo[] RoundInfos;
    }

    [MessagePackObject]
    [Message(MessageCode.JianCaiRoundChouQianRequest)]
    public class JianCaiRoundChouQianRequest : MessageData
    {
        /// <summary>
        /// 抽签的轮次
        /// </summary>
        [Key(0)] public int RoundNumber;
    }

    [MessagePackObject]
    [Message(MessageCode.JianCaiRoundChouQianResponse)]
    public class JianCaiRoundChouQianResponse : MessageData
    {
    }

    [MessagePackObject]
    [Message(MessageCode.JianCaiDuiZhenInfosRequest)]
    public class JianCaiDuiZhenInfosRequest : MessageData
    {
        /// <summary>
        /// 对阵信息 大于0指定轮次获取 小于0获取当前轮信息(如果没有当前轮次，则获取所有轮次信息)
        /// </summary>
        [Key(0)] public int RoundNumber;
    }


    [MessagePackObject]
    [Message(MessageCode.JianCaiDuiZhenInfosResponse)]
    public class JianCaiDuiZhenInfosResponse : MessageData
    {
        /// <summary>
        /// 轮次信息
        /// </summary>
        [Key(0)] public JianCaiRoundInfo RoundInfo;

        /// <summary>
        /// 参赛者信息
        /// </summary>
        [Key(1)] public JianCaiPlayerInfo[] PlayerInfos;

        /// <summary>
        /// 队伍信息
        /// </summary>
        [Key(2)] public JianCaiTeamInfo[] TeamInfos;

        /// <summary>
        /// 桌子信息
        /// </summary>
        [Key(3)] public List<JianCaiTableInfo> TableInfos;

#if Server
        public static JianCaiDuiZhenInfosResponse Create()
        {
            JianCaiDuiZhenInfosResponse self = ReferencePool.Fetch<JianCaiDuiZhenInfosResponse>();
            return self;
        }

        public override void Dispose()
        {
            RoundInfo = null;
            PlayerInfos = null;
            TeamInfos = null;
            TableInfos = null;
            ReferencePool.Recycle(this);
        }
#endif
    }

    [Message(MessageCode.JianCaiBiSaiScoreImportRequest)]
    [MessagePackObject]
    public class JianCaiBiSaiScoreImportRequest : MessageData
    {
        [Key(0)]
        public int RoundNumber;

        [Key(1)]
        public TeamScoreInfo[] TeamInfos;
    }

    [Message(MessageCode.JianCaiBiSaiScoreImportResponse)]
    [MessagePackObject]
    public class JianCaiBiSaiScoreImportResponse : MessageData
    {
        [Key(0)]
        public int ResultCode;
    }

    /// <summary>
    /// 建材比赛信息
    /// </summary>
    [MessagePackObject]
    public class JianCaiRoundInfo
    {
        [Key(0)] public int RoundId;

        [Key(1)] public int RoundNumber;

        [Key(2)] // 0-未开始, 1-进行中, 2-已结束
        public int Status;

        [Key(3)] public long CreateTime;

        [Key(4)] public long StartTime;

        [Key(5)] public long EndTime;
    }

    /// <summary>
    /// 建材比赛参赛者信息
    /// </summary>
    [MessagePackObject]
    public class JianCaiPlayerInfo
    {
        [Key(0)] public int Id;

        [Key(1)] public int PlayerId;

        [Key(2)] public string Name;

        [Key(3)] public string Phone;

        [Key(4)] public int UserId;

        [Key(5)] public string Company;

        [Key(6)] public string Position;

        [Key(7)] public int TeamId;
    }

    [MessagePackObject]
    public class JianCaiTeamInfo
    {
        [Key(0)] public int TeamId;

        [Key(1)] public string TeamName;

        [Key(2)] public int Member1Id;

        [Key(3)] public int Member2Id;

        [Key(4)] public int TotalScore;
    }

    [MessagePackObject]
    public class JianCaiTableInfo
    {
        [Key(0)] public int TableId;

        [Key(1)] public int TableNumber;

        [Key(2)] public int RoundId;

        [Key(3)] public int Team1Id;

        [Key(4)] public int Team2Id;

        [Key(5)] public int Team1Score;

        [Key(6)] public int Team2Score;
    }

    /// <summary>
    /// 报名信息
    /// </summary>
    [MessagePackObject]
    public class JianCaiRaceCompetitionInfo
    {
        /// <summary>
        /// 参赛ID
        /// </summary>
        [Key(0)] public int RaceId;

        /// <summary>
        /// 姓名
        /// </summary>
        [Key(1)] public string RealName;

        /// <summary>
        /// 手机号
        /// </summary>
        [Key(2)] public string PhoneNumber;

        /// <summary>
        /// 公司
        /// </summary>
        [Key(3)] public string Company;

        /// <summary>
        /// 职位
        /// </summary>
        [Key(4)] public string Position;
    }

    /// <summary>
    /// 游戏信息
    /// </summary>
    [MessagePackObject]
    public class RaceGameInfo
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        [Key(0)] public int UserId;
    }

    /// <summary>
    /// 队伍的分数
    /// </summary>
    [MessagePackObject]
    public class TeamScoreInfo
    {
        [Key(0)]
        public string TeamName;
        [Key(1)]
        public int Score;
    }
}