projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Knightrelay1. Some fixes. Move odd 'isAttackedBy_multiple_colors' to Checkered...
[vchess.git]
/
client
/
src
/
variants
/
Knightrelay2.js
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
43aef74
..
9fa5dcc
100644
(file)
--- a/
client/src/variants/Knightrelay.js
+++ b/
client/src/variants/Knightrelay2.js
@@
-1,6
+1,6
@@
import { ChessRules } from "@/base_rules";
import { ChessRules } from "@/base_rules";
-export const VariantRules = class KnightrelayRules extends ChessRules {
+export const VariantRules = class Knightrelay
2
Rules extends ChessRules {
getPotentialMovesFrom([x, y]) {
let moves = super.getPotentialMovesFrom([x, y]);
getPotentialMovesFrom([x, y]) {
let moves = super.getPotentialMovesFrom([x, y]);
@@
-46,9
+46,8
@@
export const VariantRules = class KnightrelayRules extends ChessRules {
return moves;
}
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)
// 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]) &&
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]) {
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) &&
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;
this.getPiece(xx,yy) == V.KNIGHT
) {
return true;