Пример #1
0
 def test_is_valid_noncontiguous_vertical(self):
     game = Game()
     is_valid = game.is_valid_play([
         Board.MIDDLE, (Board.MIDDLE[0] + 1, Board.MIDDLE[1]),
         (Board.MIDDLE[0] + 3, Board.MIDDLE[1])
     ], Orientation.VERTICAL)
     self.assertEqual(is_valid, ValidationReason.NOT_CONTIGUOUS)
Пример #2
0
 def test_is_valid_not_adjacent(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A
     game.board.is_empty = False
     is_valid = game.is_valid_play([(Board.MIDDLE[0] + 5, Board.MIDDLE[1])],
                                   Orientation.HORIZONTAL)
     self.assertEqual(is_valid, ValidationReason.NOT_ADJACENT)
Пример #3
0
 def test_is_valid_noncontiguous_horizontal(self):
     game = Game()
     is_valid = game.is_valid_play([
         Board.MIDDLE, (Board.MIDDLE[0], Board.MIDDLE[1] + 1),
         (Board.MIDDLE[0], Board.MIDDLE[1] + 3)
     ], Orientation.HORIZONTAL)
     self.assertEqual(is_valid, ValidationReason.NOT_CONTIGUOUS)
Пример #4
0
 def test_is_valid_first_play_not_on_middle(self):
     game = Game()
     is_valid = game.is_valid_play([(Board.MIDDLE[0], Board.MIDDLE[1] + 1),
                                    (Board.MIDDLE[0], Board.MIDDLE[1] + 2)],
                                   Orientation.HORIZONTAL)
     self.assertEqual(is_valid,
                      ValidationReason.FIRST_PLAY_NOT_ON_MIDDLE_CELL)
Пример #5
0
 def test_is_valid_vertical_true(self):
     game = Game()
     is_valid = game.is_valid_play([
         Board.MIDDLE, (Board.MIDDLE[0] + 1, Board.MIDDLE[1]),
         (Board.MIDDLE[0] + 2, Board.MIDDLE[1])
     ], Orientation.VERTICAL)
     self.assertEqual(is_valid, ValidationReason.VALID)
Пример #6
0
 def test_is_valid_horizontal_true(self):
     game = Game()
     is_valid = game.is_valid_play([
         Board.MIDDLE, (Board.MIDDLE[0], Board.MIDDLE[1] + 1),
         (Board.MIDDLE[0], Board.MIDDLE[1] + 2)
     ], Orientation.HORIZONTAL)
     self.assertEqual(is_valid, ValidationReason.VALID)
Пример #7
0
 def test_is_valid_invalid_orientation(self):
     game = Game()
     is_valid = game.is_valid_play([
         Board.MIDDLE, (Board.MIDDLE[0], Board.MIDDLE[1] + 1),
         (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1)
     ], Orientation.NONE)
     self.assertEqual(is_valid, ValidationReason.INVALID_ORIENTATION)
Пример #8
0
 def test_is_valid_prefix_suffix_horizontal(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A
     game.board.is_empty = False
     is_valid = game.is_valid_play([(Board.MIDDLE[0], Board.MIDDLE[1] - 1),
                                    (Board.MIDDLE[0], Board.MIDDLE[1] + 1)],
                                   Orientation.HORIZONTAL)
     self.assertEqual(is_valid, ValidationReason.VALID)
Пример #9
0
 def test_is_valid_prefix_suffix_vertical(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A
     game.board.is_empty = False
     is_valid = game.is_valid_play([(Board.MIDDLE[0] - 1, Board.MIDDLE[1]),
                                    (Board.MIDDLE[0] + 1, Board.MIDDLE[1])],
                                   Orientation.VERTICAL)
     self.assertEqual(is_valid, ValidationReason.VALID)
Пример #10
0
 def test_is_valid_cell_full(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A
     game.board.is_empty = False
     is_valid = game.is_valid_play([Board.MIDDLE], Orientation.HORIZONTAL)
     self.assertEqual(is_valid, ValidationReason.CELL_ALREADY_FULL)
Пример #11
0
 def test_is_valid_first_play_too_short(self):
     game = Game()
     game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A
     is_valid = game.is_valid_play([Board.MIDDLE], Orientation.HORIZONTAL)
     self.assertEqual(is_valid, ValidationReason.FIRST_PLAY_TOO_FEW_TILES)