Our opponents king is usually hiding in the corner behind pawns, we need to break through this in order to checkmate.
Code
//Please feel welcome to copy this code for your own creations.
fromFen("2r3rk/5ppp/4b3/3q4/8/P2Q4/1PP1R3/1K4R1 w - - 0 1");
let steps = [];
let targetMove = "";
steps.push(function() {
info("After a successful opening, our opponent's king will usually have castled, and be tucked up safe in the corner of the board behind the pawns.");
showNextButton(true);
});
steps.push(function() {
info("This means that if we want checkmate then we have to destroy the kings cover.\
<br>Find the move that removes the pawn on h7.");
targetMove = "Qxh7+";
});
steps.push(function() {
performMove("Kxh7");
nextDelayed();
});
steps.push(function() {
info("Now we are free to check the king.");
targetMove = "Rh2+";
});
steps.push(function() {
performMove("Bh3");
nextDelayed();
});
steps.push(function() {
targetMove = "Rxh3+";
});
steps.push(function() {
performMove("Qh5");
nextDelayed();
});
steps.push(function() {
targetMove = "Rxh5#";
});
steps.push(function() {
info("Checkmate");
complete();
});
onPieceClicked(function (squareName) {
if(targetMove == "") {
return false;
}
if (squareName == sourceOfSan(targetMove)) {
return true;
} else {
highlightSquareRed(squareName);
return false;
}
});
onMoveAttempted(function (san) {
if (targetMove != "" && san == targetMove) {
nextDelayed();
targetMove = "";
return true;
} else {
return false;
}
});
onNextClicked(function () {
showNextButton(false);
next();
});
function nextDelayed() {
setTimeout(next, 400);
}
function next() {
if (steps.length > 0) {
//remove the first function from the array and call it
steps.shift()();
}
}
next();