Skip to content

Commit

Permalink
fixed 0 bet, end of deck
Browse files Browse the repository at this point in the history
added letter by letter printing
  • Loading branch information
LordBaryhobal committed Feb 16, 2022
1 parent 860aa60 commit 309499d
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions 01_Acey_Ducey/acey_ducey.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random, time
import random, time, sys

COLORS = ["Hearts","Diamonds","Spade","Clubs"]

money = 100
cards = []
card1, card2 = None, None

def print(text=""):
text += "\n"
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(0.05)
time.sleep(0.5)

def generate_cards():
global cards
cards = []
Expand Down Expand Up @@ -60,8 +68,9 @@ def card_name(card):
print(f"Current balance: {money}")
time.sleep(1)

print("How much money do you want to bet ? ")
while True:
bet = input("How much money do you want to bet ? ")
bet = input()
if bet == "stop":
running = False
break
Expand All @@ -85,12 +94,16 @@ def card_name(card):
time.sleep(1)
print(f"And the third card is: "+card_name(card3))
time.sleep(0.5)
if (card1[0] < card3[0] < card2[0]) or (card2[0] < card3[0] < card1[0]):
print(f"Well done ! You won {bet}")
money += bet
if bet == 0:
print("No change to your balance")

else:
print(f"Oh no, you lost {bet}")
money -= bet
if (card1[0] < card3[0] < card2[0]) or (card2[0] < card3[0] < card1[0]):
print(f"Well done ! You won {bet}")
money += bet
else:
print(f"Oh no, you lost {bet}")
money -= bet

print()
print()
Expand All @@ -100,3 +113,7 @@ def card_name(card):
print("It seems you've spent all your money")
print("Maybe next time you'll be more lucky")
running = False

elif len(cards) < 3:
print("Reshuffling the deck")
generate_cards()

0 comments on commit 309499d

Please sign in to comment.