def plays(self, score): '''This is where the computer plays its turn''' #TODO break out Controller and View logic and make testable self.score = score set_of_dice = SetOfDice() self.turn_scorer = TurnScorer() the_dice = set_of_dice.roll_all() user_input = True while user_input is True: the_dice = self.turn_scorer.score_roll(*the_dice) if the_dice is None: print("{} went bust!".format('Computer')) self.turn_scorer.zero_score() break else: print("{}'s counting dice: ".format('Computer')) display_dice(*self.turn_scorer.return_dice_held()) print("Dice returned: ") display_dice(*the_dice, inline=True) user_input = self.will_play(len(the_dice)) print("{}'s score: {}".format('Computer', self.turn_scorer.return_score())) the_dice = set_of_dice.roll(*the_dice) sleep(2) return self.turn_scorer.return_score()
def players_turn(self, player='User'): set_of_dice = SetOfDice() the_dice = set_of_dice.roll_all() turnscorer = TurnScorer() user_input = '' while user_input == '': the_dice = turnscorer.score_roll(*the_dice) if the_dice is None: print("{} went bust!".format(player)) turnscorer.zero_score() break else: print("{}'s counting dice: ".format(player)) display_dice(*turnscorer.return_dice_held()) print("Dice returned: ") display_dice(*the_dice, inline=True) print("{}'s score: {}".format(player, turnscorer.return_score())) the_dice = set_of_dice.roll(*the_dice) user_input = input('Press return to keep going?') return turnscorer.return_score()