2 /* make sure that we are not called from outside the scripts,
3 * use a variable defined in config.php to check this
8 /* functions which only ouput html */
10 function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
14 echo "<div class=\"message\">\n<form action=\"index.php?action=new\" method=\"post\">\n";
15 echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
16 echo " <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
17 echo " <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
18 echo " <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
19 echo " <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
20 echo " <input type=\"hidden\" name=\"dullen\" value=\"".$RULES["dullen"]."\" />\n";
21 echo " <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
22 echo " <input type=\"hidden\" name=\"callrule\" value=\"".$RULES["call"]."\" />\n";
23 echo " <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
24 echo " <input type=\"submit\" value=\"keep playing\" />\n";
25 echo "</form>\n</div>";
29 function output_form_for_new_game($names)
33 <p>Please select four players (or use the randomly pre-selected names)</p>
34 <p>Remember: you need to be one of the players ;) </p>
35 <form action="index.php?action=new" method="post">
38 <img src="pics/table.png" alt="table" />
40 /* ask for player names */
42 foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
44 srand((float) microtime() * 10000000);
45 $randkey = array_rand($names);
46 $rand = $names[$randkey];
47 echo "<div class=\"table".$i."\">\n";
49 echo " Name: \n <select name=\"$player\" size=\"1\" /> \n";
50 foreach($names as $name)
54 echo " <option selected=\"selected\">$name</option>\n";
57 echo " <option>$name</option>\n";
59 echo " </select>\n</div>\n";
63 <h2 class="rules"> Rules </h2>
64 <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
67 <li> <input type="radio" name="dullen" value="none" /> just normal non-trump </li>
68 <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
69 <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
72 <p> Schweinchen (both foxes), only in normal games or silent solos:
74 <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
75 <li> <input type="radio" name="schweinchen" value="both" />
76 both become highest trump (automatic call at beginning of the game)
78 <li> <input type="radio" name="schweinchen" value="second" />
79 first one normal, second one becomes highest (call during the game) </li>
80 <li> <input type="radio" name="schweinchen" value="secondaftercall" disabled="disabled" />
81 second one become highest only in case re/contra was announced (not working yet)
85 <p> Call Re/Contra, etc.:
87 <li><input type="radio" name="callrule" value="1st-own-card" checked="checked" />
88 Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
89 <li><input type="radio" name="callrule" value="5th-card" />
90 Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
91 <li><input type="radio" name="callrule" value="9-cards" />
92 Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
95 <input type="submit" value="start game" />
100 function display_card($card,$dir="english")
102 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
103 * convert even cards to the matching odd value */
105 if( $card/2 - (int)($card/2) == 0.5)
106 echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" />\n";
108 echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" />\n";
113 function display_link_card($card,$dir="english",$type="card")
115 if( $card/2 - (int)($card/2) == 0.5)
116 echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n";
118 echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n";
122 function output_check_for_sickness($me,$mycards)
125 <div class="sickness"> Thanks for joining the game...<br />
127 do you want to play solo?
128 <select name="solo" size="1">
129 <option selected="selected">No</option>
130 <option>trumpless</option>
131 <option>trump</option>
132 <option>queen</option>
133 <option>jack</option>
134 <option>club</option>
135 <option>spade</option>
136 <option>heart</option>
143 if(check_wedding($mycards))
145 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
146 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
150 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
153 echo "Do you have poverty?";
154 if(count_trump($mycards)<4)
156 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
157 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
161 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
164 echo "Do you have too many nines?";
165 if(count_nines($mycards)>4)
167 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
168 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
172 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
175 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
176 echo "<input type=\"submit\" value=\"count me in\" />\n";
183 function output_form_calls($me)
185 if( can_call(120,$me) )
186 echo " re/contra (120):".
187 " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
188 if( can_call(90,$me) )
190 " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
191 if( can_call(60,$me) )
193 " <input type=\"radio\" name=\"call\" value=\"60\" /> <br />";
194 if( can_call(30,$me) )
196 " <input type=\"radio\" name=\"call\" value=\"30\" /> <br />";
197 if( can_call(0,$me) )
199 " <input type=\"radio\" name=\"call\" value=\"0\" /> <br />".
201 " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
204 function output_check_want_to_play($me)
207 <div class="joingame">
208 Do you want to play a game of DoKo? <br />
209 yes<input type="radio" name="in" value="yes" />
210 no<input type="radio" name="in" value="no" /> <br />
212 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
214 echo "<input type=\"submit\" value=\"submit\" />\n";
220 function output_header()
224 <!DOCTYPE html PUBLIC
225 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
226 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
227 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
229 <title>e-Doko</title>
230 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
231 <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
232 <link rel="stylesheet" type="text/css" href="css/standard001.css" />
233 <script type="text/javascript">
235 if(document.getElementById){
238 if(document.getElementById("trick"+i))
239 document.getElementById("trick"+i).style.display = 'none';
241 document.getElementById("trick"+num).style.display = 'block';
244 function high_last(){
245 if(document.getElementById){
248 if(document.getElementById("trick"+i))
258 <body onload="high_last();">
260 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
264 echo "<div class=\"main\">";
268 function output_footer()
273 echo "<div class=\"footer\">\n";
274 echo " <p class=\"left\"> copyright 2006-2008 Arun Persaud, Lance Thornton <br />\n".
275 " Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
276 " - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
277 " a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
278 echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
279 " via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
280 " <a href=\"http://www.dreamhost.com/green.cgi\">\n".
281 " <img border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
282 "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
293 function output_status()
295 global $defaulttimezone;
296 if(isset($_SESSION["name"]))
298 $name = $_SESSION["name"];
301 echo "\n<div class=\"status\">";
303 echo " <a href=\"index.php?action=logout\">logout</a>";
306 /* last logon time */
307 $myid = DB_get_userid("name",$name);
308 $zone = DB_get_user_timezone($myid);
310 $time = DB_get_user_timestamp($myid);
311 date_default_timezone_set($defaulttimezone);
312 $unixtime = strtotime($time);
313 date_default_timezone_set($zone);
315 echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>\n";
320 function output_select_timezone($name,$timezone="")
322 $Tzone = array ( "Europe/London" => "London",
323 "Europe/Berlin" => "Berlin",
324 "America/Vancouver" => "Berkeley",
325 "Pacific/Auckland" => "Wellington" );
327 echo " <select id=\"$name\" name=\"$name\" size=\"1\">\n";
329 foreach($Tzone as $zone=>$city)
332 echo " <option value=\"$zone\" selected=\"selected\">$city</option>\n";
334 echo " <option value=\"$zone\">$city</option>\n";
343 function output_password_recovery($email,$password)
346 <form action="index.php" method="post">
348 echo " <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
349 echo " <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
350 echo " <input type=\"hidden\" name=\"passwd\" value=\"set\" />\n";
353 <legend>Password recovery</legend>
356 <td><label for="email">Old password:</label></td>
357 <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
359 <td><label for="password">New password:</label></td>
360 <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
362 <td><label for="password">Retype:</label></td>
363 <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
366 <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>