lundi 22 mars 2021

Running multiple "if" statements, but multiple are met at a time

I am creating a poker game, as stated before, but some poker card "if" statements are being met multiple times, which should not happen.

"""

PPPPP      OOOOO      K   K   EEEEEEE   RRRRRR
P    P    O     O     K  K    E         R     R
P     P   O     O     K K     E         R      R
P    P    O     O     KK      EEE       R     R
PPPPP     O     O     K K     E         RRRRRR
P         O     O     K  K    E         R   R
P         O     O     K   K   E         R    R
P          OOOOO      K    K  EEEEEEE   R     R


Congratulations! My name is James Chrisaldi, and you found the source code for my new game, Poker! Here, you can view a few of my notes to see how I created this game. You can tinker with it, it won't affect the original version. Have fun!


"""




import random    
import time      


cards = ["Ace of Hearts", "Ace of Diamonds", "Ace of Clubs", "Ace of Spades", "King of Hearts", "King of Diamonds", "King of Clubs", "King of Spades", "Queen of Spades", "Queen of Hearts", "Queen of Clubs", "Queen of Diamonds", "Jack of Hearts", "Jack of Diamonds", "Jack of Clubs", "Jack of Spades", "Ten of Hearts", "Ten of Diamonds", "Ten of Clubs", "Ten of Spades", "Nine of Hearts", "Nine of Diamonds", "Nine of Clubs", "Nine of Spades", "Eight of Hearts", "Eight of Diamonds", "Eight of Clubs", "Eight of Spades", "Seven of Hearts", "Seven of Diamonds", "Seven of Clubs", "Seven of Spades", "Six of Hearts", "Six of Diamonds", "Six of Clubs", "Six of Spades", "Five of Hearts", "Five of Diamonds", "Five of Clubs", "Five of Spades", "Four of Hearts", "Four of Diamonds", "Four of Clubs", "Four of Spades", "Three of Hearts", "Three of Diamonds", "Three of Clubs", "Three of Spades", "Two of Hearts", "Two of Diamonds", "Two of Clubs", "Two of Spades"]

# Player

print("Your game is loading...")
time.sleep(5)
name = input("What is your username? \n")
    
p1c = random.choice(cards)
cards.remove(p1c)
p2c = random.choice(cards)
cards.remove(p2c)
player_money = 2000000
bb = ["Check", "Bet", "Bet"]
bot_bet = random.choice(bb)
bc = ["Check", "Check", "Bet"]
bot_check = random.choice(bc)

# John Smith
js1c = random.choice(cards)
cards.remove(js1c)
js2c = random.choice(cards)
cards.remove(js2c)
js_money = 2000000

# Dora the Explorer
de1c = random.choice(cards)
cards.remove(de1c)
de2c = random.choice(cards)
cards.remove(de2c)
de_money = 2000000

# Jeff Besos
jb1c = random.choice(cards)
cards.remove(jb1c)
jb2c = random.choice(cards)
cards.remove(jb2c)
jb_money = 2000000
bet = ["Sure, I'll bet.", "I'll bet.", "Check."]
call = ["Sure, I'll call.", "I'll call.", "Fold."]
ca = random.choice(call)
b = random.choice(bet)
check = ["Sure, I'll bet.", "Check.", "I'll check for now."]
c = random.choice(check)
burn1 = random.choice(cards)
cards.remove(burn1)
card1 = random.choice(cards)
cards.remove(card1)
card2 = random.choice(cards)
cards.remove(card2)
card3 = random.choice(cards)
cards.remove(card3)
burn2 = random.choice(cards)
cards.remove(burn2)
card4 = random.choice(cards)
cards.remove(card4)
burn3 = random.choice(cards)
cards.remove(burn3)
card5 = random.choice(cards)
cards.remove(card5)
high_bet_money = ["50000", "60000", "75000", "85000", "100000"]
med_bet_money = ["30000", "40000", "50000", "60000", "75000"]
low_money = ["10000", "20000", "30000", "40000"]
high_bet = random.choice(high_bet_money)
# Functions

def jeff_besos_bet_call():
    if "Ace" in jb1c and "Ace" in jb2c:
        print(ca)
        if ca == "Sure, I'll call." or b == "I'll call.":
            time.sleep(2)
            jb_money = jb_money - low_bet
            print("Jeff Besos calls the bet of " + low_bet + " .")
            player_bet = input(name + ", do you call, raise, or fold?\n")
            


def dora_explorer_bet_call():
    if "Ace" in de1c and "Ace" in de2c:
        print(ca)
        if ca == "Sure, I'll call." or b == "I'll call.":
            time.sleep(2)
            de_money = de_money - low_bet
            print("Dora the Explorer calls the bet of " + low_bet + " . Jeff Besos, do you call the bet of " + low_bet + " ?")
            ca = random.choice(call)
            jeff_besos_bet_call()


