X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FSittuyin.js;h=a18c2f0b3a06972750a97087258bd3b4568a2e1d;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=f37eabf3a2a56c5cdd5ff7b15652a642965d1186;hpb=0e0010227e46acb7774d134c9aa345eaa0c4404d;p=vchess.git diff --git a/client/src/variants/Sittuyin.js b/client/src/variants/Sittuyin.js index f37eabf3..a18c2f0b 100644 --- a/client/src/variants/Sittuyin.js +++ b/client/src/variants/Sittuyin.js @@ -2,6 +2,11 @@ import { ChessRules, Move, PiPo } from "@/base_rules"; import { randInt } from "@/utils/alea"; export class SittuyinRules extends ChessRules { + + static get Options() { + return null; + } + static get HasFlags() { return false; } @@ -10,12 +15,26 @@ export class SittuyinRules extends ChessRules { return false; } + static get Monochrome() { + return true; + } + + static get Notoodark() { + return true; + } + + static get Lines() { + return ChessRules.Lines.concat([ + [[0, 0], [8, 8]], + [[0, 8], [8, 0]] + ]); + } + static get PawnSpecs() { return Object.assign( {}, ChessRules.PawnSpecs, { - twoSquares: false, // Promotions are handled differently here promotions: [V.QUEEN] } @@ -119,29 +138,20 @@ export class SittuyinRules extends ChessRules { getPotentialPawnMoves([x, y]) { const color = this.turn; - const [sizeX, sizeY] = [V.size.x, V.size.y]; const shiftX = V.PawnSpecs.directions[color]; let moves = []; - // NOTE: next condition is generally true (no pawn on last rank) - if (x + shiftX >= 0 && x + shiftX < sizeX) { - if (this.board[x + shiftX][y] == V.EMPTY) { + if (x + shiftX >= 0 && x + shiftX < 8) { + if (this.board[x + shiftX][y] == V.EMPTY) // One square forward moves.push(this.getBasicMove([x, y], [x + shiftX, y])); - } // Captures - if (V.PawnSpecs.canCapture) { - for (let shiftY of [-1, 1]) { - if ( - y + shiftY >= 0 && - y + shiftY < sizeY - ) { - if ( - this.board[x + shiftX][y + shiftY] != V.EMPTY && - this.canTake([x, y], [x + shiftX, y + shiftY]) - ) { - moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY])); - } - } + for (let shiftY of [-1, 1]) { + if ( + y + shiftY >= 0 && y + shiftY < 8 && + this.board[x + shiftX][y + shiftY] != V.EMPTY && + this.canTake([x, y], [x + shiftX, y + shiftY]) + ) { + moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY])); } } } @@ -254,18 +264,11 @@ export class SittuyinRules 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); } getAllValidMoves() { @@ -283,22 +286,12 @@ export class SittuyinRules extends ChessRules { isAttackedByBishop(sq, color) { const forward = (this.turn == '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); } underCheck(color) { @@ -397,4 +390,5 @@ export class SittuyinRules extends ChessRules { } return super.getNotation(move); } + };