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