X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FMakruk.js;h=b721273b501dc56cf680614b2a5718f261ed3029;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=9f9c37b6f5c77e5a1cb303e663a4b27fe2e2a76b;hpb=118cff5c4d458f1f76a6f1f6813f4d4feaf4594c;p=vchess.git diff --git a/client/src/variants/Makruk.js b/client/src/variants/Makruk.js index 9f9c37b6..b721273b 100644 --- a/client/src/variants/Makruk.js +++ b/client/src/variants/Makruk.js @@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array"; import { randInt, shuffle } from "@/utils/alea"; export class MakrukRules extends ChessRules { + static get HasFlags() { return false; } @@ -11,14 +12,19 @@ export class MakrukRules extends ChessRules { return false; } + static get Monochrome() { + return true; + } + + static get Notoodark() { + return true; + } + static get PawnSpecs() { return Object.assign( {}, ChessRules.PawnSpecs, - { - twoSquares: false, - promotions: [V.QUEEN] - } + { promotions: [V.QUEEN] } ); } @@ -30,13 +36,13 @@ export class MakrukRules extends ChessRules { return 'f'; } - static GenRandInitFen(randomness) { - if (randomness == 0) + static GenRandInitFen(options) { + if (options.randomness == 0) return "rnbqkbnr/8/pppppppp/8/8/PPPPPPPP/8/RNBKQBNR w 0"; let pieces = { w: new Array(8), b: new Array(8) }; for (let c of ["w", "b"]) { - if (c == 'b' && randomness == 1) { + if (c == 'b' && options.randomness == 1) { pieces['b'] = pieces['w']; break; } @@ -89,39 +95,33 @@ export class MakrukRules extends ChessRules { getPotentialBishopMoves(sq) { const forward = (this.turn == 'w' ? -1 : 1); return this.getSlideNJumpMoves( - sq, - V.steps[V.BISHOP].concat([ [forward, 0] ]), - "oneStep" - ); + sq, V.steps[V.BISHOP].concat([ [forward, 0] ]), 1); } getPotentialQueenMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.BISHOP], - "oneStep" + return this.getSlideNJumpMoves(sq, V.steps[V.BISHOP], 1); + } + + isAttacked(sq, color) { + return ( + super.isAttacked(sq, color) || this.isAttackedByPromoted(sq, color) ); } isAttackedByBishop(sq, color) { const forward = (color == 'w' ? 1 : -1); return this.isAttackedBySlideNJump( - sq, - color, - V.BISHOP, - V.steps[V.BISHOP].concat([ [forward, 0] ]), - "oneStep" - ); + sq, color, V.BISHOP, V.steps[V.BISHOP].concat([ [forward, 0] ]), 1); } isAttackedByQueen(sq, color) { return this.isAttackedBySlideNJump( - sq, - color, - V.QUEEN, - V.steps[V.BISHOP], - "oneStep" - ); + sq, color, V.QUEEN, V.steps[V.BISHOP], 1); + } + + isAttackedByPromoted(sq, color) { + return super.isAttackedBySlideNJump( + sq, color, V.PROMOTED, V.steps[V.BISHOP], 1); } static get VALUES() { @@ -135,4 +135,5 @@ export class MakrukRules extends ChessRules { k: 1000 }; } + };