Skip to content

Commit

Permalink
refactor : indent 규칙에 맞게 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
fucct committed Apr 6, 2020
1 parent 6fed1bb commit 6002bdc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/main/java/chess/domain/piece/Bishop.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ protected void validateMovingPolicy(Position target, Map<Position, PieceDto> boa

Position startPathPosition = position.moveByDirection(movingDirection);
while (!startPathPosition.equals(target)) {
if (!Objects.isNull(boardDto.get(startPathPosition))) {
throw new ObstacleOnPathException();
}
checkObstacleOnPath(boardDto, startPathPosition);
startPathPosition = startPathPosition.moveByDirection(movingDirection);
}
}

private void checkObstacleOnPath(final Map<Position, PieceDto> boardDto, final Position startPathPosition) {
if (!Objects.isNull(boardDto.get(startPathPosition))) {
throw new ObstacleOnPathException();
}
}

@Override
public String getFigure() {
if (player == Player.BLACK) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/chess/domain/piece/NotMovedPawn.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,4 @@ protected PieceState makePieceState() {
//MovedPawn 리턴
return MovedPawn.of(position, player);
}


}
10 changes: 7 additions & 3 deletions src/main/java/chess/domain/piece/Queen.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ protected void validateMovingPolicy(Position target, Map<Position, PieceDto> boa

Position startPathPosition = position.moveByDirection(movingDirection);
while (!startPathPosition.equals(target)) {
if (!Objects.isNull(boardDto.get(startPathPosition))) {
throw new ObstacleOnPathException();
}
checkObstacleOnPath(boardDto, startPathPosition);
startPathPosition = startPathPosition.moveByDirection(movingDirection);
}

}

private void checkObstacleOnPath(final Map<Position, PieceDto> boardDto, final Position startPathPosition) {
if (!Objects.isNull(boardDto.get(startPathPosition))) {
throw new ObstacleOnPathException();
}
}

@Override
public String getFigure() {
if (player == Player.BLACK) {
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/chess/domain/piece/Rook.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ protected void validateMovingPolicy(Position target, Map<Position, PieceDto> boa

Position startPathPosition = position.moveByDirection(movingDirection);
while (!startPathPosition.equals(target)) {
if (!Objects.isNull(boardDto.get(startPathPosition))) {
throw new ObstacleOnPathException();
}
checkObstacleOnPath(boardDto, startPathPosition);
startPathPosition = startPathPosition.moveByDirection(movingDirection);
}
}

private void checkObstacleOnPath(final Map<Position, PieceDto> boardDto, final Position startPathPosition) {
if (!Objects.isNull(boardDto.get(startPathPosition))) {
throw new ObstacleOnPathException();
}
}

@Override
public String getFigure() {
if (player == Player.BLACK) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/chess/domain/result/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ public Player getWinner() {
return Player.WHITE;
}
return Player.BLACK;

}
}

0 comments on commit 6002bdc

Please sign in to comment.