- const flipped = this.findCaptures([m.end.x, m.end.y]);
- V.UndoOnBoard(this.board, m);
- flipped.forEach(sq => {
- const piece = this.getPiece(sq[0],sq[1]);
- const pipoA = new PiPo({
- x:sq[0],
- y:sq[1],
- c:color,
- p:piece
- });
- const pipoV = new PiPo({
- x:sq[0],
- y:sq[1],
- c:oppCol,
- p:piece
+ // If castling, m.appear has 2 elements:
+ m.appear.forEach(a => {
+ const flipped = this.findCaptures([a.x, a.y]);
+ flipped.forEach(sq => {
+ const piece = this.getPiece(sq[0],sq[1]);
+ const pipoA = new PiPo({
+ x:sq[0],
+ y:sq[1],
+ c:color,
+ p:piece
+ });
+ const pipoV = new PiPo({
+ x:sq[0],
+ y:sq[1],
+ c:oppCol,
+ p:piece
+ });
+ newAppear.push(pipoA);
+ newVanish.push(pipoV);