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

namespace GameFix.Poker
{
    /// <summary>
    /// 多副510K
    /// </summary>
    public class CardStyle510KMultHelper : CardStyleBaseHelper
    {
        public override int CardStyle => DataCardConst.CardStyle510KMult;
        public override int CardCnt { get; } = 0;
        protected int _mult;
        protected List<int> V_510K = new List<int>(){DataCardConst.CardValue5, DataCardConst.CardValue10, DataCardConst.CardValueK};

        /// <summary>
        /// 几幅起算
        /// </summary>
        public CardStyle510KMultHelper(int mult)
        {
            CardCnt = mult * 3;
            _mult = mult;
        }
        
        internal override bool CheckStyleNormal(CardBaseGroup group, out CardStyleInfo cardStyleInfo)
        {
            cardStyleInfo = null;
            if (group.Cards.Count >= CardCnt)
            {
                var c510KList = CardFunc.Get510KList(group.Cards, _mult);

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

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

        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)
                ret.Add(new CardGroupList(c510KList.SelectMany(x=>x)));
            return ret;
        }
    }
}