projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Xiangqi + a few cosmetics
[vchess.git]
/
client
/
src
/
variants
/
Monster.js
diff --git
a/client/src/variants/Monster.js
b/client/src/variants/Monster.js
index
071c8db
..
cb29ada
100644
(file)
--- a/
client/src/variants/Monster.js
+++ b/
client/src/variants/Monster.js
@@
-2,6
+2,7
@@
import { ChessRules } from "@/base_rules";
import { randInt } from "@/utils/alea";
export class MonsterRules extends ChessRules {
import { randInt } from "@/utils/alea";
export class MonsterRules extends ChessRules {
+
static IsGoodFlags(flags) {
// Only black can castle
return !!flags.match(/^[a-z]{2,2}$/);
static IsGoodFlags(flags) {
// Only black can castle
return !!flags.match(/^[a-z]{2,2}$/);
@@
-45,7
+46,7
@@
export class MonsterRules extends ChessRules {
);
}
);
}
- isAttacked(
sq, color, castling
) {
+ isAttacked() {
// Goal is king capture => no checks
return false;
}
// Goal is king capture => no checks
return false;
}
@@
-72,9
+73,17
@@
export class MonsterRules extends ChessRules {
V.PlayOnBoard(this.board, move);
if (this.turn == 'w') {
if (this.subTurn == 1) this.movesCount++;
V.PlayOnBoard(this.board, move);
if (this.turn == 'w') {
if (this.subTurn == 1) this.movesCount++;
- else this.turn = 'b';
- this.subTurn = 3 - this.subTurn;
- } else {
+ if (
+ this.subTurn == 2 ||
+ // King captured
+ (move.vanish.length == 2 && move.vanish[1].p == V.KING)
+ ) {
+ this.turn = 'b';
+ this.subTurn = 1;
+ }
+ else this.subTurn = 2;
+ }
+ else {
this.turn = 'w';
this.movesCount++;
}
this.turn = 'w';
this.movesCount++;
}
@@
-108,9
+117,11
@@
export class MonsterRules extends ChessRules {
const piece = move.vanish[0].p;
if (piece == V.KING)
this.kingPos[c] = [move.appear[0].x, move.appear[0].y];
const piece = move.vanish[0].p;
if (piece == V.KING)
this.kingPos[c] = [move.appear[0].x, move.appear[0].y];
- if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
+ if (move.vanish.length == 2 && move.vanish[1].p == V.KING)
{
// Opponent's king is captured, game over
this.kingPos[move.vanish[1].c] = [-1, -1];
// Opponent's king is captured, game over
this.kingPos[move.vanish[1].c] = [-1, -1];
+ move.captureKing = true; //for undo
+ }
this.updateCastleFlags(move, piece);
}
this.updateCastleFlags(move, piece);
}
@@
-125,7
+136,7
@@
export class MonsterRules extends ChessRules {
}
else {
this.turn = 'w';
}
else {
this.turn = 'w';
- this.subTurn =
2
;
+ this.subTurn =
(!move.captureKing ? 2 : 1)
;
}
this.postUndo(move);
}
}
this.postUndo(move);
}
@@
-204,4
+215,5
@@
export class MonsterRules extends ChessRules {
const color = this.turn;
return (color == 'w' ? getBestWhiteMove() : getBestBlackMove());
}
const color = this.turn;
return (color == 'w' ? getBestWhiteMove() : getBestBlackMove());
}
+
};
};