# HG changeset patch # User Jaroslav Tulach # Date 1256477098 -3600 # Node ID 19e81456eef297b676dc92a09acd5e1ce5641d5d # Parent 38615a81d3c408fcbe05b51f03cbeef940165128 Displaying the number of left comments for each game diff -r 38615a81d3c4 -r 19e81456eef2 webidor/pom.xml --- a/webidor/pom.xml Sun Oct 25 14:23:51 2009 +0100 +++ b/webidor/pom.xml Sun Oct 25 14:24:58 2009 +0100 @@ -9,7 +9,7 @@ org.apidesign webidor jar - 1.6 + 1.7 webidor server http://maven.apache.org diff -r 38615a81d3c4 -r 19e81456eef2 webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Sun Oct 25 14:23:51 2009 +0100 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Sun Oct 25 14:24:58 2009 +0100 @@ -106,12 +106,21 @@ if (when == null) { when = new Date(id.getModified()); } - id = new GameId(id.getId(), id.getWhite(), id.getBlack(), new Date(id.getStarted()), when, GameStatus.valueOf(board)); + id = new GameId( + id.getId(), id.getWhite(), id.getBlack(), + new Date(id.getStarted()), when, + GameStatus.valueOf(board), id.getComments() + ); getMoves().add(new CommentedMove(m, getMoves().size() + 1)); } public void comment(String player, String comment, Date date) { Note n = new Note(comment, date, player); + id = new GameId( + id.getId(), id.getWhite(), id.getBlack(), + new Date(id.getStarted()), new Date(id.getModified()), + GameStatus.valueOf(board), id.getComments() + 1 + ); getMoves().get(getMoves().size() - 1).addNote(n); } @@ -143,7 +152,7 @@ new GameId( id.getId(), id.getWhite(), id.getBlack(), new Date(id.getStarted()), new Date(id.getModified()), - GameStatus.history + GameStatus.history, id.getComments() ) ); g.board = b; diff -r 38615a81d3c4 -r 19e81456eef2 webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java Sun Oct 25 14:23:51 2009 +0100 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java Sun Oct 25 14:24:58 2009 +0100 @@ -56,6 +56,8 @@ private GameStatus status; @XmlID @XmlAttribute private String id; + @XmlAttribute + private int comments; GameId() { } @@ -66,17 +68,18 @@ private GameId(String first, String second, Date d) { this( UUID.randomUUID().toString(), - first, second, d, d, GameStatus.whiteMove + first, second, d, d, GameStatus.whiteMove, 0 ); } - public GameId(String id, String first, String second, Date started, Date last, GameStatus result) { + public GameId(String id, String first, String second, Date started, Date last, GameStatus result, int comments) { this.white = first; this.black = second; this.id = id; this.started = started.getTime(); this.modified = last.getTime(); this.status = result; + this.comments = comments; } public String getId() { @@ -103,6 +106,10 @@ return status; } + public int getComments() { + return comments; + } + private static final class NewestFirst implements Comparator { public int compare(GameId o1, GameId o2) { if (o1 == o2) { diff -r 38615a81d3c4 -r 19e81456eef2 webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sun Oct 25 14:23:51 2009 +0100 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sun Oct 25 14:24:58 2009 +0100 @@ -276,7 +276,7 @@ throw new IOException("Missing white and black identification in " + f); } if (g == null) { - GameId id = new GameId(f.getName(), white, black, new Date(f.lastModified()), new Date(f.lastModified()), GameStatus.whiteMove); + GameId id = new GameId(f.getName(), white, black, new Date(f.lastModified()), new Date(f.lastModified()), GameStatus.whiteMove, 0); g = new Game(id); } int hash = line.indexOf('#');