emilbratt/lonely-chess

Add functionality to move pieces

Closed this issue · 0 comments

There is still no functionality to move pieces in the game, althrough the logic for how pieces should move is present and returned by getPossibleMoves within handleClick.

The functionality to move a piece would need to move the actual instance of the piece in the currentPosition matrix by copying the reference, OR create a new instance of the piece in the selected tile. Copying the piece by reference is most likely more future-proof, as we'll need to store data like hasMoved for pawns, rooks and kings, as well as hasCastled and possibly other things that will not be a part of the Piece constructor for the purpose of reducing clutter.

Shape of array of objects returned by getPossibleMoves:

]
    {
        col: number,
        row: number,
        attack: boolean,
    },
]