addPawnCaptures(moves, byChameleon) {
    const steps = V.steps[V.ROOK];
    const color = this.turn;
    const oppCol = V.GetOppCol(color);
    moves.forEach(m => {
      if (!!byChameleon && m.start.x != m.end.x && m.start.y != m.end.y)
        // Chameleon not moving as pawn
        return;
      // Try capturing in every direction
      for (let step of steps) {
        const sq2 = [m.end.x + 2 * step[0], m.end.y + 2 * step[1]];
        if (
          V.OnBoard(sq2[0], sq2[1]) &&
          this.board[sq2[0]][sq2[1]] != V.EMPTY &&
          this.getColor(sq2[0], sq2[1]) == color
        ) {
          // Potential capture
          const sq1 = [m.end.x + step[0], m.end.y + step[1]];
          if (
            this.board[sq1[0]][sq1[1]] != V.EMPTY &&
            this.getColor(sq1[0], sq1[1]) == oppCol
          ) {
            const piece1 = this.getPiece(sq1[0], sq1[1]);
            if (!byChameleon || piece1 == V.PAWN) {
              m.vanish.push(
                new PiPo({
                  x: sq1[0],
                  y: sq1[1],
                  c: oppCol,
                  p: piece1
                })
              );
            }
          }
        }
      }
    });
  }
// Modify capturing moves among listed pawn moves
Modify capturing moves among listed pawn moves
Modify capturing moves among listed pawn moves
addPawnCaptures(moves, byChameleon) {
    const steps = V.steps[V.ROOK];
    const color = this.turn;
    const oppCol = V.GetOppCol(color);
    moves.forEach(m => {
      if (!!byChameleon && m.start.x != m.end.x && m.start.y != m.end.y)
        return;
      for (let step of steps) {
        const sq2 = [m.end.x + 2 * step[0], m.end.y + 2 * step[1]];
        if (
          V.OnBoard(sq2[0], sq2[1]) &&
          this.board[sq2[0]][sq2[1]] != V.EMPTY &&
          this.getColor(sq2[0], sq2[1]) == color
        ) {
          const sq1 = [m.end.x + step[0], m.end.y + step[1]];
          if (
            this.board[sq1[0]][sq1[1]] != V.EMPTY &&
            this.getColor(sq1[0], sq1[1]) == oppCol
          ) {
            const piece1 = this.getPiece(sq1[0], sq1[1]);
            if (!byChameleon || piece1 == V.PAWN) {
              m.vanish.push(
                new PiPo({
                  x: sq1[0],
                  y: sq1[1],
                  c: oppCol,
                  p: piece1
                })
              );
            }
          }
        }
      }
    });
  }
addPawnCaptures ( moves , byChameleon ) { const steps = V . steps [ V . ROOK ] ; const color = this . turn ; const oppCol = V . GetOppCol ( color ) ; moves . forEach ( m => { if ( ! ! byChameleon && m . start . x != m . end . x && m . start . y != m . end . y ) return ; for ( let step of steps ) { const sq2 = [ m . end . x + 2 * step [ 0 ] , m . end . y + 2 * step [ 1 ] ] ; if ( V . OnBoard ( sq2 [ 0 ] , sq2 [ 1 ] ) && this . board [ sq2 [ 0 ] ] [ sq2 [ 1 ] ] != V . EMPTY && this . getColor ( sq2 [ 0 ] , sq2 [ 1 ] ) == color ) { const sq1 = [ m . end . x + step [ 0 ] , m . end . y + step [ 1 ] ] ; if ( this . board [ sq1 [ 0 ] ] [ sq1 [ 1 ] ] != V . EMPTY && this . getColor ( sq1 [ 0 ] , sq1 [ 1 ] ) == oppCol ) { const piece1 = this . getPiece ( sq1 [ 0 ] , sq1 [ 1 ] ) ; if ( ! byChameleon || piece1 == V . PAWN ) { m . vanish . push ( new PiPo ( { x : sq1 [ 0 ] , y : sq1 [ 1 ] , c : oppCol , p : piece1 } ) ) ; } } } } } ) ; }
Modify capturing moves among listed pawn moves
Modify capturing moves among listed pawn moves
// Chameleon not moving as pawn // Try capturing in every direction // Potential capture