1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sat Sep 26 00:06:58 2009 +0200
1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sat Sep 26 21:47:02 2009 +0200
1.3 @@ -230,6 +230,10 @@
1.4 GameId id = new GameId(f.getName(), white, black, new Date(f.lastModified()), new Date(f.lastModified()), GameStatus.whiteMove);
1.5 g = new Game(id);
1.6 }
1.7 + int hash = line.indexOf('#');
1.8 + if (hash >= 0) {
1.9 + line = line.substring(0, hash);
1.10 + }
1.11 if (line.equals("finish")) {
1.12 break;
1.13 }
1.14 @@ -241,7 +245,9 @@
1.15 throw new IOException("Too much moves on line: " + line);
1.16 }
1.17 try {
1.18 - g.apply(white, Move.valueOf(moves[0]), null);
1.19 + if (!"...".equals(moves[0])) {
1.20 + g.apply(white, Move.valueOf(moves[0]), null);
1.21 + }
1.22 if (moves.length == 2) {
1.23 g.apply(black, Move.valueOf(moves[1]), null);
1.24 }
2.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java Sat Sep 26 00:06:58 2009 +0200
2.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java Sat Sep 26 21:47:02 2009 +0200
2.3 @@ -90,4 +90,26 @@
2.4 assertEquals("Last move is last touch of the file", middle, g.getId().getModified());
2.5 }
2.6
2.7 + @Test public void testLoadGameWithComments() throws Exception {
2.8 + File f = new File(dir, "x");
2.9 + f.getParentFile().mkdirs();
2.10 + FileOutputStream os = new FileOutputStream(f);
2.11 + os.write("# white: W\n# black: B\n# status: IN_PROGRESS\nN #good move\n... S # ok move\n\n".getBytes("UTF-8"));
2.12 + os.close();
2.13 +
2.14 + Thread.sleep(1000);
2.15 +
2.16 + long middle = f.lastModified();
2.17 +
2.18 + Thread.sleep(1000);
2.19 +
2.20 + Games games = new Games(dir, new Quoridor());
2.21 + Game g = games.getBoardInfo("x", -1);
2.22 + assertNotNull("Game found", g);
2.23 + assertNotNull("Board found", g.getBoard());
2.24 + assertEquals("List of moves has two", 2, g.getMoves().size());
2.25 +
2.26 + assertEquals("Last move is last touch of the file", middle, g.getId().getModified());
2.27 + }
2.28 +
2.29 }