White to skewer for advantage

Details

Author:Mark
Rating:
Difficulty:Beginner
Date:6th January 2021
Description:It's White's turn, and they can skewer their way to an advantage.

Code

//Please feel welcome to copy this code for your own creations.

fromFen("1nr3R1/3k4/8/2P5/p3b2p/P7/4BPPP/2B3K1 w - - 0 1");
info("It's White's turn, and they can skewer their way to an advantage");

let steps = ["Bg4+", "Kc6", "Rxc8+"];

onPieceClicked(function(squareName) {
    unhighlightAll();
    
    if(squareName == sourceOfSan(steps[0])) {
        return true;
    } else {
        highlightSquareRed(squareName);
        return false;
    }
});

onMoveAttempted(function(san) {
    if(san == steps[0]) {
        steps.shift();
        
        if(steps.length > 0) {
          setTimeout(function() {
            performMove(steps[0]);
            steps.shift();
          }, 500);
        } else {
          complete();
          info(" ");
        }

        return true;
    } else {
        return false;
    }
});