Skip to content

Commit

Permalink
fix: IsTileSafe function bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash7824 committed May 6, 2024
1 parent 275774e commit ecb2504
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions client/src/app/services/generic-rule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export class GenericRuleService {
}

for (let i = 1; i <= 7; i++) {
if (row + i >= 0 && this.IsEmptyTile(row + i, col)) continue;
if (row + i >= 0 && this.chess_Board[row + i][col] === 'R') {
if (row + i <= 7 && this.IsEmptyTile(row + i, col)) continue;
if (row + i <= 7 && this.chess_Board[row + i][col] === 'R') {
return true;
} else break;
}
Expand Down Expand Up @@ -174,8 +174,8 @@ export class GenericRuleService {
}

for (let i = 1; i <= 7; i++) {
if (row + i >= 0 && this.IsEmptyTile(row + i, col)) continue;
if (row + i >= 0 && this.chess_Board[row + i][col] === 'Q') {
if (row + i <= 7 && this.IsEmptyTile(row + i, col)) continue;
if (row + i <= 7 && this.chess_Board[row + i][col] === 'Q') {
return true;
} else break;
}
Expand Down Expand Up @@ -269,8 +269,8 @@ export class GenericRuleService {
}

for (let i = 1; i <= 7; i++) {
if (row + i >= 0 && this.IsEmptyTile(row + i, col)) continue;
if (row + i >= 0 && this.chess_Board[row + i][col] === 'r') {
if (row + i <= 7 && this.IsEmptyTile(row + i, col)) continue;
if (row + i <= 7 && this.chess_Board[row + i][col] === 'r') {
return true;
} else break;
}
Expand Down Expand Up @@ -327,8 +327,8 @@ export class GenericRuleService {
}

for (let i = 1; i <= 7; i++) {
if (row + i >= 0 && this.IsEmptyTile(row + i, col)) continue;
if (row + i >= 0 && this.chess_Board[row + i][col] === 'q') {
if (row + i <= 7 && this.IsEmptyTile(row + i, col)) continue;
if (row + i <= 7 && this.chess_Board[row + i][col] === 'q') {
return true;
} else break;
}
Expand Down

0 comments on commit ecb2504

Please sign in to comment.