-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
506 lines (388 loc) · 13.6 KB
/
main.py
File metadata and controls
506 lines (388 loc) · 13.6 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
import os
import random
import time
#TODO Add Poker game
#Main menu to select game
def main_menu(wallet):
clearConsole()
print("----[Welcome to Casino Royale Bjorn bitchboy]----")
print("----[Select your game]----\n")
print("[1] Roulette [4] Blackjack [7] Deposit money")
print("[2] Poker [5] Horses [8] Widthdraw money")
print("[3] Slots [6] Blackjack V2 [9] Exit" + "\n")
# errorHandling(wallet)
print("Wallet: $", wallet)
game = int(input("\nPlease Select your game: "))
if game == 1:
roulette(wallet)
elif game == 3:
slots(wallet)
elif game == 4:
blackjack(wallet)
elif game == 5:
horses(wallet)
elif game == 6:
blackjackV2(wallet)
elif game == 7:
depositFunds(wallet)
elif game == 8:
withdrawFunds(wallet)
# Function to clear console at start of other functions
def clearConsole():
command = 'clear'
if os.name in ('nt','dos'):
command = 'cls'
os.system(command)
#Shows the current wallet
def showWallet(wallet):
print("\nWallet: $", wallet , "\n")
#Shows to bet 0 to go to main menu
def showTip():
print("\n----[Useful Tip]----")
print("\nTo go back at the main menu at any given time, press the right shift key.")
#Checks whether the bet was over the wallet amount
def betCheck(wallet, bet):
if bet == 0:
main_menu(wallet)
if wallet == 0:
print("Sorry! Not enough funds!")
time.sleep(3)
main_menu(wallet)
if bet > wallet:
print("Not enough funds for that bet!")
time.sleep(1.4)
main_menu(wallet)
#Deposit new funds into wallet
def depositFunds(wallet):
clearConsole()
print("----[Deposit Funds]----\n")
deposit = int(input("How much would you like to deposit?: $"))
wallet += deposit
print("Succesfully updated wallet with: $", deposit)
time.sleep(2)
main_menu(wallet)
#Withdraw funds from wallet
def withdrawFunds(wallet):
clearConsole()
print("----[Withdraw Funds]----\n")
withdrawal = int(input("How much would you like to withdraw?: $"))
wallet -= withdrawal
print("Succesfully withdrawed: $", withdrawal)
time.sleep(2)
main_menu(wallet)
#Select different slot machine.
def slots(wallet):
clearConsole()
print("====[Welcome to Slots!]====\n")
print("[1] Tycoon Maniya\n")
print("[2] Fire Joker\n")
print("[3] Sweet Bonanza\n")
slot_choice = input("Please select your choice: ")
if slot_choice == "1":
tycoon(wallet)
elif slot_choice == "2":
fire_joker(wallet)
elif slot_choice == "3":
sweet_bonanza(wallet)
else:
main_menu(wallet)
#Roulette game
def roulette(wallet):
colors = ['Red', 'Black', 'Green']
random_color = random.choice(colors)
clearConsole()
winning_number = random.randint(0,36)
print("----[Now playing Roulette]----\n")
showWallet(wallet)
bet = int(input("Please place your bets [USD]: "))
betCheck(wallet, bet)
bet_number = int(input("On which number? "))
if bet_number == winning_number:
winnings = bet * 36
print("Winning number is: ", winning_number, random_color)
print("Congratulations! You could've won ", winnings)
time.sleep(3.5)
wallet += winnings
main_menu(wallet)
else:
print("Too bad! You lost! Winning number was: \n", winning_number)
wallet -= bet
time.sleep(3.5)
main_menu(wallet)
return wallet
#Blackjack game
def blackjack(wallet):
clearConsole()
dealerHand = random.randint(17,27)
playerHand = random.randint(17,27)
print("----[Now playing Blackjack]----\n")
print("If you bet 0, you'll return to the main menu\n")
showWallet(wallet)
bet = int(input("\nPlease place your bet [USD]: "))
winnings = bet * 2
winningsbj = bet * 2.5
betCheck(wallet, bet)
print("Dealer drew: ", dealerHand)
time.sleep(1)
print("You got: ", playerHand)
time.sleep(1.4)
if dealerHand > 21:
print("Congratulations! You won: $", winnings)
time.sleep(3.5)
wallet += winnings
blackjack(wallet)
elif playerHand == 21:
print("Congratulions! Blackjack! You won: $",winnings)
wallet += winningsbj
time.sleep(1.4)
blackjack(wallet)
elif playerHand > 21:
print("Too bad, you lost.")
time.sleep(3)
wallet -= bet
blackjack(wallet)
return wallet
#New blackjack with betting and standing.
def blackjackV2(wallet, totalDealer=0, totalPlayer=0, game_continued=False):
#clearConsole()
dealer_first_card = random.randint(1, 11)
dealer_second_card = random.randint(1, 11)
your_first_card = random.randint(1, 11)
your_second_card = random.randint(1, 11)
new_card = random.randint(1, 11)
if game_continued == False:
# This is in the beginning
print("----[Blackjack]----")
print("[*] New game started")
print("If you bet 0, you'll return to the main menu\n")
print("Balance: $", wallet)
totalDealer = dealer_first_card + dealer_second_card
totalPlayer = your_first_card + your_second_card
else:
print("----[Blackjack]----")
print("Continuing the game..")
print("Balance: $", wallet)
# TODO Draw code
# TODO Win code
# TODO Fix unlimited wallet
# Blackjack = bet + bet * 1.5
# Draw(push) = bet * 1
# Win = bet + bet * 1
# Lose = das pech geld weg
if totalPlayer <= 20:
bet = int(input("Please place your bets: $ "))
print("The dealer is handing out cards..")
time.sleep(1)
print(f"Dealer: {totalDealer}\nYou: {totalPlayer}")
wallet -= bet
stbet = input("Do you want to HIT or STAND? H/S: ")
if stbet.lower() == "h":
print("You chose hit. The dealer is drawing a card for you.")
time.sleep(1)
totalDealer += new_card #Reveal hidden card
totalPlayer += new_card #Draw card for u
print(f"Dealer reveals his hidden card {totalDealer}. And your card is {totalPlayer}")
if totalPlayer > 22:
print("Cards: ", totalPlayer)
print("Too bad! You lost!")
blackjackV2(wallet, game_continued=False)
elif totalPlayer == 21:
print("Cards: ", totalPlayer)
print("Blackjack!")
wallet += bet * 2.5
blackjackV2(wallet, game_continued=False)
else:
if totalPlayer < totalDealer and totalDealer >= 17:
print("You:", totalPlayer)
print("Dealer:", totalDealer)
print("Too bad! You lost!")
time.sleep(2)
blackjackV2(wallet)
elif totalDealer > 21:
print("You win")
wallet += bet * 2
blackjackV2(wallet, game_continued=False)
else:
blackjackV2(wallet, totalPlayer,
totalDealer, game_continued=True)
#Fire joker slot machine
def fire_joker(wallet):
clearConsole()
lane1 = ['Fire Joker','Grapes','Banana','Lemon','Pear','Strawberry']
lane2 = ['Fire Joker','Grapes','Banana','Lemon','Pear','Strawberry']
lane3 = ['Fire Joker','Grapes','Banana','Lemon','Pear','Strawberry']
random_lane1 = random.choice(lane1)
random_lane2 = random.choice(lane2)
random_lane3 = random.choice(lane3)
print("----[Now playing Fire Joker]----\n")
print("If you bet 0, you'll return to the main menu\n")
showWallet(wallet)
bet = int(input("\nPlease place your bet: $"))
betCheck(wallet, bet)
winning_jackpot = bet * 12300
winning1 = bet * 12
winner = "Congratulations! You won: $", winning1
jackpot = "[JACKPOT] CONGRATULATIONS! YOU WON THE JACKPOT! You could've won: $",winning_jackpot
for i in lane1:
random_lane1 = random.choice(lane1)
random_lane2 = random.choice(lane2)
random_lane3 = random.choice(lane3)
print("| " + random_lane1 + " | " + random_lane2 + " | " + random_lane3 + " | ")
time.sleep(0.2)
if random_lane1.startswith("Fire Joker") & random_lane2.startswith("Fire Joker") & random_lane3.startswith("Fire Joker"):
print(jackpot)
wallet += winning_jackpot
time.sleep(5)
fire_joker(wallet)
elif random_lane1.startswith("Fire Joker") & random_lane2.startswith("Fire Joker"):
print(winner)
wallet += winning1
time.sleep(5)
fire_joker(wallet)
elif random_lane1.startswith("Fire Joker") & random_lane3.startswith("Fire Joker"):
print(winner)
wallet += winning1
time.sleep(5)
fire_joker(wallet)
elif random_lane2.startswith("Fire Joker") & random_lane3.startswith("Fire Joker"):
print(winner)
wallet += winning1
time.sleep(5)
fire_joker(wallet)
print("You lost! Too bad.")
wallet -= bet
time.sleep(2)
fire_joker(wallet)
return wallet
#Tycoon slot machine
def tycoon(wallet):
clearConsole()
pepper = ['Black Pepper', 'Red Pepper', 'Green Pepper']
lemon = ['Black lemon', 'Red lemon', 'Green lemon']
apple = ['Black apple', 'Red apple', 'Green apple']
random_pepper = random.choice(pepper)
random_lemon = random.choice(lemon)
random_apple = random.choice(apple)
print("----[Now playing Tycoon Manya]----")
showWallet(wallet)
bet = int(input("\nPlease place your bets [Minimum $10]: "))
betCheck(wallet, bet)
winnings = bet * 250
winner = "<JACKPOT> Congratulations! You won:" , "$" , winnings
for i in range(8):
print("| " + random_pepper + " | " + random_lemon + " | " + random_apple)
time.sleep(0.8)
if random_pepper.startswith("Black") & random_apple.startswith("Black") & random_lemon.startswith("Black"):
print(winner)
wallet += winnings
time.sleep(3)
tycoon(wallet)
elif random_pepper.startswith("Red") & random_apple.startswith("Red") & random_lemon.startswith("Red"):
print(winner)
wallet += winnings
time.sleep(3)
tycoon(wallet)
elif random_pepper.startswith("Green") & random_apple.startswith("Green") & random_lemon.startswith("Green"):
print(winner)
wallet += winnings
time.sleep(3)
tycoon(wallet)
print("To bad! You lost!")
wallet -= bet
time.sleep(3)
tycoon(wallet)
return wallet
#Sweet bonanza slot machine game
def sweet_bonanza(wallet):
clearConsole()
lane1 = ['Bonus Bomb','Grapes','Banana','Lemon','Pear','Strawberry']
lane2 = ['Bonus Bomb','Grapes','Banana','Lemon','Pear','Strawberry']
lane3 = ['Bonus Bomb','Grapes','Banana','Lemon','Pear','Strawberry']
print("----[Now playing Sweet Bonanza]----\n")
showWallet(wallet)
bet = int(input("\nPlease place your bets: $"))
betCheck(wallet, bet)
for i in lane1:
random_lane1 = random.choice(lane1)
random_lane2 = random.choice(lane2)
random_lane3 = random.choice(lane3)
multipliers = ['5','10','25','50','100']
print("| " + random_lane1 + " | " + random_lane2 + " | " + random_lane3 + " | ")
time.sleep(0.2)
if random_lane1.startswith("Bonus Bomb") & random_lane2.startswith("Bonus Bomb") & random_lane3.startswith("Bonus Bomb"):
bbm = random.choice(multipliers)
bbmPlusBet = int(bbm) * bet
wallet += bbmPlusBet
print("Congratulations: $",bbmPlusBet)
time.sleep(3)
sweet_bonanza(wallet)
elif random_lane1.startswith("Bonus Bomb") & random_lane2.startswith("Bonus Bomb"):
bbm = random.choice(multipliers)
bbmPlusBet = int(bbm) * bet
wallet += bbmPlusBet
print("Congratulations: $",bbmPlusBet)
sweet_bonanza(wallet)
elif random_lane1.startswith("Bonus Bomb") & random_lane3.startswith("Bonus Bomb"):
bbm = random.choice(multipliers)
bbmPlusBet = int(bbm) * bet
wallet += bbmPlusBet
print("Congratulations: $",bbmPlusBet)
time.sleep(3)
sweet_bonanza(wallet)
elif random_lane2.startswith("Bonus Bomb") & random_lane3.startswith("Bonus Bomb"):
bbm = random.choice(multipliers)
bbmPlusBet = int(bbm) * bet
wallet += bbmPlusBet
print("Congratulations: $",bbmPlusBet)
time.sleep(3)
sweet_bonanza(wallet)
print("Too bad! You lost!")
wallet += int(bbmPlusBet)
time.sleep(1.5)
wallet -= bet
sweet_bonanza(wallet)
return wallet
#Horse betting
def horses(wallet):
clearConsole()
print("----[NOW PLAYING]----\n")
print("----[Horse betting]----\n")
showTip()
showWallet(wallet)
horses_list = ['Jack','Charlie','Billy','Harry','Alfie','George','Murphy']
print(horses_list, "\n")
selected_horse = input("Please select your horse: ")
bet = input("How much would you like to bet?: ")
#Check if bet is an integer
if errorHandling(bet, wallet, selected_horse):
betCheck(wallet, bet)
winnings = bet * 6
random_horse = random.choice(horses_list)
if selected_horse == random_horse:
print("Congratulations! Your horse won! You won: ")
wallet += winnings
else:
print("Too bad! You lost!")
wallet -= bet
print("Winning horse was: " + random_horse)
time.sleep(3)
clearConsole()
horses()
#First menu to start main menu and to some checks
def first_menu():
clearConsole()
print("----[Welcome to Casino Royale]----\n")
wallet = int(input("Please deposit funds: $"))
errorHandling(wallet)
main_menu(wallet)
#Check if int
def errorHandling(arg1, arg2="", arg3="", arg4=""):
if isinstance(arg1, int):
pass
else:
usage()
#Restarts scripts when input is not a int
def usage():
print("Please use an integer! Stupid ass bitch! ")
time.sleep(1.3)
first_menu()