- }
- else if (this.subTurn == 2) {
- this.turn = oppCol;
- this.subTurn = this.promotion ? 0 : 1;
- }
- else { //subTurn == 1, usual case
+ this.promotion = (
+ this.subTurn == 2 &&
+ move.end.x == (oppCol == 'w' ? 0 : this.size.x - 1) &&
+ move.vanish[0].p == 'p'
+ );
+ if (this.subTurn == 0) {
+ this.subTurn++;
+ if (!this.atLeastOneMove(color)) {
+ move.result = "1/2"; //avoid re-computation
+ return true;
+ }
+ return false;
+ }
+ if (this.subTurn == 2) {
+ this.subTurn = (this.promotion ? 0 : 1);
+ return true;
+ }
+ // subTurn == 1, usual case