class GoalOnes: "One point for each one" used = False 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" used = False 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" used = False 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" used = False 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: "Five points for each five" used = False 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" used = False 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 GoalThreeOfAKind: "Sum of all dice for 3 of a kind" used = False def prompt(self, dice): potential_score = self.score(dice) return f"3 of a kind ({potential_score})" def score(self, dice): total = 0 flag = False of_each_counter={1:0, 2:0, 3:0, 4:0, 5:0, 6:0} for die in dice: of_each_counter[die.face]=of_each_counter[die.face]+1 for num_of in of_each_counter.values(): if num_of>=3: flag = True if flag: for die in dice: total += die.face return total class GoalFourOfAKind: "Sum of all dice for 4 of a kind" used = False def prompt(self, dice): potential_score = self.score(dice) return f"4 of a kind ({potential_score})" def score(self, dice): total = 0 flag = False of_each_counter={1:0, 2:0, 3:0, 4:0, 5:0, 6:0} for die in dice: of_each_counter[die.face]=of_each_counter[die.face]+1 for num_of in of_each_counter.values(): if num_of>=4: flag = True if flag: for die in dice: total += die.face return total class GoalFullHouse: "25 points for full house" used = False def prompt(self, dice): potential_score = self.score(dice) return f"Full House ({potential_score})" def score(self, dice): total = 0 of_each_counter={1:0, 2:0, 3:0, 4:0, 5:0, 6:0} for die in dice: of_each_counter[die.face]=of_each_counter[die.face]+1 if 3 in of_each_counter.values() and 2 in of_each_counter.values(): total=25 return total class GoalSmallStraight: "30 points for small straight" used = False def prompt(self, dice): potential_score = self.score(dice) return f"Small Straight ({potential_score})" def score(self, dice): total = 0 nums=[] for die in dice: nums.append(die.face) op1=(1 in nums and 2 in nums and 3 in nums and 4 in nums) op2=(2 in nums and 3 in nums and 4 in nums and 5 in nums) op3=(3 in nums and 4 in nums and 5 in nums and 6 in nums) if op1 or op2 or op3: total=30 return total class GoalLargeStraight: "40 points for Large straight" used = False def prompt(self, dice): potential_score = self.score(dice) return f"Large Straight ({potential_score})" def score(self, dice): total = 0 nums=[] for die in dice: nums.append(die.face) op1=(1 in nums and 2 in nums and 3 in nums and 4 in nums and 5 in nums) op2=(2 in nums and 3 in nums and 4 in nums and 5 in nums and 6 in nums) if op1 or op2: total=40 return total class GoalYahtzee: "50 points for Yahtzee" used = False def prompt(self, dice): potential_score = self.score(dice) return f"Yahtzee ({potential_score})" def score(self, dice): total = 0 flag=True for die in dice: if die!=dice[0].face: flag=False if flag: total=50 return total class GoalChance: "Sum of all dice for Chance" used = False def prompt(self, dice): potential_score = self.score(dice) return f"Chance ({potential_score})" def score(self, dice): total = 0 for die in dice: total += die.face return total