1.1 --- a/chess/src/main/java/org/apidesign/html/demo/chess/BoardModel.java Tue Sep 24 22:37:17 2013 +0200
1.2 +++ b/chess/src/main/java/org/apidesign/html/demo/chess/BoardModel.java Tue Sep 24 23:52:32 2013 +0200
1.3 @@ -35,14 +35,12 @@
1.4 import net.java.html.json.OnPropertyChange;
1.5 import net.java.html.json.Property;
1.6 import net.java.html.sound.AudioClip;
1.7 -import org.apidesign.html.demo.chess.Communication.AlertType;
1.8
1.9 @Model(className="Board", properties={
1.10 @Property(name = "player", type = String.class),
1.11 @Property(name = "gameId", type = String.class),
1.12 @Property(name = "whitePlayer", type = String.class),
1.13 @Property(name = "blackPlayer", type = String.class),
1.14 - @Property(name = "alert", type = Alert.class),
1.15 @Property(name = "alertMessage", type = String.class),
1.16 @Property(name = "status", type = String.class),
1.17 @Property(name = "rows", type = Row.class, array = true),
1.18 @@ -85,17 +83,6 @@
1.19
1.20 private static final AudioClip CHECK = AudioClip.create("sounds/check.mp3");
1.21 private static final AudioClip CHECKMATE = AudioClip.create("sounds/checkmate.mp3");
1.22 - @OnPropertyChange("alert") static void warnCheckAndMate(Board b) {
1.23 - if (b.getAlert() == null) {
1.24 - return;
1.25 - }
1.26 - if (b.getAlert().getType() == AlertType.CHECK) {
1.27 - CHECK.play();
1.28 - }
1.29 - if (b.getAlert().getType() == AlertType.CHECKMATE) {
1.30 - CHECKMATE.play();
1.31 - }
1.32 - }
1.33
1.34 @Function static void selected(Board b, Square data) {
1.35 if (!b.isMyTurn()) {
1.36 @@ -141,17 +128,6 @@
1.37 previoslySelected.setPiece(null);
1.38 previoslySelected.setPieceColor(null);
1.39 Rules.computeAccessible(b, null);
1.40 -
1.41 - Request sm = new Request();
1.42 - sm.setMsg(MsgType.SendMove);
1.43 - sm.setGameId(b.getGameId());
1.44 - sm.setFrom(newMove.getFrom().getLocation());
1.45 - sm.setTo(newMove.getTo().getLocation());
1.46 - sm.setColor(newMove.getTurn());
1.47 - final UI ui = UIModel.findUI(b);
1.48 - if (ui != null) {
1.49 - ui.sendMsg(sm);
1.50 - }
1.51 }
1.52 }
1.53 }
1.54 @@ -259,8 +235,10 @@
1.55 return null;
1.56 }
1.57
1.58 - static void moveResponse(final Board b, final String errMsg, final List<String> whites, final List<String> blacks, final Color turn,
1.59 - Alert alert
1.60 + static void moveResponse(
1.61 + final Board b, final String errMsg,
1.62 + final List<String> whites, final List<String> blacks,
1.63 + final Color turn, Object alert
1.64 ) {
1.65 if (errMsg != null) {
1.66 b.getMoves().remove(b.getPendingMove());
1.67 @@ -270,11 +248,14 @@
1.68 b.setTurn(turn);
1.69 b.setAlertMessage(null);
1.70 }
1.71 - b.setAlert(alert);
1.72 Rules.initBoard(b, whites, blacks, turn);
1.73 }
1.74
1.75 - static void moveUpdate(final Board b, final Move move, final List<String> whites, final List<String> blacks, final Color turn, Alert alert) {
1.76 + static void moveUpdate(
1.77 + final Board b, final Move move,
1.78 + final List<String> whites, final List<String> blacks,
1.79 + final Color turn, Object alert
1.80 + ) {
1.81 final Square from = BoardModel.findSquare(b, move.getFrom());
1.82 final Square to = BoardModel.findSquare(b, move.getTo());
1.83 move.setPiece(from.getPiece());
1.84 @@ -282,8 +263,6 @@
1.85 if (to.getPiece() != null) {
1.86 move.setTakes(true);
1.87 }
1.88 - b.setAlert(alert);
1.89 - b.setAlertMessage(alert == null ? null : alert.getMessage());
1.90 move.setRound(b.getMoves().size() / 2 + 1);
1.91 b.getMoves().add(move);
1.92 Rules.initBoard(b, whites, blacks, turn);