using System.Collections.Generic;
using GameMessage;

namespace GameFix.Poker
{
    /// <summary>
    /// 3带2张 特殊牌型
    /// 最后一手牌可以带一张或者不带
    /// </summary>
    public class CardStyle311SpecialHelper : CardStyleBaseHelper
    {
        public override int CardStyle => DataCardConst.CardStyle311;
        public override int CardCnt => 5;

        private readonly CardStyle311Helper _cardStyle311 = new();
        private readonly CardStyle31Helper _cardStyle31 = new();
        private readonly CardStyle3Helper _cardStyle3 = new();

        internal override bool CheckStyleNormal(CardBaseGroup group, out CardStyleInfo cardStyleInfo)
        {
            cardStyleInfo = null;
            if (group is not CardHandGroup) return false;
            bool isStyle = false;
            if (group.SelfCards.Count == _cardStyle3.CardCnt)
                isStyle = _cardStyle3.CheckStyleNormal(group, out cardStyleInfo);
            else if (group.SelfCards.Count == _cardStyle31.CardCnt)
                isStyle = _cardStyle31.CheckStyleNormal(group, out cardStyleInfo);
            else 
                isStyle = _cardStyle311.CheckStyleNormal(group, out cardStyleInfo);
            if (isStyle)
                cardStyleInfo.CardStyle = CardStyle;
            return isStyle;
        }

        internal override List<CardGroupList> GetAllEatTipGroup(CardBaseGroup group, CardStyleInfo eatStyleInfo)
        {
            if (group is not CardHandGroup) return new List<CardGroupList>();
            if (group.SelfCards.Count == _cardStyle3.CardCnt)
                return _cardStyle3.GetAllEatTipGroup(group, eatStyleInfo);
            if (group.SelfCards.Count == _cardStyle31.CardCnt)
                return _cardStyle31.GetAllEatTipGroup(group, eatStyleInfo);
            var allEatTipGroup = _cardStyle311.GetAllEatTipGroup(group, eatStyleInfo);
            return allEatTipGroup;
        }
    }
}