using System;
using GameData;
using MessagePack;
using Newtonsoft.Json;

namespace GameMessage.WN27W
{
    [Serializable]
    [MessagePackObject]
    public class WN27WS2CDataPack
    {
        [JsonProperty("gs")]
        [Key(0)]
        public int GameState;

        [JsonProperty("con")]
        [Key(1)]
        public int IsConnect;
        
        [JsonProperty("bk")]
        [Key(2)]
        public int Banker;
        
        [JsonProperty("s")]
        [Key(3)]
        public int Score;
        
        [JsonProperty("opr")]
        [Key(4)]
        public int OptRole;
        
        [JsonProperty("opt")]
        [Key(5)]
        public int OptRoleTime;
        
        [JsonProperty("lcc")]
        [Key(6)]
        public int LostCardCnt;
        
        [JsonProperty("sci")]
        [Key(7)]
        public int[] StorageCardIds;
        
        [JsonProperty("sgc")]
        [Key(8)]
        public int[] ScoreGetCardIds;
        
        [JsonProperty("mst")]
        [Key(9)]
        public int MainSuit;
        
        [JsonProperty("ps")]
        [Key(10)]
        public WN27WS2CPlayerPack[] Players;

        [JsonProperty("ec")]
        [Key(11)]
        public int ErrorCode;
        
        // 结算相关
        [JsonProperty("pm")]
        [Key(12)]
        public int PublicMult; 
        
        [JsonIgnore]
        [Key(13)]
        public bool IsShowHandCards = false;

        [JsonProperty("islc")]
        [Key(14)]
        public bool IsShowLostCards = false;

        [JsonProperty("rwr")]
        [Key(15)]
        public int RoundWinRole { get; set; }
        
        [JsonProperty("rfr")]
        [Key(16)]
        public int RoundFirstRole { get; set; }

        [JsonProperty("sg")]
        [Key(17)]
        public int ScoreGeted { get; set; }

        [JsonProperty("fs")]
        [Key(18)]
        public int FinScore { get; set; }

        [JsonProperty("inr")]
        [Key(19)]
        public bool IsNewRound { get; set; }

        [JsonProperty("lor")]
        [Key(20)]
        public int LastOptRole { get; set; }

        [JsonProperty("gts")]
        [Key(21)]
        public int GameTriggerState { get; set; }
    }

    [Serializable]
    [MessagePackObject]
    public class WN27WS2CPlayerPack
    {
        [JsonProperty("csi")]
        [Key(0)]
        public CardStyleInfoExtend CardStyleInfo;
        
        [JsonProperty("scc")]
        [Key(1)]
        public int ShouCardCnt;
        
        [JsonProperty("csv")]
        [Key(2)]
        public int[] ShouCardIds;
        
        [JsonProperty("occ")]
        [Key(3)]
        public int OutCardCnt;
        
        [JsonProperty("ocv")]
        [Key(4)]
        public int[] OutCardIds;
        
        [JsonProperty("rr")]
        [Key(5)]
        public int[] RoundRecords;
        
        [JsonProperty("s")]
        [Key(6)]
        public int Score;
        
        [JsonProperty("gb")]
        [Key(7)]
        public int GrabBranker;

        [JsonProperty("mc")]
        [Key(8)]
        public bool MustCall;        
        
        [JsonProperty("ms")]
        [Key(9)]
        public int MultScore;  
        
        [JsonProperty("bs")]
        [Key(10)]
        public int BuyScore;        
        
        [JsonProperty("wm")]
        [Key(11)]
        public int WinMoney;

        [JsonProperty("pns")]
        [Key(12)]
        public int PunishScore { get; set; }

        [JsonProperty("ws")]
        [Key(13)]
        public int WinScore { get; set; }

        [JsonProperty("cbs")]
        [Key(14)]
        public int CallBuyScore { get; set; }
    }
    
    
    /// <summary>
    /// 客户端 - 服务器的操作包
    /// </summary>
    [MessagePackObject]
    public class WN27WC2SPack
    {
        /// <summary>
        /// 操作类型
        /// </summary>
        [Key(0)]
        public int OperateType;

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

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

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