generated from mwc/lab_dice
111 lines
2.4 KiB
Python
111 lines
2.4 KiB
Python
|
|
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 GoalFullHouse:
|
|
"25 points for a full house. one pair and three of a kind"
|
|
used = False
|
|
|
|
def prompt(self, dice):
|
|
potential_score = self.score(dice)
|
|
return f"Full House ({potential_score})"
|
|
|
|
def score(self, dice):
|
|
counts = []
|
|
for face in range(1, 7):
|
|
count = dice.count(face)
|
|
if count > 0:
|
|
counts.append(count)
|
|
if sorted(counts) == [2, 3]:
|
|
return 25
|
|
return 0
|
|
|
|
|