From: Benjamin Auder Date: Thu, 13 Dec 2018 21:17:18 +0000 (+0100) Subject: Fix bugs in Ultima X-Git-Url: https://git.auder.net/doc/html/pieces/current/img/common.css?a=commitdiff_plain;h=523da5d5adeb4abd8b165158485314d0e7de9cf4;p=vchess.git Fix bugs in Ultima --- diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 202f542a..deccd5da 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -1014,7 +1014,7 @@ Vue.component('my-game', { this.endGame(this.mycolor=="w"?"0-1":"1-0"); }, newGame: function(mode, fenInit, color, oppId, moves, continuation) { - const fen = "3N1K2/2n2q2/P1R1kPnN/p3b1p1/b7/5Q2/4r3/8 0000";//fenInit || VariantRules.GenRandInitFen(); + const fen = fenInit || VariantRules.GenRandInitFen(); console.log(fen); //DEBUG if (mode=="human" && !oppId) { @@ -1072,7 +1072,7 @@ Vue.component('my-game', { } else if (mode == "computer") { - this.mycolor = "w";//Math.random() < 0.5 ? 'w' : 'b'; + this.mycolor = Math.random() < 0.5 ? 'w' : 'b'; if (this.mycolor == 'b') setTimeout(this.playComputerMove, 500); } diff --git a/public/javascripts/variants/Ultima.js b/public/javascripts/variants/Ultima.js index 229910c2..6883c6f0 100644 --- a/public/javascripts/variants/Ultima.js +++ b/public/javascripts/variants/Ultima.js @@ -189,8 +189,8 @@ class UltimaRules extends ChessRules // Check piece-king rectangle (if any) corners for enemy pieces if (m.end.x == kp[0] || m.end.y == kp[1]) return; //"flat rectangle" - const corner1 = [Math.max(m.end.x,kp[0]), Math.min(m.end.y,kp[1])]; - const corner2 = [Math.min(m.end.x,kp[0]), Math.max(m.end.y,kp[1])]; + const corner1 = [m.end.x, kp[1]]; + const corner2 = [kp[0], m.end.y]; for (let [i,j] of [corner1,corner2]) { if (this.board[i][j] != VariantRules.EMPTY && this.getColor(i,j) == oppCol) @@ -480,16 +480,25 @@ class UltimaRules extends ChessRules { // Try in opposite direction: let [i,j] = [x-step[0],y-step[1]]; - while (i>=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j=0 && i=0 && j