-
Notifications
You must be signed in to change notification settings - Fork 550
[π μ¬μ΄ν΄2 - λ―Έμ (λΈλμ λ² ν )] νλ λ―Έμ μ μΆν©λλ€. #1099
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
Changes from all commits
8dc6e0d
1680ce9
9b6dd2e
e03c568
db4d88d
e325a08
d43da0c
da54a68
a0e2397
bee3122
14e6d8f
8d3232a
df11c83
91a11a6
a5a76a8
ba4a1de
d8a143f
dfad9b5
1486349
959d646
0b480e7
17237df
c01dd0d
24671de
8382ee9
3b4cc92
be765ab
52372d4
9bbd2b8
f14f8b1
72e273e
cf3e8c0
29e0895
3efb315
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package domain; | ||
|
|
||
| import domain.participant.Dealer; | ||
| import domain.participant.WinStatus; | ||
| import domain.participant.player.Player; | ||
| import domain.vo.Money; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class BettingTable { | ||
| private static final double BLACKJACK_BONUS = 1.5; | ||
| private final Map<Player, Money> bettingTable = new HashMap<>(); | ||
|
|
||
| public void placeBet(Player player, Money money) { | ||
| bettingTable.put(player, money); | ||
| } | ||
|
|
||
| public Money calculateProfit(Player player, Dealer dealer) { | ||
| WinStatus playerWinStatus = player.decideWinStatus(dealer); | ||
|
|
||
| if (playerWinStatus == WinStatus.WIN && player.isBlackjack()) { | ||
| return new Money(bettingTable.get(player).multiplyDouble(BLACKJACK_BONUS)); | ||
| } | ||
|
|
||
| if (playerWinStatus == WinStatus.LOSS) { | ||
| return bettingTable.get(player).negate(); | ||
| } | ||
|
|
||
| if (playerWinStatus == WinStatus.DRAW) { | ||
| return new Money(BigDecimal.ZERO); | ||
| } | ||
|
|
||
| return bettingTable.get(player); | ||
| } | ||
|
|
||
| public Money getDealerProfit(List<Player> players, Dealer dealer) { | ||
| return players.stream() | ||
| .map(player -> calculateProfit(player, dealer)) | ||
| .reduce(new Money(BigDecimal.ZERO), Money::add) | ||
| .negate(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package domain; | ||
|
|
||
| import domain.card.CardDeck; | ||
| import domain.participant.Dealer; | ||
| import domain.participant.HandCards; | ||
| import domain.participant.Participant; | ||
| import domain.participant.WinStatus; | ||
| import domain.participant.player.Player; | ||
| import domain.participant.player.PlayerGroup; | ||
| import domain.vo.Name; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class BlackjackGame { | ||
| private static final int START_CARD_COUNT = 2; | ||
| private final Dealer dealer = new Dealer(new HandCards()); | ||
| private final CardDeck cardDeck = new CardDeck(); | ||
| private PlayerGroup playerGroup; | ||
|
|
||
| public void registerPlayers(List<String> playerNames) { | ||
| List<Player> players = new ArrayList<>(); | ||
|
|
||
| for (String playerName : playerNames) { | ||
| Player player = new Player(new Name(playerName), new HandCards()); | ||
| players.add(player); | ||
| } | ||
|
|
||
| playerGroup = new PlayerGroup(players); | ||
| } | ||
|
|
||
| public void dealParticipantsCardsOut() { | ||
| dealCardsOut(dealer); | ||
|
|
||
| for (Player player : playerGroup.getPlayers()) { | ||
|
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. μ΄κΈ°μ κ°μ²΄κ° playerGroupμ΄ ν λΉλμ§ μμ μνμλ€λ©΄, (μ¦ registerPlayersμ΄ μ€νλ μ μλ€λ©΄, ) μ μλμνμ§ μμ λ©μλμμ. μΌμ’ μ State machine (μνκ° μκ³ μνμ λ°λΌ νλμ΄ λ³ννλ κ°μ²΄)μΈλ°μ, μ μ λ―Έλ±λ‘ μνμ μ μ λ±λ‘ μνμ. μ΄λ° κ°μ²΄λ₯Ό λ§λ€μλ€λ©΄ stateμ λ°λ₯Έ μμΈμ²λ¦¬λ₯Ό μ ν΄μ£Όμ΄μΌ ν΄μ. κ·Έλ°λ° μ΄ κ°μ²΄λ μνμ λ°λΌ νμλ₯Ό λ°κΏ νμκ° μμΌλ, μ΄κΈ°μ playerGroupλ₯Ό ν λΉνλ μ½λλ‘ λ§λ€ μ μμΌλ©΄ μ’λ μ’κ² μ£ . (μμ±μ μ£Όμ
λ±μΌλ‘)
Author
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. μκ°ν΄λ³΄λ©΄ νλ μ΄μ΄ μλ κ²μ μμκ³Ό λ μ¬μ΄μ λ³νλ μΌμ΄ μμΌλ μ¨μ§μ λ§μ²λΌ μ²λ¦¬ν΄μ£Όλ κ² ν¨μ¬ κΉλν΄μ§ κ² κ°μμ. κ°μ²΄κ° μΈμ μΌλ§λ μμ νκ² μμ±λ μ μλμ§ λ κ³ λ―Όν΄λ΄μΌ νλ κ² κ°μ΅λλ€... κ°μ¬ν©λλ€! |
||
| dealCardsOut(player); | ||
| } | ||
| } | ||
|
|
||
| public void playerHit(Player player) { | ||
| player.drawCard(cardDeck.getCard()); | ||
| } | ||
|
|
||
| public boolean isDealerHit() { | ||
| if (dealer.isDealerHit()) { | ||
| dealer.drawCard(cardDeck.getCard()); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public void decideDealerResult() { | ||
| playerGroup.getPlayers().stream() | ||
| .map(player -> decidePlayerResult(player)) | ||
| .forEach(winstatus -> saveDealerResult(winstatus)); | ||
| } | ||
|
|
||
| private void saveDealerResult(WinStatus winStatus) { | ||
| dealer.saveResult(winStatus); | ||
| } | ||
|
|
||
| public Dealer getDealer() { | ||
| return dealer; | ||
| } | ||
|
|
||
| private void dealCardsOut(Participant participant) { | ||
| for (int i = 0; i < START_CARD_COUNT; i++) { | ||
| participant.drawCard(cardDeck.getCard()); | ||
| } | ||
| } | ||
|
|
||
| public WinStatus decidePlayerResult(Player player) { | ||
| return player.decideWinStatus(dealer); | ||
| } | ||
|
|
||
| public List<Player> getPlayers() { | ||
| return List.copyOf(playerGroup.getPlayers()); | ||
| } | ||
| } | ||
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.
μ λ°μ μΌλ‘ 리ν©ν λ§μ΄ μ λμλ€μ.
μ λ² prμ λ°μ μνμμ κ³ λ―Όμ νλλ°μ,
νμ κ΄μ μμ λ¦¬λ·°κ° νμνλ 건 λ§μ§λ§μ
μ¬λ¬κ°μ§λ₯Ό κ³ λ €νμ λ μ΄ν μμ λ―Έμ μμ κ³ λ―Όλ€μ νλμ© ν΄κ²°ν΄ λκ°μλ κ² λ§μ§ μμκΉ μκ°ν΄μ μ΄νλ‘λΈλ₯Ό ν κΉ λ§κΉ κ³ λ―Όνμ΄μ.
리뷰μ΄λ νμ§μμ μμ μ μ£ΌκΈ° μν΄ μλ€κ³ μκ°νκΈ° λλ¬Έμ κ²°κ΅ λ³κ²½ μμ²μ λλ Έλλ°μ
μ λ°μν΄μ£Όμ μ λ리길 μ νλ€λ μκ°μ΄ λλ€μ. LLM μ΄ν μ½λ μλ² λ³΄λ€λ μ νλμ§, 무μ λλ¬Έμ νλμ§κ° μ€μν΄μ§κ³ μλλ°μ, νλμ²λΌ μ¬λ¬κ°μ§λ₯Ό μλν΄λ³΄κ³ κΉ¨λ¬μμ μ»μ΄λκ°λ μλμ΄ κ°μ₯ μ€μν΄μ§κ±°λΌκ³ μκ°ν΄μ. μμΌλ‘λ νμ΄ν μ λλ€.
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.
리ν©ν λ§μ μ¬λ¬ λ² ν΄λ³΄λ νλ€μ§λ§ κ·Έλ§νΌ λ§μ κ±Έ λ°°μΈ μ μμλ κ² κ°μμ!
μ΄λ‘ μ μΈ κ³΅λΆλ₯Ό ν΄μΌ λ νμ€ν μ μ μκ² μ§λ§, μ΄μ μ΄λ€ μ½λκ° κΉλν μ½λλ©° κ·Έ μ½λλ₯Ό μ ν΄μΌνλμ§, μ΄λ»κ² ν΄μΌνλμ§λ μ‘°κΈμ μ κ² κ°μ΅λλ€
μ κ° μ€κ°μ λ§μ΄ ν€λ§€κΈ°λ νκ³ μ€μν κ±Έ λ μ€μνκΈ°λ νλλ° κΌΌκΌΌνκ² λ€ λ¦¬λ·°ν΄μ£Όμ μ κ°μ¬ν©λλ€!!
μ¨μ§ λλΆμ μμΌλ‘ μ°ν μ½ λ―Έμ μ ν΄λκ° κΈ°λ°μ μ λ§λ ¨ν κ² κ°μμ
νλ€κΈ°λ νμ§λ§ λ μ½λκ° λ°λλ κ±Έ 보면μ μ¬λ°κΈ°λ νμ΄μγ γ
κ±°μ 3μ£Ό λμ μ λ§ λ§μ΄ λ°°μ κ³ κ°μ¬νμ΅λλ€!
ν볡νμΈμπ