- Finished HighScoreDialog.java. Now the player can play the game repeatedly.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package model;
|
||||
|
||||
import model.Board.TileColor;
|
||||
import model.playerModel.PlayerModel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@@ -8,7 +9,8 @@ import player.AlphaBetaComPlayer;
|
||||
import player.HumanPlayer;
|
||||
import player.Player;
|
||||
import view.BoardPanel;
|
||||
import view.MessagePanel;
|
||||
import view.HighScoreDialog;
|
||||
import view.MainFrame;
|
||||
import view.ScorePanel;
|
||||
|
||||
public class Referee implements Runnable {
|
||||
@@ -20,17 +22,17 @@ public class Referee implements Runnable {
|
||||
|
||||
public static final String PLAYER_TURN = "Waiting for the player's move.";
|
||||
|
||||
private final Board board;
|
||||
private Board board;
|
||||
private BoardPanel boardPanel;
|
||||
private final Player computerPlayer;
|
||||
private Player computerPlayer;
|
||||
|
||||
private final HumanPlayer humanPlayer = new HumanPlayer();
|
||||
private MessagePanel messagePanel;
|
||||
private ScorePanel scorePanel;
|
||||
|
||||
public Referee() {
|
||||
board = new Board();
|
||||
computerPlayer = new AlphaBetaComPlayer();
|
||||
private final MainFrame mf;
|
||||
|
||||
public Referee(MainFrame mnFrm) {
|
||||
mf = mnFrm;
|
||||
initGame();
|
||||
}
|
||||
|
||||
public Player getComputerPlayer() {
|
||||
@@ -69,9 +71,31 @@ public class Referee implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
initGame();
|
||||
mf.updateBoard();
|
||||
play();
|
||||
new HighScoreDialog(mf, new PlayerModel());
|
||||
}
|
||||
}
|
||||
|
||||
public void setBoardPanel(BoardPanel boardPanel) {
|
||||
this.boardPanel = boardPanel;
|
||||
}
|
||||
|
||||
private ScorePanel getScorePanel() {
|
||||
return mf.getScorePanel();
|
||||
}
|
||||
|
||||
private void initGame() {
|
||||
board = new Board();
|
||||
computerPlayer = new AlphaBetaComPlayer();
|
||||
}
|
||||
|
||||
private void play() {
|
||||
int plies = 0;
|
||||
while (!isOver()) {
|
||||
scorePanel.updateScore(getPlayerScore());
|
||||
getScorePanel().updateScore(getPlayerScore());
|
||||
if (board.isPlayerTurn()) {
|
||||
boolean wasInterrupted = false;
|
||||
while (!humanPlayer.isReady()) {
|
||||
@@ -97,7 +121,7 @@ public class Referee implements Runnable {
|
||||
playToken(mv);
|
||||
}
|
||||
|
||||
messagePanel.updateMessage(getMessage());
|
||||
mf.updateMessage(getMessage());
|
||||
boardPanel.updateIcons();
|
||||
LOGGER.info("plies: " + plies++);
|
||||
try {
|
||||
@@ -108,16 +132,4 @@ public class Referee implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBoardPanel(BoardPanel boardPanel) {
|
||||
this.boardPanel = boardPanel;
|
||||
}
|
||||
|
||||
public void setMessagePanel(MessagePanel messagePanel) {
|
||||
this.messagePanel = messagePanel;
|
||||
}
|
||||
|
||||
public void setScorePanel(ScorePanel scorePanel) {
|
||||
this.scorePanel = scorePanel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user