/// <summary> /// Initialize the hand. /// </summary> /// <param name="C1">The first of 5 cards.</param> /// <param name="C2">The second of 5 cards.</param> /// <param name="C3">The third of 5 cards.</param> /// <param name="C4">The fourth of 5 cards.</param> /// <param name="C5">The fifth of 5 cards.</param> /// <param name="EvalTable">An instance of the PokerHandList class.</param> /// <remarks>As this class initializes, it will calculate /// its "Key" value based on the cards held, and get its rank /// and description from the PokerHandList instance passed in /// by using the calculated Key value, /// which will allow the user of this class to compare /// this hand to other hands for the purpose of declaring /// winning, losing, or tied hands.</remarks> public Hand(Card C1, Card C2, Card C3, Card C4, Card C5, PokerHandRankingTable EvalTable) { int key; this.mC1 = C1; this.mC2 = C2; this.mC3 = C3; this.mC4 = C4; this.mC5 = C5; key = (int)mC1.CardValue * (int)mC2.CardValue * (int)mC3.CardValue * (int)mC4.CardValue * (int)mC5.CardValue; if (mC1.CardSuit == mC2.CardSuit && mC2.CardSuit == mC3.CardSuit && mC3.CardSuit == mC4.CardSuit && mC4.CardSuit == mC5.CardSuit) { //flush keys are negative to differentiate them //from non-flush hands of the same 5 card values key *= -1; } mEvalHand = EvalTable.EvalHands[key]; }
/// <summary> /// Initialize the hand. /// </summary> /// <param name="C1">The first of 5 cards.</param> /// <param name="C2">The second of 5 cards.</param> /// <param name="C3">The third of 5 cards.</param> /// <param name="C4">The fourth of 5 cards.</param> /// <param name="C5">The fifth of 5 cards.</param> /// <param name="EvalTable">An instance of the PokerHandList class.</param> /// <remarks>As this class initializes, it will calculate /// its "Key" value based on the cards held, and get its rank /// and description from the PokerHandList instance passed in /// by using the calculated Key value, /// which will allow the user of this class to compare /// this hand to other hands for the purpose of declaring /// winning, losing, or tied hands.</remarks> public PokerHand(Card C1, Card C2, Card C3, Card C4, Card C5, PokerHandRankingTable EvalTable) { int key; this.mC1 = C1; this.mC2 = C2; this.mC3 = C3; this.mC4 = C4; this.mC5 = C5; key = (int)mC1.CardValue * (int)mC2.CardValue * (int)mC3.CardValue * (int)mC4.CardValue * (int)mC5.CardValue; if (mC1.CardSuit == mC2.CardSuit && mC2.CardSuit == mC3.CardSuit && mC3.CardSuit == mC4.CardSuit && mC4.CardSuit == mC5.CardSuit) { //flush keys are negative to differentiate them //from non-flush hands of the same 5 card values if (mC5.CardValue != CardEnum.Dummy) { // All five cards are present so we have to allow for flushes too key *= -1; } } mEvalHand = EvalTable.EvalHands[key]; }