-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.py
76 lines (61 loc) · 1.95 KB
/
Player.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
from Agent import Agent as Parent
class Player(Parent):
'''
This class represents a Player object and extends the Agent
class. Each Player has their own pot which is affected by the
size of their bets. Each player also has a designated amount of
cash that they begin with.
'''
def __init__(self, amount_cash):
'''
Sets the amount_cash and pot
Attributes:
amount_cash (float): the amount of cash
'''
super().__init__()
self.amount_cash = amount_cash
self.pot = 0
def __str__(self):
'''
Returns the string representation of the player's hand, pot, and remaining money
Returns:
(str): string of the number and suit for every card in hand
'''
return super().__str__() + "\nPot: " + str(self.pot) + "\nAmount of Cash: " + str(self.amount_cash)
def get_pot(self):
'''
Returns the player's current pot
Returns:
pot (float): the player's current pot
'''
return self.pot
def get_amount_cash(self):
'''
Returns the player's remaining cash
Returns:
amount_cash (float): the player's remaining cash
'''
return self.amount_cash
def set_pot(self, pot):
'''
Sets the player's pot
Parameter:
pot (float): the pot value being set
'''
self.pot = pot
def set_amount_cash(self, amount_cash):
'''
Sets the player's remaining cash
Parameter:
amount_cash (float): the player's remaining cash
'''
self.amount_cash = amount_cash
def bet(self, bet):
'''
Assigns the bet value to the player's pot and subtracts that amount from amount_cash
Parameter:
bet (float): the bet being placed
'''
if bet <= self.amount_cash:
self.pot += bet
self.amount_cash -= bet