- // Artifically change turn, for checkered pawns
- this.turn = V.GetOppCol(this.turn);
- const res = this.isAttacked(this.kingPos[color], [V.GetOppCol(color), "c"])
- ? color == "w"
- ? "0-1"
- : "1-0"
- : "1/2";
- this.turn = V.GetOppCol(this.turn);
- return res;
+ if (this.stage == 1) {
+ if (this.atLeastOneMove()) return "*";
+ // Artifically change turn, for checkered pawns
+ this.turn = V.GetOppCol(this.turn);
+ const res =
+ this.isAttacked(this.kingPos[color], [V.GetOppCol(color), "c"])
+ ? color == "w"
+ ? "0-1"
+ : "1-0"
+ : "1/2";
+ this.turn = V.GetOppCol(this.turn);
+ return res;
+ }
+ // Stage == 2:
+ if (this.sideCheckered == this.turn) {
+ // Check if remaining checkered pieces: if none, I lost
+ if (this.board.some(b => b.some(cell => cell[0] == 'c'))) {
+ if (!this.atLeastOneMove()) return "1/2";
+ return "*";
+ }
+ return color == 'w' ? "0-1" : "1-0";
+ }
+ if (this.atLeastOneMove()) return "*";
+ let res = this.isAttacked(this.kingPos['w'], ["c"]);
+ if (!res) res = this.isAttacked(this.kingPos['b'], ["c"]);
+ if (res) return color == 'w' ? "0-1" : "1-0";
+ return "1/2";