-
-
-
-
-// TODO: simplify and fix this
-
-
-
- if (this.subTurn == 1) {
- // Update flags:
- if (
- this.board[move.start.x][move.start.y] != V.EMPTY &&
- this.getPiece(move.start.x, move.start.y) == V.KING &&
- (
- Math.abs(move.end.x - move.start.x) >= 2 ||
- Math.abs(move.end.y - move.start.y) >= 2
- )
- ) {
- const myColor = this.getColor(move.start.x, move.start.y);
- this.powerFlags[myColor][V.KING] = false;
- }
- else if (
- move.vanish[0].p == V.QUEEN &&
- this.getPiece(move.end.x, move.end.y) == V.INVISIBLE_QUEEN
- ) {
- this.powerFlags[move.vanish[0].c][V.QUEEN] = false;
- }
- const color = move.vanish[0].c;
- const oppCol = V.GetOppCol(color);
- if (!(Object.keys(V.IMMOBILIZE_DECODE).includes(move.appear[0].p))) {
- // Look for an immobilized piece of my color: it can now move
- // Also make opponent invisible queen visible again, if any
- for (let i=0; i<8; i++) {
- for (let j=0; j<8; j++) {
- if (this.board[i][j] != V.EMPTY) {
- const colIJ = this.getColor(i, j);
- const piece = this.getPiece(i, j);
- if (
- colIJ == color &&
- Object.keys(V.IMMOBILIZE_DECODE).includes(piece)
- ) {
- this.board[i][j] = color + V.IMMOBILIZE_DECODE[piece];
- move.wasImmobilized = [i, j];
- }
- else if (
- colIJ == oppCol &&
- piece == V.INVISIBLE_QUEEN
- ) {
- this.board[i][j] = oppCol + V.QUEEN;
- move.wasInvisible = [i, j];
- }
+ if (move.appear.length == 0) {
+ // Three cases: king "shell capture", Chomp or Koopa
+ if (this.getPiece(move.start.x, move.start.y) == V.KING)
+ // King remote capture:
+ this.powerFlags[color][V.KING] = false;
+ else if (move.end.effect == "chomp")
+ this.captured[color][move.vanish[0].p]++;
+ }
+ else if (move.appear[0].p == V.INVISIBLE_QUEEN)
+ this.powerFlags[move.appear[0].c][V.QUEEN] = false;
+ if (this.subTurn == 2) return;
+ if (
+ move.turn[1] == 1 &&
+ move.appear.length == 0 ||
+ !(Object.keys(V.IMMOBILIZE_DECODE).includes(move.appear[0].p))
+ ) {
+ // Look for an immobilized piece of my color: it can now move
+ for (let i=0; i<8; i++) {
+ for (let j=0; j<8; j++) {
+ if (this.board[i][j] != V.EMPTY) {
+ const piece = this.getPiece(i, j);
+ if (
+ this.getColor(i, j) == color &&
+ Object.keys(V.IMMOBILIZE_DECODE).includes(piece)
+ ) {
+ this.board[i][j] = color + V.IMMOBILIZE_DECODE[piece];
+ move.wasImmobilized = [i, j];