Removed use of Refreshable and replaced with several methods which update the GUI using SwingUtilities.invokeLater().

While not as clean as using ChangeListener, it completely decouples the Model and View aspects,
and also avoids the need to manually paint() a hierarchy of components (a task best handled by Swing/AWT).
This commit is contained in:
Woody Folsom
2012-04-04 17:15:21 -04:00
parent 0f616a3cc6
commit b8df412740
9 changed files with 112 additions and 192 deletions

View File

@@ -1,12 +1,10 @@
package model;
import javax.security.auth.Refreshable;
import model.Board.TileColor;
import model.comController.RandomComController;
import controller.PlayerController;
public class Referee implements Refreshable {
public class Referee {
public enum Message {
COM_TURN {
@@ -42,7 +40,6 @@ public class Referee implements Refreshable {
private final PlayerController pc = new PlayerController();
private boolean playerTurn;
private boolean refresh = true;
private int score = 0;
public Referee() {
@@ -52,28 +49,16 @@ public class Referee implements Refreshable {
}
public void doSomething() {
Move mv;
if (playerTurn && pc.isReady()) {
mv = pc.getMove();
Move mv = pc.getMove();
if (board.getTile(mv.getCell().r, mv.getCell().c) == TileColor.NONE) {
playToken(pc.getMove());
refresh = true;
}
else {
} else {
pc.denyMove();
}
}
else if (!playerTurn) {
mv = cc.getMove();
} else if (!playerTurn) {
Move mv = cc.getMove();
playToken(mv);
refresh = true;
}
}
@@ -107,11 +92,6 @@ public class Referee implements Refreshable {
return board.getTile(r, c);
}
@Override
public boolean isCurrent() {
return !refresh;
}
public boolean isOver() {
for (int r = 0; r < Board.NUM_ROWS; r++) {
for (int c = 0; c < Board.NUM_COLS; c++) {
@@ -135,11 +115,6 @@ public class Referee implements Refreshable {
incrementTurn();
}
@Override
public void refresh() {
refresh = false;
}
private void incrementScore() {
score++;
}