LAYOUT: address game by session.gamenr
[e-DoKo.git] / output.php
1 <?php
2
3 /* functions which only ouput html  */
4
5 function output_user_settings($email,$password)
6 {
7   global $PREF;
8
9   echo "<div class=\"useroptions\">\n";
10   echo "<h4> Settings </h4>\n";
11   echo "<a href=\"index.php?passwd=ask\">change password</a><br /";
12
13   if( $PREF["cardset"] == "english" )
14     echo "<a href=\"index.php?setpref=germancards\">use german cards</a><br />";
15   else
16     echo "<a href=\"index.php?setpref=englishcards\">use english cards</a> <br />";
17
18   echo "</div>\n";
19
20   return;
21 }
22
23 function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
24 {
25   global $RULES;
26
27   echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
28   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
29   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
30   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
31   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
32   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES["dullen"]."\" />\n";
33   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
34   echo "  <input type=\"hidden\" name=\"call\" value=\"".$RULES["call"]."\" />\n";
35   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
36   echo "  <input type=\"submit\" value=\"keep playing\" />\n";
37
38   return;
39 }
40
41 function output_form_for_new_game($names)
42 {
43 ?>
44     <h2> Players </h2>
45     <p>Please select four players (or use the randomly pre-selected names)</p>
46        <form action="index.php" method="post">
47 <?php
48     /* ask for player names */
49   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
50   {
51     srand((float) microtime() * 10000000);
52     $randkey = array_rand($names);
53     $rand = $names[$randkey];
54     echo "    Name:  <select name=\"$player\" size=\"1\" />  \n";
55     foreach($names as $name)
56     {
57       if($name==$rand)
58         {
59           echo "     <option selected=\"selected\">$name</option>\n";
60         }
61       else
62         echo "     <option>$name</option>\n";
63     }
64     echo "  </select>\n";
65    }
66 ?>   
67    <h2> Rules </h2> 
68       <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
69       <p> ten of hearts: 
70          <ul>
71          <li> <input type="radio" name="dullen" value="none" /> just normal non-trump  </li>
72          <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
73          <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
74          </ul>
75       </p>
76       <p> schweinchen (both foxes), only in normal games or silent solos: 
77         <ul>
78         <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
79         <li> <input type="radio" name="schweinchen" value="both" /> 
80               both become highest trump (automatic call at beginning of the game)
81         </li>
82         <li> <input type="radio" name="schweinchen" value="second" /> 
83               first one normal, second one becomes highest (call during the game) </li>
84         <li> <input type="radio" name="schweinchen" value="secondaftercall"  disabled="disabled" /> 
85       second one become highest only in case re/contra was announced (not working yet)
86         </li>
87         </ul>
88       </p>
89       <p> Call Re/Contra, etc.: 
90         <ul>
91            <li><input type="radio" name="call" value="1st-own-card" checked="checked" />
92                 Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
93            <li><input type="radio" name="call" value="5th-card" /> 
94                 Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
95            <li><input type="radio" name="call" value="9-cards"  /> 
96                 Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
97         </ul>
98       </p>      
99    <input type="submit" value="start game" />
100  </form>
101 <?php
102 }
103
104 function display_card($card,$dir="english")
105 {
106   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ... 
107    * convert even cards to the matching odd value */
108
109   if( $card/2 - (int)($card/2) == 0.5)
110     echo "<img src=\"cards/".$dir."/".$card.".png\"  alt=\"".DB_get_card_name($card)."\" />\n";
111   else
112     echo "<img src=\"cards/".$dir."/".($card-1).".png\"  alt=\"".DB_get_card_name($card-1)."\" />\n";
113
114   return;
115 }
116
117 function display_link_card($card,$dir="english",$type="card")
118 {
119   if( $card/2 - (int)($card/2) == 0.5)
120     echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n";
121   else
122     echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n";
123   return;
124 }
125
126 function output_check_for_sickness($me,$mycards)
127 {
128  ?>
129   <div class="sickness"> Thanks for joining the game...<br />
130
131     do you want to play solo? 
132     <select name="solo" size="1">
133       <option selected="selected">No</option>
134       <option>trumpless</option>
135       <option>trump</option>
136       <option>queen</option>
137       <option>jack</option>
138       <option>club</option>
139       <option>spade</option>
140       <option>heart</option>
141     </select>     
142     <br />
143
144  <?php   
145       
146   echo "Wedding?";
147   if(check_wedding($mycards))
148      {
149        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
150        echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
151      }
152    else
153      {
154        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
155      };
156
157   echo "Do you have poverty?";
158   if(count_trump($mycards)<4)
159     {
160       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
161       echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
162     }
163   else
164     {
165       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
166     };
167
168    echo "Do you have too many nines?";
169   if(count_nines($mycards)>4)
170      {
171        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
172        echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
173      }
174    else
175      {
176        echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
177      };
178
179    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
180    echo "<input type=\"submit\" value=\"count me in\" />\n";
181
182    echo "</div>\n";
183
184   return;
185 }
186
187 function output_form_calls($me)
188 {
189   if( can_call(120,$me) )
190     echo " re/contra (120):".
191       " <input type=\"radio\" name=\"call120\" value=\"yes\" /> <br />";
192   if( can_call(90,$me) )
193     echo " 90:".
194       " <input type=\"radio\" name=\"call90\" value=\"yes\" /> <br />";
195   if( can_call(60,$me) )
196     echo " 60:".
197       " <input type=\"radio\" name=\"call60\" value=\"yes\" /> <br />";
198   if( can_call(30,$me) )
199     echo " 30:".
200       " <input type=\"radio\" name=\"call30\" value=\"yes\" /> <br />";
201   if( can_call(0,$me) )
202     echo " 0:".
203       " <input type=\"radio\" name=\"call0\" value=\"yes\" /> <br />".
204       " no call:".
205       " <input type=\"radio\" name=\"call0\" value=\"no\" /> <br />";
206 }
207
208
209 function output_check_want_to_play($me)
210 {
211    ?>
212  <div class="joingame">
213    Do you want to play a game of DoKo? <br />
214    yes<input type="radio" name="in" value="yes" />
215    no<input type="radio" name="in" value="no" /> <br />
216 <?php   
217   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
218   echo "\n";
219   echo "<input type=\"submit\" value=\"submit\" />\n";
220   echo " </div>\n";
221
222   return;
223 }
224
225 function output_home_page($pre,$game,$done,$avgtime)
226 {
227 ?>
228     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
229 <?php
230     if($pre == 0)
231       echo "<p> At the moment there are no games that are being started ";
232     else if($pre==1)
233       echo "<p> At the moment there is one games that is being started ";
234     else
235       echo "<p> At the moment there are $pre games that are being started ";
236
237     echo "and ";
238
239     if($game==0)
240       echo "zero games that are ongoing. ";
241     else if($game==1)   
242       echo "one game that is ongoing. ";
243     else 
244       echo "$game games that are ongoing. ";
245
246     echo "<br />\n";
247
248     if($done==0)
249       echo "No game has been completed on this server. </p>";
250     else if($done==1)
251       echo "One game has been completed on this server. </p>";
252     else
253       echo "$done games have been completed on this server. Average time of a game: $avgtime days</p>";
254 ?>
255
256     <p> Please <a href="register.php">register</a>, in case you haven't done that yet  <br />
257         or login with you email-address or name and password here:
258     </p>
259         <form action="index.php" method="post">
260           <fieldset>
261             <legend>Login</legend>
262              <table>
263               <tr>
264                  <td><label for="email">Email:</label></td>
265                  <td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
266               </tr><tr>
267                  <td><label for="password">Password:</label></td>
268                  <td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
269               </tr><tr>
270                 <td> <input type="submit" class="submitbutton" name="login" value="login" /></td>
271                 <td> <input type="submit" class="submitbutton" name="forgot" value="Forgot your password?" /></td>
272               </tr>
273              </table>
274           </fieldset>
275         </form>
276
277 <?php
278  return;
279 }
280
281 function output_header()
282 {
283    global $REV;
284 ?>
285 <!DOCTYPE html PUBLIC
286     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
287     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
288 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
289   <head>
290      <title>e-Doko</title>
291      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
292      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
293      <script type="text/javascript">
294        function hl(num) {
295          if(document.getElementById){
296            var i;
297            for(i=1;i<14;i++){
298              if(document.getElementById("trick"+i))
299                document.getElementById("trick"+i).style.display = 'none';
300            }
301            document.getElementById("trick"+num).style.display = 'block';
302          }
303        }
304        function high_last(){
305          if(document.getElementById){
306            var i;
307            for(i=13;i>0;i--) {
308              if(document.getElementById("trick"+i))
309                {
310                  hl(i);
311                  break;
312                }
313            }
314          }
315        }
316      </script>
317   </head>
318 <body onload="high_last();">
319 <div class="header">
320 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
321 </div>
322 <div class="main">
323 <?php
324   return;
325 }
326
327 function output_footer()
328 {
329   global $REV,$PREF;
330
331   echo "</div>";
332   echo "<div class=\"footer\">\n";
333   echo "<p class=\"left\"> copyright 2006-2007 Arun Persaud <br />\n".
334     "Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />".
335     "- ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />".
336     "a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
337  echo "<p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">".
338     "via git </a> <br />or download the source via <br />'git clone http://nubati.net/git/e-DoKo.git' <br />".
339     "<a href=\"http://www.dreamhost.com/green.cgi\">".
340     "<img  border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
341     "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>".
342     "</p> \n";
343   echo "\n";
344   echo "</div>\n";
345
346   echo "</body>\n";
347   echo "</html>\n";
348
349   return;
350 }
351
352 function output_status($name)
353 {
354   echo "<div class=\"status\">\n";
355   echo $name;
356   echo " <a href=\"index.php?logout=1\">logout</a>\n";
357   echo "</div>";
358
359   return;
360 }
361
362
363 function output_password_recovery($email,$password)
364 {
365 ?>
366    <form action="index.php" method="post">
367 <?php
368   echo "  <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
369   echo "  <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
370   echo "  <input type=\"hidden\" name=\"passwd\"  value=\"set\" />\n";
371 ?>    
372      <fieldset>
373        <legend>Password recovery</legend>
374         <table>
375          <tr>
376             <td><label for="email">Old password:</label></td>
377             <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
378          </tr><tr>
379             <td><label for="password">New password:</label></td>
380             <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
381          </tr><tr>
382             <td><label for="password">Retype:</label></td>
383             <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
384          </tr><tr>
385            <td></td>
386            <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
387          </tr>
388         </table>
389      </fieldset>
390    </form>
391
392 <?php
393 }
394 ?>