X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FBaroque.js;h=92bae77f65c8f9a17944df9142e6ce88d7f93700;hb=32f6285ee325a14286562a53baefc647201df2af;hp=c7c100c670549efba556cc4b4c9535911157001a;hpb=68e19a449db7a12e0a168e99cd750d985c983ba1;p=vchess.git diff --git a/client/src/variants/Baroque.js b/client/src/variants/Baroque.js index c7c100c6..92bae77f 100644 --- a/client/src/variants/Baroque.js +++ b/client/src/variants/Baroque.js @@ -1,12 +1,16 @@ import { ChessRules, PiPo, Move } from "@/base_rules"; import { ArrayFun } from "@/utils/array"; -import { randInt } from "@/utils/alea"; +import { shuffle } from "@/utils/alea"; -export const VariantRules = class BaroqueRules extends ChessRules { +export class BaroqueRules extends ChessRules { static get HasFlags() { return false; } + static get HasCastle() { + return false; + } + static get HasEnpassant() { return false; } @@ -352,14 +356,6 @@ export const VariantRules = class BaroqueRules extends ChessRules { return super.getPotentialQueenMoves(sq); } - getPotentialKingMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); - } - // isAttacked() is OK because the immobilizer doesn't take isAttackedByPawn([x, y], color) { @@ -562,46 +558,10 @@ export const VariantRules = class BaroqueRules extends ChessRules { break; } - let positions = ArrayFun.range(8); // Get random squares for every piece, totally freely - - let randIndex = randInt(8); - const bishop1Pos = positions[randIndex]; - positions.splice(randIndex, 1); - - randIndex = randInt(7); - const bishop2Pos = positions[randIndex]; - positions.splice(randIndex, 1); - - randIndex = randInt(6); - const knight1Pos = positions[randIndex]; - positions.splice(randIndex, 1); - - randIndex = randInt(5); - const knight2Pos = positions[randIndex]; - positions.splice(randIndex, 1); - - randIndex = randInt(4); - const queenPos = positions[randIndex]; - positions.splice(randIndex, 1); - - randIndex = randInt(3); - const kingPos = positions[randIndex]; - positions.splice(randIndex, 1); - - randIndex = randInt(2); - const rookPos = positions[randIndex]; - positions.splice(randIndex, 1); - const immobilizerPos = positions[0]; - - pieces[c][bishop1Pos] = "b"; - pieces[c][bishop2Pos] = "b"; - pieces[c][knight1Pos] = "n"; - pieces[c][knight2Pos] = "n"; - pieces[c][queenPos] = "q"; - pieces[c][kingPos] = "k"; - pieces[c][rookPos] = "r"; - pieces[c][immobilizerPos] = "m"; + let positions = shuffle(ArrayFun.range(8)); + const composition = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'm']; + for (let i = 0; i < 8; i++) pieces[c][positions[i]] = composition[i]; } return ( pieces["b"].join("") +