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

namespace GameMessage
{
    /// <summary>
    /// 获取定时赛数据积分比赛记录请求
    /// </summary>
    [Message(MessageCode.GetFixedMatchDataByIdRequest)]
    [MessagePackObject()]
    public class GetFixedMatchDataByIdRequest : MessageData
    {
#if GameClient
        public static GetFixedMatchDataByIdRequest Create()
        {
            return ReferencePool.Acquire<GetFixedMatchDataByIdRequest>();
        }
#endif
    }

    /// <summary>
    /// 获取定时赛数据积分比赛记录响应
    /// </summary>
    [Message(MessageCode.GetFixedMatchDataByIdResponse)]
    [MessagePackObject()]
    public class GetFixedMatchDataByIdResponse : MessageData
    {
        [Key(0)] public byte[] Data;
    }

    /// <summary>
    /// 获取回放数据请求
    /// </summary>
    [Message(MessageCode.GetWarPlayerBackDataRequest)]
    [MessagePackObject()]
    public class GetWarPlayerBackDataRequest : MessageData
    {
        [Key(0)] public string Key;

#if GameClient
        public static GetWarPlayerBackDataRequest Create(string key)
        {
            GetWarPlayerBackDataRequest request = ReferencePool.Acquire<GetWarPlayerBackDataRequest>();
            request.Key = key;
            return request;
        }
#endif
    }

    /// <summary>
    /// 获取回放数据响应
    /// </summary>
    [Message(MessageCode.GetWarPlayerBackDataResponse)]
    [MessagePackObject()]
    public class GetWarPlayerBackDataResponse : MessageData
    {
        [Key(0)] public byte[] Data;
    }

    [Message(MessageCode.GetYearMatchInfoRequest)]
    [MessagePackObject]
    public class GetYearMatchInfoRequest : MessageData
    {
        
#if GameClient
        public static GetYearMatchInfoRequest Create()
        {
            return ReferencePool.Acquire<GetYearMatchInfoRequest>();
        }
#endif
    }

    [Message(MessageCode.GetYearMatchInfoResponse)]
    [MessagePackObject]
    public class GetYearMatchInfoResponse : MessageData
    {
        [Key(0)]
        public byte[] Data;
    }

    [MessagePackObject]
    public class YearMatchInfo
    {
        [Key(0)]
        public int GameId;

        [Key(1)]
        public MatchInfoConfig Config;

        [Key(2)]
        public List<MatchFixedTimeInfo> TimeList;
    }

    [MessagePackObject]
    public class YearMatchInfoLists
    {
        [Key(0)]
        public List<YearMatchInfo> YearMatchInfos;
    }

    [MessagePackObject]
    public class MatchInfoConfig
    {
        /// <summary>
        /// 比赛配置Id,这里的ID，AIWork 会配置对应的AI
        /// </summary>
        [Key(0)]
        public int Id;

        /// <summary>
        /// 游戏Id 服务器Id
        /// </summary>
        [Key(1)]
        public int GameId;

        /// <summary>
        /// 人数，满多少人后开赛  这个数值是分组人数的倍数
        /// </summary>
        [Key(2)]
        public int PeopleCount;

        /// <summary>
        /// 分组人数
        /// </summary>
        [Key(3)]
        public int GamePeopleCount;

        /// <summary>
        /// 一轮信息，几轮就几个记录
        /// </summary>
        [Key(4)]
        public List<LunConfig> LunConfigs;

        /// <summary>
        /// 报名费用
        /// </summary>
        [Key(5)]
        public int Money;

        /// <summary>
        /// 费用类型 1游戏币 2参赛卷 3门票 
        /// </summary>
        [Key(6)]
        public int Type;

        /// <summary>
        /// 比赛名称
        /// </summary>
        [Key(7)]
        public string Title;

        /// <summary>
        /// 比赛标签
        /// *可以投诉
        /// GNHD 这种标签的时间不止2天  2024年1月20日16:40:23
        /// </summary>
        [Key(8)]
        public string Tag;

        /// <summary>
        /// 比赛开始时间 一天
        /// </summary>
        [Key(9)]
        public long StartTime;

        /// <summary>
        /// 比赛结束时间 一天
        /// </summary>
        [Key(10)]
        public long EndTime;

        /// <summary>
        /// 比赛开始日期
        /// </summary>
        [Key(11)]
        public long StartDay;

        /// <summary>
        /// 比赛结束日期
        /// </summary>
        [Key(12)]
        public long EndDay;

        /// <summary>
        /// 比赛类型 1定局积分比赛  2打立出局比赛 --未使用
        /// </summary>
        [Key(13)]
        public byte MatchType;

        /// <summary>
        /// 开始类型 1人满即开 2定时开
        /// </summary>
        [Key(14)]
        public byte StartType;

        /// <summary>
        /// 间隔分钟  间隔时间不能超过一天（包含）。要不计算时间有误
        /// </summary>
        [Key(15)]
        public int StepMinute;

        /// <summary>
        /// 2定时开使用。每次下一次开赛的时间 --未使用
        /// </summary>
        [Key(16)]
        public long NextStartTime;

        /// <summary>
        /// 比赛最大不能超过的人数
        /// </summary>
        [Key(17)]
        public int MaxPeopleCount;

        /// <summary>
        /// 这个比赛几个房间使用
        /// </summary>
        [Key(18)]
        public int Rooms;

