From: Benjamin Auder Date: Tue, 9 Jun 2026 21:57:00 +0000 (+0200) Subject: Emergo seems ok X-Git-Url: https://git.auder.net/app_dev.php/%7B%7B%20asset('mixstore/css/current/assets/R.css?a=commitdiff_plain;p=xogo.git Emergo seems ok --- diff --git a/variants/Emergo/class.js b/variants/Emergo/class.js index 4eb5cdf..cf6db87 100644 --- a/variants/Emergo/class.js +++ b/variants/Emergo/class.js @@ -417,9 +417,10 @@ export default class EmergoRules extends ChessRules { getBasicMove([x1, y1], [x2, y2], capt) { const cp1 = this.board[x1][y1]; if (!capt) { + const color = this.getColor(x1, y1); return new Move({ - appear: [ new PiPo({ x: x2, y: y2, c: cp1[0], p: cp1[1] }) ], - vanish: [ new PiPo({ x: x1, y: y1, c: cp1[0], p: cp1[1] }) ] + appear: [ new PiPo({ x: x2, y: y2, c: color, p: cp1 }) ], + vanish: [ new PiPo({ x: x1, y: y1, c: color, p: cp1 }) ] }); } // Compute resulting types based on jumped + jumping pieces @@ -560,8 +561,6 @@ export default class EmergoRules extends ChessRules { getPotentialMovesFrom([x, y]) { const longestCaptures = this.getAllLongestCaptures(this.getColor(x, y)); - -console.log(longestCaptures); return this.getPossibleMovesFrom([x, y], longestCaptures); } @@ -569,6 +568,19 @@ console.log(longestCaptures); return moves; } + playOnBoard(move) { + for (let psq of move.vanish) + this.board[psq.x][psq.y] = ""; + for (let psq of move.appear) + this.board[psq.x][psq.y] = psq.p; + } + undoOnBoard(move) { + for (let psq of move.appear) + this.board[psq.x][psq.y] = ""; + for (let psq of move.vanish) + this.board[psq.x][psq.y] = psq.p; + } + play(move) { const color = this.turn; this.playOnBoard(move);