- isAttackedByPawn([x, y], colors) {
- const pawnShift = 1;
- if (x + pawnShift < V.size.x) {
- for (let c of colors) {
- for (let i of [-1, 1]) {
- if (
- y + i >= 0 &&
- y + i < V.size.y &&
- this.getPiece(x + pawnShift, y + i) == V.PAWN &&
- this.getColor(x + pawnShift, y + i) == c
- ) {
- return true;
- }
- }
- }
- }
- return false;
+ isAttackedByPawn([x, y], color) {
+ // Pawns can capture forward and backward:
+ return this.isAttackedBySlideNJump(
+ sq, color, V.PAWN, V.steps[V.BISHOP], 1);