-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscorecard.py
50 lines (48 loc) · 1.67 KB
/
scorecard.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
class Scorecard:
scores = {
"upper1": 0,
"upper2": 0,
"upper3": 0,
"upper4": 0,
"upper5": 0,
"upper6": 0,
"upperBonus": 0,
"three": 0,
"four": 0,
"fullHouse": 0,
"sStraight": 0,
"lStraight": 0,
"yahtzee": 0,
"chance": 0,
"yahtzeeBonus": 0,
}
upperTotal = 0
lowerTotal = 0
total = 0
def __init__(self):
pass
def addScore(self, id, score):
self.scores[id] = score;
self.upperTotal = sum([self.scores[x] for x in self.scores if "upper" in x])
self.lowerTotal = sum([self.scores[x] for x in self.scores if not "upper" in x])
if self.upperTotal >= 63: self.scores["upperBonus"] = 35
self.total = self.upperTotal + self.lowerTotal
def __repr__(self):
return "\
~~~SCORE CARD~~~\n\
Aces: {} Twos: {}\n\
Threes: {} Fours: {}\n\
Fives: {} Sixes: {}\n\
Bonus: {}\n\
Upper Total: {}\n\
\n\
3 of a kind: {}\n\
4 of a kind: {}\n\
Full House: {}\n\
Sm Straight: {}\n\
Lg Straight: {}\n\
Yahtzee: {}\n\
Chance: {}\n\
Lower Total: {}\n\
TOTAL: {}\n\
~~~~~~~~~~~~~~~~".format(self.scores["upper1"], self.scores["upper2"], self.scores["upper3"], self.scores["upper4"], self.scores["upper5"], self.scores["upper6"], self.scores["upperBonus"], self.upperTotal, self.scores["three"], self.scores["four"], self.scores["fullHouse"], self.scores["sStraight"], self.scores["lStraight"], self.scores["yahtzee"], self.scores["chance"], self.lowerTotal, self.lowerTotal + self.upperTotal)