public int CompareTo(CardMatchInfo info) { if (info.matchType == matchType) { return(0); } return(matchType.CompareTo(info.matchType)); }
public static int EvaluateCardMatch(List <Card> card1, List <Card> card2, List <Card> communityCards) { List <Card> combinedCards1 = new List <Card>(card1); combinedCards1.AddRange(communityCards); List <Card> combinedCards2 = new List <Card>(card2); combinedCards2.AddRange(communityCards); combinedCards1.Sort((a, b) => b.rank.CompareTo(a.rank)); combinedCards2.Sort((a, b) => b.rank.CompareTo(a.rank)); CardMatchType p1MatchType = combinedCards1.GetCardMatchType(); CardMatchType p2MatchType = combinedCards2.GetCardMatchType(); // NOTE: Evaluate DRAW card matches if (p1MatchType == p2MatchType) { CardMatchType matchType = p1MatchType; Debug.Log($"DRAW matchType = {matchType}"); // NOTE: We will not compare for Royal Flush since it is the highest. // It automatically results into a draw and will fall under default switch (matchType) { case CardMatchType.ONE_PAIR: case CardMatchType.TWO_PAIR: case CardMatchType.THREE_OF_A_KIND: case CardMatchType.FOUR_OF_A_KIND: return(ComparePairCards(card1, card2, communityCards)); case CardMatchType.FLUSH: return(CompareFlushCards(card1, card2, communityCards)); case CardMatchType.STRAIGHT: case CardMatchType.STRAIGHT_FLUSH: return(CompareStraightCards(card1, card2, communityCards)); case CardMatchType.HIGH_CARDS: return(CompareHighCards(combinedCards1, combinedCards2)); default: return(0); } } return(-1 * p1MatchType.CompareTo(p2MatchType)); }