From: Benjamin Auder Date: Fri, 3 Apr 2020 13:02:04 +0000 (+0200) Subject: Fix Dynamo FEN + computer play X-Git-Url: https://git.auder.net/variants/img/current/assets/DESCRIPTION?a=commitdiff_plain;h=156986e6b06dc5f0acd39860bd4fef6b030e263b;p=vchess.git Fix Dynamo FEN + computer play --- diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 1a4a32d9..167be91f 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -966,7 +966,7 @@ export const ChessRules = class ChessRules { let potentialMoves = []; for (let i = 0; i < V.size.x; i++) { for (let j = 0; j < V.size.y; j++) { - if (this.getColor(i, j) == color) { + if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == color) { Array.prototype.push.apply( potentialMoves, this.getPotentialMovesFrom([i, j]) diff --git a/client/src/variants/Dynamo.js b/client/src/variants/Dynamo.js index f7d60240..91920e07 100644 --- a/client/src/variants/Dynamo.js +++ b/client/src/variants/Dynamo.js @@ -88,7 +88,7 @@ export class DynamoRules extends ChessRules { return ( ["appear","vanish"].map( mpart => { - if (mpart.length == 0) return "-"; + if (this.amoves[L-1][mpart].length == 0) return "-"; return ( this.amoves[L-1][mpart].map( av => { @@ -479,6 +479,22 @@ export class DynamoRules extends ChessRules { return false; } + // No consideration of color: all pieces could be played + getAllPotentialMoves() { + let potentialMoves = []; + for (let i = 0; i < V.size.x; i++) { + for (let j = 0; j < V.size.y; j++) { + if (this.board[i][j] != V.EMPTY) { + Array.prototype.push.apply( + potentialMoves, + this.getPotentialMovesFrom([i, j]) + ); + } + } + } + return potentialMoves; + } + getCurrentScore() { if (this.subTurn == 2) // Move not over