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]);
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)
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]) {
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;