X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FDice.js;h=9c35204033469853b48bbd9176ed679107f01e21;hb=74afb57db5e15af26de042ba3f70f3409f13cb5f;hp=1b84be428610691d76d2658ebf586473922a7654;hpb=6e0f28425075e6d2d79cab6d30bca6ce6d55f19d;p=vchess.git diff --git a/client/src/variants/Dice.js b/client/src/variants/Dice.js index 1b84be42..9c352040 100644 --- a/client/src/variants/Dice.js +++ b/client/src/variants/Dice.js @@ -2,6 +2,24 @@ import { ChessRules, Move } from "@/base_rules"; import { randInt } from "@/utils/alea"; export class DiceRules extends ChessRules { + + static get Options() { + return { + select: [ + { + label: "Randomness", + variable: "randomness", + defaut: 2, + options: [ + { label: "Deterministic", value: 0 }, + { label: "Symmetric random", value: 1 }, + { label: "Asymmetric random", value: 2 } + ] + } + ] + }; + } + static get CanAnalyze() { return false; } @@ -25,7 +43,7 @@ export class DiceRules extends ChessRules { return super.getFen() + " " + this.getToplayFen(); } - getFen() { + getFenForRepeat() { return super.getFenForRepeat() + "_" + this.getToplayFen(); } @@ -34,8 +52,8 @@ export class DiceRules extends ChessRules { return (L > 0 ? this.p2play[L-1] : "-"); } - static GenRandInitFen(randomness) { - return ChessRules.GenRandInitFen(randomness) + " -"; + static GenRandInitFen(options) { + return ChessRules.GenRandInitFen(options) + " -"; } canMove(piece, color, [x, y]) { @@ -135,7 +153,7 @@ export class DiceRules extends ChessRules { V.PlayOnBoard(this.board, m); const [piece, square] = this.getRandPiece(oppCol); m.start.toplay = square; - m.end.piece = piece; + m.end.p = piece; V.UndoOnBoard(this.board, m); }); return moves; @@ -156,7 +174,7 @@ export class DiceRules extends ChessRules { } postPlay(move) { - this.p2play.push(move.end.piece); + this.p2play.push(move.end.p); if (move.vanish.length == 2 && move.vanish[1].p == V.KING) this.kingPos[move.vanish[1].c] = [-1, -1]; // Castle flags for captured king won't be updated (not important...) @@ -175,6 +193,7 @@ export class DiceRules extends ChessRules { } getNotation(move) { - return super.getNotation(move) + "/" + move.end.piece.toUpperCase(); + return super.getNotation(move) + "/" + move.end.p.toUpperCase(); } + };