Example #1
0
 def test_turn_display_player2(self):
     player1 = computer_player.ComputerPlayer(1)
     player2 = computer_player.ComputerPlayer(2)
     board = game_board.GameBoard()
     test_game = game.Game(player1, player2, board)
     test_game.process_turn()
     self.assertEqual(console_prompts.ConsolePrompts().alert_whose_turn_it_is(test_game), "Player 2's turn... ")
Example #2
0
 def test_asking_for_input(self):
     self.assertEqual(console_prompts.ConsolePrompts().ask_user_for_input(), "Move options: \r\n"
                                                                             + "0|1|2\r\n"
                                                                             + "_____\r\n"
                                                                             + "3|4|5\r\n"
                                                                             + "_____\r\n"
                                                                             + "6|7|8\r\n"
                                                                             + "Please enter the move number: ")
Example #3
0
 def test_game_display(self):
     board = game_board.GameBoard()
     board.change_square(1, 1)
     board.change_square(3, 1)
     board.change_square(7, 2)
     board.change_square(8, 2)
     self.assertEqual(console_prompts.ConsolePrompts().display_game(board), "Current board: \r\n"
                                                                         + " |O| \r\n"
                                                                         + "_____\r\n"
                                                                         + "O| | \r\n"
                                                                         + "_____\r\n"
                                                                         + " |X|X\r\n")
Example #4
0
from Application import console_prompts
from Application import human_input
from Application import input_output
from GameInfo import game
from GameInfo import human_player
from GameInfo import computer_player
from GameInfo import game_board

console_io = input_output.InputOutput(human_input.HumanInput(),
                                      console_prompts.ConsolePrompts())
player1 = human_player.HumanPlayer(1, console_io)
player2 = computer_player.ComputerPlayer(2)
_game = game.Game(player1, player2, game_board.GameBoard())

while not _game.game_board.is_game_over():
    console_io.alert_whose_turn_it_is(_game)
    console_io.display_game(_game.game_board)
    _game.process_turn()

console_io.alert_game_over(_game.game_board)
console_io.display_game(_game.game_board)
Example #5
0
 def test_game_over_alert_tie_game(self):
     board = game_board.GameBoard()
     board.set_board([1, 2, 1, 1, 2, 1, 2, 1, 2])
     self.assertEqual(console_prompts.ConsolePrompts().alert_game_over(board), "Tie game!")
Example #6
0
 def test_game_over_alert_player2(self):
     board = game_board.GameBoard()
     board.set_board([1, 1, 0, 1, 0, 0, 2, 2, 2])
     self.assertEqual(console_prompts.ConsolePrompts().alert_game_over(board), "Player 2 has won!")
Example #7
0
 def test_bad_input(self):
     self.assertEqual(console_prompts.ConsolePrompts().alert_bad_input(),
                      "Input is invalid. Please enter a number on the board.")