X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FZen.js;h=da4dd7af60454924f155a175ed5134c194220c37;hb=2d7194bd9c976f444e43e5dc0a725823b6472eb9;hp=c1f48147405893bf6e6af6fb2fe5260f4107c052;hpb=9234226104764b91df9d677fb360ad538b98510c;p=vchess.git diff --git a/public/javascripts/variants/Zen.js b/public/javascripts/variants/Zen.js index c1f48147..da4dd7af 100644 --- a/public/javascripts/variants/Zen.js +++ b/public/javascripts/variants/Zen.js @@ -1,25 +1,20 @@ class ZenRules extends ChessRules { // NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare - getEpSquare(move) - { - return undefined; - } + static get HasEnpassant { return false; } // TODO(?): some duplicated code in 2 next functions getSlideNJumpMoves([x,y], steps, oneStep) { const color = this.getColor(x,y); let moves = []; - const [sizeX,sizeY] = VariantRules.size; outerLoop: for (let loop=0; loop=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j= 0 && x+shift < sizeX && x+shift != lastRank) { @@ -140,31 +132,27 @@ class ZenRules extends ChessRules getPotentialRookMoves(sq) { - let noCaptures = this.getSlideNJumpMoves( - sq, VariantRules.steps[VariantRules.ROOK]); + let noCaptures = this.getSlideNJumpMoves(sq, V.steps[V.ROOK]); let captures = this.findCaptures(sq); return noCaptures.concat(captures); } getPotentialKnightMoves(sq) { - let noCaptures = this.getSlideNJumpMoves( - sq, VariantRules.steps[VariantRules.KNIGHT], "oneStep"); + let noCaptures = this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT], "oneStep"); let captures = this.findCaptures(sq); return noCaptures.concat(captures); } getPotentialBishopMoves(sq) { - let noCaptures = this.getSlideNJumpMoves( - sq, VariantRules.steps[VariantRules.BISHOP]); + let noCaptures = this.getSlideNJumpMoves(sq, V.steps[V.BISHOP]); let captures = this.findCaptures(sq); return noCaptures.concat(captures); } getPotentialQueenMoves(sq) { - const V = VariantRules; let noCaptures = this.getSlideNJumpMoves( sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP])); let captures = this.findCaptures(sq); @@ -173,7 +161,6 @@ class ZenRules extends ChessRules getPotentialKingMoves(sq) { - const V = VariantRules; // Initialize with normal moves let noCaptures = this.getSlideNJumpMoves(sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"); @@ -194,16 +181,14 @@ class ZenRules extends ChessRules } // Translate initial square (because pieces may fly unusually in this variant!) - let initialSquare = - String.fromCharCode(97 + move.start.y) + (VariantRules.size[0]-move.start.x); + const initialSquare = V.CoordsToSquare(move.start); // Translate final square - let finalSquare = - String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x); + const finalSquare = V.CoordsToSquare(move.end); let notation = ""; - let piece = this.getPiece(move.start.x, move.start.y); - if (piece == VariantRules.PAWN) + const piece = this.getPiece(move.start.x, move.start.y); + if (piece == V.PAWN) { // pawn move (TODO: enPassant indication) if (move.vanish.length > 1) @@ -228,7 +213,9 @@ class ZenRules extends ChessRules return notation; } - static get VALUES() { //TODO: experimental + static get VALUES() + { + // TODO: experimental return { 'p': 1, 'r': 3,