freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/game.fmt
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 19 Sep 2009 14:38:29 +0200
changeset 100 8b899ed24f9f
parent 99 fed05535725f
child 105 6e55d5c85d3c
permissions -rw-r--r--
Browsable history of each game
     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.MOVENUMBER}: </b> ${(doc.game.@currentMove?number / 2 + 1)?string("0")}<br>
    33           <b>${bundle.WHITE}:</b> <@status doc.game.id.@white/> ${bundle("FENCES_LEFT", board.players[0].fences)}<br>
    34           <b>${bundle.BLACK}:</b> <@status doc.game.id.@black/> ${bundle("FENCES_LEFT", board.players[1].fences)}<br>
    35       </p>
    36 
    37       <p>
    38       <a href="/">${bundle.ROOT}</a>
    39       <#if (doc.game.@currentMove?number > 0)>
    40         <a href="/games/${doc.game.id.@id}?move=${doc.game.@currentMove?number - 1}">${bundle.PREVIOUS}</a>
    41       <#else>
    42         ${bundle.PREVIOUS}
    43       </#if>
    44       <a href="/games/${doc.game.id.@id}"">${bundle.LATEST}</a>
    45       <#if (doc.game.@currentMove?number < doc.game.moves.*?size)>
    46         <a href="/games/${doc.game.id.@id}?move=${doc.game.@currentMove?number + 1}">${bundle.NEXT}</a>
    47       <#else>
    48         ${bundle.NEXT}
    49       </#if>
    50       </p>
    51       
    52       <#if message?? >
    53         <p>
    54             <span style="color: red">${message}</span>
    55         </p>
    56       </#if>
    57 
    58       <#assign play = false>
    59 
    60       <#if doc.game.id.@status = "whiteMove" || doc.game.id.@status = "blackMove" >
    61           <#assign play = user = doc.game.@currentPlayer>
    62       </#if>
    63       <#if  play>
    64           <form action="/games/${doc.game.id.@id}/move">
    65               <input type="hidden" name="type" value="fence" readonly="readonly"/>
    66               <select name="column">
    67                   <option>A</option>
    68                   <option>B</option>
    69                   <option>C</option>
    70                   <option>D</option>
    71                   <option>E</option>
    72                   <option>F</option>
    73                   <option>G</option>
    74                   <option>H</option>
    75               </select>
    76               <select name="row">
    77                   <option>1</option>
    78                   <option>2</option>
    79                   <option>3</option>
    80                   <option>4</option>
    81                   <option>5</option>
    82                   <option>6</option>
    83                   <option>7</option>
    84                   <option>8</option>
    85               </select>
    86               <select name="direction">
    87                   <option>${bundle.H}</option>
    88                   <option>${bundle.V}</option>
    89               </select>
    90               <input type="submit" value="${bundle.PLACE}" />
    91           </form>
    92           <form action="/games/${doc.game.id.@id}/move">
    93               <input type="hidden" name="type" value="move" readonly="readonly"/>
    94               <select name="direction">
    95                   <option>E</option>
    96                   <option>W</option>
    97                   <option>N</option>
    98                   <option>S</option>
    99               </select>
   100               <select name="direction-next">
   101                   <option></option>
   102                   <option>E</option>
   103                   <option>W</option>
   104                   <option>N</option>
   105                   <option>S</option>
   106               </select>
   107               <input type="submit" value="${bundle.MOVE}" />
   108           </form>
   109           <form action="/games/${doc.game.id.@id}/move">
   110               <input type="hidden" name="type" value="resign" readonly="readonly"/>
   111               <input type="submit" value="${bundle.RESIGN}" />
   112           </form>
   113       </#if>
   114       <p>
   115       ${bundle.BOARD_VIEW}
   116       <#if format?? && format = "text">
   117         <pre>${doc.game.board}</pre>
   118         <a href="/games/${doc.game.id.@id}?format=small">${bundle.BOARD_SMALL}</a>
   119         <a href="/games/${doc.game.id.@id}?format=image">${bundle.BOARD_IMAGE}</a>
   120         ${bundle.BOARD_TEXT}
   121       <#elseif format?? && format = "small">
   122         <p>
   123             <img src="/api/games/${doc.game.id.@id}?fieldSize=20<#if doc.game.@currentMove??>&move=${doc.game.@currentMove}</#if>" alt="${bundle.BOARD_TEXT}">
   124         </p>
   125         ${bundle.BOARD_SMALL}
   126         <a href="/games/${doc.game.id.@id}?format=image">${bundle.BOARD_IMAGE}</a>
   127         <a href="/games/${doc.game.id.@id}?format=text">${bundle.BOARD_TEXT}</a>
   128       <#else>
   129         <p>
   130             <img src="/api/games/${doc.game.id.@id}<#if doc.game.@currentMove??>?move=${doc.game.@currentMove}</#if>" alt="${bundle.BOARD_TEXT}">
   131         </p>
   132         <a href="/games/${doc.game.id.@id}?format=small">${bundle.BOARD_SMALL}</a>
   133         ${bundle.BOARD_IMAGE}
   134         <a href="/games/${doc.game.id.@id}?format=text">${bundle.BOARD_TEXT}</a>
   135       </#if>
   136 
   137       <#macro printMove item>
   138         <#if item.@index = doc.game.@currentMove>
   139             <b>${item.@move}</b>
   140         <#else>
   141             <a href="/games/${doc.game.id.@id}?move=${item.@index}">${item.@move}</a>
   142         </#if>
   143       </#macro>
   144 
   145       <h3><a href="/games/${doc.game.id.@id}?move=0">${bundle.MOVES}</a></h3>
   146 
   147       <table border="0">
   148           <thead>
   149               <tr>
   150                   <th>${bundle.MOVENUMBER}</th>
   151                   <th>${doc.game.id.@white}</th>
   152                   <th>${doc.game.id.@black}</th>
   153               </tr>
   154           </thead>
   155           <tbody>
   156               <#assign index = 0>
   157               <#list doc.game.moves.* as item>
   158                 
   159                 <#if item.@index?number % 2 = 1>
   160                     <#assign index = index + 1>
   161                     <tr><td>${index}</td><td><@printMove item/></td>
   162                 <#else>
   163                     <td><@printMove item/></td></tr>
   164                 </#if>
   165               </#list>
   166           </tbody>
   167       </table>
   168       <hr/>
   169       ${bundle("copyright", version)}
   170   </body>
   171 </html>