diff --git a/yahtzee.py b/yahtzee.py index 69b0e97..585ccf3 100644 --- a/yahtzee.py +++ b/yahtzee.py @@ -5,11 +5,16 @@ class Yahtzee: This version of Yahtzee is initialized with a list of goals. """ def __init__(self, goals): + """ This is the initial score keeper of the instances """ self.score = 0 self.goals = goals self.dice = [Die() for num in range(5)] def play(self): + """ Play an entire game. +14 Starts by greeting the user, then plays rounds until all the goals +15 have been used. When the game is over, tells the player their final +16 score""" print("Welcome to Yachtzee!") self.score = 0 for goal in self.goals: @@ -19,6 +24,7 @@ class Yahtzee: print(f"Your final score was {self.score}") def play_round(self): + """ """ print("=" * 80) self.rolls_left = 3 for die in self.dice: @@ -29,10 +35,12 @@ class Yahtzee: self.score += goal.score(self.dice) def show_status(self): + """prints the self score, the amount of rolls left and dice""" dice = ', '.join([str(die) for die in self.dice]) print(f"Score: {self.score}. Rolls left: {self.rolls_left}. Dice: {dice}.") def choose_goal(self): + """ Allows the user to choose goal, and the nappends that goal into their options""" options = [] unused_goals = self.get_unused_goals() for goal in unused_goals: @@ -49,6 +57,8 @@ class Yahtzee: return unused_goals[choice] def get_choice(self, options): + """ asks player what they would liek to do, + keeps track of their choice, and if not valid, informs them """ print("What would you like to do?") for i, option in enumerate(options): print(f"{i}. {option}") @@ -59,6 +69,7 @@ class Yahtzee: return int(choice) def option_choice_is_valid(self, choice, options): + """ """ if not choice.isdigit(): return False if int(choice) < 0: @@ -68,6 +79,7 @@ class Yahtzee: return True def count_unused_goals(self): + """ counts how much goals are left unused""" return len(self.get_unused_goals()) def get_unused_goals(self):