def john_smith_start():
    if "Ace" in js1c and "Ace" in js2c:
        print(b)
        if b == "Sure, I'll bet." or b == "I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(low_bet)
            time.sleep(2)
            js_money = js_money - low_bet
            print("John Smith bets " + low_bet + " .Dora the Explorer, do you call the " + low_bet + " ?")
            dora_explorer_bet_call()
            
    if "King" in js1c and "King" in js2c:
        print(b)
        if b == "Sure, I'll bet." or b == "I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Queen" in js1c and "Queen" in js2c:
        print(b)
        if b == "Sure, I'll bet." or b == "I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Ten" in js1c and "Ten" in js2c:
        print(b)
        if b == "Sure, I'll bet." or b == "I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Nine" in js1c and "Nine" in js2c:
        print(b)
        if b == "Sure, I'll bet." or b == "I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Eight" in js1c and "Eight" in js2c:
        print(b)
        if b == "Sure, I'll bet." or b == "I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Seven" in js1c and "Seven" in js2c:
        print(c)
        if b == "Sure, I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Six" in js1c and "Six" in js2c:
        print(c)
        if b == "Sure, I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Five" in js1c and "Five" in js2c:
        print(c)
        if b == "Sure, I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Four" in js1c and "Four" in js2c:
        print(c)
        if b == "Sure, I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Three" in js1c and "Five" in js2c:
        print(c)
        if b == "Sure, I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Two" in js1c and "Four" in js2c:
        print(c)
        if b == "Sure, I'll bet.":
            time.sleep(2)
            print("How much do you bet?")
            time.sleep(1.5)
            print(high_bet)
            time.sleep(2)
            print("John Smith bets " + high_bet + " . Dora the Explorer, do you call the " + high_bet + " ?")
            dora_explorer_bet_call()
    if "Spades" in js1c and "Spades" in js2c:
        print(c)
    if "Spades" in js1c and "Spades" in card1 and "Spades" not in js2c or "Spades" in js2c and "Spades" in card1 and "Spades" not in js1c:
        print(c)
    if "Spades" in js1c and "Spades" in card2 and "Spades" not in js2c or "Spades" in js2c and "Spades" in card2 and "Spades" not in js1c:
        print(c)
    if "Spades" in js1c and "Spades" in card3 and "Spades" not in js2c or "Spades" in js2c and "Spades" in card3 and "Spades" not in js1c:
        print(c)
        
    if "Clubs" in js1c and "Clubs" in card1 and "Clubs" not in js2c or "Clubs" in js2c and "Clubs" in card1 and "Clubs" not in js1c:
        print(c)
    if "Clubs" in js1c and "Clubs" in card2 and "Clubs" not in js2c or "Clubs" in js2c and "Clubs" in card2 and "Clubs" not in js1c:
        print(c)
    if "Clubs" in js1c and "Clubs" in card3 and "Clubs" not in js2c or "Clubs" in js2c and "Clubs" in card3 and "Clubs" not in js1c:
        print(c)
        
    if "Hearts" in js1c and "Hearts" in card1 and "Hearts" not in js2c or "Hearts" in js2c and "Hearts" in card1 and "Hearts" not in js1c:
        print(c)
    if "Hearts" in js1c and "Hearts" in card2 and "Hearts" not in js2c or "Hearts" in js2c and "Hearts" in card2 and "Hearts" not in js1c:
        print(c)
    if "Hearts" in js1c and "Hearts" in card3 and "Hearts" not in js2c or "Hearts" in js2c and "Hearts" in card3 and "Hearts" not in js1c:
        print(c)
        
    if "Diamonds" in js1c and "Diamonds" in card1 and "Diamonds" not in js2c or "Diamonds" in js2c and "Diamonds" in card1 and "Diamonds" not in js1c:
        print(c)
    if "Diamonds" in js1c and "Diamonds" in card2 and "Diamonds" not in js2c or "Diamonds" in js2c and "Diamonds" in card2 and "Diamonds" not in js1c:
        print(c)
    if "Diamonds" in js1c and "Diamonds" in card3 and "Diamonds" not in js2c or "Diamonds" in js2c and "Diamonds" in card3 and "Diamonds" not in js1c:
        print(c)
        
        
    if "Clubs" in js1c and "Clubs" in js2c:
        print(c)
    if "Hearts" in js1c and "Hearts" in js2c:
        print(c)
    if "Diamonds" in js1c and "Diamonds" in js2c:
        print(c)
    
    else:
        print(c)
        




print("\n")
print("Your cards are " + p1c + " and " + p2c + ".")
time.sleep(3)
print("You currently have",player_money,"dollars")
time.sleep(3)
print("")       
print("The cards on the board are: ")
time.sleep(0.3)
print(card1)
time.sleep(0.3)
print(card2)
time.sleep(0.3)
print(card3)
time.sleep(4)
print("John Smith, do you check or bet?")
time.sleep(2)
john_smith_start()






# Save the code for later

"""

    
"""

And the outcome sometimes:

Your game is loading...
What is your username?
James


Your cards are Five of Spades and Jack of Spades.
You currently have 2000000 dollars

The cards on the board are:
Four of Clubs
King of Spades
Eight of Diamonds
John Smith, do you check or bet?
I'll check for now.
I'll check for now.

[Program finished]

When you start the program, it print's print("Your game is loading..."), when it isn't, but I placed that there for some realistic parts in my game.

Then after five seconds of fake loading, it asks the user for a username. In my game, user's are not stored; the game automatically reset's after every use.

Then there are some variable on storing bot cards; "burn", or discarded cards, cards on the table, et cetera. It also removes these used cards from the variable that stores all cards, so they are not used again.

Afterwards, it sets the betting variables for the bots, which was easy.

After that, there is the functions that make up the gameplay. The bot character's names are: John Smith, Dora the Explorer, and Jeff Besos. These are random names that are used for bots.

The bot says "I'll check for now." twice, because it has multiple variations of cards I have placed. This would not look good on the final version. How do I fix this?

Aucun commentaire:

Enregistrer un commentaire