-
Notifications
You must be signed in to change notification settings - Fork 13
체스게임 1단계 미션 리뷰 요청드립니다. #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jiwoo-kimm
wants to merge
38
commits into
kiworkshop:jiwoo-kimm
Choose a base branch
from
jiwoo-kimm:jiwoo-kimm-step1
base: jiwoo-kimm
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
3a12a76
feat: 피스 생성 테스트 및 구현
seongbeenkim 667d30a
feat: 피스 위치 캐싱 테스트 및 구현
seongbeenkim 05e7c1d
feat: 체스판 32개의 피스 초기화, 생성 테스트 및 구현
seongbeenkim 2d33803
feat: 기물 종류에 따라 이름을 매핑하는 기물 이름 매퍼 테스트 및 구현
seongbeenkim cc54492
feat: 체스판 전체 출력하는 기능 구현
seongbeenkim 8bc0bd5
feat: 체스 게임 시작&종료 명령어 입력 테스트 및 구현
seongbeenkim f6c2eb4
feat: 기물 이동 시 공통 예외 케이스 테스트 및 구현
seongbeenkim 22d29d1
feat: 비숍 이동 규칙 테스트 및 구현
seongbeenkim c877ccd
feat: 룩 이동 규칙 테스트 및 구현
seongbeenkim adc18b6
feat: 퀸 이동 규칙 테스트 및 구현
seongbeenkim f3c877a
feat: 킹 이동 규칙 테스트 및 구현
seongbeenkim 12da4ca
feat: 나이트 이동 규칙 테스트 및 구현
seongbeenkim 44ecf39
feat: 폰 이동 규칙 테스트 및 구현
seongbeenkim 4498862
feat: 체스판에서 피스 이동 테스트 및 구현
seongbeenkim a40508d
refactor: 피스 색상별 체스판 분리
seongbeenkim c30f242
feat: 비숍, 룩 공격 가능한 경로 반환하는 테스트 및 기능 구현
seongbeenkim 483c149
feat: 폰 제외한 기물 패턴 테스트 및 기능 구현
seongbeenkim c2f0dea
feat: 기물 이동 시 공격 가능 위치를 갱신하는 테스트 및 기능 구현
seongbeenkim c17c852
feat: 킹 이동제한조건 테스트 및 기능 구현, 예외 처리 및 게임 흐름 제어
jiwoo-kimm 5d69a67
feat: 점수 계산 기능 테스트 및 구현
seongbeenkim be1d67e
feat: 점수 및 게임 결과 출력 기능 구현
jiwoo-kimm aba4a3a
refactor: 패키지 구조 및 테스트 케이스 정리
jiwoo-kimm 0401fb6
feat: 웹 체스 MVC 구조 및 초기화면 세팅
jiwoo-kimm bdb9729
feat: 기물 이동, 현재 점수, 안내 메시지 출력 구현
jiwoo-kimm ffec341
feat: 게임 종료, 결과 출력 기능 구현
jiwoo-kimm 8e2830b
refactor: ChessGame 도메인 삭제, ChessService로 통합
jiwoo-kimm 778b8d6
refactor: ChessService의 isGameFinished flag 제거, Status의 isKingDead fl…
jiwoo-kimm cdc9cda
fix: 퀸 이동 패턴 수정
jiwoo-kimm a0a341c
refactor: ChessGame 도메인 삭제, ChessService로 통합, 게임종료플래그
jiwoo-kimm b3770b2
refactor: Controller 역할을 Service, Command, Operation으로 분리
jiwoo-kimm d97f271
refactor: Board 가독성 개선, 메서드 길이 제한 확인
jiwoo-kimm cd61bd7
refactor: 기물 이동 리팩토링
jiwoo-kimm 9931625
test: 공격 경로 탐색 테스트 수정
jiwoo-kimm 2026dac
refactor: Player -> Team 으로 명칭 변경
jiwoo-kimm 8a8ccbb
refactor: Team 정적 팩토리 생성자 도입
jiwoo-kimm ea4b38f
refactor: Board → ChessGame 으로 명칭 변경
jiwoo-kimm 46a6daa
refactor: 기물 이동 메서드 이름 수정
jiwoo-kimm b574593
refactor: 플레이어의 플레이 순서 관리 추가
jiwoo-kimm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,127 @@ | ||
# java-chess 게임 | ||
|
||
## 구현해야할 목록 | ||
|
||
### 입력 | ||
|
||
- [x] 명령어 입력 | ||
- [x] 예외: `null` 입력 | ||
|
||
### 출력 | ||
|
||
- [x] 시작 안내 문구 출력 | ||
- [x] 체스판 스냅샷 출력 | ||
- [x] 차례 출력 | ||
- [x] 점수 출력 | ||
- [x] 승자 출력 | ||
|
||
### 서비스 | ||
|
||
#### `ChessService` | ||
|
||
- [x] `Command`에 따라 기능 수행 | ||
- [x] 게임 현재 상황 DTO | ||
|
||
### 도메인 | ||
|
||
#### `Operation` | ||
|
||
- [x] 명령어 검증 | ||
- [x] start: 게임 실행 | ||
- [x] status: 팀별 점수 | ||
- [x] move: 기물 이동 | ||
- [x] end: 강제 종료 | ||
|
||
#### `Board` | ||
|
||
- [x] 기물 이동 | ||
- [x] 예외 | ||
- [x] 움직일 기물이 자신 팀 소유가 아닌 경우 | ||
- [x] `source`와 `target`이 같은 위치인 경우 | ||
- [x] 본인의 기물을 공격하는 경우 | ||
- [x] 이동 경로가 다른 기물에 가로막힌 경우 | ||
- [x] `King`: `target`이 적이 공격 가능한 위치인 경우 | ||
- [x] `Pawn`: `target`에 적이 없는데 대각선으로 이동하는 경우 | ||
- [x] 자신의 기물 이동 | ||
- [x] 공격인 경우 적 기물 제거 | ||
- [x] 차례 변경 | ||
- [x] 현재 차례 관리 | ||
- [x] 위치 정보 | ||
- [x] 특정 위치가 비었는지 확인 | ||
- [x] 특정 위치에 있는 기물 확인 | ||
- [x] 각 팀 점수 계산 | ||
- [x] 승자 확인 | ||
- [x] 예외: 두 `King`이 모두 살아 있는 경우 | ||
|
||
#### `Team` | ||
|
||
- [x] 기물 이동 | ||
- [x] 기물 이동 경로 검색 | ||
- [x] 현위치에서 공격 가능한 모든 경로 검색 | ||
- [x] 적에게 공격받은 경우 기물 제거 | ||
- [x] 기물 검색 | ||
- [x] 점수 계산 | ||
|
||
#### `Piece` | ||
|
||
- [x] 이동 경로 검색 | ||
- [x] 현위치에서 공격 가능한 모든 경로 검색 | ||
- [x] 색상 확인 | ||
- [x] 타입 확인 | ||
- [x] `Pawn` | ||
- [x] `King` | ||
|
||
#### `MovePattern` | ||
|
||
- [x] 각 기물 타입에 맞는 패턴 검색 | ||
- [x] `Pawn`은 색상에 맞는 패턴 검색 | ||
- [x] 본인 패턴 중 `gap`에 맞는 `MoveUnit` 검색 | ||
- [x] 본인 패턴으로 공격 가능한 모든 경로 검색 | ||
|
||
#### `MoveLimit` | ||
|
||
- [x] 한 칸만 이동 가능한지 확인 | ||
|
||
#### `MoveUnits` | ||
|
||
- [x] 본인 리스트에서 매칭되는 `MoveUnit` 검색 | ||
- [x] 예외: 매칭되는 `MoveUnit`이 없는 경우 | ||
- [x] 이동 단위 별로 이동 가능한 모든 경로 검색 | ||
|
||
#### `MoveUnit` | ||
|
||
- [x] `MoveUnit`의 좌표가 `gap`에 매칭되는지 확인 | ||
|
||
#### `Position` | ||
|
||
- [x] 64개 위치 캐싱 및 검색 | ||
- [x] `Gap` 계산 | ||
- [x] 이동 단위로 타겟까지 이동할 때 지나가는 모든 위치 검색 | ||
- [x] 이동 단위로 이동 가능한 체스판의 모든 위치 검색 | ||
- [x] 이동 단위로 한 번 더 이동 가능한지 확인 | ||
- [x] 이동 단위로 이동 | ||
|
||
## 이동 규칙 | ||
|
||
- [x] 폰 (1 or 0.5) | ||
- [x] 적 방향 직선 1칸 이동 | ||
- [x] 처음 이동 시에는 2칸 이동 가능 | ||
- [x] 공격 시에는 적 방향 좌, 우 대각선 1칸 이동 | ||
|
||
- [x] 룩 (5) | ||
- [x] 모든 직선 방향으로 원하는 만큼 이동 | ||
|
||
- [x] 나이트 (2.5) | ||
- [x] 모든 직선 방향 1칸 + 이동한 직선 방향의 좌, 우 대각선 1칸으로 이동 | ||
- [x] 진행 방향이 가로막혀도 적, 아군 상관없이 뛰어넘을 수 있음 | ||
|
||
- [x] 비숍 (3) | ||
- [x] 모든 대각선 방향으로 원하는 만큼 이동 | ||
|
||
- [x] 퀸 (9) | ||
- [x] 모든 방향으로 원하는 만큼 이동 | ||
|
||
- [x] 킹 | ||
- [x] 모든 방향 1칸 이동 | ||
- [x] 상대의 공격 범위로는 이동 불가능 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package chess; | ||
|
||
import chess.controller.ConsoleChessController; | ||
import chess.view.ConsoleInputView; | ||
import chess.view.ConsoleOutputView; | ||
import chess.view.InputView; | ||
import chess.view.OutputView; | ||
|
||
public class ConsoleChessApplication { | ||
|
||
public static void main(String[] args) { | ||
OutputView outputView = new ConsoleOutputView(); | ||
InputView inputView = new ConsoleInputView(); | ||
ConsoleChessController consoleChessController = new ConsoleChessController(inputView, outputView); | ||
consoleChessController.run(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
src/main/java/chess/controller/ConsoleChessController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package chess.controller; | ||
|
||
import chess.domain.command.Command; | ||
import chess.dto.Scores; | ||
import chess.dto.TurnDto; | ||
import chess.exception.ForcedTerminationException; | ||
import chess.exception.ScoresRequestedException; | ||
import chess.service.ChessService; | ||
import chess.view.InputView; | ||
import chess.view.OutputView; | ||
|
||
import java.util.Map; | ||
|
||
public class ConsoleChessController { | ||
|
||
private final InputView inputView; | ||
private final OutputView outputView; | ||
private final ChessService chessService; | ||
|
||
public ConsoleChessController(final InputView inputView, final OutputView outputView) { | ||
this.inputView = inputView; | ||
this.outputView = outputView; | ||
this.chessService = new ChessService(); | ||
} | ||
|
||
public void run() { | ||
outputView.printGuide(); | ||
|
||
while (chessService.isGameRunning()) { | ||
try { | ||
runOneTurn(); | ||
printBoard(); | ||
} catch (ForcedTerminationException e) { | ||
outputView.printMessage(e.getMessage()); | ||
break; | ||
} | ||
} | ||
|
||
printFinalResult(); | ||
} | ||
|
||
private void runOneTurn() { | ||
try { | ||
TurnDto currentTurn = chessService.getCurrentTurnDto(); | ||
outputView.printTurn(currentTurn); | ||
|
||
Command command = new Command(inputView.getCommand()); | ||
chessService.run(command); | ||
} catch (UnsupportedOperationException | IllegalArgumentException e) { | ||
outputView.printMessage(e.getMessage()); | ||
} catch (ScoresRequestedException e) { | ||
Scores scores = chessService.getScores(); | ||
outputView.printScores(scores); | ||
} | ||
} | ||
|
||
private void printFinalResult() { | ||
printBoard(); | ||
printWinner(); | ||
} | ||
|
||
private void printBoard() { | ||
Map<String, String> boardDto = chessService.getBoardDto(); | ||
outputView.printBoard(boardDto); | ||
} | ||
|
||
private void printWinner() { | ||
try { | ||
String winner = chessService.getWinnerDto(); | ||
outputView.printWinner(winner); | ||
} catch (IllegalStateException e) { | ||
outputView.printMessage(e.getMessage()); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package chess.domain.board; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum File { | ||
|
||
a(1), | ||
b(2), | ||
c(3), | ||
d(4), | ||
e(5), | ||
f(6), | ||
g(7), | ||
h(8); | ||
|
||
private final int index; | ||
|
||
File(final int index) { | ||
this.index = index; | ||
} | ||
|
||
public static File of(final int fileIndex) { | ||
return Arrays.stream(File.values()) | ||
.filter(file -> hasSameIndex(fileIndex, file)) | ||
.findAny() | ||
.orElseThrow(IllegalArgumentException::new); | ||
} | ||
|
||
private static boolean hasSameIndex(final int fileIndex, final File file) { | ||
return file.getIndex() == fileIndex; | ||
} | ||
|
||
public int getIndex() { | ||
return index; | ||
} | ||
|
||
public int calculateGap(final File file) { | ||
return this.index - file.index; | ||
} | ||
|
||
public File add(final int amount) { | ||
return File.of(this.index + amount); | ||
} | ||
|
||
public boolean canMove(final int amount) { | ||
int fileIndex = index + amount; | ||
return fileIndex >= a.index && fileIndex <= h.index; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
각 기물 뒤에 나온 숫자가 점수인 것으로 보이는데,
점수 계산에 대한 것도 기능 목록으로 빼면 어떨까요?
해당 코드만 보고 이해하는 사람에게는 어떤 숫자를 의미하는지 알기가 어려울 것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵! Player 기능목록에 점수 계산도 추가했습니다