I am working on a project building chess game in java. For the piece movement (without knight):
-
The pawn can move only 1 cell horizontally.
-
The rook can move horizontally and vertically by any number of cells.
-
The queen can move diagonally, horizontally and vertically by any number of cells.
The way I am implementing it right now is getValidMove()
will call all the Valid Move (getValidMoveSouth(x,y,cells)
, getValidMoveNorth(x,y,cells)
, etc) methods.
The param cells are for the number of cells a piece is able to move. So for the pawn, the param cells will be 1. Inside of each Valid Move methods will be a loop to the param cells.
I wonder is there any elegant way to implement it Java?
Aucun commentaire:
Enregistrer un commentaire