X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FKnightrelay2.js;fp=client%2Fsrc%2Fvariants%2FKnightrelay.js;h=9fa5dcca87fa19324396b67f265084cca6205e01;hp=43aef74dfe243f99b0b26a985a7247e47b42a9ca;hb=68e19a449db7a12e0a168e99cd750d985c983ba1;hpb=11589e7c4bb1b69473588d133db8b6d1d37b8fee diff --git a/client/src/variants/Knightrelay.js b/client/src/variants/Knightrelay2.js similarity index 91% rename from client/src/variants/Knightrelay.js rename to client/src/variants/Knightrelay2.js index 43aef74d..9fa5dcca 100644 --- a/client/src/variants/Knightrelay.js +++ b/client/src/variants/Knightrelay2.js @@ -1,6 +1,6 @@ import { ChessRules } from "@/base_rules"; -export const VariantRules = class KnightrelayRules extends ChessRules { +export const VariantRules = class Knightrelay2Rules extends ChessRules { getPotentialMovesFrom([x, y]) { let moves = super.getPotentialMovesFrom([x, y]); @@ -46,9 +46,8 @@ export const VariantRules = class KnightrelayRules extends ChessRules { return moves; } - isAttacked(sq, colors) { - if (super.isAttacked(sq, colors)) - return true; + isAttacked(sq, color) { + if (super.isAttacked(sq, color)) return true; // Check if a (non-knight) piece at knight distance // is guarded by a knight (and thus attacking) @@ -57,7 +56,7 @@ export const VariantRules = class KnightrelayRules extends ChessRules { for (const step of V.steps[V.KNIGHT]) { if ( V.OnBoard(x+step[0],y+step[1]) && - colors.includes(this.getColor(x+step[0],y+step[1])) && + this.getColor(x+step[0],y+step[1]) == color && this.getPiece(x+step[0],y+step[1]) != V.KNIGHT ) { for (const step2 of V.steps[V.KNIGHT]) { @@ -65,7 +64,7 @@ export const VariantRules = class KnightrelayRules extends ChessRules { yy = y+step[1]+step2[1]; if ( V.OnBoard(xx,yy) && - colors.includes(this.getColor(xx,yy)) && + this.getColor(xx,yy) == color && this.getPiece(xx,yy) == V.KNIGHT ) { return true;