-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
46 lines (34 loc) · 982 Bytes
/
player.py
File metadata and controls
46 lines (34 loc) · 982 Bytes
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
from card import Card
from enum import Enum
class PlayerType(Enum):
HUMAN = 1
COMPUTER = 2
class PlayerStatus(Enum):
WIN = 1
LOST = 2
class Player:
def __init__(self, player_type, player_name):
self.__player_name = player_name
self.__player_type = player_type
self.__card = Card(player_name)
self.__status = None
@property
def type(self):
return self.__player_type
@property
def name(self):
return self.__player_name
@property
def status(self):
return self.__status
def show_card(self):
print(self.__card)
def strike_out(self, number):
if self.__player_type == PlayerType.HUMAN:
if not self.__card.strike_out(number):
self.__status = PlayerStatus.LOST
return
else:
self.__card.strike_out(number)
if self.__card.get_win_status():
self.__status = PlayerStatus.WIN