X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FTitan.js;h=425e08d8c66b778183889ce44396c15c81d6c42d;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=427eecdb67ff13b43642668b0bc44f8d651a1b8c;hpb=70c94aa7b7c3cb8832a728881a29feeb26118eb9;p=vchess.git diff --git a/client/src/variants/Titan.js b/client/src/variants/Titan.js index 427eecdb..425e08d8 100644 --- a/client/src/variants/Titan.js +++ b/client/src/variants/Titan.js @@ -154,6 +154,8 @@ export class TitanRules extends ChessRules { const [x, y] = [square[0], square[1]]; if ((color == 'w' && x != 7) || (color == 'b' && x != 0)) return null; const selectedPiece = this.board[x][y][1]; + // Prevent re-augmenting a chosen piece: + if (!ChessRules.PIECES.includes(selectedPiece)) return null; return new Move({ appear: [ new PiPo({ @@ -231,17 +233,16 @@ export class TitanRules extends ChessRules { if (this.movesCount > 4) { let piece = move.vanish[0].p; if (['j', 'l'].includes(piece)) piece = V.KING; - if (piece == V.KING && move.appear.length > 0) - this.kingPos[c] = [move.appear[0].x, move.appear[0].y]; + if (piece == V.KING) + this.kingPos[move.appear[0].c] = [move.appear[0].x, move.appear[0].y]; this.updateCastleFlags(move, piece); } } postUndo(move) { if (this.movesCount >= 4) { - const c = this.getColor(move.start.x, move.start.y); if (['j', 'k', 'l'].includes(this.getPiece(move.start.x, move.start.y))) - this.kingPos[c] = [move.start.x, move.start.y]; + this.kingPos[move.vanish[0].c] = [move.start.x, move.start.y]; } }