Rooks, bishops and queens attack from a distance. Slide outwards from the square in each direction; the first
piece met decides: straight lines are dangerous if it is an enemy rook or queen, diagonals if it is an enemy bishop or
queen.
```js
for (const [dirs, kind] of [[STRAIGHT, 'R'], [DIAGONAL, 'B']]) {
for (const [dr, dc] of dirs) {
let tr = r + dr
let tc = c + dc
while (inside(tr, tc)) {
const piece = board[tr][tc]
if (piece) {
if (piece === by + kind || piece === by + 'Q') return true
break
}
tr += dr
tc += dc
}
}
}
```
What it means
The pairs link straight directions to rooks and diagonal ones to bishops; a queen counts on both.
Empty squares are passed; the first piece ends the direction with break, attacker or not.
Your turn
In attacked, above return false, write the sliding loops.