-
Notifications
You must be signed in to change notification settings - Fork 166
[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๊ธฐ๋ฌผ ํ์ฅ + DB ์ ์ฉ)] ์์ดํ ๋ฏธ์ ์ ์ถํฉ๋๋ค. #335
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
34 commits
Select commit
Hold shift + click to select a range
ff69636
feat: Palace ๋๋ฉ์ธ ๊ฐ์ฒด ์ถ๊ฐ (๊ถ์ฑ ๋ฒ์ ๋ฐ ๋๊ฐ์ ๊ท์น)
e9ua1 c6e261c
feat: General/Guard ๊ถ์ฑ ์ด๋ ๊ท์น ์ ์ฉ
e9ua1 7db48d4
feat: Chariot/Cannon ๊ถ์ฑ ๋๊ฐ์ ์ด๋ ์ ์ฉ
e9ua1 ce3a036
feat: Soldier ๊ถ์ฑ ๋ด ์ ์ง ๋๊ฐ์ ์ด๋ ์ ์ฉ
e9ua1 7e8ae2c
refactor: Palace ๋ค์ด๋ฐ ๊ฐ์ ๋ฐ General/Guard ์ค๋ณต ๋ก์ง ์ ๊ฑฐ
e9ua1 1acb581
feat: Score ๊ฐ ๊ฐ์ฒด ์ถ๊ฐ
e9ua1 eb26f67
feat: Board ์ ์ ๊ณ์ฐ ๊ธฐ๋ฅ ์ถ๊ฐ
e9ua1 f833fa8
feat: ๊ฒ์ ์ข
๋ฃ ์ ์ ์ ์ถ๋ ฅ ๋ฐ ์นํจ ํ์ ๊ธฐ๋ฅ ์ถ๊ฐ
e9ua1 b64d64d
docs: ๊ถ์ฑ ๊ท์น ๋ฐ ์ ์ ๊ณ์ฐ ๊ธฐ๋ฅ ๋ชฉ๋ก ์ถ๊ฐ
e9ua1 51c39fe
feat: DB ์ฐ๊ฒฐ ์ค์ ์ถ๊ฐ
e9ua1 0825773
feat: GameRepository ์ธํฐํ์ด์ค ์ถ๊ฐ
e9ua1 7d3a996
feat: PieceFactory ์ถ๊ฐ (DB โ ๋๋ฉ์ธ ๋ณํ)
e9ua1 cb98270
feat: GameRepositoryImpl ์ถ๊ฐ (JDBC ๊ตฌํ์ฒด)
e9ua1 2ae2c2b
feat: FakeGameRepository ์ถ๊ฐ ๋ฐ ํ
์คํธ ์์ฑ
e9ua1 eead766
feat: JanggiGame์ Repository ์ฃผ์
๋ฐ ๊ฒ์ ์ด์ดํ๊ธฐ ๊ธฐ๋ฅ ์ถ๊ฐ
e9ua1 f65fca7
build: MySQL ์ปค๋ฅํฐ ์์กด์ฑ ์ถ๊ฐ
e9ua1 2b129e5
build: application ํ๋ฌ๊ทธ์ธ ๋ฐ mainClass ์ค์ ์ถ๊ฐ
e9ua1 e5b05ff
docs: ์คํ ๋ฐฉ๋ฒ ์ถ๊ฐ ๋ฐ DB ๋น๋ฐ๋ฒํธ ์ ๊ฑฐ
e9ua1 8a3e097
refactor: JanggiApplication main ๋ฉ์๋ ๋จ์ํ
e9ua1 395cefe
refactor: DBConnector ์์ธ๋ฅผ IllegalStateException์ผ๋ก ๋ณ๊ฒฝ
e9ua1 799a406
refactor: toTeamString() ์ฑ
์์ PieceFactory๋ก ์ด๋ ๋ฐ RuntimeException โ Ilโฆ
e9ua1 09c9b3a
refactor: save/update ํธ๋์ญ์
์ฒ๋ฆฌ ์ถ๊ฐ
e9ua1 e91cdf6
refactor: GameState์ PLAYING ์ด๊ธฐ ์ํ ์ถ๊ฐ๋ก while ๋ฃจํ ์ด๊ธฐ๊ฐ ๋ช
ํํ
e9ua1 2ec7161
refactor: Board ์์ฑ์๋ฅผ private์ผ๋ก ๋ณ๊ฒฝํ๊ณ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋ from() ์ถ๊ฐ
e9ua1 12945d7
refactor: findBoardById()์ ๊ฒ์ ์กด์ฌ ์ฌ๋ถ ์ฌ์ ๊ฒ์ฆ ์ถ๊ฐ
e9ua1 ca17737
refactor: BoardFactory ์ด์ค for๋ฌธ์ ์คํธ๋ฆผ์ผ๋ก ๋ณ๊ฒฝ (depth ๊ท์น ์ค์)
e9ua1 a32a6cb
refactor: movePiece()์์ ์
๋ ฅ ํ์ฑ ๋ก์ง์ parsePositions()๋ก ๋ถ๋ฆฌ
e9ua1 43c9d67
refactor: Board ์
๋ ฅ ๊ฒ์ฆ ์์ ๋ณ๊ฒฝ (๋น์นธ โ ๊ฐ์ ์ขํ โ ํด)
e9ua1 6ef0cf7
refactor: Path โ PiecesOnPath๋ก rename (๊ฒฝ๋ก ์ ๊ธฐ๋ฌผ ์ํ ์๋ ๋ช
ํํ)
e9ua1 2fa1c0e
refactor: ์ ์ ๊ณ์ฐ ๊ฒฐ๊ณผ๋ฅผ ScoreResult๋ก ์์งํ
e9ua1 7d37b7c
fix: ๋ฆฌ๋ฒ ์ด์ค ์ถฉ๋ ํด๊ฒฐ ๋ฐ PiecesOnPath ์ ์ฉ ๋ณต๊ตฌ
e9ua1 02fb6b4
refactor: hasDistancePair โ matchesDistance๋ก ๋ฉ์๋๋ช
๊ฐ์
e9ua1 71c53a6
refactor: Palace ๋ด๋ถ ์์๊ฐ์ Position์ผ๋ก ํํํ๊ณ of(Team) ์ถ๊ฐ
e9ua1 00e6f32
refactor: FakeGameRepository๋ฅผ test ํจํค์ง๋ก ์ด๋
e9ua1 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
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,8 +1,12 @@ | ||
| package janggi; | ||
|
|
||
| import janggi.domain.GameRepository; | ||
| import janggi.infrastructure.GameRepositoryImpl; | ||
|
|
||
| public class JanggiApplication { | ||
|
|
||
| public static void main(String[] args) { | ||
| JanggiGame.initialize().start(); | ||
| GameRepository gameRepository = new GameRepositoryImpl(); | ||
| JanggiGame.from(gameRepository).start(); | ||
| } | ||
| } |
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,11 @@ | ||
| package janggi.domain; | ||
|
|
||
| import janggi.domain.board.Board; | ||
| import java.util.Optional; | ||
|
|
||
| public interface GameRepository { | ||
| long save(Board board, Team currentTeam); | ||
| void update(long gameId, Board board, Team currentTeam); | ||
| Optional<Board> findBoardById(long gameId); | ||
| Team findTurnById(long gameId); | ||
| } |
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,6 +1,7 @@ | ||
| package janggi.domain; | ||
|
|
||
| public enum GameState { | ||
| PLAYING, | ||
| TURN_SUCCESS, | ||
| TURN_FAILED, | ||
| FINISHED, | ||
|
|
||
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,28 @@ | ||
| package janggi.domain; | ||
|
|
||
| public class Score { | ||
|
|
||
| private static final double HAN_BONUS = 1.5; | ||
|
|
||
| private final double value; | ||
|
|
||
| private Score(double value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public static Score of(double value) { | ||
| return new Score(value); | ||
| } | ||
|
|
||
| public Score applyHanBonus() { | ||
| return new Score(value + HAN_BONUS); | ||
| } | ||
|
|
||
| public boolean isHigherThan(Score other) { | ||
| return this.value > other.value; | ||
| } | ||
|
|
||
| public double getValue() { | ||
| return value; | ||
| } | ||
| } |
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,32 @@ | ||
| package janggi.domain; | ||
|
|
||
| public class ScoreResult { | ||
|
|
||
| private final Score hanScore; | ||
| private final Score choScore; | ||
|
|
||
| public ScoreResult(Score hanScore, Score choScore) { | ||
| this.hanScore = hanScore; | ||
| this.choScore = choScore; | ||
| } | ||
|
|
||
| public Score hanScore() { | ||
| return hanScore; | ||
| } | ||
|
|
||
| public Score choScore() { | ||
| return choScore; | ||
| } | ||
|
|
||
| public boolean isHanWin() { | ||
| return hanScore.isHigherThan(choScore); | ||
| } | ||
|
|
||
| public boolean isChoWin() { | ||
| return choScore.isHigherThan(hanScore); | ||
| } | ||
|
|
||
| public boolean isDraw() { | ||
| return !isHanWin() && !isChoWin(); | ||
| } | ||
| } |
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.
JanggiGame์ ์์ดํ๊ฐ ์๊ฐํ์๋ ๋๋ฉ์ธ์ธ๊ฐ์? ์ดํ๋ฆฌ์ผ์ด์ ๊ณ์ธต์ธ๊ฐ์?
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.
JanggiGame์ ์ ํ๋ฆฌ์ผ์ด์ ๊ณ์ธต์ผ๋ก ๋ณด๊ณ ์์ต๋๋ค.
๊ฒ์์ ํ๋ฆ ์ ์ด(play, progressTurn)์ ์ ์ถ๋ ฅ(InputView, OutputView) ์ฌ์ด๋ฅผ ์ฐ๊ฒฐํ๋ ์ญํ ์ ํ๊ณ ์์ด,
์์ํ ๋๋ฉ์ธ ๋ก์ง๋ณด๋ค๋ ์ ์ค์ผ์ด์ค๋ฅผ ์กฐ์จํ๋ ์ฑ ์์ ๊ฐ๊น๋ค๊ณ ํ๋จํ์ต๋๋ค.
๋ค๋ง Board, GameRepository ๊ฐ์ ๋๋ฉ์ธ ๊ฐ์ฒด์ ์ง์ ์์กดํ๊ณ ์์ด ๊ฒฝ๊ณ๊ฐ ๋ช ํํ์ง ์์ ๋ถ๋ถ์ด ์๋๋ฐ,
์ด ๋ถ๋ถ์ ๋ํด ์ด๋ป๊ฒ ๋ถ๋ฆฌํ๋ ๊ฒ์ด ์ข์์ง ์๊ฒฌ์ ๋ฃ๊ณ ์ถ์ต๋๋ค.
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.
์ง๊ธ์ JanggiGame์ InputView, OutputView, GameRepository๊น์ง ํจ๊ป ์๊ณ ์์ด์ ์์ํ ๋๋ฉ์ธ ๊ฐ์ฒด๋ผ๊ณ ๋ณด๊ธฐ๋ ์ด๋ ต์ต๋๋ค. ๊ทธ๋์ ์ง๊ธ ๊ตฌ์กฐ๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ์ฒด๋ผ๊ณ ์ ๋ฆฌํ ์๋ ์๋ค๊ณ ์๊ฐํ๊ณ ํฌ๊ฒ ์ด๊ฒฌ์ ์์ต๋๋ค~
๋ค๋ง ๊ฐ์ธ์ ์ผ๋ก๋ ๊ฒ์ ์์ฒด๋ ๋๋ฉ์ธ์ด๋ผ๊ณ ์๊ฐํด์. ํด์ด ์ด๋ป๊ฒ ์งํ๋๋์ง, ์ธ์ ๊ฒ์์ด ์ข ๋ฃ๋๋์ง, ์ด๋์ด ์ฑ๊ณตํ์ ๋ ์ํ๊ฐ ์ด๋ป๊ฒ ๋ฐ๋๋์ง ๊ฐ์ ํ๋ฆ ์์ฒด๊ฐ ์ฅ๊ธฐ ๊ท์น์ ์ผ๋ถ๋๊น์. ๋จ์ํ ํ๋ฉด๊ณผ ์ ์ฅ์๋ฅผ ์ฐ๊ฒฐํ๋ ์ ์ฐจ๋ผ๊ธฐ๋ณด๋ค ๊ฒ์์ด๋ผ๋ ๋๋ฉ์ธ์ด ์ค์ค๋ก ์ค๋ช ํด์ผ ํ๋ ์ํ ๋ณํ์ ๋ ๊ฐ๊น์ง ์๋์?
์๋ฅผ ๋ค์ด ์ดํ ์น ๋ฒ์ ๊น์ง ํจ๊ป ๊ณ ๋ คํ๋ค๊ณ ํ์ ๋, ์ ๋ ฅ์ ์ด๋ป๊ฒ ๋ฐ๊ณ ๊ฒฐ๊ณผ๋ฅผ ์ด๋ป๊ฒ ๋ณด์ฌ์ค์ง๋ ๋ถ๋ช ์ ํ๋ฆฌ์ผ์ด์ ๊ณ์ธต์ด ๋ฐ๋๋ ๋ฌธ์ ์ธ๋ฐ, ๊ฒ์์ ํ๋ฆ ์์ฒด๋ ๊ทธ๋๋ก ์ ์ง๋์ด์ผ ํ์์์. ๊ทธ๋ฐ๋ฐ ์ง๊ธ ๊ตฌ์กฐ๋ ๊ทธ ํ๋ฆ๊น์ง InputView, OutputView, Repository์ ํ ๊ฐ์ฒด ์์ ๋ฌถ์ฌ ์์ด์, ์ธํฐํ์ด์ค๊ฐ ๋ฐ๋๋ฉด ๊ฒฐ๊ตญ ์๋ก์ด ๊ฒ์ ํ๋ฆ ๊ฐ์ฒด๋ฅผ ๋ค์ ๋ง๋ค๊ฒ ๋ ๊ฐ๋ฅ์ฑ์ด ์ปค ๋ณด์ฌ์. ๊ทธ๋์ ์ ๊ธฐ์ค์์๋ ์ฝ์์ด๋ ์น์ด๋ ์๊ด์์ด ๊ณตํต์ผ๋ก ์ ์ง๋์ด์ผ ํ๋ ํด ์งํ, ์ข ๋ฃ ํ๋จ, ์ํ ๋ณํ ๊ฐ์ ๊ฒ์ ๊ท์น์ ๋๋ฉ์ธ์ ๋จ๊ณ , ์ ์ถ๋ ฅ๊ณผ ์ ์ฅ/๋ณต๊ตฌ orchestration๋ง ๋ฐ๊นฅ ๊ณ์ธต์ด ๋งก์์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.