-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table.py
112 lines (73 loc) · 3.08 KB
/
Table.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
'''
Created on 30 Jul 2018
@author: sReeall
'''
from Player import player
from Dealer import dealer
from os import system
from time import sleep
class table():
#
# class used to display game screens
#
def __init__(self,player,dealer):
self.player = player
self.dealer = dealer
def displayBoard(self):
# print(f'Player: {self.player.getName()}')
# print(f'Current Balance: {self.player.getBalance()}')
print('')
print("|{:-^60}|".format(" Table "))
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
# names + balance
print(f'| {self.player.getName():^29}| {self.dealer.getName():^28}|')
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
chipStr = 'Chips: ' + str(self.player.getBalance())
print(f'| {chipStr:^29}| ' + '{:^28}'.format('') + '|')
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
print('|{:-^60}|'.format(''))
# betting area
betStr = 'Bet'
if self.player.getBet() == 0: playerBetStr =''
else: playerBetStr = str(self.player.getBet())
print('|{:\^14}'.format('') + '|{:30}'.format('') + '|{:/^14}'.format('') +'|')
print('|{:\^14}'.format('') + f'|{betStr:^30}'.format('') + '|{:/^14}'.format('') +'|')
print('|{:\^14}'.format('') + f'|{playerBetStr:^30}'.format('') + '|{:/^14}'.format('') +'|')
print('|{:-^60}|'.format(''))
# hands
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
if (self.player.getHand()).isEmpty():
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
else:
print(f'| {str(self.player.getHand()):29}| {str(self.dealer.getHand()):28}|')
#hand value
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
if (self.player.getHand()).isEmpty():
playerHandValueStr = ''
else:
playerHandValueStr = "Hand Value: " + str(self.player.hand.getvalue())
if self.dealer.getIsTurn():
dealerHandValuestr = "Hand Value: " + str(self.dealer.hand.getvalue())
else: dealerHandValuestr = ''
print(f'| {playerHandValueStr:29}| {dealerHandValuestr:28}|')
# print('|{:^60}'.format('')+'|')
print('|{:^30}'.format('') + '|'+ '{:^29}'.format('') +'|')
print('|{:-^60}|'.format(''))
# print('Bet')
# print(f'{self.player.getBet()}')
def clearScreen (self):
system('cls')
if __name__=='__main__':
testplayer = player('sunny')
testdealer = dealer()
testtable = table(testplayer,testdealer)
testtable.displayBoard()
print('clear screen in...3')
sleep(1)
print('2')
sleep (1)
print('1')
sleep(1)
testtable.clearScreen()
sleep(3)
testtable.displayBoard()