public BaseRankedHand GetHighestMadeRankedHand() { highestMadeRankedHand = new HandStraightFlush(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandFourOfAKind(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } // SEVEN-UP // Modified for Seven-Up. Flush beats Full House. highestMadeRankedHand = new HandFlush(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandFullHouse(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandStraight(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandThreeOfAKind(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandTwoPair(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandOnePair(_cards); if (highestMadeRankedHand.IsMade()) { return(highestMadeRankedHand); } highestMadeRankedHand = new HandHighCard(_cards); return(highestMadeRankedHand); }
/// <summary> /// Static Utility method /// </summary> /// <param name="pRankedHand1"></param> /// <param name="pRankedHand2"></param> /// <returns> /// return -2 if no winner /// return -1 if 1 wins /// return 0 if tie /// return 1 if 2 wins /// </returns> public static int CompareRankedHands(BaseRankedHand pRankedHand1, BaseRankedHand pRankedHand2) { bool tIsHand1Made = pRankedHand1.IsMade(); bool tIsHand2Made = pRankedHand2.IsMade(); if (tIsHand1Made && tIsHand2Made) { // Determine if one it's a tie or one of them is the winner return(pRankedHand1.CompareSameRankHand(pRankedHand2)); } else if (tIsHand1Made) { return(-1); } else if (tIsHand2Made) { return(1); } ; // no winner return(-2); }