-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathGameLauncher.java
More file actions
50 lines (38 loc) · 1.6 KB
/
GameLauncher.java
File metadata and controls
50 lines (38 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package blackjack.controller;
import blackjack.domain.gamer.Dealer;
import blackjack.domain.gamer.Gamer;
import blackjack.domain.matchInfo.MatchResultBoard;
import blackjack.domain.gamer.Player;
import blackjack.domain.gamer.Players;
import blackjack.view.InputView;
import blackjack.view.OutputView;
public class GameLauncher {
private static final int BLACK_JACK_SUM_LIMIT = 21;
public void start() {
String[] playerNames = InputView.readPlayerName();
OutputView.printGamePlayer(playerNames);
OutputView.printCardsSetting(playerNames);
Dealer dealer = new Dealer();
OutputView.printDealerCardsSetting(dealer, true);
Players players = new Players(playerNames);
OutputView.printPlayersStatus(players);
for (Player player : players.getPlayers()) {
getCardOrNot(player);
}
if (dealer.getCardOrNot(dealer)) {
OutputView.printDealerAddCard();
}
OutputView.printDealerCardSum(dealer);
OutputView.printPlayerCardSum(players);
OutputView.printFinalGameResult();
MatchResultBoard matchResultBoard = players.playMatch(dealer);
OutputView.printDealerMatchResult(dealer, matchResultBoard.getDealerMatchResultInfo());
OutputView.printPlayersMatchResult(matchResultBoard.getPlayersMatchResultInfo());
}
private void getCardOrNot(Gamer player) {
while (InputView.readAddCardOrNot(player) && player.calcScore(player) < BLACK_JACK_SUM_LIMIT) {
player.addCard(player.getCards());
OutputView.printPlayerStatus(player);
}
}
}