Stop a piece from capturing itself
This commit is contained in:
parent
015196a52d
commit
18294b0606
|
@ -306,6 +306,12 @@
|
||||||
renderedPromotion = whiteMove ? whitePieces[promotion] : blackPieces[promotion];
|
renderedPromotion = whiteMove ? whitePieces[promotion] : blackPieces[promotion];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Are we moving the piece onto itself?
|
||||||
|
if (startLetter === endLetter && startNumber === endNumber) {
|
||||||
|
alert('Start and end squares of the move cannot be identical');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Are we moving the piece from where it is located?
|
// Are we moving the piece from where it is located?
|
||||||
let startSquare = document.getElementById(startLetter + startNumber);
|
let startSquare = document.getElementById(startLetter + startNumber);
|
||||||
if (startSquare.childNodes.length === 0) {
|
if (startSquare.childNodes.length === 0) {
|
||||||
|
|
Loading…
Reference in New Issue