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" />
43 /* ask player for names */
47 /* delete players name, since he will be on position D anyway */
48 unset($copy_names[array_search($_SESSION["name"],$copy_names)]);
50 srand((float) microtime() * 10000000);
51 foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
53 /* pick 3 names at random and put the players name on position D*/
56 $randkey = array_rand($copy_names);
57 $rand = $copy_names[$randkey];
58 /* delete this name from the list of possible names */
59 unset($copy_names[$randkey]);
63 $rand = $_SESSION["name"];
66 echo " <div class=\"table".$i."\">\n";
68 echo " <select name=\"$player\" size=\"1\"> \n";
69 foreach($names as $name)
73 echo " <option selected=\"selected\">$name</option>\n";
76 echo " <option>$name</option>\n";
78 echo " </select>\n </div>\n";
83 <h2 class="rules"> Rules </h2>
84 <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
85 <p> Ten of hearts: </p>
87 <li> <input type="radio" name="dullen" value="none" /> just normal non-trump </li>
88 <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
89 <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
91 <p> Schweinchen (both foxes), only in normal games or silent solos: </p>
93 <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
94 <li> <input type="radio" name="schweinchen" value="both" />
95 both become highest trump (automatic call at beginning of the game)
97 <li> <input type="radio" name="schweinchen" value="second" />
98 first one normal, second one becomes highest (call during the game) </li>
99 <li> <input type="radio" name="schweinchen" value="secondaftercall" />
100 second one become highest only in case re/contra was announced
103 <p> Call Re/Contra, etc.: </p>
105 <li><input type="radio" name="callrule" value="1st-own-card" checked="checked" />
106 Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
107 <li><input type="radio" name="callrule" value="5th-card" />
108 Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
109 <li><input type="radio" name="callrule" value="9-cards" />
110 Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
112 <input type="submit" value="start game" />
117 function output_table($data,$caption="",$class="")
120 $HTML = "\n<table class=\"$class\">\n";
122 $HTML = "\n<table>\n";
127 $HTML .= " <caption> $caption </caption>\n";
129 foreach($data as $record)
132 $HTML .= " <thead>\n <tr>\n";
135 if($i==1) $HTML .= " <tbody>\n";
137 $HTML .= " <tr class=\"odd\"> ";
139 $HTML .= " <tr class=\"even\"> ";
141 foreach($record as $point)
144 $HTML .= " <td>$point</td> ";
146 $HTML .= " <th>$point</th> ";
150 $HTML .= " </tr>\n </thead>\n";
157 $HTML .= " </tbody>\n</table>\n";
162 function display_card($card,$dir="english")
164 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
165 * convert even cards to the matching odd value */
167 if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
168 echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" />\n";
170 echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" />\n";
175 function display_link_card($card,$dir="english",$type="card")
177 if( $card/2 - (int)($card/2) == 0.5)
178 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";
180 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";
184 function output_check_for_sickness($me,$mycards)
187 <div class="sickness"> Thanks for joining the game...<br />
189 do you want to play solo?
190 <select name="solo" size="1">
191 <option selected="selected">No</option>
192 <option>trumpless</option>
193 <option>trump</option>
194 <option>queen</option>
195 <option>jack</option>
196 <option>club</option>
197 <option>spade</option>
198 <option>heart</option>
205 if(check_wedding($mycards))
207 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
208 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
212 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
215 echo "Do you have poverty?";
216 if(count_trump($mycards)<4)
218 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
219 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
223 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
226 echo "Do you have too many nines?";
227 if(count_nines($mycards)>4)
229 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
230 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
234 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
237 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
238 echo "<input type=\"submit\" value=\"count me in\" />\n";
245 function output_form_calls($me,$myparty)
247 if( can_call(120,$me) )
251 else if ($myparty=='contra')
252 echo "contra (120):";
254 echo " re/contra (120):";
255 echo " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
257 if( can_call(90,$me) )
259 " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
260 if( can_call(60,$me) )
262 " <input type=\"radio\" name=\"call\" value=\"60\" /> <br />";
263 if( can_call(30,$me) )
265 " <input type=\"radio\" name=\"call\" value=\"30\" /> <br />";
266 if( can_call(0,$me) )
268 " <input type=\"radio\" name=\"call\" value=\"0\" /> <br />".
270 " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
273 function output_check_want_to_play($me)
276 <div class="joingame">
277 Do you want to play a game of DoKo? <br />
278 yes<input type="radio" name="in" value="yes" />
279 no<input type="radio" name="in" value="no" /> <br />
281 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
283 echo "<input type=\"submit\" value=\"submit\" />\n";
289 function output_header()
293 <!DOCTYPE html PUBLIC
294 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
295 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
296 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
298 <title>e-Doko</title>
299 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
300 <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
301 <link rel="stylesheet" type="text/css" href="css/standard017.css" />
302 <script type="text/javascript" src="include/game.js"> </script>
304 <body onload="high_last();">
306 <h1> Welcome to E-Doko </h1>
310 echo "<div class=\"main\">";
314 function output_footer()
319 echo "<div class=\"footer\">\n";
320 echo " <p class=\"left\"> copyright 2006-2009 Arun Persaud, Lance Thornton(graphics), Jeff Zerger(database support) <br />\n".
321 " Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
322 " - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
323 " a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
324 echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
325 " via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
326 " <a href=\"http://www.dreamhost.com/green.cgi\">\n".
327 " <img border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
328 "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
339 function output_status()
341 global $defaulttimezone,$INDEX,$WIKI;
342 if(isset($_SESSION["name"]))
344 $name = $_SESSION["name"];
347 echo "\n<div class=\"status\">\n";
349 echo " | <a href=\"".$INDEX."\"> mypage </a>\n";
350 echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n";
351 echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n";
352 echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n";
353 echo " | <a href=\"".$WIKI."\">wiki</a>\n";
354 echo " | <a href=\"".$INDEX."?action=logout\">logout</a>\n";
357 /* last logon time */
358 $myid = DB_get_userid("name",$name);
359 $zone = DB_get_user_timezone($myid);
361 $time = DB_get_user_timestamp($myid);
362 date_default_timezone_set($defaulttimezone);
363 $unixtime = strtotime($time);
364 date_default_timezone_set($zone);
366 echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n";
370 echo "\n<div class=\"status\">\n";
371 echo "<a href=\"".$INDEX."\">login</a>\n";
377 function output_select_timezone($name,$timezone="")
379 $Tzone = array ( "Europe/London" => "London",
380 "Europe/Berlin" => "Berlin",
381 "America/Vancouver" => "Berkeley",
382 "Pacific/Auckland" => "Wellington" );
384 echo " <select id=\"$name\" name=\"$name\" size=\"1\">\n";
386 foreach($Tzone as $zone=>$city)
389 echo " <option value=\"$zone\" selected=\"selected\">$city</option>\n";
391 echo " <option value=\"$zone\">$city</option>\n";
398 function output_password_recovery($email,$password)
401 <form action="index.php" method="post">
403 echo " <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
404 echo " <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
405 echo " <input type=\"hidden\" name=\"passwd\" value=\"set\" />\n";
408 <legend>Password recovery</legend>
411 <td><label for="email">Old password:</label></td>
412 <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
414 <td><label for="password">New password:</label></td>
415 <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
417 <td><label for="password">Retype:</label></td>
418 <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
421 <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
430 function output_user_notes($userid,$gameid,$userstatus)
432 echo "<div class=\"notes\"> Personal notes: <br />\n";
433 $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
434 foreach($notes as $note)
435 echo "$note <hr />\n";
436 if($userstatus!='gameover')
437 echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
443 function output_robotproof($i)
460 function output_exchanged_cards()
462 /* in a poverty game this function will output the exchanged cards
463 * players in the team will see the cards, the other team will see
464 * the backside of cards
467 /* need some information about the game */
468 global $gameid,$mygametype, $PREF,$me;
470 /* some variables to track where the people with poverty are sitting */
476 /* only need to do it in a poverty game, this might not be needed, but
477 * just to make sure everything is ok
479 if($mygametype == 'poverty' || $mygametype=='dpoverty')
481 /* find out who has poverty */
482 for($mypos=1;$mypos<5;$mypos++)
484 $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
485 if($usersick == 'poverty')
487 $povertypos2 = $mypos;
489 $povertypos1 = $mypos;
491 /* get hash and exchanged cards for all involved */
492 $povertyhash1 = DB_get_hash_from_game_and_pos($gameid,$povertypos1);
493 $partnerhash1 = DB_get_partner_hash_by_hash($povertyhash1);
495 $povertycards1 = DB_get_exchanged_cards($povertyhash1);
496 $partnercards1 = DB_get_exchanged_cards($partnerhash1);
498 $partnerpos1 = DB_get_pos_by_hash($partnerhash1);
501 $povertyhash2 = DB_get_hash_from_game_and_pos($gameid,$povertypos2);
502 $partnerhash2 = DB_get_partner_hash_by_hash($povertyhash2);
504 $povertycards2 = DB_get_exchanged_cards($povertyhash2);
505 $partnercards2 = DB_get_exchanged_cards($partnerhash2);
507 $partnerpos2 = DB_get_pos_by_hash($partnerhash2);
512 * go through all positions, check that position has cards that need to be shown and
516 for($mypos=1;$mypos<5;$mypos++)
518 $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
519 if($usersick!=NULL ||
520 $mypos==$povertypos1 || $mypos==$partnerpos1 ||
521 $mypos==$povertypos2 || $mypos==$partnerpos2 )
523 echo " <div class=\"vorbehalt".($mypos-1)."\"> Vorbehalt <br />\n";
525 echo " $usersick <br />\n";
526 if($mypos==$partnerpos1)
529 foreach($partnercards1 as $card)
531 if(is_trump($card)) $trump_back=1;
533 if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
534 display_card($card,$PREF['cardset']);
536 display_card(0,$PREF['cardset']);
538 if($trump_back) echo "Trump back";
540 else if($mypos==$povertypos1)
542 foreach($povertycards1 as $card)
545 if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
546 display_card($card,$PREF['cardset']);
548 display_card(0,$PREF['cardset']);
551 else if($mypos==$povertypos2)
553 foreach($povertycards2 as $card)
556 if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
557 display_card($card,$PREF['cardset']);
559 display_card(0,$PREF['cardset']);
562 else if($mypos==$partnerpos2)
565 foreach($partnercards2 as $card)
567 if(is_trump($card)) $trump_back=1;
569 if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
570 display_card($card,$PREF['cardset']);
572 display_card(0,$PREF['cardset']);
574 if($trump_back) echo "Trump back";
578 if($mygametype == $usersick)