Especially for chess queen it is not so simple. You have to:
- determine that the move straight, i.e. horizontal, vertical, or diagonal.
- That there are no other pieces on the way.
So,
- To determine that move is horizontal check
this.x == x && this.y != y
- To determine that move is vertical check
this.y == y && this.x != x
- To determine diagonal check
Math.abs(this.x - x) == Math.abs(this.y - y)
Now chose the direction, iterate over the way and check that your matrix
does not contain elements in cells that are going to be passed by queen during this move.