Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to chess online with socket.io #17

Open
truongtrungtinh opened this issue Aug 25, 2020 · 1 comment
Open

How to chess online with socket.io #17

truongtrungtinh opened this issue Aug 25, 2020 · 1 comment

Comments

@truongtrungtinh
Copy link

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

@vitogit
Copy link
Owner

vitogit commented Sep 8, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants