From: Benjamin Auder Date: Fri, 23 Nov 2018 13:20:31 +0000 (+0100) Subject: Alice almost fixed X-Git-Url: https://git.auder.net/img/%7B%7B%20asset%28%27mixstore/css/parser.js?a=commitdiff_plain;h=55eb331d0a9262baafcae5a42258a44d00f38da4;p=vchess.git Alice almost fixed --- diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index cb426f3f..346eff0d 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -699,8 +699,6 @@ class ChessRules play(move, ingame) { - console.log("play " + this.getNotation(move)); - console.log(JSON.stringify(move)); if (!!ingame) move.notation = this.getNotation(move); @@ -718,7 +716,6 @@ class ChessRules this.moves.pop(); this.unupdateVariables(move); this.parseFlags(JSON.parse(move.flags)); - console.log("undo " + this.getNotation(move)); } ////////////// diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index ca8a6bff..397ba521 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -574,7 +574,7 @@ Vue.component('my-game', { this.newGame("computer"); }, newGame: function(mode, fenInit, color, oppId, moves, continuation) { - const fen = "pppppppp/rnbqkbnr/8/8/8/8/PPPPPPPP/ROBQKBOR 1111"; //fenInit || VariantRules.GenRandInitFen(); + const fen = fenInit || VariantRules.GenRandInitFen(); console.log(fen); //DEBUG this.score = "*"; if (mode=="human" && !oppId) @@ -672,7 +672,7 @@ Vue.component('my-game', { this.selectedPiece.style.display = "inline-block"; this.selectedPiece.style.zIndex = 3000; let startSquare = this.getSquareFromId(e.target.parentNode.id); - this.possibleMoves = true//this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare) + this.possibleMoves = this.mode!="idle" && this.vr.canIplay(this.mycolor,startSquare) ? this.vr.getPossibleMovesFrom(startSquare) : []; e.target.parentNode.appendChild(this.selectedPiece); diff --git a/public/javascripts/variants/Alice.js b/public/javascripts/variants/Alice.js index 1e1ce46d..4d105069 100644 --- a/public/javascripts/variants/Alice.js +++ b/public/javascripts/variants/Alice.js @@ -50,10 +50,8 @@ class AliceRules extends ChessRules return sideBoard; } - // TODO: castle & enPassant https://www.chessvariants.com/other.dir/alice.html - // TODO: enPassant seulement si l'on est du même coté que le coté de départ du pion adverse - // (en passant en sortant du monde... : il faut donc ajouter des coups non trouvés) - // castle: check that all destination squares are not occupied + // NOTE: castle & enPassant https://www.chessvariants.com/other.dir/alice.html + // --> Should be OK as is. getPotentialMovesFrom([x,y]) { let sideBoard = this.getBoardOfPiece([x,y]); @@ -67,8 +65,20 @@ class AliceRules extends ChessRules // Finally filter impossible moves const mirrorSide = (Object.keys(VariantRules.ALICE_CODES).includes(this.getPiece(x,y)) ? 1 : 2); return moves.filter(m => { - if (this.board[m.end.x][m.end.y] != VariantRules.EMPTY) + if (m.appear.length == 2) //castle { + // If appear[i] not in vanish array, then must be empty square on other board + m.appear.forEach(psq => { + if (this.board[psq.x][psq.y] != VariantRules.EMPTY && + ![m.vanish[0].y,m.vanish[1].y].includes(psq.y)) + { + return false; + } + }); + } + else if (this.board[m.end.x][m.end.y] != VariantRules.EMPTY) + { + // Attempt to capture const piece = this.getPiece(m.end.x,m.end.y); if ((mirrorSide==1 && Object.keys(VariantRules.ALICE_PIECES).includes(piece)) || (mirrorSide==2 && Object.keys(VariantRules.ALICE_CODES).includes(piece)))