generated from mwc/lab_dice
	Initial commit
This commit is contained in:
		
							
								
								
									
										42
									
								
								yahtzee_goals.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								yahtzee_goals.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
		Reference in New Issue
	
	Block a user