X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FWildebeest.js;h=8192fa04d6b4dce8dca6342baad1db1b0a8570a0;hb=32f6285ee325a14286562a53baefc647201df2af;hp=1634f4942712581545bcd9cbddd9ab695f720175;hpb=e3ef199cdac142f1ca14fa6ceb259eb380f63929;p=vchess.git diff --git a/client/src/variants/Wildebeest.js b/client/src/variants/Wildebeest.js index 1634f494..8192fa04 100644 --- a/client/src/variants/Wildebeest.js +++ b/client/src/variants/Wildebeest.js @@ -2,7 +2,7 @@ import { ChessRules } from "@/base_rules"; import { ArrayFun } from "@/utils/array"; import { sample, randInt } from "@/utils/alea"; -export const VariantRules = class WildebeestRules extends ChessRules { +export class WildebeestRules extends ChessRules { static get size() { return { x: 10, y: 11 }; } @@ -196,28 +196,28 @@ export const VariantRules = class WildebeestRules extends ChessRules { ); } - isAttacked(sq, colors) { + isAttacked(sq, color) { return ( - super.isAttacked(sq, colors) || - this.isAttackedByCamel(sq, colors) || - this.isAttackedByWildebeest(sq, colors) + super.isAttacked(sq, color) || + this.isAttackedByCamel(sq, color) || + this.isAttackedByWildebeest(sq, color) ); } - isAttackedByCamel(sq, colors) { + isAttackedByCamel(sq, color) { return this.isAttackedBySlideNJump( sq, - colors, + color, V.CAMEL, V.steps[V.CAMEL], "oneStep" ); } - isAttackedByWildebeest(sq, colors) { + isAttackedByWildebeest(sq, color) { return this.isAttackedBySlideNJump( sq, - colors, + color, V.WILDEBEEST, V.steps[V.KNIGHT].concat(V.steps[V.CAMEL]), "oneStep" @@ -235,8 +235,8 @@ export const VariantRules = class WildebeestRules extends ChessRules { static get VALUES() { return Object.assign( - ChessRules.VALUES, - { c: 3, w: 7 } //experimental + { c: 3, w: 7 }, //experimental + ChessRules.VALUES ); } @@ -244,9 +244,20 @@ export const VariantRules = class WildebeestRules extends ChessRules { return 2; } - static GenRandInitFen() { + static GenRandInitFen(randomness) { + if (!randomness) randomness = 2; + if (randomness == 0) + return "rnccwkqbbnr/ppppppppppp/11/11/11/11/11/11/PPPPPPPPPPP/RNBBQKWCCNR w 0 akak -"; + let pieces = { w: new Array(10), b: new Array(10) }; + let flags = ""; for (let c of ["w", "b"]) { + if (c == 'b' && randomness == 1) { + pieces['b'] = pieces['w']; + flags += flags; + break; + } + let positions = ArrayFun.range(11); // Get random squares for bishops + camels (different colors) @@ -264,7 +275,7 @@ export const VariantRules = class WildebeestRules extends ChessRules { for (let idx of randIndexes.concat(randIndexes_tmp).sort((a, b) => { return b - a; })) { - //largest indices first + // Largest indices first positions.splice(idx, 1); } @@ -299,12 +310,13 @@ export const VariantRules = class WildebeestRules extends ChessRules { pieces[c][bishop2Pos] = "b"; pieces[c][knight2Pos] = "n"; pieces[c][rook2Pos] = "r"; + flags += V.CoordToColumn(rook1Pos) + V.CoordToColumn(rook2Pos); } return ( pieces["b"].join("") + "/ppppppppppp/11/11/11/11/11/11/PPPPPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " w 0 1111 -" + " w 0 " + flags + " -" ); } };