using System;
using MessagePack;
using Newtonsoft.Json;

namespace GameMessage.ShuangKou
{
    [MessagePackObject]
    public class ShuangKouS2CPack
    {
        [Key(0)]
        public int GameState;
        
        [Key(1)]
        public int IsConnect;
        
        [Key(2)]
        public int OptRole;
        
        [Key(3)]
        public int LastOptRole;
        
        [Key(4)]
        public int LastOutCardRole;
        
        [Key(5)]
        public int OptRoleTime;
        
        [Key(6)]
        public ShuangKouPlayerS2CPack[] Players;
        
        [Key(7)]
        public int TeamCard;

        [Key(8)]
        public int ErrorCode;

        [Key(9)]
        public bool IsClientShowHandCard;        

        [Key(10)]
        public bool IsGameOver;       
        
        [Key(11)]
        public GameDeskInfo GameDeskInfo;
        
        [Key(12)]
        public byte GameOverType;

        /// <summary>
        /// 还是自己的回合
        /// </summary>
        [IgnoreMember]
        public bool IsSelfNewRound => LastOptRole < 0 || LastOutCardRole == OptRole;
    }

    [Serializable]
    [MessagePackObject]
    public class ShuangKouPlayerS2CPack
    {
        [Key(0)]
        public CardStyleInfo CardStyleInfo;
        
        [Key(1)]
        public int ShouCardCnt;
        
        [Key(2)]
        public int[] ShouCardIds;

        [Key(3)]
        public int[] OutCardIds;

        [Key(4)]
        public int TeamId;              

        [Key(5)]
        public int OverIndex;

        [Key(6)]
        public int WinMoney;

        [Key(7)]
        public int WinScore;
        
        [Key(8)]
        public int BombScore;

        [Key(9)] public int[][] BombCardIds;
    }
    
    
    /// <summary>
    /// 客户端 - 服务器的操作包
    /// </summary>
    [MessagePackObject]
    public class ShuangKouC2SPack
    {
        /// <summary>
        /// 操作类型
        /// </summary>
        [Key(0)]
        public int OperateType;

        /// <summary>
        /// 操作的牌型
        /// </summary>
        [Key(1)]
        public CardStyleInfo OpCardStyleInfo;

        /// <summary>
        /// 操作值
        /// </summary>
        [Key(2)]
        public int[] Value;

        public static ShuangKouC2SPack Create(int operateType,int[] value,CardStyleInfo cardStyleInfo = null)
        {
            ShuangKouC2SPack pack = new ShuangKouC2SPack();
            pack.OperateType = operateType;
            pack.Value = value;
            pack.OpCardStyleInfo = cardStyleInfo;
            return pack;
        }
    }
}