chess.js icon indicating copy to clipboard operation
chess.js copied to clipboard

Play without turn

Open adarshks opened this issue 8 years ago • 0 comments

Hello, I want to create a game called shatranj (an old form of chess with different moves for the pieces) based on the chess.js file. In that i want to add a new feature called "deployment". That means both player can play legal moves without waiting for their turn until first capture occurs. So to allow both pieces to play at same time i added the below code in the "generate_moves" function..

var piece = board[i]; if(piece){ us = piece.color; if(piece.color === "b"){ them = "w"; } else{ them = "b"; } } if (piece == null || piece.color !== us) { continue; }

In the above code , if (piece == null || piece.color !== us) { continue; } it was already there in the "generate_moves" function.I have added the remaining codes to add the color of the piece you are playing to "us" and opposite color to "them". After placing the above code both players can play at the same time but when it is in a position to capture the opposite piece, it is unable to capture and from there whole movements and color of pieces start to change on each movements. Can you please help me on this??

adarshks avatar Jan 17 '17 10:01 adarshks