-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathJanggiController.java
More file actions
41 lines (34 loc) · 1.34 KB
/
JanggiController.java
File metadata and controls
41 lines (34 loc) · 1.34 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
package controller;
import domain.board.Formation;
import domain.board.JanggiBoard;
import domain.board.JanggiGenerator;
import domain.game.Game;
import domain.team.Team;
import dto.MoveDTO;
import view.InputView;
import view.OutputView;
public class JanggiController {
private final InputView inputView;
private final OutputView outputView;
public JanggiController(InputView inputView, OutputView outputView) {
this.inputView = inputView;
this.outputView = outputView;
}
public void run() {
Formation hanFormation = Formation.valueOf(inputView.inputHanWingSetup());
Formation choFormation = Formation.valueOf(inputView.inputChoWingSetup());
JanggiGenerator janggiGenerator = new JanggiGenerator(hanFormation, choFormation);
Game game = new Game(new JanggiBoard(janggiGenerator));
while (true) {
try {
outputView.printCurrentBoardStatus(game.boardStatus());
final Team turn = game.currentTurn();
outputView.printCurrentTurn(turn);
MoveDTO move = new MoveDTO(inputView.inputMovePiecePoint(), inputView.inputDestinationPoint());
game.processTurn(move);
} catch (IllegalArgumentException e) {
outputView.printErrorMessage(e.getMessage());
}
}
}
}