class AntikingRules extends ChessRules
{
- // Path to pieces
static getPpath(b)
{
return b[1]=='a' ? "Antiking/"+b : b;
}
static get ANTIKING() { return 'a'; }
-
+
+ static get PIECES() {
+ return ChessRules.PIECES.concat([V.ANTIKING]);
+ }
+
initVariables(fen)
{
super.initVariables(fen);
{
switch (this.getPiece(x,y))
{
- case VariantRules.ANTIKING:
+ case V.ANTIKING:
return this.getPotentialAntikingMoves([x,y]);
default:
return super.getPotentialMovesFrom([x,y]);
getPotentialAntikingMoves(sq)
{
- const V = VariantRules;
return this.getSlideNJumpMoves(sq,
V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep");
}
isAttackedByKing([x,y], colors)
{
- const V = VariantRules;
if (this.getPiece(x,y) == V.ANTIKING)
return false; //antiking is not attacked by king
return this.isAttackedBySlideNJump([x,y], colors, V.KING,
isAttackedByAntiking([x,y], colors)
{
- const V = VariantRules;
if ([V.KING,V.ANTIKING].includes(this.getPiece(x,y)))
return false; //(anti)king is not attacked by antiking
return this.isAttackedBySlideNJump([x,y], colors, V.ANTIKING,
const piece = this.getPiece(move.start.x,move.start.y);
const c = this.getColor(move.start.x,move.start.y);
// Update antiking position
- if (piece == VariantRules.ANTIKING)
+ if (piece == V.ANTIKING)
{
this.antikingPos[c][0] = move.appear[0].x;
this.antikingPos[c][1] = move.appear[0].y;
{
super.unupdateVariables(move);
const c = this.getColor(move.start.x,move.start.y);
- if (this.getPiece(move.start.x,move.start.y) == VariantRules.ANTIKING)
+ if (this.getPiece(move.start.x,move.start.y) == V.ANTIKING)
this.antikingPos[c] = [move.start.x, move.start.y];
}
return color == "w" ? "0-1" : "1-0";
}
- // Pieces values (TODO: use Object.assign() + ChessRules.VALUES ?)
static get VALUES() {
- return {
- 'p': 1,
- 'r': 5,
- 'n': 3,
- 'b': 3,
- 'q': 9,
- 'k': 1000,
- 'a': 1000
- };
+ return Object.assign(
+ ChessRules.VALUES,
+ { 'a': 1000 }
+ );
}
static GenRandInitFen()
let fen = pieces["b"].join("") + "/" + ranks23_black +
"/8/8/" +
ranks23_white + "/" + pieces["w"].join("").toUpperCase() +
- " 1111"; //add flags
+ " 1111";
return fen;
}
}