d20d725af1fe1873da2bf9353868133ec0c8fbf9
[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     unset($names[$randkey]);
115    }
116 ?>   
117    <h2> Rules </h2> 
118       
119       <p> ten of hearts: 
120          <ul>
121          <li> <input type="radio" name="dullen" value="none" /> just normal non-trump  </li>
122          <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
123          <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
124          </ul>
125       </p>
126       <p> schweinchen (both foxes): 
127         <ul>
128         <li> <input type="radio" name="schweinchen" value="none" /> none </li>
129         <li> <input type="radio" name="schweinchen" value="both" /> 
130               both become highest trump (automatic call at beginning of the game)
131               (does not work yet) </li>
132         <li> <input type="radio" name="schweinchen" value="second" checked="checked" /> 
133               first one normal, second one becomes highest (call during the game) (does not work yet) </li>
134         <li> <input type="radio" name="schweinchen" value="secondaftercall"  /> 
135              second one become highest only in case re/contra was announced 
136             (does not work yet)</li>
137       </ul>
138       </p>
139    
140    <input type="submit" value="start game" />
141  </form>
142 <?php
143 }
144
145 function display_card($card)
146 {
147   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ... 
148    * convert even cards to the matching odd value */
149
150   if( $card/2 - (int)($card/2) == 0.5)
151     echo "<img src=\"cards/".$card.".png\"  alt=\"".card_to_name($card)."\" />\n";
152   else
153     echo "<img src=\"cards/".($card-1).".png\"  alt=\"".card_to_name($card-1)."\" />\n";
154
155   return;
156 }
157
158 function display_link_card($card)
159 {
160   if( $card/2 - (int)($card/2) == 0.5)
161     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
162   else
163     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
164   return;
165 }
166
167 function check_for_sickness($me,$mycards)
168 {
169  ?>
170   <p> Solo will work, but the first player will not change. Nothing else implemented. </p>                
171
172   <form action="index.php" method="post">
173
174     do you want to play solo? 
175     <select name="solo" size="1">
176       <option selected="selected">No</option>
177       <option>trumpless</option>
178       <option>trump</option>
179       <option>queen</option>
180       <option>jack</option>
181       <option>club</option>
182       <option>spade</option>
183       <option>heart</option>
184     </select>     
185     <br />
186
187  <?php   
188       
189   echo "wedding?";
190   if(check_wedding($mycards))
191      {
192        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
193        echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
194      }
195    else
196      {
197        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
198      };
199
200   echo "do you have poverty?";
201   if(count_trump($mycards)<4)
202     {
203       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
204       echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
205     }
206   else
207     {
208       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
209     };
210
211    echo "do you have too many nines?";
212   if(count_nines($mycards)>4)
213      {
214        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
215        echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
216      }
217    else
218      {
219        echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
220      };
221
222    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
223    echo "<input type=\"submit\" value=\"count me in\" />\n";
224
225    echo "</form>\n";
226
227   return;
228 }
229
230 function check_want_to_play($me)
231 {
232    ?>
233  <form action="index.php" method="post">
234    Do you want to play a game of DoKo?
235    yes<input type="radio" name="in" value="yes" />
236    no<input type="radio" name="in" value="no" /> <br />
237
238 <?php   
239 /*
240    Do you want to get an email for every card played or only if it your move?
241    every card<input type="radio" name="update" value="card" />
242    only on my turn<input type="radio" name="update" value="turn" /> <br />
243 */
244   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
245   echo "\n";
246   echo "<input type=\"submit\" value=\"count me in\" />\n";
247   echo " </form>\n";
248
249   return;
250 }
251
252 function output_home_page()
253 {
254 ?>
255     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
256     <p> Please <a href="index.php?register">register</a>, in case you haven't done 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><td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
265               </tr><tr>
266                <td><label for="password">Password:</label></td><td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
267               </tr><tr>
268                <td> <input type="submit" value="login" /></td>
269              </table>
270           </fieldset>
271         </form>
272
273 <?php
274  return;
275 }
276
277 function output_header()
278 {
279    global $REV;
280 ?>
281 <!DOCTYPE html PUBLIC
282     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
283     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
284 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
285   <head>
286      <title>e-Doko</title>
287      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
288      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
289      <script type="text/javascript">
290        function hl(num) {
291          if(document.getElementById){
292            var i;
293            for(i=1;i<13;i++){
294              if(document.getElementById("trick"+i))
295                document.getElementById("trick"+i).style.display = 'none';
296            }
297            document.getElementById("trick"+num).style.display = 'block';
298          }
299        }
300        function high_last(){
301          if(document.getElementById){
302            var i;
303            for(i=12;i>0;i--) {
304              if(document.getElementById("trick"+i))
305                {
306                  hl(i);
307                  break;
308                }
309            }
310          }
311        }
312      </script>
313   </head>
314 <body onload="high_last();">
315 <div class="header">
316 <h1> Welcome to E-Doko </h1>
317 <p> Revision: <?php echo "$REV"; ?></p>
318 </div>
319
320 <?php
321   return;
322 }
323
324
325
326 function output_footer()
327 {
328   echo "</body>\n";
329   echo "</html>\n";
330
331   return;
332 }
333 ?>