1.1 --- a/freemarkerdor/pom.xml Fri Sep 11 22:25:21 2009 +0200
1.2 +++ b/freemarkerdor/pom.xml Sat Sep 12 05:00:28 2009 +0200
1.3 @@ -100,7 +100,7 @@
1.4 </plugin>
1.5 </plugins>
1.6 </build>
1.7 - <version>1.3</version>
1.8 + <version>1.4</version>
1.9 </project>
1.10
1.11
2.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Fri Sep 11 22:25:21 2009 +0200
2.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Sat Sep 12 05:00:28 2009 +0200
2.3 @@ -34,7 +34,6 @@
2.4 import com.sun.jersey.api.core.ResourceConfig;
2.5 import com.sun.jersey.api.view.Viewable;
2.6 import com.sun.net.httpserver.HttpServer;
2.7 -import cz.xelfi.quoridor.webidor.resources.Quoridor;
2.8 import java.io.File;
2.9 import java.io.FileInputStream;
2.10 import java.io.IOException;
3.1 --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Fri Sep 11 22:25:21 2009 +0200
3.2 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Sat Sep 12 05:00:28 2009 +0200
3.3 @@ -21,7 +21,7 @@
3.4 <#assign unit="day"/>
3.5 <#assign value=t?float / (24.0 * 3600000.0)/>
3.6 </#if>
3.7 - ${value?float?string("0")} ${unit}
3.8 + <!--millis ${t}-->${value?float?string("0")} ${unit}
3.9 </#macro>
3.10
3.11 <#macro game game>
4.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Fri Sep 11 22:25:21 2009 +0200
4.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Sat Sep 12 05:00:28 2009 +0200
4.3 @@ -87,7 +87,7 @@
4.4 }
4.5 }
4.6
4.7 - public void apply(String player, Move m) throws IllegalPositionException {
4.8 + public void apply(String player, Move m, Date when) throws IllegalPositionException {
4.9 Player p = null;
4.10 if (id.getWhite().equals(player)) {
4.11 p = getBoard().getPlayers().get(0);
4.12 @@ -101,7 +101,10 @@
4.13 }
4.14
4.15 board = getBoard().apply(m);
4.16 - id = new GameId(id.getId(), id.getWhite(), id.getBlack(), new Date(id.getStarted()), new Date(), GameStatus.valueOf(board));
4.17 + if (when == null) {
4.18 + when = new Date(id.getModified());
4.19 + }
4.20 + id = new GameId(id.getId(), id.getWhite(), id.getBlack(), new Date(id.getStarted()), when, GameStatus.valueOf(board));
4.21 getMoves().add(m);
4.22 }
4.23
5.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Fri Sep 11 22:25:21 2009 +0200
5.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sat Sep 12 05:00:28 2009 +0200
5.3 @@ -127,7 +127,7 @@
5.4 throw new IllegalArgumentException("Unknown game " + id);
5.5 }
5.6 Move m = Move.valueOf(move);
5.7 - g.apply(player, m);
5.8 + g.apply(player, m, new Date());
5.9 try {
5.10 storeGame(g);
5.11 } catch (IOException ex) {
5.12 @@ -202,9 +202,9 @@
5.13 throw new IOException("Too much moves on line: " + line);
5.14 }
5.15 try {
5.16 - g.apply(white, Move.valueOf(moves[0]));
5.17 + g.apply(white, Move.valueOf(moves[0]), null);
5.18 if (moves.length == 2) {
5.19 - g.apply(black, Move.valueOf(moves[1]));
5.20 + g.apply(black, Move.valueOf(moves[1]), null);
5.21 }
5.22 } catch (IllegalPositionException ex) {
5.23 throw new IOException("Wrong move: " + ex.getMessage());
6.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java Fri Sep 11 22:25:21 2009 +0200
6.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java Sat Sep 12 05:00:28 2009 +0200
6.3 @@ -71,14 +71,22 @@
6.4 File f = new File(dir, "x");
6.5 f.getParentFile().mkdirs();
6.6 FileOutputStream os = new FileOutputStream(f);
6.7 - os.write("# white: W\n# black: B\n# status: IN_PROGRESS\n\n\n".getBytes("UTF-8"));
6.8 + os.write("# white: W\n# black: B\n# status: IN_PROGRESS\nN S\n\n".getBytes("UTF-8"));
6.9 os.close();
6.10
6.11 + Thread.sleep(1000);
6.12 +
6.13 + long middle = f.lastModified();
6.14 +
6.15 + Thread.sleep(1000);
6.16 +
6.17 Games games = new Games(dir);
6.18 Game g = games.getBoardInfo("x");
6.19 assertNotNull("Game found", g);
6.20 assertNotNull("Board found", g.getBoard());
6.21 - assertEquals("List of moves is empty", 0, g.getMoves().size());
6.22 + assertEquals("List of moves has two", 2, g.getMoves().size());
6.23 +
6.24 + assertEquals("Last move is last touch of the file", middle, g.getId().getModified());
6.25 }
6.26
6.27 }