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

namespace GameFix.Poker
{
    /// <summary>
    /// 多副510K (可带 5，10，k单牌)
    /// </summary>
    public class CardStyle510KMultExtendHelper : CardStyle510KMultHelper
    {
        public CardStyle510KMultExtendHelper(int mult) : base(mult)
        {
        }

        internal override List<CardGroupList> GetAllStyleCards(CardBaseGroup group, bool isSplitCard)
        {
            List<CardGroupList> ret = new List<CardGroupList>();
            var c510KList = CardFunc.Get510KList(group.SelfCards, _mult);
            if (c510KList.Count > 0)
            {
                // 剩下得 5 10 k也添加上
                var c510KGroup = new CardGroupList(c510KList.SelectMany(x => x));
                var c510KCards = group.SelfCards.Where(x => V_510K.Contains(x.Value)).ToList();
                c510KGroup.AddRange(c510KCards);
                ret.Add(c510KGroup);
            }
            return ret;
        }
        
        internal override bool CheckStyleNormal(CardBaseGroup group, out CardStyleInfo cardStyleInfo)
        {
            cardStyleInfo = null;
            if (group.Cards.Count >= CardCnt)
            {
                var c510KList = CardFunc.Get510KList(group.Cards, _mult);
                var c510KListLong = c510KList.SelectMany(x => x).ToList();
                var remainCardList = group.Cards.Where(x => !c510KListLong.Contains(x) && V_510K.Contains(x.Value)).ToList();

                if (remainCardList.Count + c510KListLong.Count == group.Cards.Count)
                {
                    cardStyleInfo = new CardStyleInfo(CardStyle, 0, c510KList.Count);
                    cardStyleInfo.CustomInt = c510KList.Count; // 510K的个数
                    return true;
                }
            }
            return false;
        }
    }
}