def _mock_input(self, *args, **kwargs): prompt = args[0] if prompt.startswith("Wanna play?"): # self.old_print(prompt, 'y') return "y" elif prompt.startswith("Enter dice to keep (no spaces), or (q)uit:"): scorers = GameLogic.get_scorers(self.roll) keepers = "".join([str(ch) for ch in scorers]) # self.old_print(prompt, keepers) return keepers elif prompt.startswith("(r)oll again, (b)ank your points or (q)uit "): # _________________________________________________________ # our average score 9175 x = GameLogic.get_scorers(self.roll) y = GameLogic.calculate_score(x) # print(type(x)) # print("x"*50) # print(x) # print("x"*50) if y < 200: # scorers = GameLogic.get_scorers(self.roll) # if keepers < 200: return ("r") else: return "b" # _________________________________________________________ # return "b" else: raise ValueError(f"Unrecognized prompt {prompt}")
def take_action(self, roll, dice_to_keep): remaining_dice = get_remaining_dice(roll, dice_to_keep) dice_to_keep = str_to_tuple(dice_to_keep) to_bank = self.banker.shelf(GameLogic.calculate_score(dice_to_keep)) print( f"You have {to_bank} unbanked points and {remaining_dice} dice remaining" ) roll_bank_quit = input("(r)oll again, (b)ank your points or (q)uit ") if (roll_bank_quit == 'b'): self.banking(to_bank) self.round += 1 if self.round > self.num_rounds: print( f'Thanks for playing. You earned {self.banker.balance} points' ) sys.exit() self.new_round() elif (roll_bank_quit == 'r'): if remaining_dice == 0: remaining_dice = 6 self.repeat_round(remaining_dice) elif (roll_bank_quit == 'q'): self.quit_game()
def is_zilch(self, roll): if GameLogic.calculate_score(roll) == 0: return True else: return False
def calculate_score(self, roll): return GameLogic.calculate_score(roll)