zacharybmeyers / janggi-game

This project creates the logic for a playable game of Janggi (Korean chess) with a GUI built on Pygame.
2 stars 0 forks source link

GameBoard Refactoring #18

Closed asiderop closed 3 years ago

asiderop commented 3 years ago

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.

asiderop commented 3 years ago

Okay. This is ready for review and merge, now. Thanks.

zacharybmeyers commented 3 years ago

Smashed it. Thank you!! You did so much dirty work...