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" />
9 <script type="text/javascript">
11 if(document.getElementById){
14 if(document.getElementById("trick"+i))
15 document.getElementById("trick"+i).style.display = 'none';
17 document.getElementById("trick"+num).style.display = 'block';
21 if(document.getElementById){
24 if(document.getElementById("trick"+i))
34 <body onload="high_last();">
36 <h1> Welcome to E-Doko </h1>
43 $host = "http://doko.nubati.net/index.php";
44 $wiki = "http://wiki.nubati.net/index.php?title=EmailDoko";
60 function mymail($To,$Subject,$message)
66 $message = str_replace("\n","<br />",$message);
67 echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
70 mail($To,$Subject,$message);
74 function is_trump($c) { return (($c<27) ? 1:0);}
75 function is_club($c) { return (in_array($c,array('27','28','29','30','31','32','33','34')));}
76 function is_space($c) { return (in_array($c,array('35','36','37','38','39','40','41','42')));}
77 function is_heart($c) { return (in_array($c,array('43','44','45','46','47','48')));}
79 function compare_cards($a,$b)
81 /* if a is higher than b return 1, else 0, a being the card first played */
83 /* first map all cards to the odd number */
84 if( $a/2 - (int)($a/2) != 0.5)
86 if( $b/2 - (int)($b/2) != 0.5)
89 if(is_trump($a) && $a<=$b)
91 else if(is_trump($a) && $a>$b)
94 { /*$a is not a trump */
100 if( is_club($a) && is_club($b))
106 if( is_spade($a) && is_spade($b))
112 if( is_heart($a) && is_heart($b))
123 function get_winner($p)
130 if( compare_cards($c1,$c2) && compare_cards($c1,$c3) && compare_cards($c1,$c4) )
132 if( compare_cards($c2,$c3) && compare_cards($c2,$c4) )
134 if( compare_cards($c3,$c4) )
139 function parse_status()
141 global $game,$history,$player,$hash,$lines;
144 $game["solo-who"] = -1;
145 $game["solo-what"] = "todo";
146 $game["wedding"] = -1;
147 $game["poverty"] = "";
149 $game["startplayer"] = 0;
153 $tmp = explode( ":",$lines[$i]);
155 $player[$tmp[0]]["number"] = $i;
156 $player[$tmp[0]]["hash"] = $tmp[0];
157 $player[$tmp[0]]["name"] = $tmp[1];
158 $player[$tmp[0]]["email"] = $tmp[2];
159 $player[$tmp[0]]["option"] = $tmp[3];
160 $player[$tmp[0]]["points"] = $tmp[4];
161 $player[$tmp[0]]["cards"] = $tmp[5];
162 if(ereg("s",$tmp[3])) $game["init"]++; /* how many players are ready? */
163 if(ereg("P",$tmp[3])) $game["poverty"].= $i; /* players with poverty, could be two, so use a string */
164 if(ereg("N",$tmp[3])) $game["nines"] = $i; /* the player with too many nines, only one possible */
165 if(ereg("W",$tmp[3])) $game["wedding"] = $i; /* the player with the wedding, also only one possible */
166 if(ereg("([OSQJCAH])",$tmp[3],$match) && ($game["solo-who"]<0) )
168 $game["solo-who"] = $i;
169 $game["startplayer"] = $i;
173 $game["solo-what"] = "No Trump";
175 $game["solo-what"] = "Trump";
177 $game["solo-what"] = "Queen";
179 $game["solo-what"] = "Jack";
181 $game["solo-what"] = "Club";
183 $game["solo-what"] = "Spade";
185 $game["solo-what"] = "Heart";
190 /* save the game history */
191 for($i=4;$i<sizeof($lines);$i++)
193 if(!ereg("^[[:space:]]*$",trim($lines[$i])))
195 $history[] = $lines[$i];
199 if(sizeof($history)==0 || (sizeof($history)==1 && strlen($history[0])==3 ))
200 $history[0] = $game["startplayer"].":";
205 function count_nines($cards)
207 $card = explode(";",$cards);
213 if($c == "25" || $c == "26") $nines++;
214 else if($c == "33" || $c == "34") $nines++;
215 else if($c == "41" || $c == "42") $nines++;
216 else if($c == "47" || $c == "48") $nines++;
222 function check_wedding($cards)
224 $card = explode(";",$cards);
228 if( in_array("3",$card) && in_array("2",$card) )
234 function count_trump($cards)
236 $card = explode(";",$cards);
240 /* count each trump */
246 if( in_array("19",$card))
248 if( in_array("20",$card) )
250 /* add one, in case the player has both foxes (schweinchen) */
251 if( in_array("19",$card) && in_array("20",$card) )
257 function card_to_name($card)
263 return "ten of hearts";
266 return "queen of clubs";
269 return "queen of spades";
272 return "queen of hearts";
275 return "queen of diamonds";
278 return "jack of clubs";
281 return "jack of spades";
284 return "jack of hearts";
287 return "jack of diamonds";
290 return "ace of diamonds";
293 return "ten of diamonds";
296 return "king of diamonds";
299 return "nine of diamonds";;
302 return "ace of clubs";
305 return "ten of clubs";
308 return "king of clubs";
311 return "nine of clubs";
314 return "ace of spades";
317 return "ten of spades";
320 return "king of spades";
323 return "nine of spades";
326 return "ace of hearts";
329 return "king of hearts";
332 return "nine of hearts";
334 return "something went wrong, please contact the admin. Error: code1.";
338 function card_value($card)
409 echo "something went wrong, please contact the admin. ErrorCode 2<br>";
414 function display_card($card)
416 if( $card/2 - (int)($card/2) == 0.5)
417 echo "<img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
419 echo "<img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
423 function display_link_card($card,$me)
425 /* if( $card/2 - (int)($card/2) == 0.5)
426 echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" /></a>\n";
428 echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" /></a>\n";
430 if( $card/2 - (int)($card/2) == 0.5)
431 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
433 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
437 function save_status()
439 global $player,$game,$hash,$history;
441 $output = fopen("status.txt","w");
444 foreach($hash as $key)
446 /* sorting the options, not sure why I do that actually */
448 if( ereg("i",$player[$key]["option"]) )
450 if( ereg("s",$player[$key]["option"]) )
452 if( ereg("t",$player[$key]["option"]) )
454 if( ereg("c",$player[$key]["option"]) )
456 if( ereg("N",$player[$key]["option"]) )
458 if( ereg("W",$player[$key]["option"]) )
460 if( ereg("P",$player[$key]["option"]) )
462 if( ereg("O",$player[$key]["option"]) )
464 if( ereg("S",$player[$key]["option"]) )
466 if( ereg("Q",$player[$key]["option"]) )
468 if( ereg("J",$player[$key]["option"]) )
470 if( ereg("C",$player[$key]["option"]) )
472 if( ereg("A",$player[$key]["option"]) )
474 if( ereg("H",$player[$key]["option"]) )
476 $player[$key]["option"]=$tmp;
478 /* saving the player stats */
479 fwrite($output,"".$player[$key]["hash"].":" );
480 fwrite($output,"".$player[$key]["name"].":" );
481 fwrite($output,"".$player[$key]["email"].":" );
482 fwrite($output,"".$player[$key]["option"].":" );
483 fwrite($output,"".$player[$key]["points"].":" );
484 fwrite($output,"".$player[$key]["cards"] .":");
485 fwrite($output,"\n");
487 fwrite($output,"\n");
488 foreach($history as $line)
489 fwrite($output,$line);
491 fwrite($output,"\n");
495 echo "can't open file for writing, please inform the admin.errorcode3";
500 /***************** M A I N **************************/
505 /* check for status file and read it, if possible */
507 if(file_exists("status.txt"))
508 $lines = file("status.txt");
512 /* check if we want to start a new game */
513 if( isset($_REQUEST["PlayerA"]) &&
514 isset($_REQUEST["PlayerB"]) &&
515 isset($_REQUEST["PlayerC"]) &&
516 isset($_REQUEST["PlayerD"]) &&
517 isset($_REQUEST["EmailA"]) &&
518 isset($_REQUEST["EmailB"]) &&
519 isset($_REQUEST["EmailC"]) &&
520 isset($_REQUEST["EmailD"]) && sizeof($lines<2))
522 $PlayerA = $_REQUEST["PlayerA"];
523 $PlayerB = $_REQUEST["PlayerB"];
524 $PlayerC = $_REQUEST["PlayerC"];
525 $PlayerD = $_REQUEST["PlayerD"];
526 $EmailA = $_REQUEST["EmailA"] ;
527 $EmailB = $_REQUEST["EmailB"] ;
528 $EmailC = $_REQUEST["EmailC"] ;
529 $EmailD = $_REQUEST["EmailD"] ;
531 $hashA = md5("AGameOfDoko".$PlayerA.$EmailA);
532 $hashB = md5("AGameOfDoko".$PlayerB.$EmailB);
533 $hashC = md5("AGameOfDoko".$PlayerC.$EmailC);
534 $hashD = md5("AGameOfDoko".$PlayerD.$EmailD);
536 /* send out email, check for error with email */
539 "you are invited to play a game of DoKo (that is to debug the program ;).\n".
540 "Place comments and bug reports here:\n".
541 "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
542 "The whole round would consist of the following players:\n".
547 "If you want to join this game, please follow this link:\n\n".
550 mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
551 mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
552 mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
553 mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
555 /* read in random.txt */
556 if(file_exists("random.txt"))
557 $random = file("random.txt");
559 die("no random file");
561 $randomNR = explode( ":", $random[2] );
563 /* write initial status into file */
564 $output = fopen("status.txt","w");
567 fwrite($output, "$hashA:$PlayerA:$EmailA:::" );
569 fwrite($output,"$randomNR[$i];" );
570 fwrite($output,"$randomNR[11]:" ); $i++;
571 fwrite($output,"\n");
573 fwrite($output, "$hashB:$PlayerB:$EmailB:::" );
575 fwrite($output,"$randomNR[$i];" );
576 fwrite($output,"$randomNR[23]:" ); $i++;
577 fwrite($output,"\n");
579 fwrite($output, "$hashC:$PlayerC:$EmailC:::" );
581 fwrite($output,"$randomNR[$i];" );
582 fwrite($output,"$randomNR[35]:" ); $i++;
583 fwrite($output,"\n");
585 fwrite($output, "$hashD:$PlayerD:$EmailD:::");
587 fwrite($output,"$randomNR[$i];" );
588 fwrite($output,"$randomNR[47]:" );
589 fwrite($output,"\n");
594 echo "can't open file for writing";
597 if(file_exists("status.txt"))
598 $lines = file("status.txt");
602 /* test if a game is running, else output everything for a new game */
606 <p> no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct! </p>
607 <form action="index.php" method="post">
608 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
609 Email: <input name="EmailA" type="text" size="20" maxlength="30" /> <br />
611 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
612 Email: <input name="EmailB" type="text" size="20" maxlength="30" /> <br />
614 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
615 Email: <input name="EmailC" type="text" size="20" maxlength="30" /> <br />
617 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
618 Email: <input name="EmailD" type="text" size="20" maxlength="30" /> <br />
620 <input type="submit" value="start game" />
625 { /* load game status */
632 * check if a player wants to accept a game
634 if(isset($_REQUEST["a"]))
638 if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
640 echo "just wait for the game to start";
642 else if( !ereg("[is]",$player[$a]["option"]) )
645 <form action="index.php" method="post">
646 Do you want to play a game of DoKo?
647 yes<input type="radio" name="in" value="yes" />
648 no<input type="radio" name="in" value="no" /> <br />
650 Do you want to get an email for every card played or only if it your move?
651 every card<input type="radio" name="update" value="card" />
652 only on my turn<input type="radio" name="update" value="turn" /> <br />
654 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
656 echo "<input type=\"submit\" value=\"count me in\" />\n";
665 * yes? email him his hand, ask for solo, poverty, email every move or every card?
667 if(isset($_REQUEST["b"]))
671 if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
672 { /* the player already filled out everything */
673 echo "just wait for the game to start";
675 else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
676 { /* the player didn't fill out the form at "a" correctly */
678 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
681 { /* show the hand and check if the player is sick*/
682 if($_REQUEST["in"]=="no")
683 { /* player doesn't want to play, cancel the game */
686 $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
687 "the game has been canceled due to the request of one of the players.\n";
688 mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
690 /* canceling the game is as easy as removing the contents of the status file*/
691 $output = fopen("status.txt","w");
695 echo "problem opening file";
699 /* player wants to play, save information from "a"*/
700 if($_REQUEST["update"]=="card")
701 $player[$b]["option"] .= "c";
703 $player[$b]["option"] .= "t";
705 $player[$b]["option"] .= "i"; /* player finished stage "a" */
709 $allcards = $player[$b]["cards"];
710 $mycards = explode(";",$allcards);
713 echo "<p class=\"mycards\">your cards are: <br />\n";
714 foreach($mycards as $card)
718 <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>
720 <form action="index.php" method="post">
722 do you want to play solo?
723 <select name="solo" size="1">
725 <option>No trump</option>
726 <option>Normal solo</option>
727 <option>Queen solo</option>
728 <option>Jack solo</option>
729 <option>Club solo</option>
730 <option>Spade solo</option>
731 <option>Heart solo</option>
738 if(check_wedding($player[$b]["cards"]))
740 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
741 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
745 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
748 echo "do you have poverty?";
749 if(count_trump($player[$b]["cards"])<4)
751 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
752 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
756 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
759 echo "do you have too many nines?";
760 if(count_nines($player[$b]["cards"])>4)
762 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
763 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
767 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
770 echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
771 echo "<input type=\"submit\" value=\"count me in\" />\n";
778 if(isset($_REQUEST["c"]))
783 if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
784 { /* the player already filled out everything */
785 echo "<p>just wait for the game to start</p>\n";
787 else if(!isset($_REQUEST["solo"]) ||
788 !isset($_REQUEST["wedding"]) ||
789 !isset($_REQUEST["poverty"]) ||
790 !isset($_REQUEST["nines"]) )
791 {/* player still needs to fill out the form */
793 echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
795 else if($game["init"]<4)
796 { /* save information */
797 if( $_REQUEST["solo"]!="No")
799 switch($_REQUEST["solo"])
802 $player[$c]["option"].="O";
805 $player[$c]["option"].="S";
808 $player[$c]["option"].="Q";
811 $player[$c]["option"].="J";
814 $player[$c]["option"].="C";
817 $player[$c]["option"].="A";
820 $player[$c]["option"].="H";
824 else if($_REQUEST["wedding"] == "yes")
826 echo "wedding was chosen<br />\n";
827 $player[$c]["option"].="W";
829 else if($_REQUEST["poverty"] == "yes")
831 echo "poverty was chosen<br />\n";
832 $player[$c]["option"].="P";
834 else if($_REQUEST["nines"] == "yes")
836 echo "nines was chosen<br />\n";
837 $player[$c]["option"].="N";
840 /* player finished setup */
841 $player[$c]["option"].="s";
844 /* reread status file, to get the correct startplayer, etc */
845 if(file_exists("status.txt"))
846 $lines = file("status.txt");
851 if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
853 echo "<p> The game can start now, it's your turn, please use this <a href=\"".
854 $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
856 else if($game["init"]==4)
858 $message = "The game can start now, it's your turn, please use this link to play a card:\n".
859 $host."?me=".$hash[$game["startplayer"]]."\n";
860 mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
861 echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
865 echo "<p>You're in. Once everyone has filled out the form, ".
866 "the game will start and you'll get an eamil on your turn.</p>\n";
875 /* check for sickness, only would need to do this on the first trick really...*/
876 /***** someone has 5 nines and no one is playing solo => cancel game */
877 if($game["nines"]>=0 && $game["solo-who"]<0)
879 $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
881 mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
883 $output = fopen("status.txt","w");
887 echo "problem opening file";
890 /* who is requesting this*/
891 if(!isset($_REQUEST["me"]))
893 if(!isset($_REQUEST["recovery"]))
895 echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
896 echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
898 <form action="index.php" method="post">
899 recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
900 <input type="submit" value="get me back into the game" />
906 $recovery = $_REQUEST["recovery"];
909 if(trim($recovery)==trim($player[$hash[$i]]["email"]))
913 $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
914 "\n if this doesn't work, contact the admin.error4\n";
915 mymail($recovery,"[DoKo-Debug] recovery ",$message);
916 echo "<p> An email with the game information has been sent.</p>\n";
920 echo "<p> can't find this email address, sorry.</p>\n";
926 $me = $_REQUEST["me"];
929 /* old tricks as list */
930 echo "<ul class=\"oldtrick\">\n";
931 echo " <li> History: </li>\n";
933 foreach($history as $play)
936 $trick = explode(":",$play);
938 /* found old trick, display it */
939 if(sizeof($trick)==5)
940 echo " <li onclick=\"hl('$j');\"><a href=\"#\">Trick $j</a>\n <div class=\"table\" id=\"trick".$j."\">\n <img class=\"table\" src=\"pics/table".$play[0].".png\" alt=\"table\" />\n";
943 /* display current trick */
944 echo "<li onclick=\"hl('$j');\"><a href=\"#\">Current Trick</a>\n <div class=\"table\" id=\"trick".$j."\">\n <img class=\"table\" src=\"pics/table".$play[0].".png\" alt=\"table\" />";
946 for($i=0;$i<sizeof($trick)-1;$i++)
951 /* has a card been played? */
954 $tmp = explode("->",$card);
956 echo " <div class=\"card".$tmp[0]."\">\n";
958 if(strlen($tmp[2])>0)
959 echo " <span class=\"comment\">";
962 echo $player[$hash[$tmp[0]]]["name"];
963 /* check for comment */
964 if(strlen($tmp[2])>0)
965 echo "<span>".$tmp[2]."</span>";
968 display_card($tmp[1]);
975 echo " </div>\n </li>\n";
979 echo "<div class=\"line\"></div>";
981 /* output if we are playing a solo or a wedding */
982 echo "<div class=\"info\">";
983 if($game["solo-who"]>=0)
984 echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
985 else if($game["wedding"]>=0)
986 echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
988 echo "<div class=\"bug\"> Poverty not working yet! <br />".
989 " Schweinchen not working yet <br />".
990 "Bug: at the end of the game the winner of the last trick can add more points to his score by reloading the page <br />".
991 "If you find more bugs, please list them in the <a href=\"".$wiki.
992 "\">wiki</a>.Hit shift reload every now and then too.</div>\n";
995 /* figure out who needs to play next */
1000 /* if no one has played yet or we are at the start of a new trick */
1002 $next = $history[sizeof($history)-1][0];
1004 /* are we trying to play a card? */
1005 if(isset($_REQUEST["card"]))
1007 if($hash[$next]==$me)
1009 $card = $_REQUEST["card"];
1010 $mycards = explode(";",$player[$me]["cards"]);
1011 $comment = $_REQUEST["comment"];
1012 $comment = str_replace(":","",$comment); /*can't have ":" in comments */
1014 /* do we have that card */
1015 if(in_array($card,$mycards))
1017 /* delete card from array */
1019 foreach($mycards as $m)
1024 for($i=0;$i<sizeof($tmp)-1;$i++)
1026 $tmp2.=$tmp[$i].";";
1029 $player[$me]["cards"]=$tmp2;
1031 /* add card to history, special case if this is the first card */
1034 $history[sizeof($history)-1]="".$player[$me]["number"]."->".$card."->$comment:\n";
1038 $tmp = explode(":",$history[sizeof($history)-1]);
1039 $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card."->$comment:";
1040 $history[sizeof($history)-1]=join(":",$tmp);
1044 echo "<div class=\"card\">";
1045 echo " you played <br />";
1046 display_card($card);
1049 /* send out email to players who want/need to get informed */
1050 /* check if we are in a trick, if trick is done, this needs to be handelt in the
1051 * who-won-the-trick section further down */
1052 $tmp = explode(":",$history[sizeof($history)-1]);
1056 $mynext = $next+1; if($mynext>3)$mynext-=4;
1058 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
1060 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1064 $message .= "it's your turn now.\n".
1065 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1067 $message .= $player[$me]["name"]." has played the following card ".
1068 card_to_name($card)."\n";
1070 if($game["solo-who"]>=0)
1071 $message .= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1072 $game["solo-what"]." solo!\n";
1074 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1077 echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
1082 echo "seems like you don't have that card<br />\n";
1084 } /* end if card is set */
1085 if(substr_count($history[sizeof($history)-1],":")==4)
1086 { /* count points, email winner */
1090 $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
1092 /* get player and cards of last trick */
1095 $tmp2 = explode("->",$tmp[$i]);
1100 $win = $p[get_winner($c)];
1102 if(strlen($player[$hash[0]]["cards"]))
1103 $history[] = "\n".$win.":\n"; /* not sure why I need the first \n here */
1105 /* email the player who needs to move next*/
1108 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
1110 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1114 $message .= "You won the last trick,it's your turn now.\n".
1115 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1118 $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
1119 "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
1121 if($game["solo-who"]>=0)
1122 $message.= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1123 $game["solo-what"]." solo!\n";
1125 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1128 echo "<a href=\"index.php?me=".$hash[$win]."\"> next player </a> <br />\n";
1132 /* count points of the last trick */
1135 $tmp = explode(":",$history[sizeof($history)-2]);
1138 $tmp2 = explode("->",$tmp[$i]);
1140 $points += card_value($c);
1142 $player[$hash[$win]]["points"] += $points;
1143 echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
1146 }; /* end if win is set */
1149 /* check if game is done */
1152 if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
1157 echo "<br /> game over, count points <br />\n";
1160 echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
1163 /* check end of game */
1165 /* do we still have cards? display them */
1166 if(strlen(trim($player[$me]["cards"]))>0 )
1168 $allcards = trim($player[$me]["cards"]);
1169 $mycards = explode(";",$allcards);
1173 echo "<div class=\"mycards\">\n";
1174 /* is it our turn? */
1175 if($hash[$next]==$me && !isset($_REQUEST["card"]))
1177 echo "Hello ".$player[$me]["name"].", it's your turn! <br />\n";
1178 echo "Your cards are: <br />\n";
1179 echo "<form action=\"index.php\" method=\"post\">\n";
1180 foreach($mycards as $card)
1181 display_link_card($card,$me);
1183 <br />A short comment:<input name="comment" type="text" size="30" maxlength="50" />
1184 <input type="hidden" name="me" value="<?php echo $me; ?>" />
1185 <input type="submit" value="move" />
1190 { /* not our turn, just show the hand */
1191 echo "Your cards are: <br />\n";
1192 foreach($mycards as $card)
1193 display_card($card);