Chuvico / MyProject

0 stars 0 forks source link

ACEY DEUCEY #5

Open Chuvico opened 5 months ago

Chuvico commented 5 months ago

import random def display_cards(left_card, middle_card, rightcard): print(" ",""7, " "4, ""7, " "4, ""7, sep="") print("|", format(left_card, "<7d"), "|", sep="", end="") print(" "2, "|", format(str(middle_card), "<7s"),"|", sep="", end="") print(" "*2,"|", format(right_card, "<7d"),"|", sep="")

# Middle cards
print("|", " "*7, "|", " "*2, "|", " "*7, "|", " "*2,"|", " "*7, "|", sep="")
print("|", " "*7, "|", " "*2, "|", " "*7, "|", " "*2,"|", " "*7, "|", sep="")
print("|", " "*7, "|", " "*2, "|", " "*7, "|", " "*2,"|", " "*7, "|", sep="")
print("|", " "*7, "|", " "*2, "|", " "*7, "|", " "*2,"|", " "*7, "|", sep="")

# Botton cards
print("|", format(left_card, "_>7d"), "|", sep="", end="")
print(" "*2, "|", format(str(middle_card), "_>7s"),"|", sep="", end="")
print(" "*2,"|", format(right_card, "_>7d"),"|", sep="")

--- ACEY DEUCEY ---

print("---","ACEY DEUCEY","---",end="\n\n") instruction = input("Do you want to read instruction(y/n): ") while instruction != "y" and instruction != "n": print("invalid choice choose again.")

if instruction == "y": print("Acey Deucey is a simple card game.",end="\n") print("Two cards are drawn and the player places a bet on",end="\n") print("whether the next card drawn will fall between the two cards.",end="\n\n") print("You play against the computer, starting with $50.",end="\n") print("Each round costs an ante of $1, which is doubled every",end="\n") print("five round.",end="\n") print("If you wish to pass, enter a bet of $0.",end="\n\n") print("However, you must still pay the ante.",end="\n\n") print("Have fun!",end="\n\n\n")

num_round = 1 computer_money =50 player_money =50 ante = 1 pot = 10

print("player= $", player_money, " computer= $", computer_money, sep="",end="\n\n\n")

print("ante= $",ante, sep="",end="")

print(" pot= $",pot,sep="",end="\n\n\n")

play = input("Do you wish to play a round(y/n): ")

Validate user input

while play !="y" and play !="n": print("invalid choice choose again.") play = input("Do you wish to play a round(y/n): ")

if play == "n": print("Another time perhaps.") else:

while play == "y":
    print("round",num_round)
    print("[PLAYER} add 1$ to the pot",sep="",end="\n")
    print("[COMPUTER] add 1$ to the pot",sep="",end="\n")
    player_money -=1
    computer_money -=1
    print("player= $",player_money," computer= $",computer_money,sep="",end="\n\n")
    print("ante= $",ante, sep="",end="")
    pot +=2
    print(" pot= $",pot,sep="",end="\n\n\n")

    left_card = random.randint(1,13)
    right_card = random.randint(1,13)
    while left_card == right_card:
        right_card = random.randint(1,13)

    if left_card > right_card:
        temp = left_card
        left_card = right_card
        right_card = temp

    # Left cards
    print("[PLAYER] Cards are:\n")

    display_cards(left_card, "?", right_card)

    max_bet = 0
    if pot < player_money:
        max_bet = pot
    else:
        max_bet = player_money

    bet = int(input("Enter a bet(max $" + str(max_bet)+"): "))
    while bet > max_bet:
        print("Maximum bet is $", max_bet, sep="")
        bet = int(input("Enter a bet(max $" + str(max_bet)+"): "))

    middle_card = random.randint(1,13)

    if bet == 0:
        print("[PLAYER] PASS!")
    else:
        input("PRESS < ENTER > to continue")
        print("[PLAYER] Cards are:\n")

        # Display card
        display_cards(left_card, middle_card, right_card)

        # Win
        if middle_card > left_card and middle_card < right_card:
            print("[PLAYER] WIN")
            player_money += bet
            pot -= bet

        # loss
        elif middle_card == left_card or middle_card == right_card:
            print("[PLAYER] LOSE DOUBLE")
            player_money -= (bet*2)
            pot += (bet*2)

        else:
            print("You lose")
            player_money -= bet
            pot += bet

    # Computer turn
    input("PRESS ENTER to continue")
    left_card = random.randint(1,13)
    right_card = random.randint(1,13)
    while left_card == right_card:
        right_card = random.randint(1,13)

    if left_card > right_card:
        temp = left_card
        left_card = right_card
        right_card = temp

    # Left cards
    print("[COMPUTER] Cards are:\n")

    display_cards(left_card, "?", right_card)

    max_bet = 0
    if pot < computer_money:
        max_bet = pot
    else:
        max_bet = computer_money

    bet = random.randint(0, max_bet)
    input("PRESS ENTER to continue")
    print("Enter a bet(max $" + str(max_bet)+"):$"+ str(bet))
    while bet > max_bet:
        print("Maximum bet is $", max_bet, sep="")
        bet = int(input("Enter a bet(max $" + str(max_bet)+"): "))

    middle_card = random.randint(1,13)

    display_cards(left_card, middle_card, right_card)
    # Win
    if middle_card > left_card and middle_card < right_card:
        print("[COMPUTER] WIN")
        computer_money += bet
        pot -= bet

        # loss
    elif middle_card == left_card or middle_card == right_card:
        print("[COMPUTER] LOSE DOUBLE")
        computer_money -= (bet*2)
        pot += (bet*2)

    else:
        print("You lose")
        computer_money -= bet
        pot += bet

    if computer_money < 0:
        print("Computer is broke $",computer_money,sep="",end="\n\n")

    if player_money < 0:
        print('Player is broke $',player_money,sep="")
    if player_money > 0:
        play = input("Do you wish to play a round(y/n): ")
        num_round +=1
        if num_round%5 == 0:
            ante = ante * 2
            print('Ante increase! It is now $' + str(ante))

            player_money -=ante
            computer_money -=ante
            pot += ante*2

        # Validate user input
        while play !="y" and play !="n":
            print("invalid choice choose again.")
            play = input("Do you wish to play a round(y/n): ")
    else:
        play = 'n'

print("\n\n--- GAME SUMMARY ---")
print("player = $",player_money, sep="")
print("computer = $", computer_money, sep="")
print("ante = $", ante," pot = $",pot,sep="")