+ playOnBoard(move) {
+ super.playOnBoard(move);
+ this.flipColorOf(move.flips);
+ }
+ undoOnBoard(move) {
+ super.undoOnBoard(move);
+ this.flipColorOf(move.flips);
+ }
+
+ flipColorOf(flips) {
+ for (let xy of flips) {
+ const newColor = C.GetOppCol(this.getColor(xy.x, xy.y));
+ this.board[xy.x][xy.y] = newColor + this.board[xy.x][xy.y][1];
+ }
+ }
+
+ postPlay(move) {
+ if (this.options["balance"] && [1, 3].includes(this.movesCount)) {
+ // If enemy king is flipped: game over
+ const oppCol = C.GetOppCol(move.vanish[0].c);
+ const oppKingPos = this.searchKingPos(oppCol);
+ if (oppKingPos[0] < 0) {
+ this.turn = oppCol;
+ this.movesCount++;
+ return;
+ }
+ }
+ super.postPlay(move);
+ }
+
+ // Moves cannot flip our king's color, so all are valid