vitogit / vue-chessboard

Chessboard vue component to load positions, create positions and see threats
http://vitomd.com/vue-chessboard-examples/
GNU General Public License v3.0
165 stars 49 forks source link

How to chess online with socket.io #17

Open truongtrungtinh opened 4 years ago

truongtrungtinh commented 4 years ago

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

vitogit commented 4 years ago

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