X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDice.js;h=68d80bb463d8fb2db3fd67012075e5edb5448e04;hp=a8ecf1b9194c9de5e0f6b066c6e51b82ba660f70;hb=0ada7ac59ce418a2f03c559ad4d495407bdc47ce;hpb=68971030c62c551e2bb030260d2346157c5652a9 diff --git a/client/src/variants/Dice.js b/client/src/variants/Dice.js index a8ecf1b9..68d80bb4 100644 --- a/client/src/variants/Dice.js +++ b/client/src/variants/Dice.js @@ -3,7 +3,7 @@ import { randInt } from "@/utils/alea"; export class DiceRules extends ChessRules { static get CanAnalyze() { - return true;//false; + return false; } doClick(square) { @@ -19,14 +19,39 @@ export class DiceRules extends ChessRules { } getPotentialMovesFrom([x, y]) { + if (this.subTurn == 1) return []; const L = this.p2play.length; - if ( - this.subTurn == 1 || + const piece = this.getPiece(x, y); + if (piece == V.PAWN && this.p2play[L-1] != V.PAWN) { + // The piece must be a pawn about to promote. + const color = this.turn; + const beforeLastRank = (color == 'w' ? 1 : 0); + const forward = (color == 'w' ? -1 : 1); + let moves = []; + if (this.board[x + forward][y] == V.EMPTY) { + moves.push( + this.getBasicMove( + [x, y], [x + forward], { c: color, p: this.p2play[L-1] }) + ); + } + for (let shift of [-1, 1]) { + const [i, j] = [x + forward, y + shift]; + if ( + V.OnBoard(i, j) && + this.board[i][j] != V.EMPTY && + this.getColor(i, j) != color + ) { + moves.push( + this.getBasicMove( + [x, y], [i, j], { c: color, p: this.p2play[L-1] }) + ); + } + } + return moves; + } + if (piece != this.p2play[L-1]) // The piece type must match last p2play - this.getPiece(x, y) != this.p2play[L-1] - ) { return []; - } return super.getPotentialMovesFrom([x, y]); }