X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FXiangqi.js;h=5deed6433fe58500d7fc22ab1173dbca0cb06213;hb=1269441e90bb8437bc63cc6cca63ca050f1e2aae;hp=1b49cedba389a6356f69fdd1fe21a00ac5f37f02;hpb=9a1e3abe33fff07218b17c7c799eb622a730b7c7;p=vchess.git diff --git a/client/src/variants/Xiangqi.js b/client/src/variants/Xiangqi.js index 1b49cedb..5deed643 100644 --- a/client/src/variants/Xiangqi.js +++ b/client/src/variants/Xiangqi.js @@ -259,17 +259,8 @@ export class XiangqiRules extends ChessRules { isAttackedByPawn([x, y], color) { // The pawn necessarily crossed the river (attack on king) const shiftX = (color == 'w' ? 1 : -1); //shift from king - for (let s of [[shiftX, 0], [0, 1], [0, -1]]) { - const [i, j] = [x + s[0], y + s[1]]; - if ( - this.board[i][j] != V.EMPTY && - this.getColor(i, j) == color && - this.getPiece(i, j) == V.PAWN - ) { - return true; - } - } - return false; + return super.isAttackedBySlideNJump( + [x, y], color, V.PAWN, [[shiftX, 0], [0, 1], [0, -1]], "oneStep"); } knightStepsFromBishopStep(step) { @@ -369,6 +360,10 @@ export class XiangqiRules extends ChessRules { return evaluation; } + static get SEARCH_DEPTH() { + return 2; + } + static GenRandInitFen() { // No randomization here (TODO?) return "rneakaenr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNEAKAENR w 0";