Пример #1
0
 def test_check_no_win_horizontal(self):
     game = Game()
     a = Piece.from_attributes(True, True, False, True)
     b = Piece.from_attributes(True, False, False, True)
     c = Piece.from_attributes(False, True, False, False)
     d = Piece.from_attributes(True, False, True, False)
     game.board.put(a, 0, 0)
     game.board.put(b, 1, 0)
     game.board.put(c, 2, 0)
     game.board.put(d, 3, 0)
     self.assertEqual(game.check_win(0, 0), False)
Пример #2
0
    def test_check_win_negative_diagonal(self):
        game = Game()
        a = Piece.from_attributes(True, True, False, True)
        b = Piece.from_attributes(True, False, False, True)
        c = Piece.from_attributes(True, True, False, False)
        d = Piece.from_attributes(True, False, True, False)

        game.board.put(a, 0, 3)
        game.board.put(b, 1, 2)
        game.board.put(c, 2, 1)
        game.board.put(d, 3, 0)
        self.assertEqual(game.check_win(0, 3), True)
Пример #3
0
    def test_check_win_vertical(self):
        game = Game()
        a = Piece.from_attributes(True, True, False, True)
        b = Piece.from_attributes(True, False, False, True)
        c = Piece.from_attributes(True, True, False, False)
        d = Piece.from_attributes(True, False, True, False)

        game.board.put(a, 0, 0)
        game.board.put(b, 0, 1)
        game.board.put(c, 0, 2)
        game.board.put(d, 0, 3)
        self.assertEqual(game.check_win(0, 0), True)
Пример #4
0
 def load_game(self, game_uuid):
     storage_path = os.path.join(self.config.get('quarto_game_store'),
                                 game_uuid)
     if not os.path.exists(storage_path):
         raise GameNotFound()
     with open(storage_path, 'r') as f:
         return Game.from_dict(json.loads(f.read()))
Пример #5
0
 def create_game(self, player_name):
     game = Game()
     game.join_game(Player(player_name))
     game_uuid = self._store_game(game)
     return game_uuid, game
Пример #6
0
 def _init_game(self):
     game = Game()
     game.player_a = Player('bob')
     game.player_b = Player('sam')
     return game
Пример #7
0
 def test_check_win_no_pieces(self):
     game = Game()
     for x in range(4):
         for y in range(4):
             self.assertEqual(game.check_win(x, y), False)