TKPending / ChessGame

HTML and Javascript Chess Game
0 stars 0 forks source link

CG-5 Create logic to prevent pieces moving in blocked routes #5

Closed TKPending closed 9 months ago

TKPending commented 9 months ago

Create logic which will reduce the amount of "valid" moves, to prevent friendly pieces jumping over each other. Aside from the knight, if there is a piece in the way. Any movement (including the friendly piece) and further should be considered an invalid movement.

TKPending commented 9 months ago

Changed the logic in the 'GenerateLegalMoves' function, added a 'IsTileOccupied' method, which deals with checking if tiles are empty. If a piece is found then we stop generating moves. Also, if the last tile checked is an enemy tile then we push that tile as the last valid move, preventing pieces from jumping over enemy tiles