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