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 $playerD 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="",$id="")
123 $HTML.= " class=\"$class\"";
125 $HTML.= " id=\"$id\"";
132 $HTML .= " <caption> $caption </caption>\n";
134 foreach($data as $record)
137 $HTML .= " <thead>\n <tr>\n";
140 if($i==1) $HTML .= " <tbody>\n";
143 foreach($record as $point)
146 $HTML .= " <td>$point</td> ";
148 $HTML .= " <th>$point</th> ";
152 $HTML .= " </tr>\n </thead>\n";
159 $HTML .= " </tbody>\n</table>\n";
164 function display_card($card,$dir="english")
166 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
167 * convert even cards to the matching odd value */
169 if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
170 echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" />\n";
172 echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" />\n";
177 function display_link_card($card,$dir="english",$type="card")
179 if( $card/2 - (int)($card/2) == 0.5)
180 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";
182 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";
186 function output_check_for_sickness($me,$mycards)
189 <div class="sickness"> Thanks for joining the game...<br />
191 do you want to play solo?
192 <select name="solo" size="1">
193 <option selected="selected">No</option>
194 <option>trumpless</option>
195 <option>trump</option>
196 <option>queen</option>
197 <option>jack</option>
198 <option>club</option>
199 <option>spade</option>
200 <option>heart</option>
207 if(check_wedding($mycards))
209 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
210 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
214 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
217 echo "Do you have poverty?";
218 if(count_trump($mycards)<4)
220 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
221 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
225 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
228 echo "Do you have too many nines?";
229 if(count_nines($mycards)>4)
231 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
232 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
236 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
239 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
240 echo "<input type=\"submit\" value=\"count me in\" />\n";
247 function output_form_calls($me,$myparty)
249 if( can_call(120,$me) )
253 else if ($myparty=='contra')
254 echo "contra (120):";
256 echo " re/contra (120):";
257 echo " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
259 if( can_call(90,$me) )
261 " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
262 if( can_call(60,$me) )
264 " <input type=\"radio\" name=\"call\" value=\"60\" /> <br />";
265 if( can_call(30,$me) )
267 " <input type=\"radio\" name=\"call\" value=\"30\" /> <br />";
268 if( can_call(0,$me) )
270 " <input type=\"radio\" name=\"call\" value=\"0\" /> <br />".
272 " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
275 function output_check_want_to_play($me)
278 <div class="joingame">
279 Do you want to play a game of DoKo? <br />
280 yes<input type="radio" name="in" value="yes" />
281 no<input type="radio" name="in" value="no" /> <br />
283 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
285 echo "<input type=\"submit\" value=\"submit\" />\n";
291 function output_header()
295 <!DOCTYPE html PUBLIC
296 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
297 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
298 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
300 <title>e-Doko</title>
301 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
302 <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
303 <link rel="stylesheet" type="text/css" href="css/standard021.css" />
304 <script type="text/javascript" src="include/game.js"> </script>
305 <script type="text/javascript" src="include/jquery.js"> </script>
306 <script type="text/javascript" src="include/jquery.tablesorter.js"></script>
307 <script type="text/javascript">
308 $(document).ready(function()
310 $("#ScoreTable").tablesorter({ widgets: ['zebra']});
314 <body onload="high_last();">
316 <h1> Welcome to E-Doko </h1>
320 echo "<div class=\"main\">";
324 function output_footer()
329 echo "<div class=\"footer\">\n";
330 echo " <p class=\"left\"> copyright 2006-2009 Arun Persaud, Lance Thornton(graphics), Jeff Zerger(database support) <br />\n".
331 " Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
332 " - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
333 " a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
334 echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
335 " via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
336 " <a href=\"http://www.dreamhost.com/green.cgi\">\n".
337 " <img border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
338 "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
349 function output_status()
351 global $defaulttimezone,$INDEX,$WIKI;
352 if(isset($_SESSION["name"]))
354 $name = $_SESSION["name"];
357 echo "\n<div class=\"status\">\n";
359 echo " | <a href=\"".$INDEX."\"> mypage </a>\n";
360 echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n";
361 echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n";
362 echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n";
363 echo " | <a href=\"".$WIKI."\">wiki</a>\n";
364 echo " | <a href=\"".$INDEX."?action=logout\">logout</a>\n";
367 /* last logon time */
368 $myid = DB_get_userid("name",$name);
369 $zone = DB_get_user_timezone($myid);
371 $time = DB_get_user_timestamp($myid);
372 date_default_timezone_set($defaulttimezone);
373 $unixtime = strtotime($time);
374 date_default_timezone_set($zone);
376 echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n";
380 echo "\n<div class=\"status\">\n";
381 echo "<a href=\"".$INDEX."\">login</a>\n";
387 function output_select_timezone($name,$timezone="")
389 $Tzone = array ( "Europe/London" => "London",
390 "Europe/Berlin" => "Berlin",
391 "America/Vancouver" => "Berkeley",
392 "Pacific/Auckland" => "Wellington" );
394 echo " <select id=\"$name\" name=\"$name\" size=\"1\">\n";
396 foreach($Tzone as $zone=>$city)
399 echo " <option value=\"$zone\" selected=\"selected\">$city</option>\n";
401 echo " <option value=\"$zone\">$city</option>\n";
408 function output_password_recovery($email,$password)
411 <form action="index.php" method="post">
413 echo " <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
414 echo " <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
415 echo " <input type=\"hidden\" name=\"passwd\" value=\"set\" />\n";
418 <legend>Password recovery</legend>
421 <td><label for="email">Old password:</label></td>
422 <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
424 <td><label for="password">New password:</label></td>
425 <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
427 <td><label for="password">Retype:</label></td>
428 <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
431 <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
440 function output_user_notes($userid,$gameid,$userstatus)
442 echo "<div class=\"notes\"> Personal notes: <br />\n";
443 $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
444 foreach($notes as $note)
445 echo "$note <hr />\n";
446 if($userstatus!='gameover')
447 echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
453 function output_robotproof($i)
470 function output_exchanged_cards()
472 /* in a poverty game this function will output the exchanged cards
473 * players in the team will see the cards, the other team will see
474 * the backside of cards
477 /* need some information about the game */
478 global $gameid,$mygametype, $PREF,$me,$mystatus;
480 /* some variables to track where the people with poverty are sitting */
486 /* only need to do it in a poverty game, this might not be needed, but
487 * just to make sure everything is ok
489 if($mygametype == 'poverty' || $mygametype=='dpoverty')
491 /* find out who has poverty */
492 for($mypos=1;$mypos<5;$mypos++)
494 $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
495 if($usersick == 'poverty')
497 $povertypos2 = $mypos;
499 $povertypos1 = $mypos;
501 /* get hash and exchanged cards for all involved */
502 $povertyhash1 = DB_get_hash_from_game_and_pos($gameid,$povertypos1);
503 $partnerhash1 = DB_get_partner_hash_by_hash($povertyhash1);
505 $povertycards1 = DB_get_exchanged_cards($povertyhash1);
506 $partnercards1 = DB_get_exchanged_cards($partnerhash1);
508 $partnerpos1 = DB_get_pos_by_hash($partnerhash1);
511 $povertyhash2 = DB_get_hash_from_game_and_pos($gameid,$povertypos2);
512 $partnerhash2 = DB_get_partner_hash_by_hash($povertyhash2);
514 $povertycards2 = DB_get_exchanged_cards($povertyhash2);
515 $partnercards2 = DB_get_exchanged_cards($partnerhash2);
517 $partnerpos2 = DB_get_pos_by_hash($partnerhash2);
522 * go through all positions, check that position has cards that need to be shown and
526 for($mypos=1;$mypos<5;$mypos++)
528 $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
529 if($usersick!=NULL ||
530 $mypos==$povertypos1 || $mypos==$partnerpos1 ||
531 $mypos==$povertypos2 || $mypos==$partnerpos2 )
533 /* figure out if we gave trump back */
536 foreach($povertycards1 as $card)
546 foreach($povertycards2 as $card)
555 /* output vorbehalt */
556 echo " <div class=\"vorbehalt".($mypos-1)."\"> Vorbehalt <br />\n";
558 echo " $usersick <br />\n";
561 if($mypos==$partnerpos1)
563 foreach($partnercards1 as $card)
566 if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
567 display_card($card,$PREF['cardset']);
569 display_card(0,$PREF['cardset']);
571 if($trump_back1) echo " Trump back";
573 else if($mypos==$povertypos1)
575 foreach($povertycards1 as $card)
578 if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
579 display_card($card,$PREF['cardset']);
581 display_card(0,$PREF['cardset']);
583 if($trump_back1) echo " Trump back";
585 else if($mypos==$povertypos2)
587 foreach($povertycards2 as $card)
590 if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
591 display_card($card,$PREF['cardset']);
593 display_card(0,$PREF['cardset']);
595 if($trump_back2) echo " Trump back";
597 else if($mypos==$partnerpos2)
599 foreach($partnercards2 as $card)
601 if(is_trump($card)) $trump_back=1;
603 if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
604 display_card($card,$PREF['cardset']);
606 display_card(0,$PREF['cardset']);
608 if($trump_back2) echo " Trump back";
612 if($mygametype == $usersick)