I am making a ren'py game that also has a poker game build in it for the story, however, I seem to be having some trouble with the poker game.
I have most things working the way it should except for the calculating / checking what each player's hands are to decide the winner.
As I am also still new to programming in ren'py I more than likely also could have made the whole poker game better in coding but I have what I have.
To decide the winning hand I currently have
Code: Select all
##Checking if player has a straight in their hand / on table
if "2" in PLAYERhandrank and "3" in PLAYERhandrank and "4" in PLAYERhandrank and "5" in PLAYERhandrank and "6" in PLAYERhandrank:
$PLAYERSecond=True
elif "3" in PLAYERhandrank and "4" in PLAYERhandrank and "5" in PLAYERhandrank and "6" in PLAYERhandrank and "7" in PLAYERhandrank:
$PLAYERSecond=True
elif "8" in PLAYERhandrank and "4" in PLAYERhandrank and "5" in PLAYERhandrank and "6" in PLAYERhandrank and "7" in PLAYERhandrank:
$PLAYERSecond=True
elif "8" in PLAYERhandrank and "9" in PLAYERhandrank and "5" in PLAYERhandrank and "6" in PLAYERhandrank and "7" in PLAYERhandrank:
$PLAYERSecond=True
elif "8" in PLAYERhandrank and "9" in PLAYERhandrank and "10" in PLAYERhandrank and "6" in PLAYERhandrank and "7" in PLAYERhandrank:
$PLAYERSecond=True
elif "8" in PLAYERhandrank and "9" in PLAYERhandrank and "10" in PLAYERhandrank and "Jack" in PLAYERhandrank and "7" in PLAYERhandrank:
$PLAYERSecond=True
elif "8" in PLAYERhandrank and "9" in PLAYERhandrank and "10" in PLAYERhandrank and "Jack" in PLAYERhandrank and "Queen" in PLAYERhandrank:
$PLAYERSecond=True
elif "9" in PLAYERhandrank and "10" in PLAYERhandrank and "Jack" in PLAYERhandrank and "Queen" in PLAYERhandrank and "King" in PLAYERhandrank:
$PLAYERSecond=True
elif "10" in PLAYERhandrank and "Jack" in PLAYERhandrank and "Queen" in PLAYERhandrank and "King" in PLAYERhandrank and "Ace" in PLAYERhandrank:
$PLAYERSecond=True
elif "Ace" in PLAYERhandrank and "2" in PLAYERhandrank and "3" in PLAYERhandrank and "4" in PLAYERhandrank and "5" in PLAYERhandrank:
$PLAYERSecond=True
#Checking how many of each card suit the player has
while "Spades" in PLAYERhandsuit:
$ PLAYERnum_of_Spades +=1
$PLAYERhandsuit.remove("Spades")
$PLAYERHighestNumOfSuits += 1
while "Hearts" in PLAYERhandsuit:
$ PLAYERnum_of_Hearts +=1
$PLAYERhandsuit.remove("Hearts")
if PLAYERHighestNumOfSuits < PLAYERnum_of_Hearts:
$PLAYERHighestNumOfSuits +=1
while "Clubs" in PLAYERhandsuit:
$ PLAYERnum_of_Clubs +=1
$PLAYERhandsuit.remove("Clubs")
if PLAYERHighestNumOfSuits < PLAYERnum_of_Clubs:
$PLAYERHighestNumOfSuits +=1
while "Diamonds" in PLAYERhandsuit:
$ PLAYERnum_of_Diamonds +=1
$PLAYERhandsuit.remove("Diamonds")
if PLAYERHighestNumOfSuits < PLAYERnum_of_Diamonds:
$PLAYERHighestNumOfSuits +=1
#Checking how many of each card number the player has
while "Ace" in PLAYERhandrank:
$PLAYERnum_of_Ace +=1
$PLAYERhandrank.remove("Ace")
$PLAYERHighestNumOfRank += 1
$PLAYERAce = True
while "2" in PLAYERhandrank:
$PLAYERnum_of_2 +=1
$PLAYERhandrank.remove("2")
if PLAYERHighestNumOfRank < PLAYERnum_of_2:
$PLAYERHighestNumOfRank += 1
$PLAYERTwo = True
while "3" in PLAYERhandrank:
$PLAYERnum_of_3 +=1
$PLAYERhandrank.remove("3")
if PLAYERHighestNumOfRank < PLAYERnum_of_3:
$PLAYERHighestNumOfRank += 1
$PLAYERThree = True
while "4" in PLAYERhandrank:
$PLAYERnum_of_4 +=1
$PLAYERhandrank.remove("4")
if PLAYERHighestNumOfRank < PLAYERnum_of_4:
$PLAYERHighestNumOfRank += 1
$PLAYERFour = True
while "5" in PLAYERhandrank:
$PLAYERnum_of_5 +=1
$PLAYERhandrank.remove("5")
if PLAYERHighestNumOfRank < PLAYERnum_of_5:
$PLAYERHighestNumOfRank += 1
$PLAYERFive = True
while "6" in PLAYERhandrank:
$PLAYERnum_of_6 +=1
$PLAYERhandrank.remove("6")
if PLAYERHighestNumOfRank < PLAYERnum_of_6:
$PLAYERHighestNumOfRank += 1
$PLAYERSix = True
while "7" in PLAYERhandrank:
$PLAYERnum_of_7 +=1
$PLAYERhandrank.remove("7")
if PLAYERHighestNumOfRank < PLAYERnum_of_7:
$PLAYERHighestNumOfRank += 1
$PLAYERSeven = True
while "8" in PLAYERhandrank:
$PLAYERnum_of_8 +=1
$PLAYERhandrank.remove("8")
if PLAYERHighestNumOfRank < PLAYERnum_of_8:
$PLAYERHighestNumOfRank += 1
$PLAYEREight = True
while "9" in PLAYERhandrank:
$PLAYERnum_of_9 +=1
$PLAYERhandrank.remove("9")
if PLAYERHighestNumOfRank < PLAYERnum_of_9:
$PLAYERHighestNumOfRank += 1
$PLAYERNine = True
while "10" in PLAYERhandrank:
$PLAYERnum_of_10 +=1
$PLAYERhandrank.remove("10")
if PLAYERHighestNumOfRank < PLAYERnum_of_10:
$PLAYERHighestNumOfRank += 1
$PLAYERTen = True
while "Jack" in PLAYERhandrank:
$PLAYERnum_of_Jack +=1
$PLAYERhandrank.remove("Jack")
if PLAYERHighestNumOfRank < PLAYERnum_of_Jack:
$PLAYERHighestNumOfRank += 1
$PLAYERJack = True
while "Queen" in PLAYERhandrank:
$PLAYERnum_of_Queen +=1
$PLAYERhandrank.remove("Queen")
if PLAYERHighestNumOfRank < PLAYERnum_of_Queen:
$PLAYERHighestNumOfRank += 1
$PLAYERQueen = True
while "King" in PLAYERhandrank:
$PLAYERnum_of_King +=1
$PLAYERhandrank.remove("King")
if PLAYERHighestNumOfRank < PLAYERnum_of_King:
$PLAYERHighestNumOfRank += 1
$PLAYERKing = True
#Checking if player has a pair or two pairs of cards
if PLAYERnum_of_Ace == 2:
$PLAYERPair = True
if PLAYERnum_of_2 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_3 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_4 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_5 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_6 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_6 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_8 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_9 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_10 == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_Jack == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_Queen == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
if PLAYERnum_of_King == 2:
if PLAYERPair == True:
$PLAYERtwoPair = True
$PLAYERPair = True
# Getting result of what cards player has
if PLAYERFolded == True:
$PLAYERScore = 0
elif PLAYERAce == True and PLAYERKing == True and PLAYERQueen == True and PLAYERJack == True and PLAYERTen == True and PLAYERHighestNumOfSuits > 4:
$ PLAYERScore = 22
elif PLAYERSecond == True and PLAYERHighestNumOfSuits >= 5:
$ PLAYERScore = 21
elif PLAYERHighestNumOfRank >= 4:
$ PLAYERScore = 20
elif PLAYERHighestNumOfRank == 3 and PLAYERPair == True:
$ PLAYERScore = 19
elif PLAYERHighestNumOfSuits >= 5:
$ PLAYERScore = 18
elif PLAYERSecond == True:
$ PLAYERScore = 17
elif PLAYERHighestNumOfRank == 3:
$ PLAYERScore = 17
elif PLAYERHighestNumOfRank == 2 and PLAYERtwoPair == True:
$ PLAYERScore = 15
elif PLAYERHighestNumOfRank == 2 and PLAYERtwoPair == False:
$ PLAYERScore = 14
elif PLAYERAce == True:
$ PLAYERScore = 13
elif PLAYERKing == True:
$ PLAYERScore = 12
elif PLAYERQueen == True:
$ PLAYERScore = 11
elif PLAYERJack == True:
$ PLAYERScore = 10
elif PLAYERTen == True:
$ PLAYERScore = 9
elif PLAYERNine == True:
$ PLAYERScore = 8
elif PLAYEREight == True:
$ PLAYERScore = 7
elif PLAYERSeven == True:
$ PLAYERScore = 6
elif PLAYERSix == True:
$ PLAYERScore = 5
elif PLAYERFive == True:
$ PLAYERScore = 4
elif PLAYERFour == True:
$ PLAYERScore = 3
elif PLAYERThree == True:
$ PLAYERScore = 2
elif PLAYERTwo == True:
$ PLAYERScore = 1
For example, I have had it multiple times that one of the players only had one pair, but the game said they had 2 pairs and sometimes it said ( but I seem to have fixed that already ) that the player had 4 of a kind or a flush when they did not.
I have been working on that for a couple weeks now and seem to be stuck on this one thing for the poker game.
Thanks in advance for any help.