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";
58 function mymail($To,$Subject,$message)
64 $message = str_replace("\n","<br />",$message);
65 echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
68 mail($To,$Subject,$message);
72 function is_trump($c) { return (($c<27) ? 1:0);}
73 function is_club($c) { return (in_array($c,array('27','28','29','30','31','32','33','34')));}
74 function is_spade($c) { return (in_array($c,array('35','36','37','38','39','40','41','42')));}
75 function is_heart($c) { return (in_array($c,array('43','44','45','46','47','48')));}
77 function compare_cards($a,$b)
79 /* if a is higher than b return 1, else 0, a being the card first played */
81 /* first map all cards to the odd number */
82 if( $a/2 - (int)($a/2) != 0.5)
84 if( $b/2 - (int)($b/2) != 0.5)
87 if(is_trump($a) && $a<=$b)
89 else if(is_trump($a) && $a>$b)
92 { /*$a is not a trump */
98 if( is_club($a) && is_club($b))
104 if( is_spade($a) && is_spade($b))
110 if( is_heart($a) && is_heart($b))
121 function get_winner($p)
123 /* get all 4 cards played in a trick */
129 /* find out who won */
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++)
192 if(!ereg("^[[:space:]]*$",trim($lines[$i])))
193 $history[] = $lines[$i];
195 if(sizeof($history)==0 || (sizeof($history)==1 && strlen($history[0])==3 ))
196 $history[0] = $game["startplayer"].":";
201 function count_nines($cards)
203 $card = explode(";",$cards);
208 if($c == "25" || $c == "26") $nines++;
209 else if($c == "33" || $c == "34") $nines++;
210 else if($c == "41" || $c == "42") $nines++;
211 else if($c == "47" || $c == "48") $nines++;
217 function check_wedding($cards)
219 $card = explode(";",$cards);
221 if( in_array("3",$card) && in_array("2",$card) )
227 function count_trump($cards)
229 $card = explode(";",$cards);
232 /* count each trump */
238 if( in_array("19",$card))
240 if( in_array("20",$card) )
242 /* add one, in case the player has both foxes (schweinchen) */
243 if( in_array("19",$card) && in_array("20",$card) )
249 function card_to_name($card)
255 return "ten of hearts";
258 return "queen of clubs";
261 return "queen of spades";
264 return "queen of hearts";
267 return "queen of diamonds";
270 return "jack of clubs";
273 return "jack of spades";
276 return "jack of hearts";
279 return "jack of diamonds";
282 return "ace of diamonds";
285 return "ten of diamonds";
288 return "king of diamonds";
291 return "nine of diamonds";;
294 return "ace of clubs";
297 return "ten of clubs";
300 return "king of clubs";
303 return "nine of clubs";
306 return "ace of spades";
309 return "ten of spades";
312 return "king of spades";
315 return "nine of spades";
318 return "ace of hearts";
321 return "king of hearts";
324 return "nine of hearts";
326 return "something went wrong, please contact the admin. Error: code1.";
330 function card_value($card)
343 case 9: /* diamonds */
346 case 11: /* clubes */
348 case 13: /* spades */
350 case 15: /* hearts */
352 case 17: /* diamonds */
355 case 19: /* diamonds */
359 case 35: /* spades */
361 case 43: /* hearts */
364 case 21: /* diamonds */
368 case 37: /* spades */
371 case 23: /* diamonds */
375 case 39: /* spades */
377 case 45: /* hearts */
380 case 25: /* diamonds */
384 case 41: /* spades */
386 case 47: /* hearts */
390 echo "something went wrong, please contact the admin. ErrorCode: 2<br>";
395 function display_card($card)
397 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
398 * convert even cards to the matching odd value */
400 if( $card/2 - (int)($card/2) == 0.5)
401 echo "<img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
403 echo "<img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
408 function display_link_card($card,$me)
410 if( $card/2 - (int)($card/2) == 0.5)
411 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
413 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
417 function save_status()
419 global $player,$game,$hash,$history;
421 $output = fopen("status.txt","w");
424 foreach($hash as $key)
426 /* sorting the options, not sure why I do that actually */
428 if( ereg("i",$player[$key]["option"]) )
430 if( ereg("s",$player[$key]["option"]) )
432 if( ereg("t",$player[$key]["option"]) )
434 if( ereg("c",$player[$key]["option"]) )
436 if( ereg("N",$player[$key]["option"]) )
438 if( ereg("W",$player[$key]["option"]) )
440 if( ereg("P",$player[$key]["option"]) )
442 if( ereg("O",$player[$key]["option"]) )
444 if( ereg("S",$player[$key]["option"]) )
446 if( ereg("Q",$player[$key]["option"]) )
448 if( ereg("J",$player[$key]["option"]) )
450 if( ereg("C",$player[$key]["option"]) )
452 if( ereg("A",$player[$key]["option"]) )
454 if( ereg("H",$player[$key]["option"]) )
456 $player[$key]["option"]=$tmp;
458 /* saving the player stats */
459 fwrite($output,"".$player[$key]["hash"].":" );
460 fwrite($output,"".$player[$key]["name"].":" );
461 fwrite($output,"".$player[$key]["email"].":" );
462 fwrite($output,"".$player[$key]["option"].":" );
463 fwrite($output,"".$player[$key]["points"].":" );
464 fwrite($output,"".$player[$key]["cards"] .":");
465 fwrite($output,"\n");
467 fwrite($output,"\n");
468 foreach($history as $line)
469 fwrite($output,$line);
471 fwrite($output,"\n");
475 echo "can't open file for writing, please inform the admin.errorcode3";
480 /***************** M A I N **************************/
484 /* check for status file and read it, if possible */
486 if(file_exists("status.txt"))
487 $lines = file("status.txt");
491 /* check if we want to start a new game */
492 if( isset($_REQUEST["PlayerA"]) &&
493 isset($_REQUEST["PlayerB"]) &&
494 isset($_REQUEST["PlayerC"]) &&
495 isset($_REQUEST["PlayerD"]) &&
496 isset($_REQUEST["EmailA"]) &&
497 isset($_REQUEST["EmailB"]) &&
498 isset($_REQUEST["EmailC"]) &&
499 isset($_REQUEST["EmailD"]) && sizeof($lines<2))
501 $PlayerA = $_REQUEST["PlayerA"];
502 $PlayerB = $_REQUEST["PlayerB"];
503 $PlayerC = $_REQUEST["PlayerC"];
504 $PlayerD = $_REQUEST["PlayerD"];
505 $EmailA = $_REQUEST["EmailA"] ;
506 $EmailB = $_REQUEST["EmailB"] ;
507 $EmailC = $_REQUEST["EmailC"] ;
508 $EmailD = $_REQUEST["EmailD"] ;
510 $hashA = md5("AGameOfDoko".$PlayerA.$EmailA);
511 $hashB = md5("AGameOfDoko".$PlayerB.$EmailB);
512 $hashC = md5("AGameOfDoko".$PlayerC.$EmailC);
513 $hashD = md5("AGameOfDoko".$PlayerD.$EmailD);
515 /* send out email, check for error with email */
518 "you are invited to play a game of DoKo (that is to debug the program ;).\n".
519 "Place comments and bug reports here:\n".
520 "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
521 "The whole round would consist of the following players:\n".
526 "If you want to join this game, please follow this link:\n\n".
529 mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
530 mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
531 mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
532 mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
534 /* read in random.txt */
535 if(file_exists("random.txt"))
536 $random = file("random.txt");
538 die("no random file");
540 $randomNR = explode( ":", $random[4] );
542 /* write initial status into file */
543 $output = fopen("status.txt","w");
546 fwrite($output, "$hashA:$PlayerA:$EmailA:::" );
548 fwrite($output,"$randomNR[$i];" );
549 fwrite($output,"$randomNR[11]:" ); $i++;
550 fwrite($output,"\n");
552 fwrite($output, "$hashB:$PlayerB:$EmailB:::" );
554 fwrite($output,"$randomNR[$i];" );
555 fwrite($output,"$randomNR[23]:" ); $i++;
556 fwrite($output,"\n");
558 fwrite($output, "$hashC:$PlayerC:$EmailC:::" );
560 fwrite($output,"$randomNR[$i];" );
561 fwrite($output,"$randomNR[35]:" ); $i++;
562 fwrite($output,"\n");
564 fwrite($output, "$hashD:$PlayerD:$EmailD:::");
566 fwrite($output,"$randomNR[$i];" );
567 fwrite($output,"$randomNR[47]:" );
568 fwrite($output,"\n");
573 echo "can't open file for writing";
576 if(file_exists("status.txt"))
577 $lines = file("status.txt");
581 /* test if a game is running, else output everything for a new game */
585 <p> no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct! </p>
586 <form action="index.php" method="post">
587 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
588 Email: <input name="EmailA" type="text" size="20" maxlength="30" /> <br />
590 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
591 Email: <input name="EmailB" type="text" size="20" maxlength="30" /> <br />
593 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
594 Email: <input name="EmailC" type="text" size="20" maxlength="30" /> <br />
596 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
597 Email: <input name="EmailD" type="text" size="20" maxlength="30" /> <br />
599 <input type="submit" value="start game" />
604 { /* load game status */
611 * check if a player wants to accept a game
613 if(isset($_REQUEST["a"]))
617 if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
619 echo "just wait for the game to start";
621 else if( !ereg("[is]",$player[$a]["option"]) )
624 <form action="index.php" method="post">
625 Do you want to play a game of DoKo?
626 yes<input type="radio" name="in" value="yes" />
627 no<input type="radio" name="in" value="no" /> <br />
629 Do you want to get an email for every card played or only if it your move?
630 every card<input type="radio" name="update" value="card" />
631 only on my turn<input type="radio" name="update" value="turn" /> <br />
633 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
635 echo "<input type=\"submit\" value=\"count me in\" />\n";
644 * yes? email him his hand, ask for solo, poverty, email every move or every card?
646 if(isset($_REQUEST["b"]))
650 if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
651 { /* the player already filled out everything */
652 echo "just wait for the game to start";
654 else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
655 { /* the player didn't fill out the form at "a" correctly */
657 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
660 { /* show the hand and check if the player is sick*/
661 if($_REQUEST["in"]=="no")
662 { /* player doesn't want to play, cancel the game */
665 $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
666 "the game has been canceled due to the request of one of the players.\n";
667 mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
669 /* canceling the game is as easy as removing the contents of the status file*/
670 $output = fopen("status.txt","w");
674 echo "problem opening file";
678 /* player wants to play, save information from "a"*/
679 if($_REQUEST["update"]=="card")
680 $player[$b]["option"] .= "c";
682 $player[$b]["option"] .= "t";
684 $player[$b]["option"] .= "i"; /* player finished stage "a" */
688 $allcards = $player[$b]["cards"];
689 $mycards = explode(";",$allcards);
692 echo "<p class=\"mycards\">your cards are: <br />\n";
693 foreach($mycards as $card)
697 <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>
699 <form action="index.php" method="post">
701 do you want to play solo?
702 <select name="solo" size="1">
704 <option>No trump</option>
705 <option>Normal solo</option>
706 <option>Queen solo</option>
707 <option>Jack solo</option>
708 <option>Club solo</option>
709 <option>Spade solo</option>
710 <option>Heart solo</option>
717 if(check_wedding($player[$b]["cards"]))
719 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
720 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
724 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
727 echo "do you have poverty?";
728 if(count_trump($player[$b]["cards"])<4)
730 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
731 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
735 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
738 echo "do you have too many nines?";
739 if(count_nines($player[$b]["cards"])>4)
741 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
742 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
746 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
749 echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
750 echo "<input type=\"submit\" value=\"count me in\" />\n";
757 if(isset($_REQUEST["c"]))
762 if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
763 { /* the player already filled out everything */
764 echo "<p>just wait for the game to start</p>\n";
766 else if(!isset($_REQUEST["solo"]) ||
767 !isset($_REQUEST["wedding"]) ||
768 !isset($_REQUEST["poverty"]) ||
769 !isset($_REQUEST["nines"]) )
770 {/* player still needs to fill out the form */
772 echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
774 else if($game["init"]<4)
775 { /* save information */
776 if( $_REQUEST["solo"]!="No")
778 switch($_REQUEST["solo"])
781 $player[$c]["option"].="O";
784 $player[$c]["option"].="S";
787 $player[$c]["option"].="Q";
790 $player[$c]["option"].="J";
793 $player[$c]["option"].="C";
796 $player[$c]["option"].="A";
799 $player[$c]["option"].="H";
803 else if($_REQUEST["wedding"] == "yes")
805 echo "wedding was chosen<br />\n";
806 $player[$c]["option"].="W";
808 else if($_REQUEST["poverty"] == "yes")
810 echo "poverty was chosen<br />\n";
811 $player[$c]["option"].="P";
813 else if($_REQUEST["nines"] == "yes")
815 echo "nines was chosen<br />\n";
816 $player[$c]["option"].="N";
819 /* player finished setup */
820 $player[$c]["option"].="s";
823 /* reread status file, to get the correct startplayer, etc */
824 if(file_exists("status.txt"))
825 $lines = file("status.txt");
830 if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
832 echo "<p> The game can start now, it's your turn, please use this <a href=\"".
833 $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
835 else if($game["init"]==4)
837 $message = "The game can start now, it's your turn, please use this link to play a card:\n".
838 $host."?me=".$hash[$game["startplayer"]]."\n";
839 mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
840 echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
844 echo "<p>You're in. Once everyone has filled out the form, ".
845 "the game will start and you'll get an eamil on your turn.</p>\n";
854 /* check for sickness, only would need to do this on the first trick really...*/
855 /***** someone has 5 nines and no one is playing solo => cancel game */
856 if($game["nines"]>=0 && $game["solo-who"]<0)
858 $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
860 mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
862 $output = fopen("status.txt","w");
866 echo "problem opening file";
869 /* who is requesting this*/
870 if(!isset($_REQUEST["me"]))
872 if(!isset($_REQUEST["recovery"]))
874 echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
875 echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
877 <form action="index.php" method="post">
878 recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
879 <input type="submit" value="get me back into the game" />
885 $recovery = $_REQUEST["recovery"];
888 if(trim($recovery)==trim($player[$hash[$i]]["email"]))
892 $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
893 "\n if this doesn't work, contact the admin.error4\n";
894 mymail($recovery,"[DoKo-Debug] recovery ",$message);
895 echo "<p> An email with the game information has been sent.</p>\n";
899 echo "<p> can't find this email address, sorry.</p>\n";
905 $me = $_REQUEST["me"];
908 /* old tricks as list */
909 echo "<ul class=\"oldtrick\">\n";
910 echo " <li> History: </li>\n";
912 foreach($history as $play)
915 $trick = explode(":",$play);
917 /* found old trick, display it */
918 if(sizeof($trick)==5)
919 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";
922 /* display current trick */
923 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\" />";
925 for($i=0;$i<sizeof($trick)-1;$i++)
930 /* has a card been played? */
933 $tmp = explode("->",$card);
935 echo " <div class=\"card".$tmp[0]."\">\n";
937 if(strlen($tmp[2])>0)
938 echo " <span class=\"comment\">";
941 echo $player[$hash[$tmp[0]]]["name"];
942 /* check for comment */
943 if(strlen($tmp[2])>0)
944 echo "<span>".$tmp[2]."</span>";
947 display_card($tmp[1]);
954 echo " </div>\n </li>\n";
956 echo "</ul> <hr />\n";
958 echo "<div class=\"line\"></div>";
960 /* output if we are playing a solo or a wedding */
961 echo "<div class=\"info\">";
962 if($game["solo-who"]>=0)
963 echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
964 else if($game["wedding"]>=0)
965 echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
967 echo "<div class=\"bug\"> Poverty not working yet! <br />".
968 " Schweinchen not working yet <br />".
969 "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 />".
970 "If you find more bugs, please list them in the <a href=\"".$wiki.
971 "\">wiki</a>.Hit shift reload every now and then too.</div>\n";
974 /* figure out who needs to play next */
979 /* if no one has played yet or we are at the start of a new trick */
981 $next = $history[sizeof($history)-1][0];
983 /* are we trying to play a card? */
984 if(isset($_REQUEST["card"]))
986 if($hash[$next]==$me)
988 $card = $_REQUEST["card"];
989 $mycards = explode(";",$player[$me]["cards"]);
990 $comment = $_REQUEST["comment"];
991 $comment = str_replace(":","",$comment); /*can't have ":" in comments */
993 /* do we have that card */
994 if(in_array($card,$mycards))
996 /* delete card from array */
998 foreach($mycards as $m)
1003 for($i=0;$i<sizeof($tmp)-1;$i++)
1005 $tmp2.=$tmp[$i].";";
1008 $player[$me]["cards"]=$tmp2;
1010 /* add card to history, special case if this is the first card */
1013 $history[sizeof($history)-1]="".$player[$me]["number"]."->".$card."->$comment:\n";
1017 $tmp = explode(":",$history[sizeof($history)-1]);
1018 $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card."->$comment:";
1019 $history[sizeof($history)-1]=join(":",$tmp);
1023 echo "<div class=\"card\">";
1024 echo " you played <br />";
1025 display_card($card);
1028 /* send out email to players who want/need to get informed */
1029 /* check if we are in a trick, if trick is done, this needs to be handelt in the
1030 * who-won-the-trick section further down */
1031 $tmp = explode(":",$history[sizeof($history)-1]);
1035 $mynext = $next+1; if($mynext>3)$mynext-=4;
1037 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
1039 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1043 $message .= "it's your turn now.\n".
1044 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1046 $message .= $player[$me]["name"]." has played the following card ".
1047 card_to_name($card)."\n";
1049 if($game["solo-who"]>=0)
1050 $message .= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1051 $game["solo-what"]." solo!\n";
1053 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1056 echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
1061 echo "seems like you don't have that card<br />\n";
1063 } /* end if card is set */
1064 if(substr_count($history[sizeof($history)-1],":")==4)
1065 { /* count points, email winner */
1069 $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
1071 /* get player and cards of last trick */
1074 $tmp2 = explode("->",$tmp[$i]);
1079 $win = $p[get_winner($c)];
1081 if(strlen($player[$hash[0]]["cards"]))
1082 $history[] = "\n".$win.":\n"; /* not sure why I need the first \n here */
1084 /* check if game is done */
1087 if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
1090 /* email the player who needs to move next*/
1094 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
1096 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1100 $message .= "You won the last trick,it's your turn now.\n".
1101 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1104 $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
1105 "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
1107 if($game["solo-who"]>=0)
1108 $message.= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1109 $game["solo-what"]." solo!\n";
1111 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1114 echo "<a href=\"index.php?me=".$hash[$win]."\"> next player </a> <br />\n";
1118 /* count points of the last trick */
1121 $tmp = explode(":",$history[sizeof($history)-2]);
1124 $tmp2 = explode("->",$tmp[$i]);
1126 $points += card_value($c);
1128 $player[$hash[$win]]["points"] += $points;
1129 echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
1132 }; /* end if win is set */
1135 /* check if game is done */
1138 if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
1143 echo "<br /> game over, count points <br />\n";
1146 echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
1149 /* check end of game */
1151 /* do we still have cards? display them */
1152 if(strlen(trim($player[$me]["cards"]))>0 )
1154 $allcards = trim($player[$me]["cards"]);
1155 $mycards = explode(";",$allcards);
1159 echo "<div class=\"mycards\">\n";
1160 /* is it our turn? */
1161 if($hash[$next]==$me && !isset($_REQUEST["card"]))
1163 echo "Hello ".$player[$me]["name"].", it's your turn! <br />\n";
1164 echo "Your cards are: <br />\n";
1165 echo "<form action=\"index.php\" method=\"post\">\n";
1166 foreach($mycards as $card)
1167 display_link_card($card,$me);
1169 <br />A short comment:<input name="comment" type="text" size="30" maxlength="50" />
1170 <input type="hidden" name="me" value="<?php echo $me; ?>" />
1171 <input type="submit" value="move" />
1176 { /* not our turn, just show the hand */
1177 echo "Your cards are: <br />\n";
1178 foreach($mycards as $card)
1179 display_card($card);