vue-chessboard icon indicating copy to clipboard operation
vue-chessboard copied to clipboard

How to chess online with socket.io

Open truongtrungtinh opened this issue 4 years ago • 1 comments

How to prevent the same player move white and black. ex: if orientation is white then can't move black Please help me.

truongtrungtinh avatar Aug 25 '20 01:08 truongtrungtinh

Hi @truongtrungtinh That's an interesting problem. I think you can extend the component so you have more flexibility to configure the underline components (chess.js and chessground), then you have to validate which user is white and which is black and prevent the movement. Here is an example of how to extend the component to play against a random move computer https://github.com/vitogit/vue-chessboard#extended-component-play-vs-random-ai In your case I think you can have 2 methods, whitePlay, blackPlay and add a condition if the currentUser is white or black make the move otherwise just return

vitogit avatar Sep 08 '20 14:09 vitogit