-
Notifications
You must be signed in to change notification settings - Fork 0
/
yahtzee.py
135 lines (90 loc) · 3.51 KB
/
yahtzee.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
########################################
# Score categories
########################################
def score_ones(dice: list[int]) -> int:
"""Score sum of all dice of a given value 1.
Only the dice of the value are counted. The rest are ignored.
"""
pass
def score_twos(dice: list[int]) -> int:
"""Score sum of all dice of a given value 2.
Only the dice of the value are counted. The rest are ignored.
"""
pass
def score_threes(dice: list[int]) -> int:
"""Score sum of all dice of a given value 3.
Only the dice of the value are counted. The rest are ignored.
"""
pass
def score_fours(dice: list[int]) -> int:
"""Score sum of all dice of a given value 4.
Only the dice of the value are counted. The rest are ignored.
"""
pass
def score_fives(dice: list[int]) -> int:
"""Score sum of all dice of a given value 5.
Only the dice of the value are counted. The rest are ignored.
"""
pass
def score_sixes(dice: list[int]) -> int:
"""Score sum of all dice of a given value 6.
Only the dice of the value are counted. The rest are ignored.
"""
pass
def score_3_of_a_kind(dice: list) -> int:
"""Score sum of all dice if at least 3 die with a given value."""
pass
def score_4_of_a_kind(dice: list) -> int:
"""Score sum of all dice if at least 4 die with a given value."""
pass
def score_small_straight(dice: list[int]) -> int:
"""Score 30 if there is a straight of 4 dice."""
pass
def score_large_straight(dice: list[int]) -> int:
"""Score 40 if there is a straight of 5 dice."""
pass
def score_full_house(dice: list[int]) -> int:
"""Score 25 if there is a pair and a three of a kind.
Allow for 5 of a kind to count as a pair and a three of a kind.
"""
pass
def score_chance(dice: list[int]) -> int:
"""Score sum of all dice."""
pass
def score_yahtzee(dice: list[int]) -> int:
"""Score 50 if all dice are the same."""
pass
########################################
# Game Logic
########################################
def roll(n: int) -> list[int]:
"""Rolls n dice and returns the result in a list."""
pass
def is_valid_to_keep(dice: list[int], keep: list[int]) -> bool:
"""Checks if the dice to keep are valid."""
pass
def prompt_dice_to_keep(dice: list[int]) -> list[int]:
"""Prompts the user to keep dice and returns the result in a list."""
pass
def prompt_category_to_score(scores: dict) -> str:
pass
def show_scores(scores: dict):
pass
def main():
scores = {
"Ones": {"score": 0, "used": False, "func": score_ones},
"Twos": {"score": 0, "used": False, "func": score_twos},
"Threes": {"score": 0, "used": False, "func": score_threes},
"Fours": {"score": 0, "used": False, "func": score_fours},
"Fives": {"score": 0, "used": False, "func": score_fives},
"Sixes": {"score": 0, "used": False, "func": score_sixes},
"Three of a Kind": {"score": 0, "used": False, "func": score_3_of_a_kind},
"Four of a Kind": {"score": 0, "used": False, "func": score_4_of_a_kind},
"Small Straight": {"score": 0, "used": False, "func": score_small_straight},
"Large Straight": {"score": 0, "used": False, "func": score_large_straight},
"Full House": {"score": 0, "used": False, "func": score_full_house},
"Chance": {"score": 0, "used": False, "func": score_chance},
"Yahtzee": {"score": 0, "used": False, "func": score_yahtzee},
}
if __name__ == "__main__":
main()