55cf0a53dfe8db171e39d34b546887504fc174aa
[e-DoKo.git] / output.php
1 <?php
2
3 /* functions which only ouput html  */
4
5 function display_status($gametype)
6 {
7   echo "<div class=\"info\">";
8   echo " Gametype: $gametype";
9   echo "</div>\n";
10   
11   return;
12 }
13
14 function display_news()
15 {
16   global $wiki;
17   echo "<div class=\"bug\">\n".
18     "  Please hit <strong>shift+reload</strong>.<br /><hr />\n".
19     "  The server now keeps score... (only from now on) <br /><hr />".
20     "  If you find more bugs, please list them in the <a href=\"".
21     $wiki."\">wiki</a>.\n</div>\n";
22   return;
23 }
24
25 function output_link_to_user_page($email,$password)
26 {
27   echo "<div class=\"over\">\n";
28   echo "<form action=\"index.php\" method=\"post\">\n";
29   echo "  <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
30   echo "  <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
31   echo "  <input type=\"submit\" value=\"go to my user page\" />\n";
32   echo "</form>\n";
33   echo "</div>\n";
34   
35   return;
36 }
37
38 function output_register()
39 {
40   echo "IMPORTANT: passwords are going over the net as clear text, so pick an easy password. No need to pick anything complicated here ;)<br /><br />";
41   echo "TODO: convert timezone into a menu<br />\n";
42   echo "TODO: figure out a way to handle passwords <br />\n";
43   ?>
44         <form action="index.php" method="post">
45           <fieldset>
46             <legend>Register</legend>
47              <table>
48               <tr>
49                <td><label for="Rfullname">Full name:</label></td>
50                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
51               </tr><tr>
52                <td><label for="Remail">Email:</label></td>
53                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
54               </tr><tr>
55                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
56                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
57               </tr><tr>
58                <td><label for="Rtimezone">Timezone:</label></td>
59                <td>
60                   <input type="text" id="Rtimezone" name="Rtimezone" size="4" maxsize="4" value="+1" />
61                </td>
62               </tr><tr>
63                <td colspan="2"> <input type="submit" value="register" /></td>
64              </table>
65           </fieldset>
66         </form>
67 <?php
68   return;
69 }                                          
70
71 function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
72 {
73   global $RULES;
74
75   echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
76   echo "<form action=\"index.php\" method=\"post\">\n";
77   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
78   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
79   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
80   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
81   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES["dullen"]."\" />\n";
82   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
83   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
84   echo "  <input type=\"submit\" value=\"keep playing\" />\n";
85   echo "</form>\n";
86
87   return;
88 }
89
90 function output_form_for_new_game($names)
91 {
92 ?>
93     <h2> Players </h2>
94     <p>Please select four players (or use the randomly pre-selected names)</p>
95        <form action="index.php" method="post">
96 <?php
97     /* ask for player names */
98   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
99   {
100     srand((float) microtime() * 10000000);
101     $randkey = array_rand($names);
102     $rand = $names[$randkey];
103     echo "    Name:  <select name=\"$player\" size=\"1\" />  \n";
104     foreach($names as $name)
105     {
106       if($name==$rand)
107         {
108           echo "     <option selected=\"selected\">$name</option>\n";
109         }
110       else
111         echo "     <option>$name</option>\n";
112     }
113     echo "  </select>\n";
114    }
115 ?>   
116    <h2> Rules </h2> 
117       <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
118       <p> ten of hearts: 
119          <ul>
120          <li> <input type="radio" name="dullen" value="none" /> just normal non-trump  </li>
121          <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
122          <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
123          </ul>
124       </p>
125       <p> schweinchen (both foxes), only in normal games or silent solos: 
126         <ul>
127         <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
128         <li> <input type="radio" name="schweinchen" value="both" /> 
129               both become highest trump (automatic call at beginning of the game)
130         </li>
131         <li> <input type="radio" name="schweinchen" value="second" /> 
132               first one normal, second one becomes highest (call during the game) </li>
133         <li> <input type="radio" name="schweinchen" value="secondaftercall"  disabled="disabled" /> 
134       second one become highest only in case re/contra was announced (not working yet)
135         </li>
136         </ul>
137       </p>
138       
139    <input type="submit" value="start game" />
140  </form>
141 <?php
142 }
143
144 function display_card($card)
145 {
146   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ... 
147    * convert even cards to the matching odd value */
148
149   if( $card/2 - (int)($card/2) == 0.5)
150     echo "<img src=\"cards/".$card.".png\"  alt=\"".card_to_name($card)."\" />\n";
151   else
152     echo "<img src=\"cards/".($card-1).".png\"  alt=\"".card_to_name($card-1)."\" />\n";
153
154   return;
155 }
156
157 function display_link_card($card)
158 {
159   if( $card/2 - (int)($card/2) == 0.5)
160     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
161   else
162     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
163   return;
164 }
165
166 function check_for_sickness($me,$mycards)
167 {
168  ?>
169   <p> Solo will work, but the first player will not change. Nothing else implemented. </p>                
170
171   <form action="index.php" method="post">
172
173     do you want to play solo? 
174     <select name="solo" size="1">
175       <option selected="selected">No</option>
176       <option>trumpless</option>
177       <option>trump</option>
178       <option>queen</option>
179       <option>jack</option>
180       <option>club</option>
181       <option>spade</option>
182       <option>heart</option>
183     </select>     
184     <br />
185
186  <?php   
187       
188   echo "wedding?";
189   if(check_wedding($mycards))
190      {
191        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
192        echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
193      }
194    else
195      {
196        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
197      };
198
199   echo "do you have poverty?";
200   if(count_trump($mycards)<4)
201     {
202       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
203       echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
204     }
205   else
206     {
207       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
208     };
209
210    echo "do you have too many nines?";
211   if(count_nines($mycards)>4)
212      {
213        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
214        echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
215      }
216    else
217      {
218        echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
219      };
220
221    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
222    echo "<input type=\"submit\" value=\"count me in\" />\n";
223
224    echo "</form>\n";
225
226   return;
227 }
228
229 function check_want_to_play($me)
230 {
231    ?>
232  <form action="index.php" method="post">
233    Do you want to play a game of DoKo?
234    yes<input type="radio" name="in" value="yes" />
235    no<input type="radio" name="in" value="no" /> <br />
236
237 <?php   
238 /*
239    Do you want to get an email for every card played or only if it your move?
240    every card<input type="radio" name="update" value="card" />
241    only on my turn<input type="radio" name="update" value="turn" /> <br />
242 */
243   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
244   echo "\n";
245   echo "<input type=\"submit\" value=\"count me in\" />\n";
246   echo " </form>\n";
247
248   return;
249 }
250
251 function output_home_page()
252 {
253 ?>
254     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
255     <p> Please <a href="index.php?register">register</a>, in case you haven't done yet  <br />
256         or login with you email-address or name and password here:
257     </p>
258         <form action="index.php" method="post">
259           <fieldset>
260             <legend>Login</legend>
261              <table>
262               <tr>
263                  <td><label for="email">Email:</label></td>
264                  <td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
265               </tr><tr>
266                  <td><label for="password">Password:</label></td>
267                  <td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
268               </tr><tr>
269                 <td> <input type="submit" value="login" /></td>
270                 <td></td>
271               </tr>
272              </table>
273           </fieldset>
274         </form>
275
276 <?php
277  return;
278 }
279
280 function output_header()
281 {
282    global $REV;
283 ?>
284 <!DOCTYPE html PUBLIC
285     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
286     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
287 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
288   <head>
289      <title>e-Doko</title>
290      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
291      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
292      <script type="text/javascript">
293        function hl(num) {
294          if(document.getElementById){
295            var i;
296            for(i=1;i<13;i++){
297              if(document.getElementById("trick"+i))
298                document.getElementById("trick"+i).style.display = 'none';
299            }
300            document.getElementById("trick"+num).style.display = 'block';
301          }
302        }
303        function high_last(){
304          if(document.getElementById){
305            var i;
306            for(i=12;i>0;i--) {
307              if(document.getElementById("trick"+i))
308                {
309                  hl(i);
310                  break;
311                }
312            }
313          }
314        }
315      </script>
316   </head>
317 <body onload="high_last();">
318 <div class="header">
319 <h1> Welcome to E-Doko </h1>
320 <p> Revision: <?php echo "$REV"; ?></p>
321 </div>
322
323 <?php
324   return;
325 }
326
327
328
329 function output_footer()
330 {
331   echo "</body>\n";
332   echo "</html>\n";
333
334   return;
335 }
336 ?>