This PR splits the JanggiGame class into separate Game and Board classes; the associated unit test modules are also split. The Board class handles all lower-level grid manipulations (e.g. moves) and checks (e.g. out-of-bounds) and the Game class handles higher-level game logic (e.g. player turns) and rules. The class usage (where -> means "has") is now: JanggiGui -> Game -> Board -> Piece
The Board's internal 2d array is renamed from _board to _grid for clarity, and access from outside the Board class is removed.
Static utility functions (e.g. numeric_to_algebraic()) are moved into a new jangii.utils module, with unit tests moved as needed. The parameters for each function are annotated for static analysis.
The Piece class (and its children) are updated to annotate parameter types (helps IDE static analyzers) and makes use of the various functions that are moved (e.g. board checkers moving into Board, util routines moving into utils.py).
Lastly, there is some refactoring in the gui.py module to reduce duplicate code, and some overall PEP-style refactoring throughout the project.
This PR splits the
JanggiGame
class into separateGame
andBoard
classes; the associated unit test modules are also split. TheBoard
class handles all lower-level grid manipulations (e.g. moves) and checks (e.g. out-of-bounds) and theGame
class handles higher-level game logic (e.g. player turns) and rules. The class usage (where->
means "has") is now:JanggiGui -> Game -> Board -> Piece
The
Board
's internal 2d array is renamed from_board
to_grid
for clarity, and access from outside theBoard
class is removed.Static utility functions (e.g.
numeric_to_algebraic()
) are moved into a newjangii.utils
module, with unit tests moved as needed. The parameters for each function are annotated for static analysis.The
Piece
class (and its children) are updated to annotate parameter types (helps IDE static analyzers) and makes use of the various functions that are moved (e.g. board checkers moving intoBoard
, util routines moving intoutils.py
).Lastly, there is some refactoring in the
gui.py
module to reduce duplicate code, and some overall PEP-style refactoring throughout the project.