-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
185 lines (154 loc) · 6.69 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
from functions.deck import deck
from functions.gamerules import gameplay
from functions.scoreboard import scorekeeper
from time import sleep
card_deck = deck()
score = scorekeeper()
gameplay = gameplay(score)
dealtime = 2
def game():
print("(You walk up to the table confidently with " + str(score.get_player_score()) +
" points in your pocket and take a seat at a blackjack table)")
sleep(dealtime/3)
print("(The man looks at you)")
sleep(dealtime/3)
print("Hi! Welcome to Blackjack!\n\n")
leave = False
while (score.get_player_score() > 0) and (leave is False):
# Bidding
leave = bid()
if(leave):
print("You leave the table with " + str(score.get_player_score()))
else:
# Gameplay
print("Let's begin!\n\n")
gameplay.start_new_game()
card_deck.make_deck()
print("Here are your two cards")
sleep(dealtime)
# Draw two cards for each the player and house
for i in range(2):
p_card = card_deck.draw()
h_card = card_deck.draw()
gameplay.player_add_card_to_drawn_cards(p_card)
gameplay.house_add_card_to_drawn_cards(h_card)
print("*House flips their last drawn card*")
sleep(dealtime/2)
print("Their card: " + str(h_card[0]) + " of " + str(h_card[1]))
sleep(dealtime/4)
print("*You flip your cards*")
sleep(dealtime/2)
print("Your cards: " + str(gameplay.player_drawn_cards))
sleep(dealtime/2)
print("You total score: " + str(gameplay.player_get_card_score()))
sleep(dealtime/2)
player_play()
house_play()
gameplay.win_check()
sleep(dealtime)
print("\n\n\n\n\n")
if (score.get_player_score() <= 0):
print("Oh, it looks like you are out of funds... Boys! Get this person out of here!")
sleep(dealtime)
print("You get up and try to run but the 2 large people come up to you, grab you, and push you outside.")
sleep(dealtime)
print("Well, there\'s no way home... So I guess I will sleep here...")
sleep(dealtime)
print("You fell asleep on the concrete outside of the casino...")
sleep(dealtime)
print("Thanks for playing!")
else:
print("You then see the doors open by two men holding the door for you.")
sleep(dealtime)
print("You pass the two men holding the door with a smile.")
sleep(dealtime)
print("You then look in your pockets and see that your winnings.")
sleep(dealtime)
print("\"Ahh, " + str(score.get_player_score()) + " points... \" You say to yourself")
sleep(dealtime)
print("What will I do with these points? Buy a fancy car? A house? Or charity?")
sleep(dealtime)
print("\"Oh I don't know, let\'s just go home and enjoy the evening.\"")
sleep(dealtime)
print("You get into your car and then start to drive home... The end.")
sleep(dealtime)
for i in range(5):
print(".", end='')
sleep(dealtime/2)
print(" or is it???")
sleep(dealtime*2)
print("\nThanks for playing!")
def bid():
print("What is your bid? Bid 0 to leave table.\n")
sleep(dealtime/2)
print("Current points: " + str(score.get_player_score()))
has_bid = False
while(not has_bid):
try:
bid = int(input("Bid: "))
if (bid > score.get_player_score()):
print("...\nI think that you are short in funds... Could you make a bid that you can afford?")
elif (bid < 0):
print("...\nI don\'t let people play for free around here. You\'re going to need to make a bid")
elif (bid == 0):
print("You get up from the table")
has_bid = True
escape = True
else:
print("Alright, here we go!")
score.set_bet(bid)
has_bid = True
escape = False
except KeyboardInterrupt:
has_bid = True
escape = True
except:
print("Could you repeat that in gambling terms this time?\n")
sleep(dealtime/2)
return escape
def player_play():
move = 0
not_fold = True
while(gameplay.player_status() and not_fold):
print("\n\n\nYour Score Now: " + str(gameplay.player_get_card_score()) + "\n1. Draw\n2. Stay")
try:
play = int(input("Choice > "))
if play == 1: # Draw
print("You flip another card...")
card = card_deck.draw()
gameplay.player_add_card_to_drawn_cards(card)
print("You drew a " + str(card[0]) + " of " + str(card[1]) + "!")
print("Your new score: " + str(gameplay.player_get_card_score()))
move += 1
elif play == 2: # Stay
print("You are staying at " + str(gameplay.player_get_card_score()))
not_fold = False
else:
print("Please pick another number!")
# Double down will be available later
except:
print("Uhh that\'s not a number! Try again!")
sleep(dealtime/2)
# Since class deck is only accessed here.
def house_play():
print("House will now play") # This is used for debugging purpose
sleep(dealtime)
print("\n*House flips their cards*")
sleep(dealtime/2)
print("House\'s cards: " + str(gameplay.house_drawn_cards))
sleep(dealtime/2)
print("House\'s score: " + str(gameplay.house_get_card_score()))
# Debugging purpose: to see if methods worked for bot
# print("-= Debug: Is house <= 17?: " + str(gameplay.house_get_card_score() <= 17) + " | Is player beating house?: " + str(gameplay.is_player_beating_house()) + " =-")
# House stands on 17
while((gameplay.house_get_card_score() <= 17)): # and (gameplay.is_player_beating_house()) # <-- Since house stands on 17, this will be added later
# Debugging purpose: to see if methods worked for bot
# print("-= Debug: Is house <= 17?: " + str(gameplay.house_get_card_score() <= 17) + " | Is player beating house?: " + str(gameplay.is_player_beating_house()) + " =-")
card = card_deck.draw()
print("House drew a " + str(card[0]) + " of " + str(card[1]))
sleep(dealtime/2)
gameplay.house_add_card_to_drawn_cards(card)
print("House score: " + str(gameplay.house_get_card_score()))
sleep(dealtime/2)
if __name__ == '__main__':
game()