projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Football
[vchess.git]
/
client
/
src
/
variants
/
Dark.js
diff --git
a/client/src/variants/Dark.js
b/client/src/variants/Dark.js
index
8f94176
..
e7ba40c
100644
(file)
--- a/
client/src/variants/Dark.js
+++ b/
client/src/variants/Dark.js
@@
-3,6
+3,7
@@
import { ArrayFun } from "@/utils/array";
import { randInt } from "@/utils/alea";
export class DarkRules extends ChessRules {
import { randInt } from "@/utils/alea";
export class DarkRules extends ChessRules {
+
// Analyse in Dark mode makes no sense
static get CanAnalyze() {
return false;
// Analyse in Dark mode makes no sense
static get CanAnalyze() {
return false;
@@
-13,6
+14,10
@@
export class DarkRules extends ChessRules {
return "none";
}
return "none";
}
+ static get SomeHiddenMoves() {
+ return true;
+ }
+
setOtherVariables(fen) {
super.setOtherVariables(fen);
const [sizeX, sizeY] = [V.size.x, V.size.y];
setOtherVariables(fen) {
super.setOtherVariables(fen);
const [sizeX, sizeY] = [V.size.x, V.size.y];
@@
-78,6
+83,11
@@
export class DarkRules extends ChessRules {
}
}
}
}
+ // To always allow castling:
+ isAttacked() {
+ return false;
+ }
+
filterValid(moves) {
// Used in the interface
return moves;
filterValid(moves) {
// Used in the interface
return moves;
@@
-105,7
+115,7
@@
export class DarkRules extends ChessRules {
postPlay(move) {
super.postPlay(move);
postPlay(move) {
super.postPlay(move);
- if (move.vanish.length
>
= 2 && move.vanish[1].p == V.KING)
+ if (move.vanish.length
=
= 2 && move.vanish[1].p == V.KING)
// We took opponent king (because if castle vanish[1] is a rook)
this.kingPos[this.turn] = [-1, -1];
// We took opponent king (because if castle vanish[1] is a rook)
this.kingPos[this.turn] = [-1, -1];
@@
-115,11
+125,9
@@
export class DarkRules extends ChessRules {
postUndo(move) {
super.postUndo(move);
postUndo(move) {
super.postUndo(move);
- const c = move.vanish[0].c;
- const oppCol = V.GetOppCol(c);
- if (this.kingPos[oppCol][0] < 0)
+ if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
// Last move took opponent's king:
// Last move took opponent's king:
- this.kingPos[
oppCol
] = [move.vanish[1].x, move.vanish[1].y];
+ this.kingPos[
move.vanish[1].c
] = [move.vanish[1].x, move.vanish[1].y];
// Update lights for both colors:
this.updateEnlightened();
// Update lights for both colors:
this.updateEnlightened();
@@
-267,4
+275,5
@@
export class DarkRules extends ChessRules {
candidates.push(j);
return moves[candidates[randInt(candidates.length)]];
}
candidates.push(j);
return moves[candidates[randInt(candidates.length)]];
}
+
};
};