Code: Select all
function findBestHand()
hand_type = NOTHING
str = "nothing"
-- Search in this order
if isRoyalFlush() == 1 then
hand_type = ROYAL_FLUSH
str = "Royal Flush"
elseif isStraightFlush() == 1 then
hand_type = STRAIGHT_FLUSH
str = "Straight Flush"
elseif isFourOfKind() == 1 then
hand_type = FOUR_KIND
str = "Four of a Kind"
elseif isFullHouse() == 1 then
hand_type = FULL_HOUSE
str = "Full House"
elseif isFlush() == 1 then
hand_type = FLUSH
str = "Flush"
elseif isStraight() == 1 then
hand_type = STRAIGHT
str = "Straight"
elseif isThreeOfKind() == 1 then
hand_type = THREE_KIND
str = "Three of a Kind"
elseif isTwoPairs() == 1 then
hand_type = TWO_PAIRS
str = "Two Pairs"
elseif isOnePair() == 1 then
hand_type = ONE_PAIR
str = "One Pair"
else
hand_type = getHighCard()
str = "High Card: " .. hand_type
end
y = 25 + card_back:height()
screen:print(5, y, "You got " .. str, white)
screen.waitVblankStart()
screen:flip()
return hand_type
end -- findBestHand
The problem is, when I run this function on my PSP, it appears that whenever I have two pairs in my hand, it prints "You got Two Pairs"; but then, ON TOP of that string, it also overlaps it with "You got One Pair"! So it seems like when the Two Pair condition is met, it still checks the next condition, which is One Pair (which would also be met), and then prints both of them!
When I don't have two pairs, but have one pair instead, it correctly prints the One Pair string only. Likewise, when I don't have a single pair, it prints the High Card string only.
Any idea what I may have done wrong in the two pair case??