X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FTitan.js;h=9e651b0da49823f155b04902bbe123632a414772;hp=e9b0594f96a877ef67d1357306ae58fc791dcad4;hb=3208c66750e6a677b407267c44c35a395208c196;hpb=2fac4d67083700a1f1e85ed8662c176c24cdea6b diff --git a/client/src/variants/Titan.js b/client/src/variants/Titan.js index e9b0594f..9e651b0d 100644 --- a/client/src/variants/Titan.js +++ b/client/src/variants/Titan.js @@ -145,8 +145,8 @@ export class TitanRules extends ChessRules { const initialPiece = this.getPiece(x, y); const color = this.turn; if ( - V.AUGMENTED_PIECES.includes(this.board[x][y][1]) && - ((color == 'w' && x == 7) || (color == "b" && x == 0)) + ((color == 'w' && x == 7) || (color == "b" && x == 0)) && + V.AUGMENTED_PIECES.includes(this.board[x][y][1]) ) { const newPiece = this.getExtraPiece(this.board[x][y][1]); moves.forEach(m => { @@ -160,28 +160,28 @@ export class TitanRules extends ChessRules { }) ); }); + moves.forEach(m => { + if (m.vanish.length <= 1) return; + const [vx, vy] = [m.vanish[1].x, m.vanish[1].y]; + if ( + m.appear.length >= 2 && //3 if the king was also augmented + m.vanish.length == 2 && + m.vanish[1].c == color && + V.AUGMENTED_PIECES.includes(this.board[vx][vy][1]) + ) { + // Castle, rook is an "augmented piece" + m.appear[1].p = V.ROOK; + m.appear.push( + new PiPo({ + p: this.getExtraPiece(this.board[vx][vy][1]), + c: color, + x: vx, + y: vy + }) + ); + } + }); } - moves.forEach(m => { - if (m.vanish.length <= 1) return; - const [vx, vy] = [m.vanish[1].x, m.vanish[1].y]; - if ( - m.appear.length >= 2 && //3 if the king was also augmented - m.vanish.length == 2 && - m.vanish[1].c == color && - V.AUGMENTED_PIECES.includes(this.board[vx][vy][1]) - ) { - // Castle, rook is an "augmented piece" - m.appear[1].p = V.ROOK; - m.appear.push( - new PiPo({ - p: this.getExtraPiece(this.board[vx][vy][1]), - c: color, - x: vx, - y: vy - }) - ); - } - }); return moves; }