X-Git-Url: https://git.auder.net/?a=blobdiff_plain;ds=sidebyside;f=public%2Fjavascripts%2Fvariants%2FCheckered.js;h=f1cf771f948e585ce9a4ce7342058c154b7d69e0;hb=f3c10e18c1585f043e22b875e9755814fa9218d7;hp=4f523edba74f675b4714bc1124040a973fcac167;hpb=2526c041baf44968b0aa7b98af56730e88f6a595;p=vchess.git diff --git a/public/javascripts/variants/Checkered.js b/public/javascripts/variants/Checkered.js index 4f523edb..f1cf771f 100644 --- a/public/javascripts/variants/Checkered.js +++ b/public/javascripts/variants/Checkered.js @@ -1,6 +1,5 @@ class CheckeredRules extends ChessRules { - // Path to pieces static getPpath(b) { return b[0]=='c' ? "Checkered/"+b : b; @@ -72,6 +71,7 @@ class CheckeredRules extends ChessRules getPotentialMovesFrom([x,y]) { let standardMoves = super.getPotentialMovesFrom([x,y]); + const lastRank = this.turn == "w" ? 0 : 7; if (this.getPiece(x,y) == VariantRules.KING) return standardMoves; //king has to be treated differently (for castles) let moves = []; @@ -87,12 +87,13 @@ class CheckeredRules extends ChessRules { // A capture occured (m.vanish.length == 2) m.appear[0].c = "c"; - moves.push(JSON.parse(JSON.stringify(m))); - if (m.appear[0].p != m.vanish[1].p) + moves.push(m); + if (m.appear[0].p != m.vanish[1].p //avoid promotions: + && (m.vanish[0].p != VariantRules.PAWN || m.end.x != lastRank)) { // Add transformation into captured piece let m2 = JSON.parse(JSON.stringify(m)); - m2.vanish[1].p = m.appear[0].p; + m2.appear[0].p = m.vanish[1].p; moves.push(m2); } }