X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=9f6ec9ecbb2b2e7ff3d197422d37462cb50cb9a7;hb=59d58d7da742c937bca80c2102c2e72cc7d6e840;hp=718261d2a3509f1fad550324c0c4dd2dece050ad;hpb=26b8e4f7c71030d49e44fe1d89632ef91b886d67;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 718261d2..9f6ec9ec 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -221,7 +221,7 @@ class ChessRules // On which squares is color under check ? (for interface) getCheckSquares(color) { - return this.isAttacked(this.kingPos[color], [this.getOppCol(color)]) + return this.isAttacked(this.kingPos[color], [V.GetOppCol(color)]) ? [JSON.parse(JSON.stringify(this.kingPos[color]))] //need to duplicate! : []; } @@ -280,7 +280,7 @@ class ChessRules return pieces["b"].join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " w 1111 -"; //add turn + flags + enpassant + " w 0 1111 -"; //add turn + flags + enpassant } // "Parse" FEN: just return untransformed string data @@ -734,7 +734,7 @@ class ChessRules return []; //x isn't first rank, or king has moved (shortcut) // Castling ? - const oppCol = this.getOppCol(c); + const oppCol = V.GetOppCol(c); let moves = []; let i = 0; const finalSquares = [ [2,3], [V.size.y-2,V.size.y-3] ]; //king, then rook @@ -824,7 +824,7 @@ class ChessRules getAllValidMoves() { const color = this.turn; - const oppCol = this.getOppCol(color); + const oppCol = V.GetOppCol(color); let potentialMoves = []; for (let i=0; i move.appear.length ? "x" : "") + finalSquare; } } - - // Complete the usual notation, may be required for de-ambiguification - getLongNotation(move) - { - // Not encoding move. But short+long is enough - return V.CoordsToSquare(move.start) + V.CoordsToSquare(move.end); - } - - // The score is already computed when calling this function - getPGN(moves, mycolor, score, fenStart, mode) - { - let pgn = ""; - pgn += '[Site "vchess.club"]\n'; - const opponent = mode=="human" ? "Anonymous" : "Computer"; - pgn += '[Variant "' + variant + '"]\n'; - pgn += '[Date "' + getDate(new Date()) + '"]\n'; - // TODO: later when users are a bit less anonymous, use better names - const whiteName = ["human","computer"].includes(mode) - ? (mycolor=='w'?'Myself':opponent) - : "analyze"; - const blackName = ["human","computer"].includes(mode) - ? (mycolor=='b'?'Myself':opponent) - : "analyze"; - pgn += '[White "' + whiteName + '"]\n'; - pgn += '[Black "' + blackName + '"]\n'; - pgn += '[Fen "' + fenStart + '"]\n'; - pgn += '[Result "' + score + '"]\n\n'; - - // Print moves - for (let i=0; i