Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7d27a33
fix: 향상된 문법으로 equals 수정
junseoplee Jul 19, 2024
d6ca9b5
docs: 기능 요구 사항 업데이트
junseoplee Jul 20, 2024
5e9f872
feat: 승리한 팀을 찾고 출력하는 기능 구현
junseoplee Jul 20, 2024
fba2d73
feat: King 이 잡혔을 때 승리 팀과 점수를 출력하는 기능 구현
junseoplee Jul 22, 2024
90f634b
fix: Pawn 피스가 적이 없을 경우에도 대각선으로 움직일 수 있던 오류 수정
junseoplee Jul 22, 2024
89edcb7
docs: 기능 요구 사항 정리
junseoplee Jul 22, 2024
0218cec
refactor: 프로젝트 구조 수정
junseoplee Jul 23, 2024
c786f3d
feat: 게임별로 구분할 수 있는 ChessGame 클래스 구현, 저장할 수 있도록 상태를 나타내는 State 열거형 구현
junseoplee Jul 23, 2024
5fd16d9
feat: DB 연결에 필요한 설정 추가
junseoplee Jul 23, 2024
54b66b5
feat: DB 연결을 위한 ChessGameDao 기능 추가
junseoplee Jul 23, 2024
9f7f78c
feat: DB 연결을 위한 PieceDao 기능 추가
junseoplee Jul 23, 2024
037471d
feat: DB 연결을 위한 PieceDao 기능 추가
junseoplee Jul 23, 2024
61d451a
fix: DB 연결을 위한 설정 수정
junseoplee Jul 25, 2024
3f07391
refactor: Board 반환을 위한 리팩토링
junseoplee Jul 25, 2024
a4d293e
refactor: 진행 상태를 보다 명확하게 알 수 있도록 변경
junseoplee Jul 25, 2024
e20a260
feat: DB 연결 기능과 컨트롤러 조립
junseoplee Jul 25, 2024
80b7e47
docs: 기능 요구 사항 및 에러메세지 업데이트
junseoplee Jul 25, 2024
a3ac67f
fix: 기존 게임이 정상적으로 불러와지지 않던 오류 수정
junseoplee Jul 25, 2024
ddfb961
refactor: 명령어를 다루는 책임을 컨트롤러에서 분리
junseoplee Jul 29, 2024
7c6c78e
feat: UnsupportedOperationException 으로 사용되지 않는 메서드 관리
junseoplee Jul 29, 2024
0ad0e65
test: 폰의 공격 움직임을 검증하는 테스트 추가
junseoplee Jul 29, 2024
3ce712d
fix: 변수 이름을 명확하게 수정
junseoplee Jul 29, 2024
d5483e4
fix: 상태를 더 명확하게 나타낼 수 있는 이름으로 수정
junseoplee Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
## 4단계 - DB 적용
### 기능 요구 사항
- **DB 연결 전 기능**
- [ ] end 명령어를 입력하면 각자의 점수와 승리 팀을 출력한다
- [ ] 점수를 계산해서 점수가 높은 팀이 승리한다
- [x] end 명령어를 입력하면 각자의 점수와 승리 팀을 출력한다
- [x] 점수를 계산해서 점수가 높은 팀이 승리한다
- **DAO**
- [ ] 이전에 하던 체스 게임을 다시 시작할 수 있어야 한다
- [ ] 사용자 ID로 사용자 엔티티를 조회한다
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/chess/controller/ChessController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public void runChess() {
receivedCommand = commandFactory.createCommand(commandInput);
if (receivedCommand.validateStatusCommandType()) {
calculateAndPrintCurrentTurnScore();
} else {
receivedCommand.execute(this);
currentTurn = currentTurn.changeTurn(currentTurn);
continue;
}
receivedCommand.execute(this);
currentTurn = currentTurn.changeTurn();
} catch (IllegalArgumentException exception) {
System.out.println(exception.getMessage());
}
Expand All @@ -87,4 +87,20 @@ public void calculateAndPrintCurrentTurnScore() {
double score = ScoreCalculator.calculate(board.getMap(), currentTurn);
outputView.printCurrentTurnScore(currentTurn, score);
}

public void printScoreAndWinningColor() {
double currentTurnScore = ScoreCalculator.calculate(board.getMap(), currentTurn);
double opponentScore = ScoreCalculator.calculate(board.getMap(), currentTurn.changeTurn());
outputView.printCurrentScore(currentTurn, currentTurnScore);
outputView.printCurrentScore(currentTurn.changeTurn(), opponentScore);
if (currentTurnScore > opponentScore) {
outputView.printWinningColor(currentTurn);
}
if (opponentScore > currentTurnScore) {
outputView.printWinningColor(currentTurn.changeTurn());
}
if (currentTurnScore == opponentScore) {
outputView.printDraw();
}
}
}
1 change: 1 addition & 0 deletions src/main/java/chess/model/command/commands/EndCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class EndCommand implements CommandLauncher {
@Override
public void execute(ChessController controller) {
controller.printScoreAndWinningColor();
controller.endGame();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/chess/model/position/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public boolean isSameColor(Color color) {
return this == color;
}

public Color changeTurn(Color currentTurn) {
if (currentTurn == WHITE) {
public Color changeTurn() {
if (this == WHITE) {
return BLACK;
}
return WHITE;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/chess/view/OutputView.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void printStartMessage() {
System.out.println("> 체스 게임을 시작합니다.");
System.out.println("> 게임 시작 : start");
System.out.println("> 게임 종료 : end");
System.out.println("> 게임 이동 : move source위치 target위치 - 예. move b2 b3");
System.out.println("> 게임 이동 : move source 위치 target 위치 - 예. move b2 b3");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디테일 👍

}

public void printBoard(final Map<Position, Piece> boardMap) {
Expand Down Expand Up @@ -58,4 +58,16 @@ private List<List<String>> createEmptyBoard() {
.mapToObj(it -> new ArrayList<>(Collections.nCopies(BOARD_SIZE, Symbol.EMPTY.getSymbol())))
.collect(Collectors.toList());
}

public void printCurrentScore(Color currentTurn, double score) {
System.out.println("Color: " + currentTurn + ", Score: " + score);
}

public void printWinningColor(Color currentTurn) {
System.out.println("Winning Color: " + currentTurn);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매개변수 이름이 currentTurn인 이유는 뭔가요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런. 리팩토링 업데이트가 안됐네요


public void printDraw() {
System.out.println("Draw");
}
}