1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Tue Dec 08 18:35:11 2009 +0100
1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Tue Dec 08 18:47:49 2009 +0100
1.3 @@ -106,11 +106,11 @@
1.4 if (when == null) {
1.5 when = new Date(id.getModified());
1.6 }
1.7 + final GameStatus status = GameStatus.valueOf(board);
1.8 id = new GameId(
1.9 id.getId(), id.getWhite(), id.getBlack(),
1.10 - new Date(id.getStarted()), when,
1.11 - GameStatus.valueOf(board), id.getComments()
1.12 - );
1.13 + new Date(id.getStarted()), when, status,
1.14 + id.getComments(), !status.isInProgress());
1.15 getMoves().add(new CommentedMove(m, getMoves().size() + 1));
1.16 }
1.17
1.18 @@ -119,7 +119,7 @@
1.19 id = new GameId(
1.20 id.getId(), id.getWhite(), id.getBlack(),
1.21 new Date(id.getStarted()), new Date(id.getModified()),
1.22 - GameStatus.valueOf(board), id.getComments() + 1
1.23 + GameStatus.valueOf(board), id.getComments() + 1, id.isFinished()
1.24 );
1.25 getMoves().get(getMoves().size() - 1).addNote(n);
1.26 }
1.27 @@ -152,7 +152,7 @@
1.28 new GameId(
1.29 id.getId(), id.getWhite(), id.getBlack(),
1.30 new Date(id.getStarted()), new Date(id.getModified()),
1.31 - GameStatus.history, id.getComments()
1.32 + GameStatus.history, id.getComments(), id.isFinished()
1.33 )
1.34 );
1.35 g.board = b;
2.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java Tue Dec 08 18:35:11 2009 +0100
2.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java Tue Dec 08 18:47:49 2009 +0100
2.3 @@ -58,6 +58,8 @@
2.4 private String id;
2.5 @XmlAttribute
2.6 private int comments;
2.7 + @XmlAttribute
2.8 + private boolean finished;
2.9
2.10 GameId() {
2.11 }
2.12 @@ -68,11 +70,15 @@
2.13 private GameId(String first, String second, Date d) {
2.14 this(
2.15 UUID.randomUUID().toString(),
2.16 - first, second, d, d, GameStatus.whiteMove, 0
2.17 + first, second, d, d, GameStatus.whiteMove, 0, false
2.18 );
2.19 }
2.20
2.21 - public GameId(String id, String first, String second, Date started, Date last, GameStatus result, int comments) {
2.22 + public GameId(
2.23 + String id, String first, String second,
2.24 + Date started, Date last, GameStatus result,
2.25 + int comments, boolean finished
2.26 + ) {
2.27 this.white = first;
2.28 this.black = second;
2.29 this.id = id;
2.30 @@ -80,6 +86,7 @@
2.31 this.modified = last.getTime();
2.32 this.status = result;
2.33 this.comments = comments;
2.34 + this.finished = finished;
2.35 }
2.36
2.37 public String getId() {
2.38 @@ -110,6 +117,10 @@
2.39 return comments;
2.40 }
2.41
2.42 + public boolean isFinished() {
2.43 + return finished;
2.44 + }
2.45 +
2.46 private static final class NewestFirst implements Comparator<GameId> {
2.47 public int compare(GameId o1, GameId o2) {
2.48 if (o1 == o2) {
3.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Tue Dec 08 18:35:11 2009 +0100
3.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Tue Dec 08 18:47:49 2009 +0100
3.3 @@ -136,7 +136,7 @@
3.4 @QueryParam("move") @DefaultValue("-1") int move
3.5 ) {
3.6 Game g = findGame(id, move);
3.7 - if (g.getId().getStatus().isInProgress()) {
3.8 + if (!g.getId().isFinished()) {
3.9 return g;
3.10 }
3.11 String logUser = quoridor.isLoggedIn(loginId);
3.12 @@ -291,7 +291,7 @@
3.13 throw new IOException("Missing white and black identification in " + f);
3.14 }
3.15 if (g == null) {
3.16 - GameId id = new GameId(f.getName(), white, black, new Date(f.lastModified()), new Date(f.lastModified()), GameStatus.whiteMove, 0);
3.17 + GameId id = new GameId(f.getName(), white, black, new Date(f.lastModified()), new Date(f.lastModified()), GameStatus.whiteMove, 0, false);
3.18 g = new Game(id);
3.19 }
3.20 int hash = line.indexOf('#');