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
166 stars 50 forks source link

How to lock a color #2

Closed clementvp closed 6 years ago

clementvp commented 6 years ago

Hi and thank you for this vue chessboard. Can I lock a colour to not to be played ? My plan is to make a online multi player game with socketIo and I need to lock the opponent colour. Example: If I'm white, I can't move black pieces on the chessboard when it's my turn and when it's my opponent turn. When it's my opponent turn I just can wait for a socketIo message of the new fen played by my opponent. You give just a method to make free movements and legal movements but not to lock a colour movements. How can I achieve this ?

vitogit commented 6 years ago

Hi, that functionality is out of the scope of this project as it´s primary for displaying positions. But if you fork the project and change the code you can do that. https://github.com/vitogit/vue-chessboard/blob/master/src/components/chessboard/index.vue there is a method called possibleMoves that you could modify.

But I think that you will need more custom code so my recommendation is to use the code as a base but study how https://github.com/jhlywa/chess.js (legal moves) and https://github.com/ornicar/chessground (board display) works. Also this examples are useful https://github.com/oddskill/chessground-examples

clementvp commented 6 years ago

Thank you for the quick answer. Yes, I will integrate a base chessground + chessJs skeleton to my app. Thank you anyway :+1: