Skip to content

Commit

Permalink
feat : 게임 시작 참여자들에게 카드 2장씩 지급 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
goodbyeyo committed Dec 16, 2024
1 parent 768e53d commit fa0faeb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ jason카드: 7클로버, K스페이드 - 결과: 17
- [x] 플레이어는 카드를 추가 할 수 있다
- [x] 플레이어의 카드의 포인트를 합산 할 수 있다
- [x] 카드 드로우를 중지하면 더이상 카드를 받을 수 없다
- [x] 쉼표로 구분된 이름 문자열을 전달하면 플레이어를 생성 할 수 있다
- 컨트롤러
- [ ] 게임을 시작하면 게임에 참여할 사람들 입력 요청한다
- [ ] 게임을 시작하면 무작위 전체 카드를 생성한다
- [ ] 게임 참여자들에게 2장씩 카드를 지급한다
- [x] 게임을 시작하면 게임에 참여할 사람들 입력 요청한다
- [x] 게임을 시작하면 무작위 전체 카드를 생성한다
- [x] 게임 참여자들에게 2장씩 카드를 지급한다
- [ ] 모든 참여자가 카드 추가 지급을 거절하면 게임을 종료하고 합산결과 출력 요청한다
- 승리자
- [ ] 카드들의 점수들을 비교하여 21점에 근접한 사람이 승리한다
- InputView
- [ ] 게임에 참여하는 사람을 직접 입력 받는다
- [x] 게임에 참여하는 사람을 직접 입력 받는다
- [ ] 카드를 더 받을지 입력받는다
- OutputView
- [ ] 게임 참여자들에게 처음 지급된 카드 리스트를 출력한다
Expand Down
35 changes: 35 additions & 0 deletions src/test/kotlin/blackjack/BlackJackTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,41 @@ class BlackJackTest {
val players = Players.create("kim,lee,hong")
players.size shouldBe 3
}

@Test
fun `게임을 시작하면 각 플레이어들은 2장씩 카드를 지급 받는다`() {
val players = Players.create("kim,lee,hong")
val gameCards = GameCards.create()
val game = BlackJackGame(players, gameCards)
game.startGame()
players.size shouldBe 3
players.sumOf { player -> player.cardSize() } shouldBe 6
players.forEach {
it.cardSize() shouldBe 2
}
}
}

class BlackJackGame(
private val players: Players,
private val gameCards: GameCards
) {
fun startGame() {
repeat(FIRST_ROUND_HAND_SIZE) {
giveOutCards()
}
}

private fun giveOutCards() {
players.forEach { players ->
players.receiveCard(gameCards.drawCard())
}
}

companion object {
private const val FIRST_ROUND_HAND_SIZE = 2
}

}

object UserInput {
Expand Down

0 comments on commit fa0faeb

Please sign in to comment.