FEATURE: added solo and now you also can only play cards that are valid on a trick
[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     "  added local time display, let me know what you think<br /><hr />\n".
20     "  If you find more bugs, please list them in the <a href=\"".$wiki.
21     "\">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()
87 {
88 ?>
89     <p>Please add 4 names, please make sure that the names are correct! </p>
90        <form action="index.php" method="post">
91    Name:  <input name="PlayerA" type="text" size="10" maxlength="20" /> 
92    Name:  <input name="PlayerB" type="text" size="10" maxlength="20" /> 
93    Name:  <input name="PlayerC" type="text" size="10" maxlength="20" /> 
94    Name:  <input name="PlayerD" type="text" size="10" maxlength="20" /> 
95
96    <input type="submit" value="start game" />
97  </form>
98 <?php
99 }
100
101 function display_card($card)
102 {
103   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ... 
104    * convert even cards to the matching odd value */
105
106   if( $card/2 - (int)($card/2) == 0.5)
107     echo "<img src=\"cards/".$card.".png\"  alt=\"".card_to_name($card)."\" />\n";
108   else
109     echo "<img src=\"cards/".($card-1).".png\"  alt=\"".card_to_name($card-1)."\" />\n";
110
111   return;
112 }
113
114 function display_link_card($card)
115 {
116   if( $card/2 - (int)($card/2) == 0.5)
117     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
118   else
119     echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
120   return;
121 }
122
123 function check_for_sickness($me,$mycards)
124 {
125  ?>
126   <p> nothing implemented so far, but give it a try anyway ;) </p>                
127
128   <form action="index.php" method="post">
129
130     do you want to play solo? 
131     <select name="solo" size="1">
132       <option selected="selected">No</option>
133       <option>trumpless</option>
134       <option>trump</option>
135       <option>queen</option>
136       <option>jack</option>
137       <option>club</option>
138       <option>spade</option>
139       <option>heart</option>
140     </select>     
141     <br />
142
143  <?php   
144       
145   echo "wedding?";
146   if(check_wedding($mycards))
147      {
148        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
149        echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
150      }
151    else
152      {
153        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
154      };
155
156   echo "do you have poverty?";
157   if(count_trump($mycards)<4)
158     {
159       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
160       echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
161     }
162   else
163     {
164       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
165     };
166
167    echo "do you have too many nines?";
168   if(count_nines($mycards)>4)
169      {
170        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
171        echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
172      }
173    else
174      {
175        echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
176      };
177
178    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
179    echo "<input type=\"submit\" value=\"count me in\" />\n";
180
181    echo "</form>\n";
182
183   return;
184 }
185
186 function check_want_to_play($me)
187 {
188    ?>
189  <form action="index.php" method="post">
190    Do you want to play a game of DoKo?
191    yes<input type="radio" name="in" value="yes" />
192    no<input type="radio" name="in" value="no" /> <br />
193
194    Do you want to get an email for every card played or only if it your move?
195    every card<input type="radio" name="update" value="card" />
196    only on my turn<input type="radio" name="update" value="turn" /> <br />
197 <?php   
198   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
199   echo "\n";
200   echo "<input type=\"submit\" value=\"count me in\" />\n";
201   echo " </form>\n";
202
203   return;
204 }
205
206 function output_home_page()
207 {
208 ?>
209     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
210     <p> Please <a href="index.php?register">register</a>, in case you haven't done yet  <br />
211         or login with you email-address or name and password here:
212     </p>
213         <form action="index.php" method="post">
214           <fieldset>
215             <legend>Login</legend>
216              <table>
217               <tr>
218                <td><label for="email">Email:</label></td><td><input type="text" id="email" name="email" size="20" maxlength="30" /> </td>
219               </tr><tr>
220                <td><label for="password">Password:</label></td><td><input type="password" id="password" name="password" size="20" maxlength="30" /></td>
221               </tr><tr>
222                <td> <input type="submit" value="login" /></td>
223              </table>
224           </fieldset>
225         </form>
226
227 <?php
228  return;
229 }
230
231 function output_header()
232 {
233 ?>
234 <!DOCTYPE html PUBLIC
235     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
236     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
237 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
238   <head>
239      <title>e-Doko</title>
240      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
241      <link rel="stylesheet" type="text/css" href="css/standard.css" />  
242      <script type="text/javascript">
243        function hl(num) {
244          if(document.getElementById){
245            var i;
246            for(i=1;i<13;i++){
247              if(document.getElementById("trick"+i))
248                document.getElementById("trick"+i).style.display = 'none';
249            }
250            document.getElementById("trick"+num).style.display = 'block';
251          }
252        }
253        function high_last(){
254          if(document.getElementById){
255            var i;
256            for(i=12;i>0;i--) {
257              if(document.getElementById("trick"+i))
258                {
259                  hl(i);
260                  break;
261                }
262            }
263          }
264        }
265      </script>
266   </head>
267 <body onload="high_last();">
268 <div class="header">
269 <h1> Welcome to E-Doko </h1>
270 </div>
271
272 <?php
273   return;
274 }
275
276
277
278 function output_footer()
279 {
280   echo "</body>\n";
281   echo "</html>\n";
282
283   return;
284 }
285 ?>