Simplify goals interface, remove .
This commit is contained in:
parent
88b65f75a9
commit
1d97a0df20
4
play.py
4
play.py
|
@ -1,4 +1,4 @@
|
||||||
from yahtzee import Yachtzee
|
from yahtzee import Yahtzee
|
||||||
from yahtzee_goals import (
|
from yahtzee_goals import (
|
||||||
GoalOnes,
|
GoalOnes,
|
||||||
GoalTwos,
|
GoalTwos,
|
||||||
|
@ -11,5 +11,5 @@ goals = [
|
||||||
GoalThrees(),
|
GoalThrees(),
|
||||||
]
|
]
|
||||||
|
|
||||||
game = Yachtzee(goals)
|
game = Yahtzee(goals)
|
||||||
game.play()
|
game.play()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from die import Die
|
from die import Die
|
||||||
|
|
||||||
class Yachtzee:
|
class Yahtzee:
|
||||||
"""A command-line Yahtzee game.
|
"""A command-line Yahtzee game.
|
||||||
This version of Yahtzee is initialized with a list of goals.
|
This version of Yahtzee is initialized with a list of goals.
|
||||||
"""
|
"""
|
||||||
|
@ -11,6 +11,9 @@ class Yachtzee:
|
||||||
|
|
||||||
def play(self):
|
def play(self):
|
||||||
print("Welcome to Yachtzee!")
|
print("Welcome to Yachtzee!")
|
||||||
|
self.score = 0
|
||||||
|
for goal in self.goals:
|
||||||
|
goal.used = False
|
||||||
while self.count_unused_goals() > 0:
|
while self.count_unused_goals() > 0:
|
||||||
self.play_round()
|
self.play_round()
|
||||||
print(f"Your final score was {self.score}")
|
print(f"Your final score was {self.score}")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
class GoalOnes:
|
class GoalOnes:
|
||||||
"One point for each one"
|
"One point for each one"
|
||||||
used = False
|
|
||||||
|
|
||||||
def prompt(self, dice):
|
def prompt(self, dice):
|
||||||
potential_score = self.score(dice)
|
potential_score = self.score(dice)
|
||||||
|
@ -16,7 +15,6 @@ class GoalOnes:
|
||||||
|
|
||||||
class GoalTwos:
|
class GoalTwos:
|
||||||
"Two points for each two"
|
"Two points for each two"
|
||||||
used = False
|
|
||||||
|
|
||||||
def prompt(self, dice):
|
def prompt(self, dice):
|
||||||
potential_score = self.score(dice)
|
potential_score = self.score(dice)
|
||||||
|
@ -31,7 +29,6 @@ class GoalTwos:
|
||||||
|
|
||||||
class GoalThrees:
|
class GoalThrees:
|
||||||
"Three points for each three"
|
"Three points for each three"
|
||||||
used = False
|
|
||||||
|
|
||||||
def prompt(self, dice):
|
def prompt(self, dice):
|
||||||
potential_score = self.score(dice)
|
potential_score = self.score(dice)
|
||||||
|
|
Loading…
Reference in New Issue