using System.Collections.Generic;
using System.Linq;

namespace GameFix.Poker
{
    public class DataCardConst
    { 
        public const byte CardTypeNormal = 1; // 普通牌
        public const byte CardTypeLZ = 2; // 癞子牌
        public const byte CardTypeMain = 1 << 2; // 主牌
        public const byte CardTypeSecond = 1 << 3; // 副牌
        
        /// <summary>
        /// 黑桃
        /// </summary>
        public const byte SuitSpade = 1;

        /// <summary>
        /// 红桃
        /// </summary>
        public const byte SuitHeart = 2;

        /// <summary>
        /// 梅花
        /// </summary>
        public const byte SuitClub = 3;

        /// <summary>
        /// 方块
        /// </summary>
        public const byte SuitDiamond = 4;

        /// <summary>
        /// 王
        /// </summary>
        public const byte SuitJoker = 5;

        /// <summary>
        /// 无牌型
        /// </summary>
        public const byte CardStyle0 = 0;

        /// <summary>
        /// 单张
        /// </summary>
        public const byte CardStyle1 = 1;

        /// <summary>
        /// 对子
        /// </summary>
        public const byte CardStyle2 = 2;

        /// <summary>
        /// 三张
        /// </summary>
        public const byte CardStyle3 = 3;

        /// <summary>
        /// 炸弹 （四张以上）
        /// </summary>
        public const byte CardStyleBomb = 4;

        /// <summary>
        /// 火箭
        /// </summary>
        public const byte CardStyle5 = 5;

        /// <summary>
        /// 顺子
        /// </summary>
        public const byte CardStyle123 = 6;

        /// <summary>
        /// 双顺 （3个起）
        /// </summary>
        public const byte CardStyle112233 = 7;

        /// <summary>
        /// 三顺
        /// </summary>
        public const byte CardStyle111222 = 8;

        /// <summary>
        /// 三带一
        /// </summary>
        public const byte CardStyle31 = 9;

        /// <summary>
        /// 三带对
        /// </summary>
        public const byte CardStyle32 = 10;

        /// <summary>
        /// 四带两张或者一对
        /// </summary>
        public const byte CardStyle41 = 11;

        /// <summary>
        /// 四带两对
        /// </summary>
        public const byte CardStyle42 = 12;

        /// <summary>
        /// 飞机带单张
        /// </summary>
        public const byte CardStyle331 = 13;

        /// <summary>
        /// 飞机带对子
        /// </summary>
        public const byte CardStyle332 = 14;
        
        /// <summary>
        /// 双顺 （2个起）
        /// </summary>
        public const byte CardStyle1122 = 15;
        
        /// <summary>
        /// 510K
        /// </summary>
        public const byte CardStyle510K = 16;
        
        /// <summary>
        /// 正510K
        /// </summary>
        public const byte CardStyle510KPlus = 17;
        
        /// <summary>
        /// 三带两张
        /// </summary>
        public const byte CardStyle311 = 18;
        
        /// <summary>
        /// 飞机带两张
        /// </summary>
        public const byte CardStyle3311 = 19;
        
        /// <summary>
        /// 带王炸弹 （四张以上）
        /// </summary>
        public const byte CardStyleJokerBomb = 20;
        
        /// <summary>
        /// 甩牌牌型
        /// </summary>
        public const byte CardStylePutCards = 21;
        
        /// <summary>
        /// 三顺 (3个起)
        /// </summary>
        public const byte CardStyle111222333 = 22;
        
        /// <summary>
        /// 全王炸弹
        /// </summary>
        public const byte CardStyleAllJokerBomb = 23;
        
        /// <summary>
        /// 连炸 （3连以上）
        /// </summary>
        public const byte CardStyleBomb123 = 24;
        
        /// <summary>
        /// 连炸 （2连以上）
        /// </summary>
        public const byte CardStyleBomb12 = 25;
        
        /// <summary>
        /// 单牌炸弹
        /// </summary>
        public const byte CardStyleBomb1 = 26;
        
        /// <summary>
        /// 对子炸弹
        /// </summary>
        public const byte CardStyleBomb2 = 27;
        
        /// <summary>
        /// 多副510K
        /// </summary>
        public const byte CardStyle510KMult = 28;


        #region 牌值

        public const byte CardValue2 = 16;
        public const byte CardValue3 = 3;
        public const byte CardValue5 = 5;
        public const byte CardValue10 = 10;
        public const byte CardValueK = 13;
        public const byte CardValueSmallJoker = 18;
        public const byte CardValueBigJoker = 19;

        #endregion
        
        // 花色
        public static readonly byte[] CardSuits = new byte[]
        {
            SuitSpade, SuitHeart, SuitClub, SuitDiamond,
        };
        
        // A-K
        public static readonly byte[] CardValues = new byte[]
        {
            14, 16, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
        };
        
        public static readonly string[] CardValueText = new string[]
        {
            "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"
        };

        // 小王 大王
        public static readonly byte[] JokerValues = new byte[]
        {
            18, 19
        };

        public static readonly Dictionary<int, string> CardStyleReadableText = new Dictionary<int, string>()
        {
            {CardStyle0, "无牌型" },
            {CardStyle1, "单张" },
            {CardStyle2, "对子" },
            {CardStyle3, "三张" },
            {CardStyleBomb, "炸弹" },
            {CardStyleJokerBomb, "炸弹" },
            {CardStyle5, "火箭" },
            {CardStyle31, "三带一" },
            {CardStyle311, "三带两张" },
            {CardStyle32, "三带二" },
            {CardStyle41, "四带两张或者一对" },
            {CardStyle42, "四带两对" },
            {CardStyle331, "飞机带单张" },
            {CardStyle3311, "飞机带两张" },
            {CardStyle332, "飞机带对子" },
            {CardStyle123, "顺子" },
            {CardStyle112233, "双顺" },
            {CardStyle111222, "三顺" },
            {CardStyle1122, "双顺" },
            {CardStyle510K, "副510K" },
            {CardStyle510KPlus, "正510K" },
            {CardStylePutCards, "甩牌" },
            {CardStyleAllJokerBomb, "王炸" },
            {CardStyleBomb1, "单牌炸" },
            {CardStyleBomb2, "对子炸" },
            {CardStyle510KMult, "多510K"}
        };
        
        public static bool IsJoker(Card card)
        {
            return JokerValues.Contains(card.Value);
        }
    }
}