diff --git a/__pycache__/yahtzee.cpython-310.pyc b/__pycache__/yahtzee.cpython-310.pyc new file mode 100644 index 0000000..c6e4127 Binary files /dev/null and b/__pycache__/yahtzee.cpython-310.pyc differ diff --git a/__pycache__/yahtzee_goals.cpython-310.pyc b/__pycache__/yahtzee_goals.cpython-310.pyc new file mode 100644 index 0000000..ef31ea3 Binary files /dev/null and b/__pycache__/yahtzee_goals.cpython-310.pyc differ diff --git a/dice_stats.py b/dice_stats.py index aee761d..52f8924 100644 --- a/dice_stats.py +++ b/dice_stats.py @@ -20,7 +20,6 @@ class FiveDice: return False return True - def is_three_of_a_kind(self): count = Counter(self.faces()) for face_count in count.values(): diff --git a/yahtzee.py b/yahtzee.py index 8ae2b41..0944f41 100644 --- a/yahtzee.py +++ b/yahtzee.py @@ -4,17 +4,26 @@ class Yachtzee: """A command-line Yahtzee game. This version of Yahtzee is initialized with a list of goals. """ + + """runs when the object is instantiated, sets attributes for score, goals and dice. Dice is creating a dice roll 5 times + """ def __init__(self, goals): self.score = 0 self.goals = goals self.dice = [Die() for num in range(5)] + + """prints a welcome message and uses a while loop to say if the goal is 0, then run the play_round() method. then print your final score out. + """ def play(self): print("Welcome to Yachtzee!") while self.count_unused_goals() > 0: self.play_round() print(f"Your final score was {self.score}") + + """its prints =*80 then it sets rolls to 3. Then it shows how many rolls you have left. it shows how many rolls you ahve left after thdice roles. adds to the score + """ def play_round(self): print("=" * 80) self.rolls_left = 3 @@ -25,10 +34,14 @@ class Yachtzee: goal.used = True self.score += goal.score(self.dice) + """Used to show score, rolls left and dice in the game. + """ def show_status(self): dice = ', '.join([str(die) for die in self.dice]) print(f"Score: {self.score}. Rolls left: {self.rolls_left}. Dice: {dice}.") + """Used to show score, rolls left and dice in the game. + """ def choose_goal(self): options = [] unused_goals = self.get_unused_goals() @@ -44,7 +57,10 @@ class Yachtzee: return self.choose_goal() else: return unused_goals[choice] - + + """ + Displays options amd prompts user to make choice. If input is valid return the choice. + """ def get_choice(self, options): print("What would you like to do?") for i, option in enumerate(options): @@ -55,6 +71,9 @@ class Yachtzee: choice = input("> ") return int(choice) + """ + Chekcs if the users chouice is valid, returns true or false. + """ def option_choice_is_valid(self, choice, options): if not choice.isdigit(): return False @@ -64,9 +83,15 @@ class Yachtzee: return False return True + """ + counts unused goals + """ def count_unused_goals(self): return len(self.get_unused_goals()) + """ + iterates through sel.goals and ammends unused goals list with unused goals. + """ def get_unused_goals(self): unused_goals = [] for goal in self.goals: @@ -74,6 +99,9 @@ class Yachtzee: unused_goals.append(goal) return unused_goals + """ + rerolls dice, decreased amount of rolls + """ def reroll(self): self.rolls_left -= 1 choices = self.get_reroll_choices() @@ -81,6 +109,9 @@ class Yachtzee: for die in dice_to_reroll: die.roll() + """ + Determiens whcih dice should be rerolled + """ def get_dice_to_reroll(self, choice_ints): dice_to_reroll = [] for die in self.dice: @@ -89,6 +120,9 @@ class Yachtzee: dice_to_reroll.append(die) return dice_to_reroll + """ + Prompts to enter which dice to re-roll + """ def get_reroll_choices(self): print("Which dice do you want to re-roll?") choices = input("> ") @@ -98,6 +132,9 @@ class Yachtzee: choice_ints = [int(digit) for digit in choices] return choice_ints + """ + Validates choices for reroll + """ def reroll_choices_are_valid(self, choices_str): if not choices_str.isdigit(): return False