- isAttackedByPawn([x,y], colors)
- {
- for (let c of colors)
- {
- const color = (c=="c" ? this.turn : c);
- let pawnShift = (color=="w" ? 1 : -1);
- if (x+pawnShift>=0 && x+pawnShift<8)
- {
- for (let i of [-1,1])
- {
- if (y+i>=0 && y+i<8 && this.getPiece(x+pawnShift,y+i)==V.PAWN
- && this.getColor(x+pawnShift,y+i)==c)
- {
+ isAttackedByPawn([x, y], colors) {
+ for (let c of colors) {
+ const color = c == "c" ? this.turn : c;
+ let pawnShift = color == "w" ? 1 : -1;
+ if (x + pawnShift >= 0 && x + pawnShift < 8) {
+ for (let i of [-1, 1]) {
+ if (
+ y + i >= 0 &&
+ y + i < 8 &&
+ this.getPiece(x + pawnShift, y + i) == V.PAWN &&
+ this.getColor(x + pawnShift, y + i) == c
+ ) {