def start_play(self): points = 0 self.the_pair = PairOfDice() text = input("Press enter to roll the dice...\n") if text == "": self.the_pair.roll_dice() first_roll = self.the_pair.current_value() if (first_roll == 2 or first_roll == 3 or first_roll == 12): print("You rolled", first_roll, ". You lose!") elif (first_roll == 7 or first_roll == 11): print("You rolled", first_roll, ". You win!") else: points = self.the_pair.current_value() print("Your point is", points) self.the_pair.roll_dice() next_roll = self.the_pair.current_value() while (next_roll != points or next_roll != 7): text = input("Press enter to roll the dice...\n") if text == "": self.the_pair.roll_dice() next_roll = self.the_pair.current_value() if next_roll == points: print("You rolled", next_roll, ". You win.") break elif next_roll == 7: print("You rolled 7. You lose.") break else: print("You rolled", next_roll, ".") else: print("Press enter to roll the dice...\n") else: print("Press enter to roll the dice...\n")
def start_play(self): pairofdice = PairOfDice() # If you roll 7 or 11 on your first roll, you win. if pairofdice.current_value() in FIRST_ROUND_WIN: print(f"You rolled {pairofdice.current_value()}. You win!") # If you roll 2, 3, or 12 on your first role, you lose. elif pairofdice.current_value() in FIRST_ROUND_LOSE: print(f"You rolled {pairofdice.current_value()}. You lose.") # If you roll anything else, that's your 'point', and # you keep rolling until you either roll your point # again (win) or roll a 7 (lose) else: point = pairofdice.current_value() print(f"Your point is {point}") input("Press enter to roll the dice...\n") pairofdice.roll_dice() while pairofdice.current_value() not in [point, LOSING_NUM]: print(f"You rolled {pairofdice.current_value()}.") input("Press enter to roll the dice...\n") pairofdice.roll_dice() if pairofdice.current_value() == point: print(f"You rolled {pairofdice.current_value()}. You win!") else: print(f"You rolled {pairofdice.current_value()}. You lose.")
def __init__(self): ''' create the PairOfDice object ''' self.PairOfDice = PairOfDice()
def __init__(self): self.player_dice = PairOfDice()
def __init__(self): """creat a PairOfDice() object, initialize the point and score value""" self.pair = PairOfDice() self.point = None self.origin_point = None
def __init__(self): self.the_pair = PairOfDice()
def __init__(self): self.dice = PairOfDice() self.first_value = 0
def __init__(self): self.pair_of_dice = PairOfDice()