// A capture occured (m.vanish.length == 2)
m.appear[0].c = "c";
moves.push(m);
- if (m.appear[0].p != m.vanish[1].p //avoid promotions:
+ if (m.appear[0].p != m.vanish[1].p //avoid promotions (already treated):
&& (m.vanish[0].p != VariantRules.PAWN || m.end.x != lastRank))
{
// Add transformation into captured piece
checkGameEnd()
{
const color = this.turn;
- if (!this.isAttacked(this.kingPos[color], this.getOppCol(color))
- && !this.isAttacked(this.kingPos[color], 'c'))
- {
- return "1/2";
- }
- // OK, checkmate
- return color == "w" ? "0-1" : "1-0";
+ this.moves.length++; //artifically change turn, for checkered pawns (TODO)
+ const res = this.isAttacked(this.kingPos[color], [this.getOppCol(color),'c'])
+ ? (color == "w" ? "0-1" : "1-0")
+ : "1/2";
+ this.moves.length--;
+ return res;
}
evalPosition()