Exemple #1
0
def main(player_1_name, player_2_name, input_turns):
    """
    Main program where the Clear Strike Game starts
    """
    print("Starting Clear Strike Game!!")

    print("Initializing a Carrom Board.")
    # Initial coin details for a Carrom Board
    coins = {'black_coin': 9, 'red_coin': 1}

    # Initializing players
    player_1 = Player(player_1_name)
    player_2 = Player(player_2_name)
    players = [player_1, player_2]

    carrom_board = CarromBoard(coins=coins, players=players)
    print("Carrom Board created!!")

    print("Start Playing")
    result = carrom_board.play(input_turns)
    print("Game Ended!!")

    print('--------- RESULTS ---------')
    result = carrom_board.results()
    if result.outcome == 'Won':
        print(
            f"{result.player.name} has won the game. Final Score: {result.statistics}"
        )
    elif result.outcome == 'Draw':
        print(f"The Game is Draw with Final score: {result.statistics}")
    print('---------------------------')
Exemple #2
0
def main(player_1_name, player_2_name, input_turns):

    print("Clear Strike starting!")

    print("Initializing Carrom Board")
    # Initial coin details for a Carrom Board
    coins = {'black_coin': 9, 'red_coin': 1}

    # Initializing players
    player_1 = Player(player_1_name)
    player_2 = Player(player_2_name)
    players = [player_1, player_2]

    carrom_board = CarromBoard(coins=coins, players=players)
    print("Carrom Board created")

    print("Start Playing")

    result = carrom_board.play(input_turns)
    print("Game Ended!")

    print('------ RESULTS ------')
    result = carrom_board.results()
    if result.outcome == 'Won':
        print("{0} has won the game. Final Score: {1}".format(
            result.player.name, result.statistics))
    elif result.outcome == 'Draw':
        print("The Game is Draw with Final score: {0}".format(
            result.statistics))
    print('---------------------------')
Exemple #3
0
    def test_creation(self):

        # invaid coins param testing
        with self.assertRaises(ValueError):
            CarromBoard('invalid_datatype', [Player('player 1')])
        with self.assertRaises(ValueError):
            CarromBoard({'invalid_coin': 3}, [Player('player 1')])

        # invalid players param testing
        with self.assertRaises(ValueError):
            CarromBoard({'black_coin': 9}, Player('Invalid type'))
        with self.assertRaises(ValueError):
            CarromBoard({'black_coin': 3},
                        [Player('Player 1'), 'Not a player'])

        # Check the game state
        self.assertEqual(self.carrom_board.game_state, 'NotYetBegan')
Exemple #4
0
    def setUp(self):
        print("Initializing a Carrom Board.")
        # Initial coin details for a Carrom Board
        coins = {'black_coin': 9, 'red_coin': 1}

        # Initializing players
        player_1 = Player(name='Player 1')
        player_2 = Player(name='Player 2')
        players = [player_1, player_2]

        self.carrom_board = CarromBoard(coins=coins, players=players)
        print("Carrom Board created!!")