-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.py
101 lines (69 loc) · 2.29 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class Player():
def __init__(self,name):
self.name = name
self.points = 0
self.hand = []
self.state = ""
self.notOmmited = True
self.retired = ""
def showHand(self):
a = 0
for m in self.hand:
print(a,m)
a+=1
print("\n")
def Uno(self):
if len(self.hand) == 2:
print("Uno")
self.state = "Uno"
else:
print("You can only say one as you play the penultimate card")
def showOptions(self):
print("Press 'q' to play card \nPress 'w' to say Uno and play the penultimate card \nPress 'e' to retire\nPress 'r' to draw a card\n")
def playCard(self,option):
play = self.hand[option]
self.hand.remove(self.hand[option])
return play
def checkPoints(self,players):
for e in players:
if e.points > 500:
return True
return False
def addPoints(self,players,player,cardPack):
for j in players:
for e in j.hand:
if e[0] not in cardPack.cardsValue:
player.points+=e[0]
else:
player.points+= cardPack.cardsValue[e[0]]
def restartHand(self,players):
for player in players:
player.hand.clear()
def restartStates(self,players):
for e in players:
e.state = ""
def giveUp(self,player):
player.retired = "Retired"
def checkRetired(self,players):
cont = 0
for r in players:
if r.retired == "":
cont+= 1
if cont == 1:
return True
else:
return False
while True:
try:
totalPlayers = int(input("How many players will participate?: "))
while totalPlayers < 2 or totalPlayers > 10:
print("The number of players must be between 2 to 10.")
totalPlayers = int(input("How many players will participate?: "))
players = []
for a in range(totalPlayers):
name = input("Player's name : ").capitalize()
player = Player(name)
players.append(player)
break
except:
print("You enter a letter")