X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDynamo.js;h=3cb8dc473420ec895121fac2403568034b81a0ed;hb=e78633dbd29be1920e0c02509b6ce62b87b61d77;hp=f7d602405cffd8080d999795d52bba08b9bc58e9;hpb=8c267d0c700050831a10d0934df1d1606aa0d654;p=vchess.git diff --git a/client/src/variants/Dynamo.js b/client/src/variants/Dynamo.js index f7d60240..3cb8dc47 100644 --- a/client/src/variants/Dynamo.js +++ b/client/src/variants/Dynamo.js @@ -9,7 +9,7 @@ export class DynamoRules extends ChessRules { canIplay(side, [x, y]) { // Sometimes opponent's pieces can be moved directly - return true; + return this.turn == side; } setOtherVariables(fen) { @@ -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