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