X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FLoser.js;h=6731d322f57d8ebc09ec05ea3189dc58b5905ad8;hb=643479f8d7c3622b57fc49c4f10d9950793ebf4f;hp=98bd94437febf64a920d59c245bae8ceae2a4e41;hpb=7931e479adf93c87771ded1892a0873af72ae46d;p=vchess.git diff --git a/public/javascripts/variants/Loser.js b/public/javascripts/variants/Loser.js index 98bd9443..6731d322 100644 --- a/public/javascripts/variants/Loser.js +++ b/public/javascripts/variants/Loser.js @@ -1,20 +1,15 @@ class LoserRules extends ChessRules { - initVariables(fen) - { - const epSq = this.moves.length > 0 ? this.getEpSquare(this.lastMove) : undefined; - this.epSquares = [ epSq ]; - } - - static IsGoodFlags(flags) - { - return true; //anything is good: no flags - } + static get HasFlags() { return false; } - setFlags(fen) + setOtherVariables(fen) { - // No castling, hence no flags; but flags defined for compatibility - this.castleFlags = { "w":[false,false], "b":[false,false] }; + const parsedFen = V.ParseFen(fen); + const epSq = parsedFen.enpassant != "-" + ? V.SquareToCoords(parsedFen.enpassant) + : undefined; + this.epSquares = [ epSq ]; + this.scanKingsRooks(fen); } getPotentialPawnMoves([x,y]) @@ -48,6 +43,7 @@ class LoserRules extends ChessRules getPotentialKingMoves(sq) { + // No castle: return this.getSlideNJumpMoves(sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"); } @@ -111,22 +107,19 @@ class LoserRules extends ChessRules return []; } - // Unused: + // No variables update because no castling updateVariables(move) { } unupdateVariables(move) { } - getFlagsFen() - { - return "-"; - } - checkGameEnd() { // No valid move: you win! return this.turn == "w" ? "1-0" : "0-1"; } - static get VALUES() { //experimental... + static get VALUES() + { + // Experimental... return { 'p': 1, 'r': 7, @@ -197,6 +190,8 @@ class LoserRules extends ChessRules return pieces["b"].join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " 0000"; //add flags (TODO?!) + " w -"; //no en-passant } } + +const VariantRules = LoserRules;