Skip to content
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

[1, 2, 3단계 - 체스] 기론(김규철) 미션 제출합니다. #295

Merged
merged 53 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6c8ca60
docs: 1단계 기능 요구 사항 정리
Gyuchool Mar 22, 2022
5fbb082
feat: 체스판을 만들고 체스 말들을 초기화 시킨다.
Gyuchool Mar 22, 2022
325f6ee
feat: start와 end가 아닌 입력이 들어오면 예외가 발생한다.
Gyuchool Mar 22, 2022
110c301
feat: 게임 시작과 종료 기능 구현
Gyuchool Mar 22, 2022
742ff00
feat: 체스판과 말들을 출력한다.
Gyuchool Mar 22, 2022
9f5689e
refactor: rank 순서 변경
Gyuchool Mar 22, 2022
10e5026
docs: 2단계 기능 요구 사항 정리
Gyuchool Mar 23, 2022
23e2261
feat: position끼리 수평에 위치하는지 비교하는 기능 구현
Gyuchool Mar 23, 2022
27341e6
feat: position끼리 수직에 위치하는지 확인하는 기능 구현
Gyuchool Mar 23, 2022
4a094b2
test: 룩의 진행방향이 다르면 예외가 발생하는 테스트 추가
Gyuchool Mar 23, 2022
84c3914
refactor: piece의 추상메서드 수정
Gyuchool Mar 23, 2022
649f8db
feat: position이 대각선에 있는지 비교하는 기능 구현
Gyuchool Mar 23, 2022
78e60ce
feat: 퀸의 진행방향이 옳은지 확인하는 기능 구현
Gyuchool Mar 23, 2022
0447917
feat: 킹의 진행방향과 거리가 옳은지 확인하는 기능 구현
Gyuchool Mar 23, 2022
32e0cf8
feat: 나이트의 진행방향과 거리가 옳은지 확인하는 기능 구현
Gyuchool Mar 23, 2022
62d79c0
feat: 폰의 진행방향과 거리가 옳은지 확인하는 기능 구현
Gyuchool Mar 23, 2022
cc548fe
refactor: piece들이 각각 이름을 갖도록 수정
Gyuchool Mar 24, 2022
0f6128e
feat: 체스판의 빈곳을 표현하는 말 추가
Gyuchool Mar 24, 2022
4baa7d6
refactor: compareTo 메서드에서 depth 2 제거
Gyuchool Mar 24, 2022
95abedd
feat: command 구조 상태패턴으로 변경
Gyuchool Mar 24, 2022
d44b7f2
feat: 룩이 상하좌우로 칸수 제한없이 움직이도록 기능 구현
Gyuchool Mar 25, 2022
e2b867a
feat: 킹이 상하좌우, 대각선 한 칸만 움직일수 있다.
Gyuchool Mar 25, 2022
e9a9253
feat: 비숍은 대각선으로만 칸수 제한없이 움직인다.
Gyuchool Mar 25, 2022
61b3ce2
feat: 나이트의 이동 규칙에 맞게 기능 구현
Gyuchool Mar 25, 2022
754ff24
feat: 퀸이 상하좌우, 대각선 칸수 제한없이 움직인다.
Gyuchool Mar 25, 2022
708d657
feat: 폰의 이동규칙에 맞게 기능 추가
Gyuchool Mar 26, 2022
aadcce9
feat: 폰이 상대 말을 잡을때의 기능 구현
Gyuchool Mar 26, 2022
7bb3409
test: 체스판 범위를 벗어나는지 검증 테스트
Gyuchool Mar 26, 2022
c235483
refactor: OutputView에서 게임 시작 메세지를 출력한다.
Gyuchool Mar 26, 2022
7f92619
docs: 3단계 기능 요구사항 정리
Gyuchool Mar 26, 2022
a267622
feat: 킹이 죽어도 게임이 끝난다.
Gyuchool Mar 26, 2022
0a4fead
feat: 남아있는 말에 대한 점수를 계산한다.
Gyuchool Mar 26, 2022
2cd9b8b
feat: 게임이 끝나고 status를 입력하면 결과를 보여주고 우승 팀을 알려준다.
Gyuchool Mar 26, 2022
daa63dc
feat: 턴을 추가한다.
Gyuchool Mar 28, 2022
58212d7
refactor: 안쓰는 import문 제거 및 코드 포멧팅
Gyuchool Mar 28, 2022
1283e48
refactor: final class로 수정
Gyuchool Mar 28, 2022
5c6e0a8
refactor: killstrategy 제거
Gyuchool Mar 28, 2022
afbbb7a
refactor: stream을 이용하여 변경
Gyuchool Mar 28, 2022
354e7bd
feat: docker-compose 설치
Gyuchool Mar 29, 2022
8e2d464
refactor: error메시지 수정
Gyuchool Mar 29, 2022
5a60cb1
refactor: 예외가 발생할 때 return 을 던짐으로써 validate메서드 분리
Gyuchool Mar 29, 2022
7f111ef
refactor: 불필요한 주석 제거
Gyuchool Mar 29, 2022
40b2a1f
refactor: 인터페이스 이름 범용적이도록 수정
Gyuchool Mar 29, 2022
0e074b5
refactor: 정적 펙터리 메서드 네이밍 수정
Gyuchool Mar 29, 2022
4f377c2
refactor: 빈칸 초기화하는 메서드 네이밍 수정
Gyuchool Mar 29, 2022
c0c53e8
refactor: view에서 도메인 의존성 제거
Gyuchool Mar 29, 2022
3190f12
test: pieces 테스트 추가
Gyuchool Mar 29, 2022
b7b3972
test: command관련 테스트 추가
Gyuchool Mar 30, 2022
ad6e2bb
refactor: 변수 이름 의미 명확하도록 수정
Gyuchool Mar 30, 2022
42df1b1
refactor: 조건문 메서드로 분리
Gyuchool Mar 30, 2022
8235b85
refactor: 게임이 바로 종료되지 않도록 수정
Gyuchool Mar 30, 2022
6c770d0
refactor: 명령어 입력 형식 잘못되어도 다시 입력받도록 수정
Gyuchool Mar 30, 2022
6896212
refactor: position에 캐싱 적용
Gyuchool Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main/java/chess/controller/ChessController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@

