freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 19 Sep 2009 12:51:50 +0200
changeset 99 fed05535725f
parent 98 37ac8eb59b1b
child 100 8b899ed24f9f
permissions -rw-r--r--
Describing how many fences are left in the page header
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     2 <html>
     3   <head>
     4     <title>
     5       <#if user = doc.game.@currentPlayer>
     6          ${bundle.YourTurn}
     7       <#else>
     8          ${bundle("Waiting", doc.game.@currentPlayer?string)}
     9       </#if>
    10     </title>
    11     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    12     <#if user != doc.game.@currentPlayer >
    13         <meta http-equiv="REFRESH" content="60;URL=/games/${doc.game.id.@id}">
    14     </#if>
    15   </head>
    16   <body>
    17       <h1><a href="/games/${doc.game.id.@id}">${bundle.GAME}</a></h1>
    18 
    19       <#macro status who>
    20           ${who?string}
    21           <#if who = doc.game.@currentPlayer>
    22               <#if doc.game.id.@status = "whiteWon" || doc.game.id.@status = "blackWon" >
    23                 - ${bundle.HAS_WON}
    24               <#else>
    25                 - ${bundle.TO_MOVE}
    26               </#if>
    27           </#if>
    28       </#macro>
    29 
    30 
    31       <p>
    32           <b>${bundle.WHITE}:</b> <@status doc.game.id.@white/> ${bundle("FENCES_LEFT", board.players[0].fences)}<br>
    33           <b>${bundle.BLACK}:</b> <@status doc.game.id.@black/> ${bundle("FENCES_LEFT", board.players[1].fences)}<br>
    34       </p>
    35 
    36       <p>
    37       <a href="/">${bundle.ROOT}</a>
    38       </p>
    39       
    40       <#if message?? >
    41         <p>
    42             <span style="color: red">${message}</span>
    43         </p>
    44       </#if>
    45 
    46       <#assign play = false>
    47 
    48       <#if doc.game.id.@status = "whiteMove" || doc.game.id.@status = "blackMove" >
    49           <#assign play = user = doc.game.@currentPlayer>
    50       </#if>
    51       <#if  play>
    52           <form action="/games/${doc.game.id.@id}/move">
    53               <input type="hidden" name="type" value="fence" readonly="readonly"/>
    54               <select name="column">
    55                   <option>A</option>
    56                   <option>B</option>
    57                   <option>C</option>
    58                   <option>D</option>
    59                   <option>E</option>
    60                   <option>F</option>
    61                   <option>G</option>
    62                   <option>H</option>
    63               </select>
    64               <select name="row">
    65                   <option>1</option>
    66                   <option>2</option>
    67                   <option>3</option>
    68                   <option>4</option>
    69                   <option>5</option>
    70                   <option>6</option>
    71                   <option>7</option>
    72                   <option>8</option>
    73               </select>
    74               <select name="direction">
    75                   <option>${bundle.H}</option>
    76                   <option>${bundle.V}</option>
    77               </select>
    78               <input type="submit" value="${bundle.PLACE}" />
    79           </form>
    80           <form action="/games/${doc.game.id.@id}/move">
    81               <input type="hidden" name="type" value="move" readonly="readonly"/>
    82               <select name="direction">
    83                   <option>E</option>
    84                   <option>W</option>
    85                   <option>N</option>
    86                   <option>S</option>
    87               </select>
    88               <select name="direction-next">
    89                   <option></option>
    90                   <option>E</option>
    91                   <option>W</option>
    92                   <option>N</option>
    93                   <option>S</option>
    94               </select>
    95               <input type="submit" value="${bundle.MOVE}" />
    96           </form>
    97           <form action="/games/${doc.game.id.@id}/move">
    98               <input type="hidden" name="type" value="resign" readonly="readonly"/>
    99               <input type="submit" value="${bundle.RESIGN}" />
   100           </form>
   101       </#if>
   102 
   103       <#if format?? && format = "text">
   104         <pre>${doc.game.board}</pre>
   105         <a href="/games/${doc.game.id.@id}?format=image">${bundle.BOARD_IMAGE}</a>
   106       <#else>
   107         <p>
   108         <img src="/api/games/${doc.game.id.@id}" alt="text">
   109         </p>
   110         <a href="/games/${doc.game.id.@id}?format=text">${bundle.BOARD_TEXT}</a>
   111 
   112       </#if>
   113 
   114 
   115       <h3>${bundle.MOVES}</h3>
   116 
   117       <table border="0">
   118           <thead>
   119               <tr>
   120                   <th>${bundle.MOVENUMBER}</th>
   121                   <th>${doc.game.id.@white}</th>
   122                   <th>${doc.game.id.@black}</th>
   123               </tr>
   124           </thead>
   125           <tbody>
   126               <#assign index = 0>
   127               <#list doc.game.moves.* as item>
   128                 <#if item.@index?number % 2 = 1>
   129                     <#assign index = index + 1>
   130                     <tr><td>${index}</td><td>${item.@move}</td>
   131                 <#else>
   132                     <td>${item.@move}</td></tr>
   133                 </#if>
   134               </#list>
   135           </tbody>
   136       </table>
   137       <hr/>
   138       ${bundle("copyright", version)}
   139   </body>
   140 </html>