from collections import Counter from die import Die class GoalOnes: "One point for each one" def prompt(self, dice): potential_score = self.score(dice) return f"Ones ({potential_score})" def score(self, dice): total = 0 for die in dice: if die.face == 1: total += 1 return total class GoalTwos: "Two points for each two" def prompt(self, dice): potential_score = self.score(dice) return f"Twos ({potential_score})" def score(self, dice): total = 0 for die in dice: if die.face == 2: total += 2 return total class GoalThrees: "Three points for each three" def prompt(self, dice): potential_score = self.score(dice) return f"Threes ({potential_score})" def score(self, dice): total = 0 for die in dice: if die.face == 3: total += 3 return total class GoalFours: "Four points for each four" def prompt(self, dice): potential_score = self.score(dice) return f"Fours ({potential_score})" def score(self, dice): total = 0 for die in dice: if die.face == 4: total += 4 return total class GoalFives: "Fives points for each five" def prompt(self, dice): potential_score = self.score(dice) return f"Fives ({potential_score})" def score(self, dice): total = 0 for die in dice: if die.face == 5: total += 5 return total class GoalSixes: "Six points for each six" def prompt(self, dice): potential_score = self.score(dice) return f"Sixes ({potential_score})" def score(self, dice): total = 0 for die in dice: if die.face == 6: total += 6 return total class Goal_is_three_of_a_kind: "Score is total all 5 dice for three-of-a-kind" def prompt(self, dice): potential_score = self.score(dice) return f"3 of a kind ({potential_score})" def score(self, dice): total=0 for die in dice: counts = Counter([die.face for die in dice]) my_dict=dict(counts) values = list(my_dict.values()) for a in values: if a == 3: total += die.face return total class Goal_is_four_of_a_kind: "Score is total all 5 dice for four-of-a-kind" def prompt(self, dice): potential_score = self.score(dice) return f"4 of a kind ({potential_score})" def score(self, dice): total=0 for die in dice: counts = Counter([die.face for die in dice]) my_dict=dict(counts) values = list(my_dict.values()) for a in values: if a == 4: total += die.face return total class Goal_is_full_house: "25 points for a full house (three-of-a-kind plus a pair of a different number)" def prompt(self, dice): potential_score = self.score(dice) return f"Full House ({potential_score})" def score(self, dice): total=0 for die in dice: counts = Counter([die.face for die in dice]) my_dict=dict(counts) values = list(my_dict.values()) for a in values: if (a == 3 and len(values) == 2): total = 25 return total