-
Notifications
You must be signed in to change notification settings - Fork 461
[3,4 단계 - 체스] 제나(위예나) 미션 제출합니다. #579
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
Merged
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
f491808
refactor : 게임 상태 패키지 이름 변경 (State)
yenawee 4d5a5d7
docs : 2단계 기능 요구사항 정리
yenawee 6736e0c
feat : Command 상태에 Status 추가
yenawee 9811eb5
feat : King 이 잡혔을 때 게임 종료 기능 구현
yenawee 35a81cd
feat : 기물별 점수 정의
yenawee e00d95e
feat : 점수 계산 기능 구현
yenawee a808317
feat : status 입력 시 점수 및 어느 진영이 이겼는지 출력 기능 구현
yenawee 0dd3b82
feat : Camp -> TeamColor 로 안바뀐 메소드명 및 매개변수 이름 수정
yenawee 0c9985a
docs : 4단계 요구사항 정리
yenawee e490901
refactor : package 이름 변경
yenawee 6e2c09a
feat : 불필요한 ChessBoardFactory 캐싱 제거. ChessGame 을 키로 하여 ChessBoard 를 캐싱
yenawee 6a351ee
feat : king 이 잡혀서 종료되었을 시에만 status 에 우승자 출력. 아닐 시에는 점수만 출력
yenawee e80a84b
docs : CRUD 쿼리문 작성
yenawee 7244de8
feat : DB 연결
yenawee 978d9aa
feat : PieceType, TeamColor 를 바탕으로 Piece 생성 기능 구현 추가
yenawee 63f6dbd
feat : ChessGameDao 인터페이스 생성, DB 연결 전 InMemomryChessGameDao 사용
yenawee 64d46dc
feat : ChessGameLoader 생성
yenawee 8f87503
feat : ChessBoard, ChessGame 생성자 추가
yenawee dc89d3f
test : ChessGame 생성자 수정에 따른 테스트 수정
yenawee 79ca4a3
feat : ChessBoardDao 구현 (DB connection)
yenawee f0cc766
feat : Move 생성 시 현재 팀은 chessGame 에서 받아온 팀으로 받아오게끔 수정
yenawee 494b1e2
feat : CREATE TABLE chess_game 정보 추가
yenawee f118208
docs : 기능 구현 사항 업데이트
yenawee 4500fb4
fix : 다음 체스 게임이 시작될 때는 현재 저장되어 있는 turn 과 다른 팀으로 시작되어야 한다
yenawee 798aed2
fix : Select 쿼리 실행 시 Pawn 은 BlackPawn, WhitePawn 으로 나눠서 생성해야 한다
yenawee 8be2aa3
feat : king 이 잡혀서 게임 종료 시엔 DB 초기화
yenawee e8152d3
feat : chess_game table 의 piece_rank, piece_file 자료형을 TINYINT로 변경
yenawee 66552cd
refactor : source 와 target 의 위치가 상향 대각선인지 하향대각선인지 판단하는 로직을 Direction …
yenawee 853381b
style : 자바 컨벤션
yenawee 71f80eb
docs : 3단계 기능 요구사항 정리
yenawee 5b7c3de
feat : Command 상태에 Status 추가
yenawee ebc319e
feat : King 이 잡혔을 때 게임 종료 기능 구현
yenawee 17a3ef4
feat : 기물별 점수 정의
yenawee 6b8d545
feat : 점수 계산 기능 구현
yenawee ad007cd
feat : status 입력 시 점수 및 어느 진영이 이겼는지 출력 기능 구현
yenawee d65f72f
feat : Camp -> TeamColor 로 안바뀐 메소드명 및 매개변수 이름 수정
yenawee b90ad88
docs : 4단계 요구사항 정리
yenawee f3bde69
refactor : package 이름 변경
yenawee 66a295f
feat : 불필요한 ChessBoardFactory 캐싱 제거. ChessGame 을 키로 하여 ChessBoard 를 캐싱
yenawee a72d05d
feat : king 이 잡혀서 종료되었을 시에만 status 에 우승자 출력. 아닐 시에는 점수만 출력
yenawee c883c3a
docs : CRUD 쿼리문 작성
yenawee 2045f4e
feat : DB 연결
yenawee 6da294d
feat : PieceType, TeamColor 를 바탕으로 Piece 생성 기능 구현 추가
yenawee b496182
feat : ChessGameDao 인터페이스 생성, DB 연결 전 InMemomryChessGameDao 사용
yenawee d13c399
feat : ChessGameLoader 생성
yenawee 9e1be36
feat : ChessBoard, ChessGame 생성자 추가
yenawee e76dc72
test : ChessGame 생성자 수정에 따른 테스트 수정
yenawee 629c160
feat : ChessBoardDao 구현 (DB connection)
yenawee 4ca82a3
feat : Move 생성 시 현재 팀은 chessGame 에서 받아온 팀으로 받아오게끔 수정
yenawee a038e53
feat : CREATE TABLE chess_game 정보 추가
yenawee 8b1db28
docs : 기능 구현 사항 업데이트
yenawee 3c937a6
fix : 다음 체스 게임이 시작될 때는 현재 저장되어 있는 turn 과 다른 팀으로 시작되어야 한다
yenawee 157e5a5
fix : Select 쿼리 실행 시 Pawn 은 BlackPawn, WhitePawn 으로 나눠서 생성해야 한다
yenawee 2a2998b
feat : king 이 잡혀서 게임 종료 시엔 DB 초기화
yenawee 3b4087a
feat : chess_game table 의 piece_rank, piece_file 자료형을 TINYINT로 변경
yenawee d8e9d97
refactor : source 와 target 의 위치가 상향 대각선인지 하향대각선인지 판단하는 로직을 Direction …
yenawee d763820
style : 자바 컨벤션
yenawee 9687d63
Merge remote-tracking branch 'origin/step2' into step2
yenawee 74200e4
feat : docker 실행 시 chessgame 테이블 생성되도록 설정
yenawee 692af06
docs : chess_game table 자료형 업데이트
yenawee 8b3b61a
.gitignore 에 docker file 추가
yenawee 1cbffc1
docs : 3, 4 단계 수정 사항 기능목록 정리
yenawee 5e8bd2d
.gitignore 수정
yenawee b9b29bc
docs : readme 에 도커 환경 설정 방법 추가
yenawee 605c525
feat : DB 연결 실패했을 때 커스텀 예외 던지게 수정
yenawee 1d23898
style : 불필요한 주석 삭제
yenawee 19db20e
feat : Direction 에게 상향,하향 대각선인지 물어보는 것으로 수정
yenawee 0b59baa
feat : 매직 넘버 상수화 및 메소드 이름 구체화
yenawee 0309457
feat : 하나의 요청에 대해 하나의 Connection 으로 처리하도록 수정
yenawee f1c6205
refactor : chessGamecontroller play 메소드 분리
yenawee 456dfff
feat : init.sql 추가
yenawee 00f9208
docs : readme 추가
yenawee 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 |
|---|---|---|
|
|
@@ -30,3 +30,6 @@ out/ | |
|
|
||
| ### VS Code ### | ||
| .vscode/ | ||
|
|
||
| ### docker ### | ||
| ./src/main/java/chess/docker/db.mysql | ||
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 |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| package chess; | ||
|
|
||
| import chess.controller.ChessController; | ||
| import chess.dao.ChessBoardDao; | ||
|
|
||
| public class ChessApplication { | ||
| public static void main(String[] args) { | ||
| final ChessController chessController = new ChessController(); | ||
| final ChessController chessController = new ChessController(new ChessBoardDao()); | ||
| chessController.run(); | ||
| } | ||
| } |
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
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,22 @@ | ||
| package chess.controller; | ||
|
|
||
| import chess.domain.piece.TeamColor; | ||
| import chess.domain.result.Score; | ||
|
|
||
| public class ScoreDto { | ||
| private final Double whiteScore; | ||
| private final Double blackScore; | ||
|
|
||
| public ScoreDto(Score score) { | ||
| whiteScore = score.getScore(TeamColor.WHITE); | ||
| blackScore = score.getScore(TeamColor.BLACK); | ||
| } | ||
|
|
||
| public Double getWhiteScore() { | ||
| return whiteScore; | ||
| } | ||
|
|
||
| public Double getBlackScore() { | ||
| return blackScore; | ||
| } | ||
| } |
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,5 @@ | ||
| package chess.controller.state; | ||
|
|
||
| public enum CommandType { | ||
| START, MOVE, END, STATUS | ||
| } |
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,30 @@ | ||
| package chess.controller.state; | ||
|
|
||
| import chess.controller.Command; | ||
| import chess.controller.ScoreDto; | ||
| import chess.domain.game.ChessGame; | ||
| import chess.domain.piece.TeamColor; | ||
| import chess.domain.result.Score; | ||
| import chess.view.OutputView; | ||
|
|
||
| public final class End implements State { | ||
| @Override | ||
| public State checkCommand(final Command command) { | ||
| throw new IllegalArgumentException("게임이 끝났습니다."); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRun() { | ||
| return false; | ||
| } | ||
|
|
||
| public State run(ChessGame chessGame) { | ||
| Score score = Score.calculate(chessGame.getChessBoard()); | ||
| OutputView.printStatus(new ScoreDto(score)); | ||
| if (chessGame.isEnd()) { | ||
| TeamColor winner = chessGame.getCurrentTeamColor(); | ||
| OutputView.print(winner.name()); | ||
| } | ||
| return new End(); | ||
| } | ||
| } |
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,29 @@ | ||
| package chess.controller.state; | ||
|
|
||
| import chess.controller.Command; | ||
| import chess.domain.game.ChessGame; | ||
|
|
||
| public final class Start implements State { | ||
|
|
||
| private final ChessGame chessGame; | ||
|
|
||
| public Start(final ChessGame chessGame) { | ||
| this.chessGame = chessGame; | ||
| } | ||
|
|
||
| @Override | ||
| public State checkCommand(final Command command) { | ||
| if (command.isStart()) { | ||
| return new Move(chessGame, chessGame.getCurrentTeamColor()); | ||
| } | ||
| if (command.isEnd()) { | ||
| return new End(); | ||
| } | ||
| throw new IllegalArgumentException("게임이 시작되지 않았습니다."); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRun() { | ||
| return true; | ||
| } | ||
| } |
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,9 @@ | ||
| package chess.controller.state; | ||
|
|
||
| import chess.controller.Command; | ||
|
|
||
| public interface State { | ||
| State checkCommand(final Command command); | ||
|
|
||
| boolean isRun(); | ||
| } |
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,44 @@ | ||
| package chess.controller.state; | ||
|
|
||
| import chess.controller.Command; | ||
| import chess.controller.ScoreDto; | ||
| import chess.domain.game.ChessGame; | ||
| import chess.domain.piece.TeamColor; | ||
| import chess.domain.result.Score; | ||
| import chess.view.OutputView; | ||
|
|
||
| public class Status implements State { | ||
| private final ChessGame chessGame; | ||
| private final TeamColor teamColor; | ||
|
|
||
| public Status(ChessGame chessGame, TeamColor teamColor) { | ||
| this.chessGame = chessGame; | ||
| this.teamColor = teamColor; | ||
| } | ||
|
|
||
| State run() { | ||
| Score score = Score.calculate(chessGame.getChessBoard()); | ||
| OutputView.printStatus(new ScoreDto(score)); | ||
| return new Status(chessGame, teamColor); | ||
| } | ||
|
|
||
| @Override | ||
| public State checkCommand(Command command) { | ||
| if (command.isEnd()) { | ||
| return new End().run(chessGame); | ||
| } | ||
| if (command.isMove()) { | ||
| Move move = new Move(chessGame, teamColor); | ||
| return move.checkCommand(command); | ||
| } | ||
| if (command.isStatus()) { | ||
| return run(); | ||
| } | ||
| throw new UnsupportedOperationException("end, move 명령어만 입력 가능합니다."); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRun() { | ||
| return true; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
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.
좋은 고민이네요! 지금 구조에서는 Move에서 분기문을 처리하지 않고, Status에서 처리해도 될 것 같아요.
그리고 State에 available(Command)와 같은 메서드를 만들어 각 구현체의 조건을 넣어주면 위 분기문도 없앨 수 있을 것 같은데요, 혹시 이해가 안가시거나 제가 질문을 잘못 이해한거라면 DM 주세요 😃
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.
지금 체스 게임 플레이가 Move 상태의 move 메소드에서 chessgame.setup() 으로 시작해서 Status 에서 처리하기는 힘들거같아보입니다..!! (Status 에서 처리가 된다면 status 를 입력해야만 체스게임이 종료되었는지를 확인하게 됨)
말씀해주신대로 available(Command) 의 메소드를 만들어서 분기문을 없애는 방식이 최선일 거 같은데 혹시 어떻게 조건을 넣어줘야 할지 힌트를 좀만 더 주실수있을까요 ?? 😿
Uh oh!
There was an error while loading. Please reload this page.
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.
앗 그렇군요. 제가 구조를 잘못 이해한 것 같네요 😭😭 그렇다면 현재 �로직도 괜찮을 것 같아요!