else if (m.vanish.length == 0)
this.reserve[m.appear[0].c][m.appear[0].p]--;
});
+ // TODO: keep track of promoted pawns ==> give a pawn if captured.
+ }
+
+ getColor(i,j)
+ {
+ const sizeX = VariantRules.size[0];
+ if (i >= sizeX)
+ return (i==sizeX ? "w" : "b");
+ return this.board[i][j].charAt(0);
+ }
+ getPiece(i,j)
+ {
+ const sizeX = VariantRules.size[0];
+ if (i >= sizeX)
+ return VariantRules.RESERVE_PIECES[j];
+ return this.board[i][j].charAt(1);
}
// Used by the interface:
if (this.reserve[color][p] == 0)
return [];
let moves = [];
- for (let i=0; i<sizeX; i++)
+ const [sizeX,sizeY] = VariantRules.size;
+ const pawnShift = (p==VariantRules.PAWN ? 1 : 0);
+ for (let i=pawnShift; i<sizeX-pawnShift; i++)
{
for (let j=0; j<sizeY; j++)
{
- if (this.board[i][j] != VariantRules.EMPTY)
+ if (this.board[i][j] == VariantRules.EMPTY)
{
let mv = new Move({
appear: [
c: color,
p: p
})
- ]
+ ],
+ vanish: [],
+ start: {x:sizeX, y:y}, //a bit artificial...
+ end: {x:i, y:j}
});
moves.push(mv);
}
super.updateVariables(move);
const color = this.turn;
if (move.vanish.length==2)
- this.reserve[color][move.appear[0].p]++;
+ this.reserve[color][move.vanish[1].p]++;
if (move.vanish.length==0)
this.reserve[color][move.appear[0].p]--;
}
super.unupdateVariables(move);
const color = this.turn;
if (move.vanish.length==2)
- this.reserve[color][move.appear[0].p]--;
+ this.reserve[color][move.vanish[1].p]--;
if (move.vanish.length==0)
this.reserve[color][move.appear[0].p]++;
}
return super.getNotation(move);
// Rebirth:
const piece =
- (move.appear[0].p != VariantRules.PAWN ? move.appear.p.toUpperCase() : "");
+ (move.appear[0].p != VariantRules.PAWN ? move.appear[0].p.toUpperCase() : "");
const finalSquare =
String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x);
return piece + "@" + finalSquare;