feature request: show complete hand for completed games
[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 passwrods <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   echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
74   echo "<form action=\"index.php\" method=\"post\">\n";
75   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
76   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
77   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
78   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
79   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
80   echo "  <input type=\"submit\" value=\"keep playing\" />\n";
81   echo "</form>\n";
82
83   return;
84 }
85
86 function output_form_for_new_game($names)
87 {
88 ?>
89     <p>Please select four players (or use the randomly pre-selected names)</p>
90        <form action="index.php" method="post">
91 <?php
92   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
93   {
94     srand((float) microtime() * 10000000);
95     $randkey = array_rand($names);
96     $rand = $names[$randkey];
97     echo "    Name:  <select name=\"$player\" size=\"1\" />  \n";
98     foreach($names as $name)
99     {
100       if($name==$rand)
101         {
102           echo "     <option selected=\"selected\">$name</option>\n";
103         }
104       else
105         echo "     <option>$name</option>\n";
106     }
107     echo "  </select>\n";
108     unset($names[$randkey]);
109    }
110 ?>   
111
112    <input type="submit" value="start game" />
113  </form>
114 <?php
115 }
116
117 function display_card($card)
118 {
119   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ... 
120    * convert even cards to the matching odd value */
121
122   if( $card/2 - (int)($card/2) == 0.5)
123     echo "<img src=\"cards/".$card.".png\"  alt=\"".card_to_name($card)."\" />\n";
124   else
125     echo "<img src=\"cards/".($card-1).".png\"  alt=\"".card_to_name($card-1)."\" />\n";
126
127   return;
128 }
129
130 function display_link_card($card)
131 {
132   if( $card/2 - (int)($card/2) == 0.5)
133     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
134   else
135     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
136   return;
137 }
138
139 function check_for_sickness($me,$mycards)
140 {
141  ?>
142   <p> Solo will work, but the first player will not change. Nothing else implemented. </p>                
143
144   <form action="index.php" method="post">
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 "</form>\n";
198
199   return;
200 }
201
202 function check_want_to_play($me)
203 {
204    ?>
205  <form action="index.php" method="post">
206    Do you want to play a game of DoKo?
207    yes<input type="radio" name="in" value="yes" />
208    no<input type="radio" name="in" value="no" /> <br />
209
210    Do you want to get an email for every card played or only if it your move?
211    every card<input type="radio" name="update" value="card" />
212    only on my turn<input type="radio" name="update" value="turn" /> <br />
213 <?php   
214   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
215   echo "\n";
216   echo "<input type=\"submit\" value=\"count me in\" />\n";
217   echo " </form>\n";
218
219   return;
220 }
221
222 function output_home_page()
223 {
224 ?>
225     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
226     <p> Please <a href="index.php?register">register</a>, in case you haven't done yet  <br />
227         or login with you email-address or name and password here:
228     </p>
229         <form action="index.php" method="post">
230           <fieldset>
231             <legend>Login</legend>
232              <table>
233               <tr>
234                <td><label for="email">Email:</label></td><td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
235               </tr><tr>
236                <td><label for="password">Password:</label></td><td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
237               </tr><tr>
238                <td> <input type="submit" value="login" /></td>
239              </table>
240           </fieldset>
241         </form>
242
243 <?php
244  return;
245 }
246
247 function output_header()
248 {
249    global $REV;
250 ?>
251 <!DOCTYPE html PUBLIC
252     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
253     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
254 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
255   <head>
256      <title>e-Doko</title>
257      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
258      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
259      <script type="text/javascript">
260        function hl(num) {
261          if(document.getElementById){
262            var i;
263            for(i=1;i<13;i++){
264              if(document.getElementById("trick"+i))
265                document.getElementById("trick"+i).style.display = 'none';
266            }
267            document.getElementById("trick"+num).style.display = 'block';
268          }
269        }
270        function high_last(){
271          if(document.getElementById){
272            var i;
273            for(i=12;i>0;i--) {
274              if(document.getElementById("trick"+i))
275                {
276                  hl(i);
277                  break;
278                }
279            }
280          }
281        }
282      </script>
283   </head>
284 <body onload="high_last();">
285 <div class="header">
286 <h1> Welcome to E-Doko </h1>
287 <p> Revision: <?php echo "$REV"; ?></p>
288 </div>
289
290 <?php
291   return;
292 }
293
294
295
296 function output_footer()
297 {
298   echo "</body>\n";
299   echo "</html>\n";
300
301   return;
302 }
303 ?>