-
Notifications
You must be signed in to change notification settings - Fork 313
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
Step3: 블랙잭(딜러) #553
Open
peter-shlee
wants to merge
20
commits into
next-step:shlee4290
Choose a base branch
from
peter-shlee:step3
base: shlee4290
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.
+659
−191
Open
Step3: 블랙잭(딜러) #553
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
12c86aa
refactor(step2): infix function 활용
peter-shlee 5ce4251
refactor(step2): Players 클래스를 domain으로 옮기고 입출력 관련 코드와 분리
peter-shlee 520ee4a
refactor(step2): Game이 players를 들고있도록 수정
peter-shlee 19cace4
refactor(step2): Game -> Turn으로 이름 변경 및 게임 진행 방식 수정
peter-shlee f60f2ee
refactor(step2): Turn과 InitialTurn 분리
peter-shlee ca87c66
feat(step3): TODO 작성
peter-shlee a519b5d
feat(step3): 게임 시작 시 딜러에게 카드 2장 지급, 1장 오픈 & 게임 진행 시 딜러 카드 합계가 16 이하이면…
peter-shlee 99009b4
feat(step3): 딜러 21 초과하면 플레이어 승리 & 플레이어 별 승패 출력
peter-shlee 99535ec
refactor(step3): 불필요한 메서드 제거
peter-shlee d911e3b
refactor(step3): Player, Dealer가 state 기반으로 동작하도록 변경
peter-shlee 50d4b40
refactor(step3): Turn이 state 기반으로 동작하도록 변경
peter-shlee 8abb360
feat(step3): InitialTurn 카드 나눠주는 순서 변경
peter-shlee ca809df
feat(step3): 카드 나눠주는 순서 블랙잭 룰에 맞춰 수정
peter-shlee 5238474
refactor(step3): player hit 여부 결정 시 콜백 이용하도록 변경
peter-shlee 77cdaf6
refactor(step3): DealerState, PlayerState를 State로 합침
peter-shlee 8d90951
refactor(step3): 승패 결정을 Dealer가 하도록 수정
peter-shlee 73cebac
refactor(step3): Players 위임 메서드 추가
peter-shlee 4e4022e
refactor(step3): Dealer.onHit을 생성자 주입 받을 수 있게 변경
peter-shlee bc6a7e4
refactor(step3): 점수 상수를 모아놓은 클래스 추가
peter-shlee 52788be
refactor(step3): Score에서 점수 계산 수행
peter-shlee 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
refactor(step3): 점수 상수를 모아놓은 클래스 추가
commit bc6a7e4f297b8dfb2e342454dbbd5287c978019b
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package domain | ||
|
||
object Score { | ||
const val BLACKJACK = 21 | ||
const val DEALER_HIT_ON_MAX = 16 | ||
} |
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
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
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,24 +1,24 @@ | ||
package blackjack | ||
|
||
import domain.Score | ||
import domain.State | ||
import domain.card.Cards | ||
import domain.gamer.dealer.Dealer | ||
|
||
fun DealerState(cards: Cards): State { | ||
val result = cards.score() | ||
return when { | ||
result > Cards.BLACKJACK_POINT -> State.Bust | ||
result == Cards.BLACKJACK_POINT -> State.BlackJack | ||
result > Dealer.DEALER_MAX_POINT -> State.Stay | ||
result > Score.BLACKJACK -> State.Bust | ||
result == Score.BLACKJACK -> State.BlackJack | ||
result > Score.DEALER_HIT_ON_MAX -> State.Stay | ||
else -> State.Hit | ||
} | ||
} | ||
|
||
fun PlayerState(cards: Cards): State { | ||
val result = cards.score() | ||
return when { | ||
result == Cards.BLACKJACK_POINT -> State.BlackJack | ||
result < Cards.BLACKJACK_POINT -> State.Hit | ||
result == Score.BLACKJACK -> State.BlackJack | ||
result < Score.BLACKJACK -> State.Hit | ||
else -> State.Bust | ||
} | ||
} |
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.
지금은 Score과 관련된 기능을 수행하는 유틸 클래스가 되어버린 것 같아요.
구현하시는 블랙잭 시스템에 Score라는 타입을 새롭게 정의하는 건 어떨까요?