-
Notifications
You must be signed in to change notification settings - Fork 461
Expand file tree
/
Copy pathChessGame.java
More file actions
34 lines (28 loc) · 1.03 KB
/
ChessGame.java
File metadata and controls
34 lines (28 loc) · 1.03 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
package chess;
import chess.board.ChessBoard;
import chess.board.Position;
import view.ConsoleView;
public class ChessGame {
private final ChessBoard chessBoard;
private final ConsoleView consoleView;
public ChessGame(ChessBoard chessBoard, ConsoleView consoleView) {
this.chessBoard = chessBoard;
this.consoleView = consoleView;
}
public void start() {
Turn currentTurn = Turn.getStartingTurn();
boolean isGameStop = false;
while (!isGameStop) {
try {
consoleView.printBoard(chessBoard.getPieces());
consoleView.printTurn(currentTurn);
Position startPoint = consoleView.requestStartPoint();
Position destination = consoleView.requestDestination();
isGameStop = chessBoard.move(startPoint, destination);
currentTurn = currentTurn.changeTurn();
} catch (RuntimeException e) {
consoleView.printMessage(e.getMessage());
}
}
}
}