projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix SuctionChess, draft HiddenRules (unfinished)
[vchess.git]
/
client
/
src
/
variants
/
Checkered.js
diff --git
a/client/src/variants/Checkered.js
b/client/src/variants/Checkered.js
index
0e4f0a0
..
d477a6d
100644
(file)
--- a/
client/src/variants/Checkered.js
+++ b/
client/src/variants/Checkered.js
@@
-1,10
+1,6
@@
import { ChessRules } from "@/base_rules";
export const VariantRules = class CheckeredRules extends ChessRules {
import { ChessRules } from "@/base_rules";
export const VariantRules = class CheckeredRules extends ChessRules {
- static getPpath(b) {
- return b[0] == "c" ? "Checkered/" + b : b;
- }
-
static board2fen(b) {
const checkered_codes = {
p: "s",
static board2fen(b) {
const checkered_codes = {
p: "s",
@@
-40,6
+36,10
@@
export const VariantRules = class CheckeredRules extends ChessRules {
return ChessRules.PIECES.concat(["s", "t", "u", "c", "o"]);
}
return ChessRules.PIECES.concat(["s", "t", "u", "c", "o"]);
}
+ getPpath(b) {
+ return b[0] == "c" ? "Checkered/" + b : b;
+ }
+
setOtherVariables(fen) {
super.setOtherVariables(fen);
// Local stack of non-capturing checkered moves:
setOtherVariables(fen) {
super.setOtherVariables(fen);
// Local stack of non-capturing checkered moves:
@@
-130,7
+130,7
@@
export const VariantRules = class CheckeredRules extends ChessRules {
}
}
if (m.vanish.length == 1) moves.push(m);
}
}
if (m.vanish.length == 1) moves.push(m);
- //
n
o capture
+ //
N
o capture
else {
// A capture occured (m.vanish.length == 2)
m.appear[0].c = "c";
else {
// A capture occured (m.vanish.length == 2)
m.appear[0].c = "c";
@@
-156,7
+156,7
@@
export const VariantRules = class CheckeredRules extends ChessRules {
// Does m2 un-do m1 ? (to disallow undoing checkered moves)
oppositeMoves(m1, m2) {
return (
// Does m2 un-do m1 ? (to disallow undoing checkered moves)
oppositeMoves(m1, m2) {
return (
-
!!
m1 &&
+ m1 &&
m2.appear[0].c == "c" &&
m2.appear.length == 1 &&
m2.vanish.length == 1 &&
m2.appear[0].c == "c" &&
m2.appear.length == 1 &&
m2.vanish.length == 1 &&
@@
-170,8
+170,8
@@
export const VariantRules = class CheckeredRules extends ChessRules {
filterValid(moves) {
if (moves.length == 0) return [];
const color = this.turn;
filterValid(moves) {
if (moves.length == 0) return [];
const color = this.turn;
+ const L = this.cmoves.length; //at least 1: init from FEN
return moves.filter(m => {
return moves.filter(m => {
- const L = this.cmoves.length; //at least 1: init from FEN
if (this.oppositeMoves(this.cmoves[L - 1], m)) return false;
this.play(m);
const res = !this.underCheck(color);
if (this.oppositeMoves(this.cmoves[L - 1], m)) return false;
this.play(m);
const res = !this.underCheck(color);