1.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Mon Aug 31 22:44:47 2009 +0200
1.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Fri Sep 04 18:01:01 2009 +0200
1.3 @@ -38,6 +38,8 @@
1.4 import java.io.FileInputStream;
1.5 import java.io.IOException;
1.6 import java.net.URI;
1.7 +import java.util.HashMap;
1.8 +import java.util.Map;
1.9 import java.util.Properties;
1.10 import java.util.concurrent.Callable;
1.11 import javax.ws.rs.DefaultValue;
1.12 @@ -117,8 +119,11 @@
1.13 if (v != null) {
1.14 return v;
1.15 }
1.16 + Map<String,Object> map = new HashMap<String,Object>();
1.17 Document doc = base.path("games").path(id).accept(MediaType.TEXT_XML).get(Document.class);
1.18 - return new Viewable("game.fmt", doc);
1.19 + map.put("doc", doc);
1.20 + map.put("user", user);
1.21 + return new Viewable("game.fmt", map);
1.22 }
1.23
1.24 @GET
2.1 --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt Mon Aug 31 22:44:47 2009 +0200
2.2 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt Fri Sep 04 18:01:01 2009 +0200
2.3 @@ -7,51 +7,53 @@
2.4 <body>
2.5 <h1>Game</h1>
2.6 <h3>${doc.game.id.@white} vs. ${doc.game.id.@black}</h3>
2.7 - <form action="move">
2.8 - <input type="hidden" name="type" value="fence" readonly="readonly"/>
2.9 - <select name="column">
2.10 - <option>A</option>
2.11 - <option>B</option>
2.12 - <option>C</option>
2.13 - <option>D</option>
2.14 - <option>E</option>
2.15 - <option>F</option>
2.16 - <option>G</option>
2.17 - <option>H</option>
2.18 - </select>
2.19 - <select name="row">
2.20 - <option>1</option>
2.21 - <option>2</option>
2.22 - <option>3</option>
2.23 - <option>4</option>
2.24 - <option>5</option>
2.25 - <option>6</option>
2.26 - <option>7</option>
2.27 - <option>8</option>
2.28 - </select>
2.29 - <select name="direction">
2.30 - <option>horizontal</option>
2.31 - <option>vertical</option>
2.32 - </select>
2.33 - <input type="submit" value="Place!" />
2.34 - </form>
2.35 - <form action="move">
2.36 - <input type="hidden" name="type" value="move" readonly="readonly"/>
2.37 - <select name="direction">
2.38 - <option>E</option>
2.39 - <option>W</option>
2.40 - <option>N</option>
2.41 - <option>S</option>
2.42 - </select>
2.43 - <select name="direction-next">
2.44 - <option></option>
2.45 - <option>E</option>
2.46 - <option>W</option>
2.47 - <option>N</option>
2.48 - <option>S</option>
2.49 - </select>
2.50 - <input type="submit" value="Move!" />
2.51 - </form>
2.52 + <#if user = doc.game.@currentPlayer >
2.53 + <form action="move">
2.54 + <input type="hidden" name="type" value="fence" readonly="readonly"/>
2.55 + <select name="column">
2.56 + <option>A</option>
2.57 + <option>B</option>
2.58 + <option>C</option>
2.59 + <option>D</option>
2.60 + <option>E</option>
2.61 + <option>F</option>
2.62 + <option>G</option>
2.63 + <option>H</option>
2.64 + </select>
2.65 + <select name="row">
2.66 + <option>1</option>
2.67 + <option>2</option>
2.68 + <option>3</option>
2.69 + <option>4</option>
2.70 + <option>5</option>
2.71 + <option>6</option>
2.72 + <option>7</option>
2.73 + <option>8</option>
2.74 + </select>
2.75 + <select name="direction">
2.76 + <option>Horizontal</option>
2.77 + <option>Vertical</option>
2.78 + </select>
2.79 + <input type="submit" value="Place!" />
2.80 + </form>
2.81 + <form action="move">
2.82 + <input type="hidden" name="type" value="move" readonly="readonly"/>
2.83 + <select name="direction">
2.84 + <option>E</option>
2.85 + <option>W</option>
2.86 + <option>N</option>
2.87 + <option>S</option>
2.88 + </select>
2.89 + <select name="direction-next">
2.90 + <option></option>
2.91 + <option>E</option>
2.92 + <option>W</option>
2.93 + <option>N</option>
2.94 + <option>S</option>
2.95 + </select>
2.96 + <input type="submit" value="Move!" />
2.97 + </form>
2.98 + </#if>
2.99 <pre>${doc.game.board}</pre>
2.100 </body>
2.101 </html>
2.102 \ No newline at end of file
3.1 --- a/webidor/nb-configuration.xml Mon Aug 31 22:44:47 2009 +0200
3.2 +++ b/webidor/nb-configuration.xml Fri Sep 04 18:01:01 2009 +0200
3.3 @@ -18,4 +18,13 @@
3.4 </config-file-group>
3.5 </config-file-groups>
3.6 </spring-data>
3.7 + <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
3.8 + <!--
3.9 +Properties that influence various parts of the IDE, especially code formatting and the like.
3.10 +You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
3.11 +That way multiple projects can share the same settings (useful for formatting rules for example).
3.12 +Any value defined here will override the pom.xml file value but is only applicable to the current project.
3.13 +-->
3.14 + <netbeans.compile.on.save>none</netbeans.compile.on.save>
3.15 + </properties>
3.16 </project-shared-configuration>
4.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Mon Aug 31 22:44:47 2009 +0200
4.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/Game.java Fri Sep 04 18:01:01 2009 +0200
4.3 @@ -77,6 +77,15 @@
4.4 return board;
4.5 }
4.6
4.7 + @XmlAttribute
4.8 + final String getCurrentPlayer() {
4.9 + if (board.getCurrentPlayer() == board.getPlayers().get(0)) {
4.10 + return id.getWhite();
4.11 + } else {
4.12 + return id.getBlack();
4.13 + }
4.14 + }
4.15 +
4.16 public void apply(String player, Move m) throws IllegalPositionException {
4.17 Player p = null;
4.18 if (id.getWhite().equals(player)) {