2 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
3 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
7 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
8 <link rel="stylesheet" type="text/css" href="standard.css" />
12 <h1> Welcome to E-Doko </h1>
19 $host = "http://doko.nubati.net/index.php";
20 $wiki = "http://wiki.nubati.net/index.php?title=EmailDoko";
28 function mymail($To,$Subject,$message)
34 $message = str_replace("\n","<br />",$message);
35 echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
38 mail($To,$Subject,$message);
42 function parse_status()
44 global $game,$history,$player,$hash,$lines;
47 $game["solo-who"] = -1;
48 $game["solo-what"] = "todo";
49 $game["wedding"] = -1;
50 $game["poverty"] = "";
52 $game["startplayer"] = 0;
56 $tmp = explode( ":",$lines[$i]);
58 $player[$tmp[0]]["number"] = $i;
59 $player[$tmp[0]]["hash"] = $tmp[0];
60 $player[$tmp[0]]["name"] = $tmp[1];
61 $player[$tmp[0]]["email"] = $tmp[2];
62 $player[$tmp[0]]["option"] = $tmp[3];
63 $player[$tmp[0]]["points"] = $tmp[4];
64 $player[$tmp[0]]["cards"] = $tmp[5];
65 if(ereg("s",$tmp[3])) $game["init"]++; /* how many players are ready? */
66 if(ereg("P",$tmp[3])) $game["poverty"].= $i; /* players with poverty, could be two, so use a string */
67 if(ereg("N",$tmp[3])) $game["nines"] = $i; /* the player with too many nines, only one possible */
68 if(ereg("W",$tmp[3])) $game["wedding"] = $i; /* the player with the wedding, also only one possible */
69 if(ereg("([OSQJCAH])",$tmp[3],$match) && ($game["solo-who"]<0) )
71 $game["solo-who"] = $i;
72 $game["startplayer"] = $i;
76 $game["solo-what"] = "No Trump";
78 $game["solo-what"] = "Trump";
80 $game["solo-what"] = "Queen";
82 $game["solo-what"] = "Jack";
84 $game["solo-what"] = "Club";
86 $game["solo-what"] = "Spade";
88 $game["solo-what"] = "Heart";
93 /* save the game history */
94 for($i=4;$i<sizeof($lines);$i++)
96 if(!ereg("^[[:space:]]*$",trim($lines[$i])))
98 $history[] = $lines[$i];
102 if(sizeof($history)==0 || (sizeof($history)==1 && strlen($history[0])==3 ))
103 $history[0] = $game["startplayer"].":";
108 function count_nines($cards)
110 $card = explode(";",$cards);
116 if($c == "25" || $c == "26") $nines++;
117 else if($c == "33" || $c == "34") $nines++;
118 else if($c == "41" || $c == "42") $nines++;
119 else if($c == "47" || $c == "48") $nines++;
125 function check_wedding($cards)
127 $card = explode(";",$cards);
131 if( in_array("3",$card) && in_array("2",$card) )
137 function count_trump($cards)
139 $card = explode(";",$cards);
143 /* count each trump */
149 if( in_array("19",$card))
151 if( in_array("20",$card) )
153 /* add one, in case the player has both foxes (schweinchen) */
154 if( in_array("19",$card) && in_array("20",$card) )
160 function card_to_name($card)
166 return "ten of hearts";
169 return "queen of clubs";
172 return "queen of spades";
175 return "queen of hearts";
178 return "queen of diamonds";
181 return "jack of clubs";
184 return "jack of spades";
187 return "jack of hearts";
190 return "jack of diamonds";
193 return "ace of diamonds";
196 return "ten of diamonds";
199 return "king of diamonds";
202 return "nine of diamonds";;
205 return "ace of clubs";
208 return "ten of clubs";
211 return "king of clubs";
214 return "nine of clubs";
217 return "ace of spades";
220 return "ten of spades";
223 return "king of spades";
226 return "nine of spades";
229 return "ace of hearts";
232 return "king of hearts";
235 return "nine of hearts";
237 return "something went wrong, please contact the admin";
241 function card_value($card)
312 echo "something went wrong, please contact the admin <br>";
317 function display_card($card)
319 if( $card/2 - (int)($card/2) == 0.5)
320 echo "<img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
322 echo "<img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
326 function display_link_card($card,$me)
328 if( $card/2 - (int)($card/2) == 0.5)
329 echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" /></a>\n";
331 echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" /></a>\n";
335 function save_status()
337 global $player,$game,$hash,$history;
339 $output = fopen("status.txt","w");
342 foreach($hash as $key)
344 /* sorting the options, not sure why I do that actually */
346 if( ereg("i",$player[$key]["option"]) )
348 if( ereg("s",$player[$key]["option"]) )
350 if( ereg("t",$player[$key]["option"]) )
352 if( ereg("c",$player[$key]["option"]) )
354 if( ereg("N",$player[$key]["option"]) )
356 if( ereg("W",$player[$key]["option"]) )
358 if( ereg("P",$player[$key]["option"]) )
360 if( ereg("O",$player[$key]["option"]) )
362 if( ereg("S",$player[$key]["option"]) )
364 if( ereg("Q",$player[$key]["option"]) )
366 if( ereg("J",$player[$key]["option"]) )
368 if( ereg("C",$player[$key]["option"]) )
370 if( ereg("A",$player[$key]["option"]) )
372 if( ereg("H",$player[$key]["option"]) )
374 $player[$key]["option"]=$tmp;
376 /* saving the player stats */
377 fwrite($output,"".$player[$key]["hash"].":" );
378 fwrite($output,"".$player[$key]["name"].":" );
379 fwrite($output,"".$player[$key]["email"].":" );
380 fwrite($output,"".$player[$key]["option"].":" );
381 fwrite($output,"".$player[$key]["points"].":" );
382 fwrite($output,"".$player[$key]["cards"] .":");
383 fwrite($output,"\n");
385 fwrite($output,"\n");
386 foreach($history as $line)
387 fwrite($output,$line);
389 fwrite($output,"\n");
393 echo "can't open file for writing, please inform the admin.";
398 /***************** M A I N **************************/
400 echo "<p>If you find bugs, please list them in the <a href=\"".$wiki."\">wiki</a>.</p>\n";
402 echo "<p> Names that are underlined have a comment, which you can access by hovering over the name with your mouse ;)</p>\n";
410 /* check for status file and read it, if possible */
412 if(file_exists("status.txt"))
413 $lines = file("status.txt");
417 /* check if we want to start a new game */
418 if( isset($_REQUEST["PlayerA"]) &&
419 isset($_REQUEST["PlayerB"]) &&
420 isset($_REQUEST["PlayerC"]) &&
421 isset($_REQUEST["PlayerD"]) &&
422 isset($_REQUEST["EmailA"]) &&
423 isset($_REQUEST["EmailB"]) &&
424 isset($_REQUEST["EmailC"]) &&
425 isset($_REQUEST["EmailD"]) && sizeof($lines<2))
427 $PlayerA = $_REQUEST["PlayerA"];
428 $PlayerB = $_REQUEST["PlayerB"];
429 $PlayerC = $_REQUEST["PlayerC"];
430 $PlayerD = $_REQUEST["PlayerD"];
431 $EmailA = $_REQUEST["EmailA"] ;
432 $EmailB = $_REQUEST["EmailB"] ;
433 $EmailC = $_REQUEST["EmailC"] ;
434 $EmailD = $_REQUEST["EmailD"] ;
436 $hashA = md5("AGameOfDoko".$PlayerA.$EmailA);
437 $hashB = md5("AGameOfDoko".$PlayerB.$EmailB);
438 $hashC = md5("AGameOfDoko".$PlayerC.$EmailC);
439 $hashD = md5("AGameOfDoko".$PlayerD.$EmailD);
441 /* send out email, check for error with email */
444 "you are invited to play a game of DoKo (that is to debug the program ;).\n".
445 "Place comments and bug reports here:\n".
446 "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
447 "The whole round would consist of the following players:\n".
452 "If you want to join this game, please follow this link:\n\n".
455 mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
456 mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
457 mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
458 mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
460 /* read in random.txt */
461 if(file_exists("random.txt"))
462 $random = file("random.txt");
464 die("no random file");
466 $randomNR = explode( ":", $random[2] );
468 /* write initial status into file */
469 $output = fopen("status.txt","w");
472 fwrite($output, "$hashA:$PlayerA:$EmailA:::" );
474 fwrite($output,"$randomNR[$i];" );
475 fwrite($output,"$randomNR[11]:" ); $i++;
476 fwrite($output,"\n");
478 fwrite($output, "$hashB:$PlayerB:$EmailB:::" );
480 fwrite($output,"$randomNR[$i];" );
481 fwrite($output,"$randomNR[23]:" ); $i++;
482 fwrite($output,"\n");
484 fwrite($output, "$hashC:$PlayerC:$EmailC:::" );
486 fwrite($output,"$randomNR[$i];" );
487 fwrite($output,"$randomNR[35]:" ); $i++;
488 fwrite($output,"\n");
490 fwrite($output, "$hashD:$PlayerD:$EmailD:::");
492 fwrite($output,"$randomNR[$i];" );
493 fwrite($output,"$randomNR[47]:" );
494 fwrite($output,"\n");
499 echo "can't open file for writing";
502 if(file_exists("status.txt"))
503 $lines = file("status.txt");
507 /* test if a game is running, else output everything for a new game */
511 <p> no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct! </p>
512 <form action="index.php" method="post">
513 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
514 Email: <input name="EmailA" type="text" size="20" maxlength="30" /> <br />
516 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
517 Email: <input name="EmailB" type="text" size="20" maxlength="30" /> <br />
519 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
520 Email: <input name="EmailC" type="text" size="20" maxlength="30" /> <br />
522 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
523 Email: <input name="EmailD" type="text" size="20" maxlength="30" /> <br />
525 <input type="submit" value="start game" />
530 { /* load game status */
537 * check if a player wants to accept a game
539 if(isset($_REQUEST["a"]))
543 if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
545 echo "just wait for the game to start";
547 else if( !ereg("[is]",$player[$a]["option"]) )
550 <form action="index.php" method="post">
551 Do you want to play a game of DoKo?
552 yes<input type="radio" name="in" value="yes" />
553 no<input type="radio" name="in" value="no" /> <br />
555 Do you want to get an email for every card played or only if it your move?
556 every card<input type="radio" name="update" value="card" />
557 only on my turn<input type="radio" name="update" value="turn" /> <br />
559 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
561 echo "<input type=\"submit\" value=\"count me in\" />\n";
570 * yes? email him his hand, ask for solo, poverty, email every move or every card?
572 if(isset($_REQUEST["b"]))
576 if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
577 { /* the player already filled out everything */
578 echo "just wait for the game to start";
580 else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
581 { /* the player didn't fill out the form at "a" correctly */
583 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
586 { /* show the hand and check if the player is sick*/
587 if($_REQUEST["in"]=="no")
588 { /* player doesn't want to play, cancel the game */
591 $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
592 "the game has been canceled due to the request of one of the players.\n";
593 mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
595 /* canceling the game is as easy as removing the contents of the status file*/
596 $output = fopen("status.txt","w");
600 echo "problem opening file";
604 /* player wants to play, save information from "a"*/
605 if($_REQUEST["update"]=="card")
606 $player[$b]["option"] .= "c";
608 $player[$b]["option"] .= "t";
610 $player[$b]["option"] .= "i"; /* player finished stage "a" */
614 $allcards = $player[$b]["cards"];
615 $mycards = explode(";",$allcards);
618 echo "<p class=\"mycards\">your cards are: <br />\n";
619 foreach($mycards as $card)
623 <p> aehm... at the moment poverty is not implented. so I guess you need to play a normal game, even if you have less than 3 trump :(...sorry </p>
625 <form action="index.php" method="post">
627 do you want to play solo?
628 <select name="solo" size="1">
630 <option>No trump</option>
631 <option>Normal solo</option>
632 <option>Queen solo</option>
633 <option>Jack solo</option>
634 <option>Club solo</option>
635 <option>Spade solo</option>
636 <option>Heart solo</option>
643 if(check_wedding($player[$b]["cards"]))
645 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
646 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
650 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
653 echo "do you have poverty?";
654 if(count_trump($player[$b]["cards"])<4)
656 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
657 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
661 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
664 echo "do you have too many nines?";
665 if(count_nines($player[$b]["cards"])>4)
667 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
668 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
672 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
675 echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
676 echo "<input type=\"submit\" value=\"count me in\" />\n";
683 if(isset($_REQUEST["c"]))
688 if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
689 { /* the player already filled out everything */
690 echo "<p>just wait for the game to start</p>\n";
692 else if(!isset($_REQUEST["solo"]) ||
693 !isset($_REQUEST["wedding"]) ||
694 !isset($_REQUEST["poverty"]) ||
695 !isset($_REQUEST["nines"]) )
696 {/* player still needs to fill out the form */
698 echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
700 else if($game["init"]<4)
701 { /* save information */
702 if( $_REQUEST["solo"]!="No")
704 switch($_REQUEST["solo"])
707 $player[$c]["option"].="O";
710 $player[$c]["option"].="S";
713 $player[$c]["option"].="Q";
716 $player[$c]["option"].="J";
719 $player[$c]["option"].="C";
722 $player[$c]["option"].="A";
725 $player[$c]["option"].="H";
729 else if($_REQUEST["wedding"] == "yes")
731 echo "wedding was chosen<br />\n";
732 $player[$c]["option"].="W";
734 else if($_REQUEST["poverty"] == "yes")
736 echo "poverty was chosen<br />\n";
737 $player[$c]["option"].="P";
739 else if($_REQUEST["nines"] == "yes")
741 echo "nines was chosen<br />\n";
742 $player[$c]["option"].="N";
745 /* player finished setup */
746 $player[$c]["option"].="s";
749 /* reread status file, to get the correct startplayer, etc */
750 if(file_exists("status.txt"))
751 $lines = file("status.txt");
756 if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
758 echo "<p> The game can start now, it's your turn, please use this <a href=\"".
759 $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
761 else if($game["init"]==4)
763 $message = "The game can start now, it's your turn, please use this link to play a card:\n".
764 $host."?me=".$hash[$game["startplayer"]]."\n";
765 mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
766 echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
770 echo "<p>You're in. Once everyone has filled out the form, ".
771 "the game will start and you'll get an eamil on your turn.</p>\n";
780 /* check for sickness, only would need to do this on the first trick really...*/
781 /***** someone has 5 nines and no one is playing solo => cancel game */
782 if($game["nines"]>=0 && $game["solo-who"]<0)
784 $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
786 mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
788 $output = fopen("status.txt","w");
792 echo "problem opening file";
795 /* who is requesting this*/
796 if(!isset($_REQUEST["me"]))
798 if(!isset($_REQUEST["recovery"]))
800 echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
801 echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
803 <form action="index.php" method="post">
804 recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
805 <input type="submit" value="get me back into the game" />
811 $recovery = $_REQUEST["recovery"];
814 if(trim($recovery)==trim($player[$hash[$i]]["email"]))
818 $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
819 "\n if this doesn't work, contact the admin.\n";
820 mymail($recovery,"[DoKo-Debug] recovery ",$message);
821 echo "<p> An email with the game information has been sent.</p>\n";
825 echo "<p> can't find this email address, sorry.</p>\n";
831 $me = $_REQUEST["me"];
833 /* output if we are playing a solo or a wedding */
834 if($game["solo-who"]>=0)
835 echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
836 else if($game["wedding"]>=0)
837 echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
840 foreach($history as $play)
842 $trick = explode(":",$play);
845 /* found old trick, display it */
846 if(sizeof($trick)==5)
847 echo "<div class=\"oldtrick background".$play[0]."\"><div class=\"table\">\n";
849 echo "<div class=\"trick back".$play[0]."\"><div class=\"table\">\n";
850 for($i=0;$i<sizeof($trick)-1;$i++)
855 $tmp = explode("->",$card);
857 echo "<div class=\"card".$tmp[0]."\">";
859 if(strlen($tmp[2])>0)
860 echo "<span class=\"comment\">";
863 echo $player[$hash[$tmp[0]]]["name"];
864 /* check for comment */
865 if(strlen($tmp[2])>0)
866 echo " <span>".$tmp[2]."</span>";
869 display_card($tmp[1]);
875 echo "</div></div>\n";
878 /* figure out who needs to play next */
883 $next = $history[sizeof($history)-1][0];
885 /* are we trying to play a card? */
886 if(isset($_REQUEST["card"]))
888 if($hash[$next]==$me)
890 $card = $_REQUEST["card"];
891 $mycards = explode(";",$player[$me]["cards"]);
893 /* do we have that card */
894 if(in_array($card,$mycards))
896 /* delete card from array */
898 foreach($mycards as $m)
903 for($i=0;$i<sizeof($tmp)-1;$i++)
908 $player[$me]["cards"]=$tmp2;
910 /* add card to history, special case if this is the first card */
913 $history[sizeof($history)-1]="".$player[$me]["number"]."->".$card.":\n";
917 $tmp = explode(":",$history[sizeof($history)-1]);
918 $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card.":";
919 $history[sizeof($history)-1]=join(":",$tmp);
923 echo "<div class=\"card\">";
924 echo " you played <br />";
930 <form action="index.php" method="post">
931 A short comment:<input name="comment" type="text" size="30" maxlength="50" />
932 <input type="hidden" name="me" value="<?php echo $me; ?>" />
933 <input type="submit" value="submit comment" />
936 /* send out email to players who want/need to get informed */
937 /* check if we are in a trick, if trick is done, this needs to be handelt in the
938 * who-won-the-trick section further down */
939 $tmp = explode(":",$history[sizeof($history)-1]);
943 $mynext = $next+1; if($mynext>3)$mynext-=4;
945 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
947 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
951 $message .= "it's your turn now.\n".
952 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
954 $message .= $player[$me]["name"]." has played the following card ".
955 card_to_name($card)."\n";
957 if($game["solo-who"]>=0)
958 $message .= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
959 $game["solo-what"]." solo!\n";
961 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
964 echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
969 echo "seems like you don't have that card<br />\n";
973 } /* end if card is set */
974 else if(isset($_REQUEST["comment"]))
976 $comment = $_REQUEST["comment"];
977 $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
978 $tmp2 = explode("->",$tmp[sizeof($tmp)-2]); /*last played card */
980 $comment = str_replace(":","",$comment); /*can't have ":" in comments */
983 $tmp[sizeof($tmp)-2] .= "->".$comment;
984 $history[sizeof($history)-1]=join(":",$tmp);
988 else if(isset($_REQUEST["win"]) && strlen($history[sizeof($history)-1])>3)
989 { /* count points, email winner */
990 $win = $_REQUEST["win"];
992 if(strlen($player[$hash[0]]["cards"]))
993 $history[] = $win.":\n";
995 /* email the player who needs to move next*/
998 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
1000 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1004 $message .= "You won the last trick,it's your turn now.\n".
1005 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1008 $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
1009 "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
1011 if($game["solo-who"]>=0)
1012 $message.= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1013 $game["solo-what"]." solo!\n";
1015 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1018 echo "<a href=\"index.php?me=".$hash[$win]."\"> next player </a> <br />\n";
1022 /* count points of the last trick */
1025 $tmp = explode(":",$history[sizeof($history)-2]);
1028 $tmp2 = explode("->",$tmp[$i]);
1030 $points += card_value($c);
1032 $player[$hash[$win]]["points"] += $points;
1033 echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
1036 }; /* end if win is set */
1039 /* check last history entry: end of a trick? ask who won it, unless it was the last trick */
1040 $tmp = explode(":",$history[sizeof($history)-1]);
1041 if(sizeof($tmp)==5 && strlen($player[$hash[0]]["cards"]))
1044 <form action="index.php" method="post">
1048 echo $player[$hash[$i]]["name"]." <input type=\"radio\" name=\"win\" value=\"$i\" />";
1049 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />";
1051 <input type="submit" value="submit" />
1056 else if(sizeof($tmp)<5 && 1<sizeof($tmp) && !isset($_REQUEST["card"]))
1058 if(sizeof($tmp)==2 && strlen($tmp[0])==1)
1063 echo "DEBUG: the next move is for <a href=\"index.php?me=".$hash[$next]."\">the next player</a><br />\n";
1064 if(strlen(trim($player[$me]["cards"]))==0)
1066 echo "<br /> game over, count points <br />\n";
1069 echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
1074 } /* end check for winner */
1076 /* do we still have cards? display them */
1077 if(strlen(trim($player[$me]["cards"]))>0 )
1079 $allcards = trim($player[$me]["cards"]);
1080 $mycards = explode(";",$allcards);
1084 echo "<p class=\"mycards\">\n";
1085 /* is it our turn? */
1086 if($hash[$next]==$me && !isset($_REQUEST["card"]) && !isset($_REQUEST["win"]))
1088 echo "ITS YOUR TURN! <br />\n";
1089 echo "Your cards are: <br />\n";
1090 foreach($mycards as $card)
1091 display_link_card($card,$me);
1094 { /* not our turn, just show the hand */
1095 echo "Your cards are: <br />\n";
1096 foreach($mycards as $card)
1097 display_card($card);