-
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
π 3λ¨κ³ - λΈλμ(λλ¬) #653
Open
moto6
wants to merge
81
commits into
next-step:moto6
Choose a base branch
from
moto6:step3
base: moto6
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.
Open
Changes from 25 commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
4530961
refactor : μΈλΆμμ λΈλμ μΉ΄λλ₯Ό λ½λ μ λ΅μ μ£Όμ
λ°λλ‘ λ¦¬ν©ν λ§
768e5e8
learn : λ―Έμμ± νμ΅μ½λλ₯Ό μμ±μν΄ : λ°©μ΄μ λ³΅μ¬ κ΄λ ¨ μμ μ½λ
f595abb
learn : λ―Έμμ± νμ΅μ½λλ₯Ό μμ±μν΄ : λ°©μ΄μ λ³΅μ¬ κ΄λ ¨ μμ μ½λ μμ±
2c3439f
learn : λ―Έμμ± νμ΅μ½λλ₯Ό μμ±μν΄ : λ°©μ΄μ λ³΅μ¬ κ΄λ ¨ μμ μ½λ μμ±
ec334d4
refactor : Pair<> μλ£κ΅¬μ‘°λ₯Ό νλμ ν΄λμ€λ‘ λ¬Άμ
2196d5b
refactor : κ³Όλνκ² κΈΈκ³ λ€μ λΆμ‘±ν ννμ λ³μλͺ
μ μ μ νκ² μμ
193b74b
docs : μꡬμ¬ν λΆμ
2e6ed51
test : λλ¬ ν΄λμ€λ₯Ό μΆκ°νκ³ , λλ¬ν΄λμ€μμ μ±
μμ μΌν μν μ λν΄ ν
μ€νΈμ½λ μμ±
dc3c6f6
feat : μ°Έκ°μ λͺ
λ¨μ λλ¬ μΆκ°
01dd4ca
refactor : νλ μ΄μ΄λ‘ λ³μλͺ
μμ
c294555
refactor : λλ¬ ν΄λμ€ μΆκ°
2f9e2f2
refactor : λλ¬μ μν μ λν ν
μ€νΈμ½λ μμ±
cf0f5f2
refactor : λλ¬μ μν μ λν ν
μ€νΈμ½λ μμ±
c651d71
feat : λλ¬ ν΄λμ€μ κΈ°λ₯ ꡬν
1f8d48f
feat : λλ¬ κΈ°λ₯ ꡬνμ μν ν΄λμ€ μμ±
2008753
feat : λλ¬ κΈ°λ₯ ꡬν
0cf2ee0
feat : λλ¬ κΈ°λ₯ ꡬν
d5d036d
test : ν΄λμ€ μ΄μ μΌλ‘ μΈν μ±
μμμ¬ λ³κ²½μΌλ‘ ν
μ€νΈλ₯Ό μ΄λμν¨λ€
e1a92a3
feat : λλ¬ μΆλ ₯ κΈ°λ₯ ꡬν
fd08d2e
feat : λλ¬ μΆλ ₯ κΈ°λ₯ ꡬν
72c2a9f
feat : λλ¬μ νλ μ΄μ΄κ° κ³΅ν΅ λμμ μΈν°νμ΄μ€λ‘ λ¬Άμ
405c44e
feat : λλ¬μ νλ μ΄μ΄κ° κ³΅ν΅ λμμ μΈν°νμ΄μ€λ‘ λ¬Άμ
3fc2d98
feat : λλ¬μ νλ μ΄μ΄κ° κ³΅ν΅ λμμΈ κ²μ νλ μ΄λ₯Ό μΈν
νμ΄μ€λ‘ μΆμνν¨
118b83b
feat : λλ¬μ νλ μ΄μ΄μ λΈλμ νλμ΄μ μ λ΅μ μΈν°νμ΄μ€ν νλ€
bc99f47
feat : κΉ¨μ§ ν
μ€νΈμ½λ μ κ±°
0e3a932
refactor : ν¨ν€μ§ ꡬ쑰ν
73c8890
refactor : λΆνμν μ£Όμ μ κ±°
cea03de
refactor : ν¨ν€μ§ μ΄λ
030b03f
refactor : μμΉ λ³κ²½
f3ce24d
refactor : ν½μ€μ³λ₯Όμ΄μ©ν΄μ λ°λ³΅λλ λ°μ΄ν° μμ± μ€λ³΅ μ½λλ₯Ό μ κ±°
b90b454
refactor : κ²μ¦ λ¨μΈλ¬Έμ μΆκ°ν¨
8426423
refactor : λΈλμ κ²μμΌλ‘ ν΄λμ€λ₯Ό λΆλ¦¬ν¨
a83a725
refactor : λ©μλλͺ
μμ
a33565d
refactor : λλ¬μ κ²°κ³Όμ 보λ₯Ό λ§λ€κΈ° μν΄μ μ¬νμ΄ μ νλκ²μ΄ μλ, λλ¬ κ°μ²΄ λ΄λΆμμ λλ¬μ κ²°κ³Όλ₯Ό λ§λ€λλ‘ μμ
5267bff
refactor : κ²°κ³Όμ 보λ₯Ό μΆλ ₯νκΈ° μν΄ λ€λ₯Έ νλ μ΄μ΄λΈμ μ
λ ₯λ°λλ‘ μμ
fb97643
refactor : κ³Όλνκ² λ³΅μ‘ν result κ°μ²΄λ€μ μ κ±°νλ€
7abf5ad
refactor : λΈλμμ μ μλ₯Ό λνλ΄λ λλ§€μΈ ν¬μ₯ν΄λμ€λ₯Ό μΆκ°νλ€
3ee585d
refactor : BlackJack() λλ§€μΈ ν¬μ₯ν΄λμ€λ₯Ό μ μ©νλ€
7c15dae
refactor : BlackJack() λλ§€μΈ ν¬μ₯ν΄λμ€λ₯Ό μ μ©ν΄μ νλ μ΄μ΄λΈ μΈν°νμ΄μ€μμ λ©μμ§λ‘ μ¬μ©νκ² μμ νμμ΅λλ€
73e3a94
refactor : λΈλμμ κ²°κ³Όλ₯Ό λνλ΄λ λ°©λ²μ κ°μ ν΄μ μ
λ ₯ arg λ‘ λ°λ ν΄λμ€λ₯Ό λ³κ²½νμμ΅λλ€
0f0ea7d
refactor : burst μ¬λΆλ₯Ό μΈλΆμ κ°μ²΄(Referee) κ° κ°μ κΊΌλ΄μ νλ¨ν΄μ£Όλ κΈ°μ‘΄ λ°©μμ μμ νμμ΅λλ€.
8481f0e
refactor : 리ν©ν λ§μ νλ€ λ³΄λ μ¬ν μν μ νλ Referee λ₯Ό μ κ±°ν μ μκ² λμμ΅λλ€
9df4b97
refactor : λμ΄λ player, Dealer ν΄λμ€μ μ±
μκ³Ό μν μ κ²μ¦νκΈ° μν΄ λ¨μν
μ€νΈλ μΆκ°λμμ΅λλ€
bc61788
refactor : λλ¬μ κ²°κ³Όλ₯Ό λλ¬ ν΄λμ€ λ΄λΆμμ κ²°μ νλλ‘ μμ
a0f1238
refactor : λͺ¨λ νλ μ΄μ΄λ νλ½ν λκΉμ§ μΉ΄λλ₯Ό λ°μ μ μλ€ κΈ°λ₯μ ꡬν
57bc00c
refactor : μΈν
리μ μ΄ μλμ΄ λ¨μ§μλλ‘ κ²½κ³ λ₯Ό μμ
f96536d
refactor : λΈλμ κ²μμ λ£°μΈ, νλ μ΄μ΄μ€ μ΅νν¬ νλͺ
μ΄ λ¨μλκΉμ§ μΉ΄λλ₯Ό λ°μ μ μλ€
caf5ab4
refactor : λΈλμ κ²μμμ μΉ΄λλ₯Όλ½λ μ μ±
μ μΈλΆμμ μ£Όμ
λ°λλ‘ μμ
d15d30e
refactor : λΆνμν λ©μλ μ κ±°
149d549
refactor : λΈλμμ μνλ₯Ό λνλ΄λ λ³μ μΆκ°
fd79141
refactor : λΈλμ κ²μμμ νλ μ΄μ΄μ μνλ₯Ό νμΈν μ μλ λ³μ μΆκ°
92ec4b5
refactor : λλ¬μ νλ μ΄μ΄κ° μμ‘΄μ¬λΆμ λν΄μ μνλ₯Ό μ μ₯νμ§ μκ³ λ§€λ² κ³μ°νλλ‘ μμ
0bde0c3
style : style formatting
b58ab33
test : λ³νλ μ±
μκ³Ό μν μ λ°λΌ ν
μ€νΈμ½λ μ΄λ λ° μΆκ°
57d5ed8
test : νλ μ΄μ΄κ° μ΄κΈ°λ κ²½μ°μ λν ν
μ€νΈμ½λ μΆκ°
ec56d38
test : λλ¬ ν΄λμ€μ λν ν
μ€νΈ μ½λ μΆκ°
de4eb89
style : μ€νμΌ ν¬λ©ν
f7d07c5
refactor : μ μ±
μμ μ
λ ₯μ λ°λλ‘ μμ
a2a5e6e
refactor : ν¨ν€μ§ μ΄λ
1292c65
refactor : νλ μ΄μ΄ μ΄λ¦μ μΆλ ₯νλλ‘ μμ
3e17672
refactor : μΆλ ₯ λ‘μ§ μ κ²
9a47953
refactor : μΆλ ₯ λ‘μ§ μ κ²
515e2a9
refactor : λΆνμν μ½λ μ κ±°
cbf46fc
feat : κ²μ¦μ© νμ€, λλ²κΉ
ν¬μΈνΈ
953086a
refactor : ν¨ν€μ§ μ΄λ
9bd27f7
refactor : ν¨ν€μ§ μ΄λ
f3773b7
test : μλ¬κ° λλ λΆλΆμ ν
μ€νΈμ½λ μΆκ°
a81cff6
refactor : κ°λ
μ±μ λ리기 μν΄ νλ¦¬λ―Έν° λ€μ΄λ°
f0a699c
refactor : ν¨ν€μ§ ꡬ쑰 μ 리
d7d3af1
refactor : ν¨ν€μ§ ꡬ쑰 μ 리
1d1e228
refactor : λΈλμμ κ²½κΈ° κ²°κ³Όλ₯Ό μ ν΄μ£Όλ ν΄λμ€ λΆλ¦¬
043ffcc
test : λΈλμμ λ£°μ λͺ°λΌ μμμ μΌλ‘ μ νλ ν
μ€νΈμ½λλ€μ μμ
930745b
test : λΈλμμ κ²½κΈ° κ²°κ³Όλ₯Ό κ²°μ νλ ν
μ€νΈμ½λλ₯Ό μμ±νλ€
366b2b2
test : stand λ₯Ό μΈμΉλ©΄ μλμΌλ‘ λμ΄μ μΉ΄λλ₯Ό λ°μ μ μλ μνκ° λμ΄μΌνλ€
be3bc4d
bugfix : λ²κ·Έκ° λλ λΆλΆμ μμ
b20b5c5
refactor : μλͺ» μμ±λ ν
μ€νΈμ½λ μμ
4f07cb3
refactor : μΆλ ₯νμ μμ
e4a59a0
bugfix : λλ¬μ μΉν¨ μΆλ ₯ λ²κ·Έλ₯Ό μμ
9632f36
test : ν
μ€νΈμ½λ μΆκ°
53faf16
refactor : μμ±μ νλΌλ―Έν° μΆκ°
4769e26
bugfix: λ²κ·Έμμ
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 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,30 +1,40 @@ | ||
package blackjack | ||
|
||
import blackjack.model.DealerStrategy | ||
import blackjack.model.Participants | ||
import blackjack.model.PlayableReaction | ||
import blackjack.model.Player | ||
import blackjack.model.Referee | ||
import blackjack.model.pack.ShuffledPack | ||
import blackjack.view.InputView | ||
import blackjack.view.OutputView | ||
|
||
fun main() { | ||
val participants = InputView.join() | ||
participants.dealing() | ||
participants.dealing(ShuffledPack) | ||
OutputView.dealing(participants) | ||
OutputView.presentCards(participants) | ||
while (participants.isContinue()) { | ||
playingBlackJack(participants) | ||
} | ||
OutputView.result(participants) | ||
OutputView.presentScores(participants) | ||
OutputView.presentResult(Referee.blackJackResult(participants)) | ||
} | ||
|
||
fun playingBlackJack(participants: Participants) { | ||
participants.participants.forEach { | ||
it.hitOrStand() | ||
participants.players.values.forEach { | ||
it.playing(InputView.askHit(it), ShuffledPack) | ||
} | ||
when (participants.dealer.playing(DealerStrategy(participants.dealer.score()), ShuffledPack)) { | ||
PlayableReaction.HIT -> println("λλ¬λ 16μ΄νλΌ νμ₯μ μΉ΄λλ₯Ό λ λ°μμ΅λλ€.") | ||
PlayableReaction.STAND -> println("λλ¬λ 17μ΄μμ΄λΌ μΉ΄λλ₯Ό λ°μ§ μμμ΅λλ€.") | ||
} | ||
} | ||
|
||
private fun Player.hitOrStand() { | ||
if (InputView.askHit(this)) { | ||
this.hit() | ||
} | ||
OutputView.playerCardPresent(this) | ||
|
||
// if () { | ||
// this.hit(ShuffledPack) | ||
// } | ||
// OutputView.playerCardPresent(this) | ||
} | ||
moto6 marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
---|---|---|
|
@@ -28,10 +28,10 @@ class Cards( | |
|
||
private fun scoreWithAce(): Int { | ||
val simpleSum = simpleSumOfScore() | ||
if (simpleSum + ALTERNATIVE_ACE_SCORE_DIFF > HIGHEST_SCORE) { | ||
if (simpleSum + ACE_BONUS_SCORE > HIGHEST_SCORE) { | ||
return simpleSum | ||
} | ||
return simpleSum + ALTERNATIVE_ACE_SCORE_DIFF | ||
return simpleSum + ACE_BONUS_SCORE | ||
} | ||
|
||
fun count(): Int { | ||
|
@@ -40,7 +40,7 @@ class Cards( | |
|
||
companion object { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cards κ°μ²΄λ₯Ό λΆλ³ κ°μ²΄λ‘ λ§λ€μ΄λ³΄λ μλλ₯Ό ν΄λ³΄μ λ μ’κ² λ€μ π |
||
private const val HIGHEST_SCORE: Int = 21 | ||
private const val ALTERNATIVE_ACE_SCORE_DIFF: Int = 11 - 1 | ||
private const val ACE_BONUS_SCORE: Int = 10 | ||
|
||
fun emptyCards(): Cards { | ||
return Cards(mutableListOf()) | ||
|
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,33 @@ | ||
package blackjack.model | ||
|
||
import blackjack.model.pack.Pack | ||
|
||
class Dealer( | ||
val cards: Cards = Cards(), | ||
) : Playable { | ||
|
||
override fun score(): Int { | ||
return cards.totalScore() | ||
} | ||
|
||
override fun dealing(pack: Pack) { | ||
this.cards.add(pack.pickCard()) | ||
this.cards.add(pack.pickCard()) | ||
} | ||
|
||
fun countOfCards(): Int { | ||
return cards.count() | ||
} | ||
|
||
override fun playing(playingStrategy: PlayingStrategy, pack: Pack): PlayableReaction { | ||
if (playingStrategy.isHit()) { | ||
cards.add(pack.pickCard()) | ||
return PlayableReaction.HIT | ||
} | ||
return PlayableReaction.STAND | ||
} | ||
|
||
companion object { | ||
private const val DEALER_PICK_THRESHOLD = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package blackjack.model | ||
|
||
data class DealerResult( | ||
val point: Int, | ||
val winning: Int, | ||
val drawing: Int, | ||
val losing: Int, | ||
) |
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,14 @@ | ||
package blackjack.model | ||
|
||
class DealerStrategy( | ||
private val currentScore: Int, | ||
) : PlayingStrategy { | ||
|
||
override fun isHit(): Boolean { | ||
return currentScore <= DEALER_PICK_THRESHOLD | ||
} | ||
|
||
companion object { | ||
private const val DEALER_PICK_THRESHOLD = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package blackjack.model | ||
|
||
class ParticipantResults( | ||
val playerResults: PlayersResults, | ||
val dealerDealerResult: Pair<Dealer, DealerResult>, | ||
) { | ||
fun dealerResult(): DealerResult { | ||
return dealerDealerResult.second | ||
} | ||
|
||
fun playerResult(player: Player): PlayerResult { | ||
return playerResults.resultOfPlayer(player) | ||
} | ||
|
||
fun dealerWinCount(): Int { | ||
return this.dealerDealerResult.second.winning | ||
} | ||
|
||
fun dealerLoseCount(): Int { | ||
return this.dealerDealerResult.second.losing | ||
} | ||
|
||
companion object { | ||
fun ofDealerLose(participants: Participants): ParticipantResults { | ||
return ParticipantResults( | ||
PlayersResults(participants.players.walkover()), | ||
participants.dealer to DealerResult(participants.dealer.score(), 0, 0, participants.count() - 1) | ||
) | ||
} | ||
} | ||
} |
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,21 +1,26 @@ | ||
package blackjack.model | ||
|
||
import blackjack.model.pack.Pack | ||
|
||
class Participants( | ||
val participants: Set<Player>, | ||
val players: Players, | ||
val dealer: Dealer, | ||
) { | ||
fun count(): Int { | ||
return participants.size | ||
} | ||
|
||
fun dealing() { | ||
participants.forEach { it.deal() } | ||
fun dealing(pack: Pack) { | ||
players.dealing(pack) | ||
dealer.dealing(pack) | ||
} | ||
|
||
private fun isGameOver(): Boolean { | ||
return participants.none { Referee.isBlackJack(it) } | ||
return players.isGameOver() || Referee.isGameOver(dealer) | ||
} | ||
|
||
fun isContinue(): Boolean { | ||
return !isGameOver() | ||
} | ||
|
||
fun count(): Int { | ||
return players.count() + 1 | ||
} | ||
} |
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,9 @@ | ||
package blackjack.model | ||
|
||
import blackjack.model.pack.Pack | ||
|
||
interface Playable { | ||
fun score(): Int | ||
fun dealing(pack: Pack) | ||
fun playing(playingStrategy: PlayingStrategy, pack: Pack): PlayableReaction | ||
} |
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 blackjack.model | ||
|
||
enum class PlayableReaction { | ||
HIT, | ||
STAND | ||
} |
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,17 +1,29 @@ | ||
package blackjack.model | ||
|
||
import blackjack.model.pack.ShuffledPack | ||
import blackjack.model.pack.Pack | ||
|
||
data class Player( | ||
class Player( | ||
val name: String, | ||
val cards: Cards = Cards.emptyCards(), | ||
) { | ||
fun deal() { | ||
cards.add(ShuffledPack.pickCard()) | ||
cards.add(ShuffledPack.pickCard()) | ||
) : Playable { | ||
override fun dealing(pack: Pack) { | ||
cards.add(pack.pickCard()) | ||
cards.add(pack.pickCard()) | ||
} | ||
|
||
fun hit() { | ||
cards.add(ShuffledPack.pickCard()) | ||
override fun playing(playingStrategy: PlayingStrategy, pack: Pack): PlayableReaction { | ||
if (playingStrategy.isHit()) { | ||
this.hit(pack) | ||
return PlayableReaction.HIT | ||
} | ||
return PlayableReaction.STAND | ||
} | ||
|
||
fun hit(pack: Pack) { | ||
cards.add(pack.pickCard()) | ||
} | ||
|
||
override fun score(): Int { | ||
return this.cards.totalScore() | ||
} | ||
} |
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,7 @@ | ||
package blackjack.model | ||
|
||
enum class PlayerResult { | ||
WIN, | ||
LOSE, | ||
DRAW, | ||
} |
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,33 @@ | ||
package blackjack.model | ||
|
||
import blackjack.model.pack.Pack | ||
|
||
class Players( | ||
val values: Set<Player>, | ||
) { | ||
constructor(vararg players: Player) : this(players.toSet()) | ||
|
||
fun dealing(pack: Pack) { | ||
values.forEach { it.dealing(pack) } | ||
} | ||
|
||
fun isGameOver(): Boolean { | ||
return values.any { Referee.isGameOver(it) } | ||
} | ||
|
||
fun count(): Int { | ||
return values.size | ||
} | ||
|
||
fun scoreBattle(dealerScore: Int): Map<Player, PlayerResult> { | ||
return values.associateWith { Referee.playerResult(it, dealerScore) } | ||
} | ||
|
||
fun walkover(): Map<Player, PlayerResult> { | ||
return values.associateWith { PlayerResult.WIN } | ||
} | ||
|
||
init { | ||
require(values.map { it.name }.distinct().size == values.size) { "Player λ€μ μ΄λ¦μ μ€λ³΅μ΄ νμ©λμ§ μμ΅λλ€" } | ||
} | ||
moto6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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,29 @@ | ||
package blackjack.model | ||
|
||
class PlayersResults( | ||
private val value: Map<Player, PlayerResult>, | ||
) { | ||
fun loseCount(): Int { | ||
return value.values.count { it == PlayerResult.LOSE } | ||
} | ||
|
||
fun winningCount(): Int { | ||
return value.values.count { it == PlayerResult.WIN } | ||
} | ||
|
||
fun drawingCount(): Int { | ||
return value.values.count { it == PlayerResult.DRAW } | ||
} | ||
|
||
fun resultOfPlayer(player: Player): PlayerResult { | ||
return requireNotNull(value[player]) { "νλ μ΄μ΄λ₯Ό μ°Ύμ μ μμ" } | ||
} | ||
|
||
fun playerResult(): List<Pair<String, PlayerResult>> { | ||
return value.keys.map { playerNameAndResult(it) }.toList() | ||
} | ||
|
||
private fun playerNameAndResult(it: Player): Pair<String, PlayerResult> { | ||
return it.name to requireNotNull(value[it]) { "νλ μ΄μ΄ ${it.name} μ μ°Ύμ μ μμ΅λλ€" } | ||
} | ||
} |
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,5 @@ | ||
package blackjack.model | ||
|
||
interface PlayingStrategy { | ||
fun isHit(): Boolean | ||
} |
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.
λΈλμ λ£°μ΄ μ λ°μλμ΄μμ§ μμ 보μ¬μ.
μλ λ£°λ€μ΄ λ°μλμ΄μμ§ μμμ, λΈλμ λ£°μ λ€μ ν λ² νμ ν΄λ³΄μ ν νλ‘μ νΈμ λ°μν΄λ³΄λ 건 μ΄λ¨κΉμ?