Total Complexity | 8 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 50% |
1 | 1 | from .board import ChessBoard |
|
4 | 1 | class Chess: |
|
5 | |||
6 | 1 | def __init__(self, existing_board=None): |
|
7 | 1 | self._board = ChessBoard(existing_board) |
|
8 | |||
9 | 1 | @property |
|
10 | def board(self): |
||
11 | 1 | return self._get_board() |
|
12 | |||
13 | 1 | def _get_board(self): |
|
14 | 1 | return self._board.board |
|
15 | |||
16 | 1 | def generate_fen(self): |
|
17 | return self._board.generate_fen() |
||
18 | |||
19 | 1 | def export(self): |
|
20 | return self._board.export() |
||
21 | |||
22 | 1 | def move(self, start_location, end_location): |
|
23 | start = self._convert_location_to_board_indices(start_location) |
||
24 | end = self._convert_location_to_board_indices(end_location) |
||
25 | return self._board.move(start, end) |
||
26 | |||
27 | 1 | def destinations(self, start_location): |
|
28 | return self._board.end_locations_for_piece_at_location(start_location) |
||
29 | |||
30 | 1 | @staticmethod |
|
31 | def _convert_location_to_board_indices(location): |
||
32 | assert len(location) == 2 |
||
33 | alphabet = "abcdefghijklmnopqrstuvwxyz" |
||
34 | col = alphabet.index(location[0].lower()) |
||
35 | row = int(location[1]) - 1 |
||
38 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.