canIplay(color, sq)
{
- return ((color=='w' && this.movesCount%2==0) || color=='c'
- || (color=='b' && this.movesCount%2==1))
+ return ((color=='w' && this.moves.length%2==0) || color=='c'
+ || (color=='b' && this.moves.length%2==1))
&& [color,'c'].includes(this.getColor(sq[0], sq[1]));
}
getCheckSquares(move, c)
{
this.play(move);
+ this.moves.push(move); //artifically change turn, for checkered pawns (TODO)
const kingAttacked = this.isAttacked(this.kingPos[c], this.getOppCol(c))
|| this.isAttacked(this.kingPos[c], 'c');
let res = kingAttacked
? [ JSON.parse(JSON.stringify(this.kingPos[c])) ] //need to duplicate!
: [ ];
+ this.moves.pop();
this.undo(move);
return res;
}
this.flags[1][move.start.x==6 ? "w" : "b"][move.start.y] = false;
}
- play(move, ingame)
- {
- super.play(move, ingame);
- if (!ingame)
- this.moves.push(move); //needed for turn indication for checkered pieces
- }
-
- undo(move)
- {
- super.undo(move);
- this.moves.pop();
- }
-
checkGameEnd(color)
{
if (!this.isAttacked(this.kingPos[color], this.getOppCol(color))