TKPending / ChessGame

HTML and Javascript Chess Game
0 stars 0 forks source link

CG-26 King moving into pawn capture check #39

Closed TKPending closed 9 months ago

TKPending commented 9 months ago

Need to work on the implementation of checking for check, since pawn capture tiles currently isn't recognised as a move that a king can't move into.

TKPending commented 9 months ago

Update: The issue is that for Pawn pieces, they only generate diagonal captures as legal moves only when pieces are in that tile. With that being the case, the way to solve this issue is by:

When we are generating Pawn moves, we want to add the capture store to a separate array. Such as creating a object attribute specifically for this. After doing that, when generating all the enemy moves. We need to separately add that object which holds the diagonal moves, into the enemy moves. So, when we are generating the King moves the Pawn diagonal moves are also a part of the valid enemy moves.