using MessagePack;

namespace GameMessage.YunShan510K
{
    [MessagePackObject]
    public class YunShan510KS2CPack
    {
        [Key(0)]
        public int GameState;

        [Key(1)]
        public int IsConnect;

        [Key(2)]
        public int Banker;

        [Key(3)]
        public int Score;

        [Key(4)]
        public int OptRole;

        [Key(5)]
        public int LastOptRole;

        [Key(6)]
        public int LastOutCardRole;

        [Key(7)]
        public int OptRoleTime;

        [Key(8)]
        public YunShan510KPlayerS2CPack[] Players;

        [Key(9)]
        public int CallCard;

        [Key(10)]
        public int ErrorCode;

        [Key(11)]
        public int FightSingleRole;

        [Key(12)]
        public bool IsGameOver;

        /// <summary>
        /// 还是自己的回合
        /// </summary>
        [IgnoreMember]
        public bool IsSelfNewRound => LastOptRole < 0 || LastOutCardRole == OptRole;
    }
    
    [MessagePackObject]
    public class YunShan510KPlayerS2CPack
    {
        [Key(0)]
        public CardStyleInfo CardStyleInfo;

        [Key(1)]
        public int ShouCardCnt;

        [Key(2)]
        public int[] HandCardIds;

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

        [Key(4)]
        public int TeamId;

        [Key(5)]
        public int Score;

        [Key(6)]
        public int IsFightSingle;

        [Key(7)]
        public int OverIndex;

        [Key(8)]
        public int WinMoney;

        [Key(9)]
        public int AwardCount;
        
        [Key(10)]
        public int AwardScore;

        [Key(11)]
        public int WinScore;

        [Key(12)]
        public int CardStyleAwardScore;

        [Key(13)]
        public bool IsShowHandCards;
        
        [Key(14)] 
        public int[][] BombCardIds;
    }

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

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

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

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