X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FUpsidedown.js;h=de7221689b0f2fd52baeaf01092d72ac3dce0795;hb=0c3fe8a6c3e02af46e0bc646b40c1a0c420f9dcd;hp=7198c0b1e98df5c4f25a71b7b22afc03a0103752;hpb=8d61fc4ab7373b4a576f3f9108cdf7768ae27096;p=vchess.git diff --git a/client/src/variants/Upsidedown.js b/client/src/variants/Upsidedown.js index 7198c0b1..de722168 100644 --- a/client/src/variants/Upsidedown.js +++ b/client/src/variants/Upsidedown.js @@ -1,4 +1,8 @@ -class UpsidedownRules extends ChessRules +import { ChessRules } from "@/base_rules"; +import { randInt } from "@/utils/alea"; +import { ArrayFun } from "@/utils/array"; + +export const VariantRules = class UpsidedownRules extends ChessRules { static get HasFlags() { return false; } @@ -16,9 +20,9 @@ class UpsidedownRules extends ChessRules let pieces = { "w": new Array(8), "b": new Array(8) }; for (let c of ["w","b"]) { - let positions = range(8); + let positions = ArrayFun.range(8); - let randIndex = random(8); + let randIndex = randInt(8); const kingPos = positions[randIndex]; positions.splice(randIndex, 1); @@ -35,18 +39,18 @@ class UpsidedownRules extends ChessRules positions.splice(knight1Index, 1); // King+knight1 are on two consecutive squares: one light, one dark - randIndex = 2 * random(3); + randIndex = 2 * randInt(3); const bishop1Pos = positions[randIndex]; - let randIndex_tmp = 2 * random(3) + 1; + let randIndex_tmp = 2 * randInt(3) + 1; const bishop2Pos = positions[randIndex_tmp]; positions.splice(Math.max(randIndex,randIndex_tmp), 1); positions.splice(Math.min(randIndex,randIndex_tmp), 1); - randIndex = random(4); + randIndex = randInt(4); const knight2Pos = positions[randIndex]; positions.splice(randIndex, 1); - randIndex = random(3); + randIndex = randInt(3); const queenPos = positions[randIndex]; positions.splice(randIndex, 1); @@ -65,6 +69,6 @@ class UpsidedownRules extends ChessRules return pieces["w"].join("").toUpperCase() + "/PPPPPPPP/8/8/8/8/pppppppp/" + pieces["b"].join("") + - " w"; //no castle, no en-passant + " w 0"; //no castle, no en-passant } }