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

[Step3] 블랙잭(딜러) #541

Open
wants to merge 5 commits into
base: graygreat
Choose a base branch
from

Conversation

kakao-gray-great
Copy link

안녕하세요 :)

리뷰 잘 부탁드립니다!

Copy link

@ddaaac ddaaac left a comment

Choose a reason for hiding this comment

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

안녕하세요 준형님 👋

3단계 구현 잘 해주셨습니다!

몇 가지 코멘트 남겼으니 확인해주세요~

Comment on lines +66 to +72
val dealerResult = game.gamers.gamers.map { gamer ->
GameResult.calculate(game.dealer, gamer).reverse()
}.toMutableList()

val gamerResults = game.gamers.gamers.associate { gamer ->
gamer.name to GameResult.calculate(game.dealer, gamer)
}.toMutableMap()
Copy link

Choose a reason for hiding this comment

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

이 로직들은 Game 또는 Gamers에서 수행할 수 있지 않을까요?

@@ -0,0 +1,14 @@
package blackjack.domain.player

data class Dealer(
Copy link

Choose a reason for hiding this comment

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

딜러는 처음에 한 장의 카드만 공개하는 룰이 있습니다. 이 부분이 반영이 안 된 것 같아요!

Comment on lines +21 to +25
fun calculate(dealer: Dealer, gamer: Gamer): GameResult {
if (hasDealerHigherScoreThanWinningNumber(dealer) || hasGamerHigherScoreThanDealer(dealer, gamer)) {
return WIN
}
return LOSE
Copy link

Choose a reason for hiding this comment

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

블랙잭의 승무패를 계산하는 데는 여러 룰들이 있습니다. 이번 블랙잭 미션 같은 경우에 복잡한 도메인 규칙을 코드로 녹이는 목표도 있는 만큼 룰들을 꼼꼼하게 반영해보시면 좋을 것 같아요 😄

Comment on lines +29 to +32
dealer.getDeckScore() > Denomination.WINNING_NUMBER

private fun hasGamerHigherScoreThanDealer(dealer: Dealer, gamer: Gamer): Boolean {
return gamer.getDeckScore() <= Denomination.WINNING_NUMBER &&
Copy link

Choose a reason for hiding this comment

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

반복적으로 등장하는 코드네요. 앞선 코멘트에서 남긴 블랙잭 룰들을 적용하다보면 블랙잭 도메인 용어로 이 규칙을 표현할 수 있을 것 같네요.

Comment on lines +68 to +72
}.toMutableList()

val gamerResults = game.gamers.gamers.associate { gamer ->
gamer.name to GameResult.calculate(game.dealer, gamer)
}.toMutableMap()
Copy link

Choose a reason for hiding this comment

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

가변 컬렉션을 사용해주신 이유가 있을까요?

Comment on lines +3 to +5
data class Dealer(
override val name: String
) : Player(name) {
Copy link

Choose a reason for hiding this comment

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

딜러의 이름은 항상 고정되어있는데 생성자로 받을 필요가 있을까요?
data class를 쓰기 위해서 생성자 프로퍼티를 두는 건 조금 어색하게 느껴지네요.

Comment on lines +10 to +11
WIN("승"),
LOSE("패");
Copy link

Choose a reason for hiding this comment

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

String으로의 변환은 View에서 해야하지 않을까요? 콘솔이 아닌 뷰를 사용하게 될 경우를 고려해보시면 좋을 것 같아요!

Comment on lines +20 to +21
companion object {
fun calculate(dealer: Dealer, gamer: Gamer): GameResult {
Copy link

Choose a reason for hiding this comment

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

블랙잭 미션을 구현하는 데 중요한 점 중 하나는 블랙잭은 딜러와 게이머의 1:1 대결이라는 점이에요. 이 부분이 함수에 잘 나타나있는 것 같습니다 👍

저는 static하게 구현된 함수들을 보면 도메인으로 옮길 수 있지 않을까?하는 고민을 항상 하는 것 같아요. 룰들이 늘어나면 이 static 함수도 뚱뚱해질텐데요, 도메인 내부로 옮겨보는 것도 고려해볼 수 있을 것 같습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants