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