-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.py
135 lines (110 loc) · 3.16 KB
/
controller.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
import os
import random
from view import *
from model.shoe import Shoe
def create_shoe():
values = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
number = [[1, 11], 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
suits = ["♥", "♠", "♦", "♣"]
sh = []
for deck in range(6):
for suit in suits:
for x in range(len(values)):
sh.append({"card": values[x], "number": number[x], "suit": suit})
random.shuffle(sh)
return sh
shoe = create_shoe()
def set_balance():
balance0 = 1000.00
return balance0
balance = set_balance()
def get_count(p_cards):
count1 = 0
count2 = 0
for c in p_cards:
if c['card'] == "A":
count1 += int(c['number'][0])
count2 += int(c['number'][1])
else:
count1 += int(c['number'])
count2 += int(c['number'])
return count1, count2
def initial_deal(dealer, player):
player.append(shoe.pop())
dealer.append(shoe.pop())
player.append(shoe.pop())
dealer.append(shoe.pop())
return dealer, player
def new_draw(balance=balance):
my_cards = []
dealers_cards = []
balance -= bet_options()
show_newdraw()
dealers_cards, my_cards = initial_deal(dealers_cards, my_cards)
show_cards(dealers_cards,True,my_cards,balance)
def stay():
print("Player stays")
def double():
print("Player doubles")
def split():
print("Player splits")
def menu_options(shoe, player, dealer, balance):
choice = ""
while choice != "5":
options_bj_print(False, False)
choice = str(input())
if choice == "0":
clear()
result = ""
if result == "busted":
print("sneed")
show_busted(balance=balance)
new_draw()
elif choice == "1":
clear()
stay()
show_cards(dealer, True, player, balance)
elif choice == "2":
clear()
double()
show_cards(dealer, True, player, balance)
elif choice == "3":
clear()
split()
show_cards(dealer, True, player, balance)
elif choice == "5":
print("Adios")
clear()
else:
print("Choice not valid")
def bet_options():
choice = ""
show_bets()
while choice != "5":
choice = str(input())
if choice == "0":
return 10
elif choice == "1":
return 20
elif choice == "2":
return 50
elif choice == "3":
return 100
elif choice == "4":
return int(input("Ingrese el valor a apostar: "))
elif choice == "5":
return 0
else:
print("Choice not valid")
def round(balance=balance):
my_cards = []
dealers_cards = []
dealers_cards, my_cards = initial_deal(dealers_cards, my_cards)
balance -= bet_options()
show_cards(dealers_cards, True, my_cards, balance)
menu_options(shoe, my_cards, dealers_cards, balance)
def start():
os.system('setterm -background green -foreground black -store')
clear()
#global sh
#sh = Shoe()