X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FSittuyin.js;h=aae1890ea9a6cd007da3e05c2069c8314ad507e0;hp=f37eabf3a2a56c5cdd5ff7b15652a642965d1186;hb=cd49e617866590dbc68530ad961b109cdbe1ce55;hpb=665eed903c4f294de82e7cb0ce4026b64fe64765 diff --git a/client/src/variants/Sittuyin.js b/client/src/variants/Sittuyin.js index f37eabf3..aae1890e 100644 --- a/client/src/variants/Sittuyin.js +++ b/client/src/variants/Sittuyin.js @@ -119,29 +119,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])); } } }