public class ChessController {
public void run() {

Choose a reason for hiding this comment

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

코드 리뷰를 하는 동안 해당 클래스의 길이가 줄어들었네요!

메서드 분리 적절하게 잘 하신거 같아요 👍


Command command = startGame();
Board board = Board.create(Pieces.createInit());
Turn turn = Turn.init();
command = playGame(turn, command, board);
command = playGame(command, board);
OutputView.printFinishMessage();
finishGame(command, board);
}
Expand All @@ -38,7 +36,8 @@ private Command startGame() {

}

private Command playGame(Turn turn, Command command, Board board) {
private Command playGame(Command command, Board board) {
Turn turn = Turn.init();
while (isRunning(command, board)) {
turn = nextTurn(command, board, turn);
OutputView.printBoard(convertToPieceDtos(board.getPieces()));
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/chess/piece/position/Position.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package chess.piece.position;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public final class Position {
private static final int ASCII_TO_INT = 96;
private static final int CHESS_POSITION_SIZE = 64;
private static final Map<String, Position> CACHE = new HashMap<>(CHESS_POSITION_SIZE);

private final Rank rank;
private final File file;

Expand All @@ -15,8 +20,11 @@ private Position(File file, Rank rank) {
public static Position of(char... position) {
File file = File.valueOf(position[0] - ASCII_TO_INT);
Rank rank = Rank.valueOf(Character.getNumericValue(position[1]));
return CACHE.computeIfAbsent(createKey(file, rank), absent -> new Position(file, rank));

Choose a reason for hiding this comment

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

요 메서드는 저도 배워가네요! 굳굳

}

return new Position(file, rank);
private static String createKey(File file, Rank rank) {
return file.name() + rank.name();
}

public boolean isHorizontal(Position position) {
Expand Down