lee croydon

lee croydon

  • NA
  • 48
  • 12k

test 2 equal poker hands for highest card to determine winni

Nov 21 2014 10:06 AM
Hi all,
 
i am trying to find a way of testing 2 equal poker hands (for example: two hands with two pairs) to determine which one wins according to the highest ranked card.
 
i have already tested the hands to determine there rank (for example: three of a kind, two pair etc..)
 
the code i have so far for determining the best hand is as follows.
 
 
if (winningHand.Length <= 0)
                {
                    winningHand = myHand;
                    bestHand = hand;
                    handRef++;
                }
                else if (allHandTypes[handRef] < allHandTypes[handRef - 1])
                {
                    winningHand = myHand;
                    bestHand = hand;
                    handRef++;
                }
                else if (allHandTypes[handRef] == allHandTypes[handRef - 1])
                {
                    
                }
            }
which works well up until there are 2 hands of the same rank as explained above.
 
what i am trying to do is compare the hand in "bestHand" to the hand in "hand" if and when we get to the last "else if" statement, then if the hand in "hand" is better than the hand in "bestHnad" then replace "bestHand" with the hand in "hand" and add "myHand" to "winningHand" any help on this would be massively appreciated or just a point in the right direction.
 
Thank you in advance Lee. 

Answers (10)