public static bool TryFind(Card[] orderedCards, bool[] cards_equality_by_value_helper, out FourOfAKindHand hand) { int startIndx = 0; int count = 1; for (int i = 1; i < orderedCards.Length; i++) { if (cards_equality_by_value_helper[i - 1]) { count++; if (count >= 4) { break; } } else { startIndx = i; count = 1; } } if (count < 4) { hand = null; return false; } hand = new FourOfAKindHand() { Card1 = orderedCards[startIndx], Card2 = orderedCards[startIndx + 1], Card3 = orderedCards[startIndx + 2], Card4 = orderedCards[startIndx + 3], }; hand.Kickers = HandHelper.GetKickers(orderedCards, 1, hand.Card1, hand.Card2, hand.Card3, hand.Card4); return true; }
public static bool TryFind(Card[] orderedCards, out FourOfAKindHand hand) { int startIndx = 0; int count = 1; Card sampleCard = orderedCards[0]; for (int i = 1; i < orderedCards.Length; i++) { Card card = orderedCards[i]; if (CardComparer.IsEqualByValue(sampleCard, card)) { count++; if (count >= 4) { break; } } else { startIndx = i; count = 1; sampleCard = card; } } if (count < 4) { hand = null; return false; } hand = new FourOfAKindHand() { Card1 = orderedCards[startIndx], Card2 = orderedCards[startIndx + 1], Card3 = orderedCards[startIndx + 2], Card4 = orderedCards[startIndx + 3], }; hand.Kickers = HandHelper.GetKickers(orderedCards, 1, hand.Card1, hand.Card2, hand.Card3, hand.Card4); return true; }