TKPending / ChessGame

HTML and Javascript Chess Game
0 stars 0 forks source link

CG-6 Unable to move to tiles with existing pieces. #7

Closed TKPending closed 9 months ago

TKPending commented 9 months ago

Whenever moving a piece to a tile that already has a piece on it, causes an error. Need to check on the logic of checking tiles, taking over tiles. Bonus Bug: When making invalid moves, it logs taking over friendly.

TKPending commented 9 months ago

Problem was due to the logic of the 'LegalMoveCheck' function. It was only function when moving to empty tiles. As piece and tile objects are different, when trying to move to a tile where another piece was. This would cause an error. Solved this by creating a variable which distinguish the difference between tile and piece, and returning the correct location based on which object it was.