- if (
- // NOTE: no need to check OnBoard in this special case
- (!lancer && this.board[sq[0]][sq[1]] != V.EMPTY) ||
- (!!lancer && this.getColor(sq[0], sq[1]) == oppCol)
- ) {
- return false;
+ // NOTE: no need to check OnBoard in this special case
+ if (this.board[sq[0]][sq[1]] != V.EMPTY) {
+ const p = this.getPiece(sq[0], sq[1]);
+ const pc = this.getColor(sq[0], sq[1]);
+ if (
+ // Enemy sentry on the way will be gone:
+ (p != V.SENTRY || pc != oppCol) &&
+ // Lancer temporarily "changed color":
+ (!lancer || pc == color)
+ ) {
+ return false;
+ }