# HG changeset patch # User Jaroslav Tulach # Date 1260294469 -3600 # Node ID 2949998db4f686c85f1e6bf35a02dfd3d5e34b8a # Parent 2a870f6d560ef2df5bed545f7507bb0f9838299e Keeping the current game finished status when showing its history diff -r 2a870f6d560e -r 2949998db4f6 webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Tue Dec 08 18:35:11 2009 +0100 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Tue Dec 08 18:47:49 2009 +0100 @@ -106,11 +106,11 @@ if (when == null) { when = new Date(id.getModified()); } + final GameStatus status = GameStatus.valueOf(board); id = new GameId( id.getId(), id.getWhite(), id.getBlack(), - new Date(id.getStarted()), when, - GameStatus.valueOf(board), id.getComments() - ); + new Date(id.getStarted()), when, status, + id.getComments(), !status.isInProgress()); getMoves().add(new CommentedMove(m, getMoves().size() + 1)); } @@ -119,7 +119,7 @@ id = new GameId( id.getId(), id.getWhite(), id.getBlack(), new Date(id.getStarted()), new Date(id.getModified()), - GameStatus.valueOf(board), id.getComments() + 1 + GameStatus.valueOf(board), id.getComments() + 1, id.isFinished() ); getMoves().get(getMoves().size() - 1).addNote(n); } @@ -152,7 +152,7 @@ new GameId( id.getId(), id.getWhite(), id.getBlack(), new Date(id.getStarted()), new Date(id.getModified()), - GameStatus.history, id.getComments() + GameStatus.history, id.getComments(), id.isFinished() ) ); g.board = b; diff -r 2a870f6d560e -r 2949998db4f6 webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java Tue Dec 08 18:35:11 2009 +0100 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/GameId.java Tue Dec 08 18:47:49 2009 +0100 @@ -58,6 +58,8 @@ private String id; @XmlAttribute private int comments; + @XmlAttribute + private boolean finished; GameId() { } @@ -68,11 +70,15 @@ private GameId(String first, String second, Date d) { this( UUID.randomUUID().toString(), - first, second, d, d, GameStatus.whiteMove, 0 + first, second, d, d, GameStatus.whiteMove, 0, false ); } - public GameId(String id, String first, String second, Date started, Date last, GameStatus result, int comments) { + public GameId( + String id, String first, String second, + Date started, Date last, GameStatus result, + int comments, boolean finished + ) { this.white = first; this.black = second; this.id = id; @@ -80,6 +86,7 @@ this.modified = last.getTime(); this.status = result; this.comments = comments; + this.finished = finished; } public String getId() { @@ -110,6 +117,10 @@ return comments; } + public boolean isFinished() { + return finished; + } + private static final class NewestFirst implements Comparator { public int compare(GameId o1, GameId o2) { if (o1 == o2) { diff -r 2a870f6d560e -r 2949998db4f6 webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Tue Dec 08 18:35:11 2009 +0100 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Tue Dec 08 18:47:49 2009 +0100 @@ -136,7 +136,7 @@ @QueryParam("move") @DefaultValue("-1") int move ) { Game g = findGame(id, move); - if (g.getId().getStatus().isInProgress()) { + if (!g.getId().isFinished()) { return g; } String logUser = quoridor.isLoggedIn(loginId); @@ -291,7 +291,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, 0); + GameId id = new GameId(f.getName(), white, black, new Date(f.lastModified()), new Date(f.lastModified()), GameStatus.whiteMove, 0, false); g = new Game(id); } int hash = line.indexOf('#');