using System;
using MessagePack;

namespace GameMessage.Wlong
{
    [Serializable]
    [MessagePackObject]
    public class WlongGameS2CPack
    {
        [Key(0)]
        public int GameState;

        [Key(1)]
        public int IsConnect;
        
        [Key(2)]
        public int Banker;
        
        [Key(3)]
        public int DeskScore;
        
        [Key(4)]
        public int OptRole;
        
        [Key(5)]
        public int LastOptRole;
        
        [Key(6)]
        public int LastOutCardRole;
        
        [Key(7)]
        public int OptRoleTime;
        
        [Key(8)]
        public WlongPlayerS2CPack[] Players;

        [Key(9)]
        public int ErrorCode;

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

    [Serializable]
    [MessagePackObject]
    public class WlongPlayerS2CPack
    {
        [Key(0)]
        public CardStyleInfo CardStyleInfo;
        
        [Key(1)]
        public int HandCardCnt;
        
        [Key(2)]
        public int[] HandCardIds;
        
        [Key(3)]
        public int OutCardCnt;
        
        [Key(4)]
        public int[] OutCardIds;
        
        [Key(5)]
        public int JokerCardCount;
        
        [Key(6)]
        public int FinAwardCount;
        
        [Key(7)]
        public int DuanScore;        
        
        [Key(8)]
        public int AwardCount;
        
        [Key(9)]
        public int ScoreCount;

        [Key(10)] 
        public int AwardScore;
        
        [Key(11)]
        public bool IsShowHandCards;
        
        [Key(12)]
        public int WinMoney;
                
        [Key(13)]
        public bool IsBanker;
        
        [Key(14)]
        public sbyte OverIndex;
        
        [Key(15)]
        public bool IsAuto;

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

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

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

        /// <summary>
        /// 是否自动操作
        /// </summary>
        [Key(3)]
        public bool IsAuto;

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