X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FUltima.js;h=0b00c262a07602f49d65bbdb54c6bc4e817c728d;hb=388e4c401f05b1f6a4c54e33c9da9114969a53c0;hp=d6fecb70d49d5c74eb7f1509ee7358190176393c;hpb=7931e479adf93c87771ded1892a0873af72ae46d;p=vchess.git diff --git a/public/javascripts/variants/Ultima.js b/public/javascripts/variants/Ultima.js index d6fecb70..0b00c262 100644 --- a/public/javascripts/variants/Ultima.js +++ b/public/javascripts/variants/Ultima.js @@ -1,5 +1,9 @@ class UltimaRules extends ChessRules { + static get HasFlags() { return false; } + + static get HasEnpassant() { return false; } + static getPpath(b) { if (b[1] == "m") //'m' for Immobilizer (I is too similar to 1) @@ -7,16 +11,13 @@ class UltimaRules extends ChessRules return b; //usual piece } - static get PIECES() { - return ChessRules.PIECES.concat([V.IMMOBILIZER]); - } - - static IsGoodFlags(flags) + static get PIECES() { - return true; //anything is good: no flags + return ChessRules.PIECES.concat([V.IMMOBILIZER]); } - initVariables(fen) + // No castling, but checks, so keep track of kings + setOtherVariables(fen) { this.kingPos = {'w':[-1,-1], 'b':[-1,-1]}; const fenParts = fen.split(" "); @@ -42,13 +43,6 @@ class UltimaRules extends ChessRules k++; } } - this.epSquares = []; //no en-passant here - } - - setFlags(fen) - { - // TODO: for compatibility? - this.castleFlags = {"w":[false,false], "b":[false,false]}; } static get IMMOBILIZER() { return 'm'; } @@ -535,8 +529,8 @@ class UltimaRules extends ChessRules updateVariables(move) { // Just update king(s) position(s) - const piece = this.getPiece(move.start.x,move.start.y); - const c = this.getColor(move.start.x,move.start.y); + const piece = move.vanish[0].p; + const c = move.vanish[0].c; if (piece == V.KING && move.appear.length > 0) { this.kingPos[c][0] = move.appear[0].x; @@ -544,7 +538,9 @@ class UltimaRules extends ChessRules } } - static get VALUES() { //TODO: totally experimental! + static get VALUES() + { + // TODO: totally experimental! return { 'p': 1, 'r': 2, @@ -608,19 +604,13 @@ class UltimaRules extends ChessRules return pieces["b"].join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " 0000"; //TODO: flags?! - } - - getFlagsFen() - { - return "0000"; //TODO: or "-" ? + " w"; } getNotation(move) { - const initialSquare = - String.fromCharCode(97 + move.start.y) + (V.size.x-move.start.x); - const finalSquare = String.fromCharCode(97 + move.end.y) + (V.size.x-move.end.x); + const initialSquare = V.CoordsToSquare(move.start); + const finalSquare = V.CoordsToSquare(move.end); let notation = undefined; if (move.appear[0].p == V.PAWN) { @@ -636,3 +626,5 @@ class UltimaRules extends ChessRules return notation; } } + +const VariantRules = UltimaRules;