X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FLoser.js;h=5f15612980575458acc51c0022921338f83fceb3;hb=2d7194bd9c976f444e43e5dc0a725823b6472eb9;hp=2d60d6e8fc10a8aa4d91241d327441220da33997;hpb=1a788978e3682ab54b77af3edfe38e0b371edbc4;p=vchess.git diff --git a/public/javascripts/variants/Loser.js b/public/javascripts/variants/Loser.js index 2d60d6e8..5f156129 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(fenflags) + 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,6 @@ class LoserRules extends ChessRules return pieces["b"].join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " 0000 w"; //add flags (TODO?!) + " w -"; //no en-passant } }