- 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";
+ // Artifically change turn, for checkered pawns
+ this.turn = this.getOppCol(this.turn);
+ const res = this.isAttacked(this.kingPos[color], [this.getOppCol(color),'c'])
+ ? (color == "w" ? "0-1" : "1-0")
+ : "1/2";
+ this.turn = this.getOppCol(this.turn);
+ return res;