X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FGrand.js;h=6ddfbd7cbfecd57edb17c94131b9e3f1539b8c16;hb=0c3fe8a6c3e02af46e0bc646b40c1a0c420f9dcd;hp=c056244d48ce427ecf1ed34943ab7edfe0905fae;hpb=8d61fc4ab7373b4a576f3f9108cdf7768ae27096;p=vchess.git diff --git a/client/src/variants/Grand.js b/client/src/variants/Grand.js index c056244d..6ddfbd7c 100644 --- a/client/src/variants/Grand.js +++ b/client/src/variants/Grand.js @@ -1,6 +1,10 @@ +import { ChessRules } from "@/base_rules"; +import { ArrayFun } from "@/utils/array"; +import { randInt } from "@/utils/alea"; + // NOTE: initial setup differs from the original; see // https://www.chessvariants.com/large.dir/freeling.html -class GrandRules extends ChessRules +export const VariantRules = class GrandRules extends ChessRules { static getPpath(b) { @@ -329,38 +333,38 @@ class GrandRules extends ChessRules // Shuffle pieces on first and last rank for (let c of ["w","b"]) { - let positions = range(10); + let positions = ArrayFun.range(10); // Get random squares for bishops - let randIndex = 2 * random(5); + let randIndex = 2 * randInt(5); let bishop1Pos = positions[randIndex]; // The second bishop must be on a square of different color - let randIndex_tmp = 2 * random(5) + 1; + let randIndex_tmp = 2 * randInt(5) + 1; let bishop2Pos = positions[randIndex_tmp]; // Remove chosen squares positions.splice(Math.max(randIndex,randIndex_tmp), 1); positions.splice(Math.min(randIndex,randIndex_tmp), 1); // Get random squares for knights - randIndex = random(8); + randIndex = randInt(8); let knight1Pos = positions[randIndex]; positions.splice(randIndex, 1); - randIndex = random(7); + randIndex = randInt(7); let knight2Pos = positions[randIndex]; positions.splice(randIndex, 1); // Get random square for queen - randIndex = random(6); + randIndex = randInt(6); let queenPos = positions[randIndex]; positions.splice(randIndex, 1); // ...random square for marshall - randIndex = random(5); + randIndex = randInt(5); let marshallPos = positions[randIndex]; positions.splice(randIndex, 1); // ...random square for cardinal - randIndex = random(4); + randIndex = randInt(4); let cardinalPos = positions[randIndex]; positions.splice(randIndex, 1); @@ -384,6 +388,6 @@ class GrandRules extends ChessRules return pieces["b"].join("") + "/pppppppppp/10/10/10/10/10/10/PPPPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " w 1111 - 00000000000000"; + " w 0 1111 - 00000000000000"; } }