projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Attempt to fix Convert variant
[vchess.git]
/
client
/
src
/
variants
/
Screen.js
diff --git
a/client/src/variants/Screen.js
b/client/src/variants/Screen.js
index
0a8a75e
..
8785560
100644
(file)
--- a/
client/src/variants/Screen.js
+++ b/
client/src/variants/Screen.js
@@
-12,10
+12,6
@@
export class ScreenRules extends ChessRules {
return false;
}
return false;
}
- get showFirstTurn() {
- return true;
- }
-
get canAnalyze() {
return this.movesCount >= 2;
}
get canAnalyze() {
return this.movesCount >= 2;
}
@@
-65,7
+61,7
@@
export class ScreenRules extends ChessRules {
for (let i=0; i<4; i++) {
for (let j=0; j<8; j++) this.enlightened['b'][i][j] = true;
}
for (let i=0; i<4; i++) {
for (let j=0; j<8; j++) this.enlightened['b'][i][j] = true;
}
- for (let i=
5
; i<8; i++) {
+ for (let i=
4
; i<8; i++) {
for (let j=0; j<8; j++) this.enlightened['w'][i][j] = true;
}
}
for (let j=0; j<8; j++) this.enlightened['w'][i][j] = true;
}
}
@@
-181,7
+177,13
@@
export class ScreenRules extends ChessRules {
this.getPotentialMovesFrom([V.size.x + (color == "w" ? 0 : 1), i])
);
}
this.getPotentialMovesFrom([V.size.x + (color == "w" ? 0 : 1), i])
);
}
- return this.filterValid(moves);
+ // Some setup moves may let the king en prise (thus game would be lost)
+ return moves;
+ }
+
+ filterValid(moves) {
+ if (this.movesCount <= 1) return moves;
+ return super.filterValid(moves);
}
play(move) {
}
play(move) {
@@
-210,6
+212,13
@@
export class ScreenRules extends ChessRules {
}
}
}
}
+ postPlay(move) {
+ if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
+ // Only black king could be captured (theoretically...)
+ this.kingPos['b'] = [-1, -1];
+ super.postPlay(move);
+ }
+
undo(move) {
const color = move.appear[0].c;
if (this.movesCount <= 2) {
undo(move) {
const color = move.appear[0].c;
if (this.movesCount <= 2) {
@@
-230,6
+239,12
@@
export class ScreenRules extends ChessRules {
else super.undo(move);
}
else super.undo(move);
}
+ postUndo(move) {
+ if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
+ this.kingPos['b'] = [move.vanish[1].x, move.vanish[1].y];
+ super.postUndo(move);
+ }
+
getCheckSquares() {
if (this.movesCount <= 1) return [];
return super.getCheckSquares();
getCheckSquares() {
if (this.movesCount <= 1) return [];
return super.getCheckSquares();
@@
-237,6
+252,8
@@
export class ScreenRules extends ChessRules {
getCurrentScore() {
if (this.movesCount <= 1) return "*";
getCurrentScore() {
if (this.movesCount <= 1) return "*";
+ // Only black king could be eaten on move 2:
+ if (this.kingPos['b'][0] < 0) return "1-0";
return super.getCurrentScore();
}
return super.getCurrentScore();
}