Ejemplo n.º 1
0
 def test_no_winner_board_full(self):
     x_token = XToken()
     o_token = OToken()
     grid = Grid(3, 3)
     grid_controller = GridController()
     grid_controller.assign_grid(grid)
     grid.add_token_position(x_token, 0, 0)
     grid.add_token_position(x_token, 0, 1)
     grid.add_token_position(x_token, 1, 2)
     grid.add_token_position(x_token, 2, 0)
     grid.add_token_position(x_token, 2, 1)
     grid.add_token_position(o_token, 0, 2)
     grid.add_token_position(o_token, 1, 0)
     grid.add_token_position(o_token, 1, 1)
     grid.add_token_position(o_token, 2, 2)
     winner = grid_controller.check_for_win()
     assert winner is None
     assert grid_controller.grid_is_full()
Ejemplo n.º 2
0
 def play_round(
     self,
     player_controllers: List[PlayerController],
     grid_controller: GridController,
 ):
     for player_controller in player_controllers:
         row = None
         column = None
         while not grid_controller.check_if_position_available(row, column):
             grid_controller.print_grid_with_prompt()
             if self.game_won(player_controllers, grid_controller):
                 return
             if grid_controller.grid_is_full():
                 self.__game.game_over = True
                 return
             player_controller.print_player()
             rows, columns = grid_controller.get_grid_dimensions()
             row = player_controller.select_row(rows)
             column = player_controller.select_column(columns)
         player_token = player_controller.retrieve_token()
         grid_controller.place_token_in_spot(player_token, row, column)