class TestDice(unittest.TestCase):
    def setUp(self):
        self.dice = Dice()

    def test_roll(self):
        """the total of the rolled dice should be no less than 2 and no greater than 12"""
        roll = self.dice.roll()
        self.assertTrue(roll >= 2 and roll <= 12)

    def test_doubles_rolled(self):
        """if each dye has the same roll, doubles has been rolled"""
        self.dice.dye_1 = 1
        self.dice.dye_2 = 1
        self.assertEqual(self.dice.is_doubles(), True)

    def test_doubles_not_rolled(self):
        """if each dye has a different roll, doubles has not been rolled"""
        self.dice.dye_1 = 1
        self.dice.dye_2 = 5
        self.assertEqual(self.dice.is_doubles(), False)
Beispiel #2
0
    # Begin game
    for player in all_players:
        double_count = 1
        print(colored(f"\nCurrent player: {player.name.upper()}", "cyan"))
        while in_jail[player] is True:
            jail_count[player] = jail_count[player] + 1
            if jail_count[player] == 3:
                print("You are now released from jail.")
                jail_count[player] = 0
                in_jail[player] = False
                break
            print(
                "You are in jail. You will need to roll a double to get out or wait until your third turn."
            )
            DICE.roll()
            if DICE.is_doubles():
                jail_count[player] = 0
                print("You are now released from jail.")
                input("Press Enter")
                break
            else:
                print("Sorry, you did not roll doubles this time.")
                input("Press Enter")
                break
        if in_jail[player] == False:
            DICE.roll()
            update_player_balance()
            while DICE.is_doubles():  #DICE.is_doubles()

                if double_count >= 3:
                    print(