        /// <summary>
        /// 身上不能低于多少游戏币
        /// </summary>
        [Key(19)]
        public int Money1;

        /// <summary>
        /// 比赛的奖品
        /// </summary>
        [Key(20)]
        public List<MatchPrize> Prizes;

        /// <summary>
        /// 限进超过这个游戏币就不让报名，0不起作用
        /// </summary>
        [Key(21)]
        public int MaxMoney = 0;

        /// <summary>
        /// 如果该字段有值的话，那说明只有该名单下的玩家才可以报名
        /// </summary>
        /// JsonIgnore 为什么不要忽略标签，是为了界面可以反序列化出来再改动里面的值
        /// 以后做一个工具来动态的修改该字段。 给比赛做了界面来配置的话，做删除比赛之前得判断报名和开赛的情况
        [Key(22)]
        public List<int> Users = null; //

        /// <summary>
        /// 比赛是否有积分
        /// </summary>
        [Key(23)]
        public bool IsHaveScore = false;

        /// <summary>
        /// 是否保存战斗数据
        /// </summary>
        //JsonIgnore 为什么不要忽略标签，是为了界面可以反序列化出来再改动里面的值
        [Key(24)]
        public bool IsSaveWarFile = false;

        /// <summary>
        /// 信誉分，玩家低于信誉分就不让玩游戏
        /// </summary>
        [Key(25)]
        public int CreditNum = 0;

        /// <summary>
        /// 多扣多少倍的税收。1就是在金币场的基础上多收一倍。0就是不多收金币场的税收
        /// </summary>
        [Key(26)]
        public int ShuiBei = 0;

        /// <summary>
        /// 比赛报名方式，允许多种报名方式就配置多个记录
        /// </summary>
        [Key(27)]
        public List<MatchEnlistCostType> EnlistRes = null;

        /// <summary>
        /// 创建比赛的用户id
        /// </summary>
        [Key(28)]
        public int CreateUser;

        /// <summary>
        /// 比赛密码，有密码的比赛需要输入密码才能比赛
        /// </summary>
        [Key(29)]
        public string Password;

        /// <summary>
        /// 比赛说明 例如规则什么的
        /// </summary>
        [Key(30)]
        public string Memo;

        /// <summary>
        /// 机器人轮空概率
        /// </summary>
        [Key(31)]
        public int RobotLunKongChance;

        /// <summary>
        /// 机器人复活概率
        /// </summary>
        [Key(32)]
        public int RobotRebornChance;

        /// <summary>
        /// 机器人数量
        /// </summary>
        [Key(33)]
        public int[] RobotCount;


        /// <summary>
        /// 比赛倍率
        /// </summary>
        [Key(34)]
        public int RaceBeiLv;

        /// <summary>
        /// 比赛税收
        /// </summary>
        [Key(35)]
        public int RaceShui;
    }

    [MessagePackObject]
    public class LunConfig
    {
        [Key(0)]
        public int Id;
        
        /// <summary>
        /// 一轮有几局，每一轮的局数都不是固定的
        /// </summary>
        [Key(1)]
        public byte LunGameCount;

        /// <summary>
        /// 每轮晋级人数，如果发现最后晋级0人的话说明比赛结束
        /// </summary>
        [Key(2)]
        public int LunPromotionCount;

        /// <summary>
        /// 使用复活卡数量
        /// </summary>
        [Key(3)]
        public int UserReviveCount = 0;

        /// <summary>
        /// 等待的玩家操作的秒数
        /// </summary>
        [Key(4)]
        public int Second = 0;
    }

    [MessagePackObject]
    public class MatchPrize
    {
        /// <summary>
        /// 名次
        /// </summary>
        [Key(0)]
        public int Index;

        /// <summary>
        /// 奖励的游戏币
        /// </summary>
        [Key(1)]
        public int Winmoney;

        /// <summary>
        /// 奖励的礼券
        /// </summary>
        [Key(2)]
        public int Wincoupon;

        /// <summary>
        /// 房卡
        /// </summary>
        [Key(3)]
        public int CarNum;

        /// <summary>
        /// 红包积分--1积分等于1分
        /// </summary>
        [Key(4)]
        public int RedEnvelopes;
        
        /// <summary>
        /// 参赛券
        /// </summary>
        [Key(5)]
        public int CanSaiJuan;

        /// <summary>
        /// 都市放心购电子券，值是放心购卡的面值。比如20，就是放心购20元的电子券
        /// </summary>
        [Key(6)]
        public int DSFXGVoucherNum;

        /// <summary>
        /// 复活卡
        /// </summary>
        [Key(7)]
        public int FuHuoKa;
    }

    [MessagePackObject]
    public class MatchEnlistCostType
    {
        /// <summary>
        /// 类型 1游戏币 2参赛卷 3门票 4礼券 5红包券 6比赛积分 7钻石（服务器判断积分满足不满足，下面的数值就代表满足多少积分免费）
        /// </summary>
        [Key(0)]
        public int Type;

        /// <summary>
        /// 数值
        /// </summary>
        [Key(1)]
        public int Money;
    }

    [MessagePackObject]
    public class MatchFixedTimeInfo
    {
        /// <summary>
        /// 比赛配置Id
        /// </summary>
        [Key(0)]
        public int SessionsId;

        /// <summary>
        /// 开始时间列表
        /// </summary>
        [Key(1)]
        public long StartTime;
    }
    
}