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