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)
31 $copy_names = $names; /* local copy, so that we can delete names from it
32 * after we selected them to make sure that each name
36 <form action="index.php?action=new" method="post">
37 <h2> Select players (Remember: you need to be one of the players) </h2>
40 <img class="table" src="pics/table.png" alt="table" />
42 /* ask for player names */
44 /* delete players name, since he will be on position D anyway */
45 unset($copy_names[array_search($_SESSION["name"],$copy_names)]);
47 srand((float) microtime() * 10000000);
48 foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
50 /* pick 3 names at random and put the players name on position D*/
53 $randkey = array_rand($copy_names);
54 $rand = $copy_names[$randkey];
55 /* delete this name from the list of possible names */
56 unset($copy_names[$randkey]);
60 $rand = $_SESSION["name"];
63 echo " <div class=\"table".$i."\">\n";
65 echo " <select name=\"$player\" size=\"1\"> \n";
66 foreach($names as $name)
70 echo " <option selected=\"selected\">$name</option>\n";
73 echo " <option>$name</option>\n";
75 echo " </select>\n </div>\n";
80 <h2 class="rules"> Rules </h2>
81 <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
82 <p> Ten of hearts: </p>
84 <li> <input type="radio" name="dullen" value="none" /> just normal non-trump </li>
85 <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
86 <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
88 <p> Schweinchen (both foxes), only in normal games or silent solos: </p>
90 <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
91 <li> <input type="radio" name="schweinchen" value="both" />
92 both become highest trump (automatic call at beginning of the game)
94 <li> <input type="radio" name="schweinchen" value="second" />
95 first one normal, second one becomes highest (call during the game) </li>
96 <li> <input type="radio" name="schweinchen" value="secondaftercall" />
97 second one become highest only in case re/contra was announced
100 <p> Call Re/Contra, etc.: </p>
102 <li><input type="radio" name="callrule" value="1st-own-card" checked="checked" />
103 Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
104 <li><input type="radio" name="callrule" value="5th-card" />
105 Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
106 <li><input type="radio" name="callrule" value="9-cards" />
107 Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
109 <input type="submit" value="start game" />
114 function output_table($data,$caption="",$class="")
117 $HTML = "\n<table class=\"$class\">\n";
119 $HTML = "\n<table>\n";
124 $HTML .= " <caption> $caption </caption>\n";
126 foreach($data as $record)
129 $HTML .= " <thead>\n <tr>\n";
132 if($i==1) $HTML .= " <tbody>\n";
134 $HTML .= " <tr class=\"odd\"> ";
136 $HTML .= " <tr class=\"even\"> ";
138 foreach($record as $point)
141 $HTML .= " <td>$point</td> ";
143 $HTML .= " <th>$point</th> ";
147 $HTML .= " </tr>\n </thead>\n";
154 $HTML .= " </tbody>\n</table>\n";
159 function display_card($card,$dir="english")
161 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
162 * convert even cards to the matching odd value */
164 if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
165 echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" />\n";
167 echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" />\n";
172 function display_link_card($card,$dir="english",$type="card")
174 if( $card/2 - (int)($card/2) == 0.5)
175 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";
177 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";
181 function output_check_for_sickness($me,$mycards)
184 <div class="sickness"> Thanks for joining the game...<br />
186 do you want to play solo?
187 <select name="solo" size="1">
188 <option selected="selected">No</option>
189 <option>trumpless</option>
190 <option>trump</option>
191 <option>queen</option>
192 <option>jack</option>
193 <option>club</option>
194 <option>spade</option>
195 <option>heart</option>
202 if(check_wedding($mycards))
204 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
205 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
209 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
212 echo "Do you have poverty?";
213 if(count_trump($mycards)<4)
215 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
216 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
220 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
223 echo "Do you have too many nines?";
224 if(count_nines($mycards)>4)
226 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
227 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
231 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
234 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
235 echo "<input type=\"submit\" value=\"count me in\" />\n";
242 function output_form_calls($me,$myparty)
244 if( can_call(120,$me) )
248 else if ($myparty=='contra')
249 echo "contra (120):";
251 echo " re/contra (120):";
252 echo " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
254 if( can_call(90,$me) )
256 " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
257 if( can_call(60,$me) )
259 " <input type=\"radio\" name=\"call\" value=\"60\" /> <br />";
260 if( can_call(30,$me) )
262 " <input type=\"radio\" name=\"call\" value=\"30\" /> <br />";
263 if( can_call(0,$me) )
265 " <input type=\"radio\" name=\"call\" value=\"0\" /> <br />".
267 " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
270 function output_check_want_to_play($me)
273 <div class="joingame">
274 Do you want to play a game of DoKo? <br />
275 yes<input type="radio" name="in" value="yes" />
276 no<input type="radio" name="in" value="no" /> <br />
278 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
280 echo "<input type=\"submit\" value=\"submit\" />\n";
286 function output_header()
290 <!DOCTYPE html PUBLIC
291 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
292 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
293 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
295 <title>e-Doko</title>
296 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
297 <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
298 <link rel="stylesheet" type="text/css" href="css/standard017.css" />
299 <script type="text/javascript" src="include/game.js"> </script>
301 <body onload="high_last();">
303 <h1> Welcome to E-Doko </h1>
307 echo "<div class=\"main\">";
311 function output_footer()
316 echo "<div class=\"footer\">\n";
317 echo " <p class=\"left\"> copyright 2006-2008 Arun Persaud, Lance Thornton <br />\n".
318 " Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
319 " - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
320 " a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
321 echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
322 " via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
323 " <a href=\"http://www.dreamhost.com/green.cgi\">\n".
324 " <img border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
325 "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
336 function output_status()
338 global $defaulttimezone,$INDEX,$WIKI;
339 if(isset($_SESSION["name"]))
341 $name = $_SESSION["name"];
344 echo "\n<div class=\"status\">\n";
346 echo " | <a href=\"".$INDEX."\"> mypage </a>\n";
347 echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n";
348 echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n";
349 echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n";
350 echo " | <a href=\"".$WIKI."\">wiki</a>\n";
351 echo " | <a href=\"".$INDEX."?action=logout\">logout</a>\n";
354 /* last logon time */
355 $myid = DB_get_userid("name",$name);
356 $zone = DB_get_user_timezone($myid);
358 $time = DB_get_user_timestamp($myid);
359 date_default_timezone_set($defaulttimezone);
360 $unixtime = strtotime($time);
361 date_default_timezone_set($zone);
363 echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n";
367 echo "\n<div class=\"status\">\n";
368 echo "<a href=\"".$INDEX."\">login</a>\n";
374 function output_select_timezone($name,$timezone="")
376 $Tzone = array ( "Europe/London" => "London",
377 "Europe/Berlin" => "Berlin",
378 "America/Vancouver" => "Berkeley",
379 "Pacific/Auckland" => "Wellington" );
381 echo " <select id=\"$name\" name=\"$name\" size=\"1\">\n";
383 foreach($Tzone as $zone=>$city)
386 echo " <option value=\"$zone\" selected=\"selected\">$city</option>\n";
388 echo " <option value=\"$zone\">$city</option>\n";
395 function output_password_recovery($email,$password)
398 <form action="index.php" method="post">
400 echo " <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
401 echo " <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
402 echo " <input type=\"hidden\" name=\"passwd\" value=\"set\" />\n";
405 <legend>Password recovery</legend>
408 <td><label for="email">Old password:</label></td>
409 <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
411 <td><label for="password">New password:</label></td>
412 <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
414 <td><label for="password">Retype:</label></td>
415 <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
418 <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
427 function output_user_notes($userid,$gameid,$userstatus)
429 echo "<div class=\"notes\"> Personal notes: <br />\n";
430 $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
431 foreach($notes as $note)
432 echo "$note <hr />\n";
433 if($userstatus!='gameover')
434 echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";