# HG changeset patch # User Jaroslav Tulach # Date 1249996643 -7200 # Node ID 58b8db5faf2c17a6a0d59593ebc4b9faa9dc2747 # Parent c5726abc1218a30542dfed981b553655e14aeb59 Simple UI for submitting moves (without implementation) diff -r c5726abc1218 -r 58b8db5faf2c freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Tue Aug 11 14:51:47 2009 +0200 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Tue Aug 11 15:17:23 2009 +0200 @@ -42,6 +42,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -81,13 +82,34 @@ } @GET - @Path("games/{id}") + @Path("games/{id}/") public Viewable board(@PathParam("id") String id) throws JSONException { Object obj = convert(base.path("games").path(id).accept(MediaType.TEXT_PLAIN_TYPE).get(String.class)); return new Viewable("game.fmt", obj); } @GET + @Path("games/{id}/move") + public Viewable move( + @PathParam("id") String id, + @QueryParam("type") String type, + @QueryParam("direction") String direction, + @QueryParam("direction-next") @DefaultValue("") String directionNext, + @QueryParam("column") @DefaultValue("") String column, + @QueryParam("row") @DefaultValue("") String row + ) throws JSONException { + if (type.equals("fence")) { + base.path("games").path(id).queryParam("move", direction.charAt(0) + column + row).post(); + return board(id); + } + if (type.equals("move")) { + base.path("games").path(id).queryParam("move", direction + directionNext); + return board(id); + } + return board(id); + } + + @GET @Path("games/create") public Viewable create( @QueryParam("white") String white, diff -r c5726abc1218 -r 58b8db5faf2c freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt Tue Aug 11 14:51:47 2009 +0200 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt Tue Aug 11 15:17:23 2009 +0200 @@ -6,6 +6,51 @@

Game

+
+ + + + + +
+
+ + + + +
${model}
\ No newline at end of file diff -r c5726abc1218 -r 58b8db5faf2c freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt --- a/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Tue Aug 11 14:51:47 2009 +0200 +++ b/freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt Tue Aug 11 15:17:23 2009 +0200 @@ -9,7 +9,7 @@
    <#list model as item> -
  1. ${item.white} vs. ${item.black} board
  2. +
  3. ${item.white} vs. ${item.black} board