X-Git-Url: https://git.auder.net/variants/Chakart/style.css?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShatranj.js;h=969b8197606c8872b84b13e8953a9b0118baddb7;hb=68e19a449db7a12e0a168e99cd750d985c983ba1;hp=ef6f65b57cda3647dc0454d21c76931b837f8ef0;hpb=7ba4a5bc5b64e19a1e7f26aa232d5c50770d07ad;p=vchess.git diff --git a/client/src/variants/Shatranj.js b/client/src/variants/Shatranj.js index ef6f65b5..969b8197 100644 --- a/client/src/variants/Shatranj.js +++ b/client/src/variants/Shatranj.js @@ -1,6 +1,3 @@ -// TODO: bishop OK, but queen should move vertical/horizontal and capture diagonally. -// ==> then the pawn promotion is a real promotion (enhancement). - import { ChessRules } from "@/base_rules"; export const VariantRules = class ShatranjRules extends ChessRules { @@ -22,7 +19,8 @@ export const VariantRules = class ShatranjRules extends ChessRules { } static GenRandInitFen(randomness) { - return ChessRules.GenRandInitFen(randomness).replace("w 1111 -", "w"); + // Remove castle flags and en-passant indication + return ChessRules.GenRandInitFen(randomness).slice(0, -7); } getPotentialPawnMoves([x, y]) { @@ -100,20 +98,20 @@ export const VariantRules = class ShatranjRules extends ChessRules { ); } - isAttackedByBishop(sq, colors) { + isAttackedByBishop(sq, color) { return this.isAttackedBySlideNJump( sq, - colors, + color, V.BISHOP, V.ElephantSteps, "oneStep" ); } - isAttackedByQueen(sq, colors) { + isAttackedByQueen(sq, color) { return this.isAttackedBySlideNJump( sq, - colors, + color, V.QUEEN, V.steps[V.BISHOP], "oneStep" @@ -159,7 +157,7 @@ export const VariantRules = class ShatranjRules extends ChessRules { // 2 enemy units or more: I lose return getScoreLost(); // I don't have any piece, my opponent have one: can I take it? - if (this.isAttacked(piecesLeft[oppCol].square, [color])) + if (this.isAttacked(piecesLeft[oppCol].square, color)) // Yes! But I still need to take it return "*"; // No :(