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