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

namespace GameFix.Poker
{
    /// <summary>
    /// 全王炸弹
    /// </summary>
    public class CardStyleAllJokerBombHelper: CardStyleBaseHelper
    {
        public override int CardStyle => DataCardConst.CardStyleAllJokerBomb;
        public override int CardCnt => mCardCnt;

        private int mCardCnt = 4;

        public CardStyleAllJokerBombHelper() { }

        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="cardCnt">几个王起算炸</param>
        public CardStyleAllJokerBombHelper(int cardCnt)
        {
            mCardCnt = cardCnt;
        }
        
        internal override bool CheckStyleNormal(CardBaseGroup group, out CardStyleInfo cardStyleInfo)
        {
            cardStyleInfo = null;
            if (group.Cards.Count >= CardCnt)
            {
                var isOtherCards = group.Cards.Any(x=>!DataCardConst.JokerValues.Contains(x.Value));
                if (isOtherCards) return false;
                
                cardStyleInfo = CardStyleHelper.CreateCardStyleInfo(CardStyle, group.Cards);
                return true;
            }
            return false;
        }

        internal override bool CheckStyleWithLZ(CardBaseGroup group, out CardStyleInfo cardStyleInfo)
        { 
            // 癞子不当王
            cardStyleInfo = null;
            return false;
        }

        internal override List<CardGroupList> GetAllStyleCards(CardBaseGroup group, bool isSplitCard)
        { 
            List<CardGroupList> ret = new List<CardGroupList>();
            var jokerCards = group.SelfCards.Where(x=>DataCardConst.JokerValues.Contains(x.Value)).ToList();
            if (jokerCards.Count < CardCnt) return ret;
            CardGroupList cardGroupList = new CardGroupList();
            cardGroupList.AddRange(jokerCards);
            ret.Add(cardGroupList);
            return ret;
        }

        internal override List<CardGroupList> GetAllEatTipGroup(CardBaseGroup group, CardStyleInfo eatStyleInfo)
        {
            return GetAllStyleCards(group, false);
        }

        internal override List<CardGroupList> GetAllEatTipGroupWithLZ(CardBaseGroup group, CardStyleInfo eatStyleInfo)
        {
            // 癞子不当王
            return new List<CardGroupList>();
        }
    }
}