class LoserRules extends ChessRules
{
- initVariables(fen)
- {
- const epSq = this.moves.length > 0 ? this.getEpSquare(this.lastMove) : undefined;
- this.epSquares = [ epSq ];
- }
-
- setFlags(fen)
- {
- // No castling, hence no flags; but flags defined for compatibility
- this.castleFlags = { "w":[false,false], "b":[false,false] };
- }
+ static get HasFlags() { return false; }
getPotentialPawnMoves([x,y])
{
// Complete with promotion(s) into king, if possible
const color = this.turn;
- const V = VariantRules;
- const [sizeX,sizeY] = VariantRules.size;
const shift = (color == "w" ? -1 : 1);
- const lastRank = (color == "w" ? 0 : sizeX-1);
+ const lastRank = (color == "w" ? 0 : V.size.x-1);
if (x+shift == lastRank)
{
// Normal move
{
moves.push(this.getBasicMove([x,y], [x+shift,y-1], {c:color,p:V.KING}));
}
- if (y<sizeY-1 && this.canTake([x,y], [x+shift,y+1])
+ if (y<V.size.y-1 && this.canTake([x,y], [x+shift,y+1])
&& this.board[x+shift][y+1] != V.EMPTY)
{
moves.push(this.getBasicMove([x,y], [x+shift,y+1], {c:color,p:V.KING}));
getPotentialKingMoves(sq)
{
- const V = VariantRules;
+ // No castle:
return this.getSlideNJumpMoves(sq,
V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep");
}
{
const color = this.turn;
const oppCol = this.getOppCol(color);
- const [sizeX,sizeY] = VariantRules.size;
- for (let i=0; i<sizeX; i++)
+ for (let i=0; i<V.size.x; i++)
{
- for (let j=0; j<sizeY; j++)
+ for (let j=0; j<V.size.y; j++)
{
- if (this.board[i][j] != VariantRules.EMPTY && this.getColor(i,j) != oppCol)
+ if (this.board[i][j] != V.EMPTY && this.getColor(i,j) != oppCol)
{
const moves = this.getPotentialMovesFrom([i,j]);
if (moves.length > 0)
let moves = this.filterValid( this.getPotentialMovesFrom(sq) );
// This is called from interface: we need to know if a capture is possible
if (this.atLeastOneCapture())
- moves = VariantRules.KeepCaptures(moves);
+ moves = V.KeepCaptures(moves);
return moves;
}
{
let moves = super.getAllValidMoves();
if (moves.some(m => { return m.vanish.length == 2; }))
- moves = VariantRules.KeepCaptures(moves);
+ moves = V.KeepCaptures(moves);
return moves;
}
- underCheck(move)
+ underCheck(color)
{
return false; //No notion of check
}
return [];
}
- // Unused:
+ // No variables update because no royal king + no castling
updateVariables(move) { }
unupdateVariables(move) { }
- getFlagsFen()
- {
- return "-";
- }
-
checkGameEnd()
{
// No valid move: you win!
return this.turn == "w" ? "1-0" : "0-1";
}
- static get VALUES() { //experimental...
+ static get VALUES()
+ {
+ // Experimental...
return {
'p': 1,
'r': 7,
return pieces["b"].join("") +
"/pppppppp/8/8/8/8/PPPPPPPP/" +
pieces["w"].join("").toUpperCase() +
- " 0000"; //add flags (TODO?!)
+ " w -"; //no en-passant
}
}
+
+const VariantRules = LoserRules;