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)
32 <form action="index.php?action=new" method="post">
33 <h2> Select players (Remember: you need to be one of the players) </h2>
36 <img class="table" src="pics/table.png" alt="table" />
38 /* ask for player names */
40 foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
42 srand((float) microtime() * 10000000);
43 $randkey = array_rand($names);
44 $rand = $names[$randkey];
45 echo " <div class=\"table".$i."\">\n";
47 echo " <select name=\"$player\" size=\"1\"> \n";
48 foreach($names as $name)
52 echo " <option selected=\"selected\">$name</option>\n";
55 echo " <option>$name</option>\n";
57 echo " </select>\n </div>\n";
62 <h2 class="rules"> Rules </h2>
63 <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
64 <p> Ten of hearts: </p>
66 <li> <input type="radio" name="dullen" value="none" /> just normal non-trump </li>
67 <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
68 <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
70 <p> Schweinchen (both foxes), only in normal games or silent solos: </p>
72 <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
73 <li> <input type="radio" name="schweinchen" value="both" />
74 both become highest trump (automatic call at beginning of the game)
76 <li> <input type="radio" name="schweinchen" value="second" />
77 first one normal, second one becomes highest (call during the game) </li>
78 <li> <input type="radio" name="schweinchen" value="secondaftercall" disabled="disabled" />
79 second one become highest only in case re/contra was announced (not working yet)
82 <p> Call Re/Contra, etc.: </p>
84 <li><input type="radio" name="callrule" value="1st-own-card" checked="checked" />
85 Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
86 <li><input type="radio" name="callrule" value="5th-card" />
87 Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
88 <li><input type="radio" name="callrule" value="9-cards" />
89 Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
91 <input type="submit" value="start game" />
96 function output_table($data,$caption="",$class="")
99 $HTML = "\n<table class=\"$class\">\n";
101 $HTML = "\n<table>\n";
106 $HTML .= " <caption> $caption </caption>\n";
108 foreach($data as $record)
111 $HTML .= " <thead>\n <tr>\n";
114 if($i==1) $HTML .= " <tbody>\n";
116 $HTML .= " <tr class=\"odd\"> ";
118 $HTML .= " <tr class=\"even\"> ";
120 foreach($record as $point)
123 $HTML .= " <td>$point</td> ";
125 $HTML .= " <th>$point</th> ";
129 $HTML .= " </tr>\n </thead>\n";
136 $HTML .= " </tbody>\n</table>\n";
141 function display_card($card,$dir="english")
143 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
144 * convert even cards to the matching odd value */
146 if( $card/2 - (int)($card/2) == 0.5)
147 echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" />\n";
149 echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" />\n";
154 function display_link_card($card,$dir="english",$type="card")
156 if( $card/2 - (int)($card/2) == 0.5)
157 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";
159 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";
163 function output_check_for_sickness($me,$mycards)
166 <div class="sickness"> Thanks for joining the game...<br />
168 do you want to play solo?
169 <select name="solo" size="1">
170 <option selected="selected">No</option>
171 <option>trumpless</option>
172 <option>trump</option>
173 <option>queen</option>
174 <option>jack</option>
175 <option>club</option>
176 <option>spade</option>
177 <option>heart</option>
184 if(check_wedding($mycards))
186 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
187 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
191 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
194 echo "Do you have poverty?";
195 if(count_trump($mycards)<4)
197 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
198 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
202 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
205 echo "Do you have too many nines?";
206 if(count_nines($mycards)>4)
208 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
209 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
213 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
216 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
217 echo "<input type=\"submit\" value=\"count me in\" />\n";
224 function output_form_calls($me)
226 if( can_call(120,$me) )
227 echo " re/contra (120):".
228 " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
229 if( can_call(90,$me) )
231 " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
232 if( can_call(60,$me) )
234 " <input type=\"radio\" name=\"call\" value=\"60\" /> <br />";
235 if( can_call(30,$me) )
237 " <input type=\"radio\" name=\"call\" value=\"30\" /> <br />";
238 if( can_call(0,$me) )
240 " <input type=\"radio\" name=\"call\" value=\"0\" /> <br />".
242 " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
245 function output_check_want_to_play($me)
248 <div class="joingame">
249 Do you want to play a game of DoKo? <br />
250 yes<input type="radio" name="in" value="yes" />
251 no<input type="radio" name="in" value="no" /> <br />
253 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
255 echo "<input type=\"submit\" value=\"submit\" />\n";
261 function output_header()
265 <!DOCTYPE html PUBLIC
266 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
267 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
268 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
270 <title>e-Doko</title>
271 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
272 <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
273 <link rel="stylesheet" type="text/css" href="css/standard009.css" />
274 <script type="text/javascript">
277 if(document.getElementById){
280 if(document.getElementById("trick"+i))
281 document.getElementById("trick"+i).style.display = 'none';
283 document.getElementById("trick"+num).style.display = 'block';
287 function high_last(){
288 if(document.getElementById){
291 if(document.getElementById("trick"+i))
302 if(document.getElementById("trick"+(current+1)))
307 if(document.getElementById("trick"+(current-1)))
312 <body onload="high_last();">
314 <h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
318 echo "<div class=\"main\">";
322 function output_footer()
327 echo "<div class=\"footer\">\n";
328 echo " <p class=\"left\"> copyright 2006-2008 Arun Persaud, Lance Thornton <br />\n".
329 " Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
330 " - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
331 " a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
332 echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
333 " via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
334 " <a href=\"http://www.dreamhost.com/green.cgi\">\n".
335 " <img border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
336 "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
347 function output_status()
349 global $defaulttimezone,$INDEX,$WIKI;
350 if(isset($_SESSION["name"]))
352 $name = $_SESSION["name"];
355 echo "\n<div class=\"status\">\n";
357 echo " | <a href=\"".$INDEX."\"> mypage </a>\n";
358 echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n";
359 echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n";
360 echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n";
361 echo " | <a href=\"".$WIKI."\">wiki</a>\n";
362 echo " | <a href=\"".$INDEX."?action=logout\">logout</a>\n";
365 /* last logon time */
366 $myid = DB_get_userid("name",$name);
367 $zone = DB_get_user_timezone($myid);
369 $time = DB_get_user_timestamp($myid);
370 date_default_timezone_set($defaulttimezone);
371 $unixtime = strtotime($time);
372 date_default_timezone_set($zone);
374 echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n";
378 echo "\n<div class=\"status\">\n";
379 echo "<a href=\"".$INDEX."\">login</a>\n";
385 function output_select_timezone($name,$timezone="")
387 $Tzone = array ( "Europe/London" => "London",
388 "Europe/Berlin" => "Berlin",
389 "America/Vancouver" => "Berkeley",
390 "Pacific/Auckland" => "Wellington" );
392 echo " <select id=\"$name\" name=\"$name\" size=\"1\">\n";
394 foreach($Tzone as $zone=>$city)
397 echo " <option value=\"$zone\" selected=\"selected\">$city</option>\n";
399 echo " <option value=\"$zone\">$city</option>\n";
406 function output_password_recovery($email,$password)
409 <form action="index.php" method="post">
411 echo " <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
412 echo " <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
413 echo " <input type=\"hidden\" name=\"passwd\" value=\"set\" />\n";
416 <legend>Password recovery</legend>
419 <td><label for="email">Old password:</label></td>
420 <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
422 <td><label for="password">New password:</label></td>
423 <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
425 <td><label for="password">Retype:</label></td>
426 <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
429 <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
438 function output_user_notes($userid,$gameid,$userstatus)
440 echo "<div class=\"notes\"> Personal notes: <br />\n";
441 $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
442 foreach($notes as $note)
443 echo "$note <hr />\n";
444 if($userstatus!='gameover')
445 echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";