| Total Complexity | 10 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 50% |
| Changes | 6 | ||
| Bugs | 0 | Features | 1 |
| 1 | 1 | from .board import ChessBoard |
|
| 3 | class Chess: |
||
| 4 | 1 | ||
| 5 | def __init__(self, existing_board=None): |
||
| 6 | 1 | self._board = ChessBoard(existing_board) |
|
| 7 | 1 | ||
| 8 | @property |
||
| 9 | 1 | def board(self): |
|
| 10 | return self._get_board() |
||
| 11 | 1 | ||
| 12 | def _get_board(self): |
||
| 13 | 1 | return self._board.board |
|
| 14 | 1 | ||
| 15 | def generate_fen(self): |
||
| 16 | 1 | return self._board.generate_fen() |
|
| 17 | |||
| 18 | def export(self): |
||
| 19 | 1 | return self._board.export() |
|
| 20 | |||
| 21 | def move(self, start_location, end_location): |
||
| 22 | 1 | start = self._convert_location_to_board_indices(start_location) |
|
| 23 | end = self._convert_location_to_board_indices(end_location) |
||
| 24 | return self._board.move(start, end) |
||
| 25 | |||
| 26 | def destinations(self, start_location): |
||
| 27 | 1 | return self._board.end_locations_for_piece_at_location(start_location) |
|
| 28 | |||
| 29 | @staticmethod |
||
| 30 | 1 | def _convert_location_to_board_indices(location): |
|
| 31 | if isinstance(location, str): |
||
| 32 | assert len(location) == 2 |
||
| 33 | alphabet = "abcdefghijklmnopqrstuvwxyz" |
||
| 34 | col = alphabet.index(location[0].lower()) |
||
| 35 | row = int(location[1]) - 1 |
||
| 36 | key = (row, col) |
||
| 37 | return key |
||
| 38 | return location |
||
| 39 |
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.