projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Pandemonium pawn moves
[vchess.git]
/
client
/
src
/
variants
/
Dark.js
diff --git
a/client/src/variants/Dark.js
b/client/src/variants/Dark.js
index
96163bf
..
e7ba40c
100644
(file)
--- a/
client/src/variants/Dark.js
+++ b/
client/src/variants/Dark.js
@@
-2,7
+2,8
@@
import { ChessRules } from "@/base_rules";
import { ArrayFun } from "@/utils/array";
import { randInt } from "@/utils/alea";
import { ArrayFun } from "@/utils/array";
import { randInt } from "@/utils/alea";
-export const VariantRules = class DarkRules extends ChessRules {
+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 const VariantRules = 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];
@@
-37,16
+42,16
@@
export const VariantRules = class DarkRules extends ChessRules {
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
if (this.board[i][j] != V.EMPTY) {
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
if (this.board[i][j] != V.EMPTY) {
- const c
olor
= this.getColor(i, j);
- this.enlightened[c
olor
][i][j] = true;
+ const c = this.getColor(i, j);
+ this.enlightened[c][i][j] = true;
// Add potential squares visible by "impossible pawn capture"
if (this.getPiece(i, j) == V.PAWN) {
for (let shiftY of [-1, 1]) {
if (
// Add potential squares visible by "impossible pawn capture"
if (this.getPiece(i, j) == V.PAWN) {
for (let shiftY of [-1, 1]) {
if (
- V.OnBoard(i + pawnShift[c
olor
], j + shiftY) &&
- this.board[i + pawnShift[c
olor
]][j + shiftY] == V.EMPTY
+ V.OnBoard(i + pawnShift[c], j + shiftY) &&
+ this.board[i + pawnShift[c]][j + shiftY] == V.EMPTY
) {
) {
- this.enlightened[c
olor][i + pawnShift[color
]][j + shiftY] = true;
+ this.enlightened[c
][i + pawnShift[c
]][j + shiftY] = true;
}
}
}
}
}
}
@@
-78,6
+83,11
@@
export const VariantRules = 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;
@@
-103,9
+113,9
@@
export const VariantRules = class DarkRules extends ChessRules {
return [];
}
return [];
}
-
updateVariables
(move) {
- super.
updateVariables
(move);
- if (move.vanish.length
>
= 2 && move.vanish[1].p == V.KING)
+
postPlay
(move) {
+ super.
postPlay
(move);
+ 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];
@@
-113,13
+123,11
@@
export const VariantRules = class DarkRules extends ChessRules {
this.updateEnlightened();
}
this.updateEnlightened();
}
- unupdateVariables(move) {
- super.unupdateVariables(move);
- const c = move.vanish[0].c;
- const oppCol = V.GetOppCol(c);
- if (this.kingPos[oppCol][0] < 0)
+ postUndo(move) {
+ super.postUndo(move);
+ 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();
@@
-245,7
+253,8
@@
export const VariantRules = class DarkRules extends ChessRules {
const myPieceVal = V.VALUES[move.appear[0].p];
const hisPieceVal = V.VALUES[move.vanish[1].p];
// Favor captures
const myPieceVal = V.VALUES[move.appear[0].p];
const hisPieceVal = V.VALUES[move.vanish[1].p];
// Favor captures
- if (myPieceVal <= hisPieceVal) move.eval = hisPieceVal - myPieceVal + 1;
+ if (myPieceVal <= hisPieceVal)
+ move.eval = hisPieceVal - myPieceVal + 1;
else {
// Taking a pawn with minor piece,
// or minor piece or pawn with a rook,
else {
// Taking a pawn with minor piece,
// or minor piece or pawn with a rook,
@@
-266,4
+275,5
@@
export const VariantRules = class DarkRules extends ChessRules {
candidates.push(j);
return moves[candidates[randInt(candidates.length)]];
}
candidates.push(j);
return moves[candidates[randInt(candidates.length)]];
}
+
};
};