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

Clean up the Piece classes to not hold embedded game rules #20

Open asiderop opened 3 years ago

asiderop commented 3 years ago

The Piece classes should just hold the move paths, without any knowledge of whether a given move path is valid in its current position and board. Those rules logics should be moved into the Game class instead.

I am thinking the possible moves are encoded as a list of relative coordinates, where a value of 1 equates to moving forward and -1 equates to moving backward. A simple example of the Soldier class would be [ (0,0), (1,0) ] to move the piece forward one cell.

These lists of move paths are then processed by the Game (and Board) class to remove invalid paths, e.g. when it's blocked by a friendly piece.