X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FLoser.js;h=da4999fe61bfeab78f92f7c49cdedf6a747b1a38;hb=32cfcea44bf00b0c6c4d172cca715823076ff490;hp=0ed3edc2ee294c2ec033bd30b5e0cb039e3072e5;hpb=6752407b88b6d7678b9b19df4ffe1224d17625d7;p=vchess.git diff --git a/public/javascripts/variants/Loser.js b/public/javascripts/variants/Loser.js index 0ed3edc2..da4999fe 100644 --- a/public/javascripts/variants/Loser.js +++ b/public/javascripts/variants/Loser.js @@ -2,13 +2,15 @@ class LoserRules extends ChessRules { initVariables(fen) { - // No castling, hence no flags; but flags defined for compatibility - this.flags = "-"; const epSq = this.moves.length > 0 ? this.getEpSquare(this.lastMove) : undefined; this.epSquares = [ epSq ]; } - setFlags(fen) { } + setFlags(fen) + { + // No castling, hence no flags; but flags defined for compatibility + this.castleFlags = { "w":[false,false], "b":[false,false] }; + } getPotentialPawnMoves([x,y]) { @@ -22,15 +24,20 @@ class LoserRules extends ChessRules const lastRank = (color == "w" ? 0 : sizeX-1); if (x+shift == lastRank) { - let p = V.KING; // Normal move if (this.board[x+shift][y] == V.EMPTY) - moves.push(this.getBasicMove([x,y], [x+shift,y], {c:color,p:p})); + moves.push(this.getBasicMove([x,y], [x+shift,y], {c:color,p:V.KING})); // Captures - if (y>0 && this.canTake([x,y], [x+shift,y-1]) && this.board[x+shift][y-1] != V.EMPTY) - moves.push(this.getBasicMove([x,y], [x+shift,y-1], {c:color,p:p})); - if (y0 && this.canTake([x,y], [x+shift,y-1]) + && this.board[x+shift][y-1] != V.EMPTY) + { + moves.push(this.getBasicMove([x,y], [x+shift,y-1], {c:color,p:V.KING})); + } + if (y