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";
59 function mymail($To,$Subject,$message)
65 $message = str_replace("\n","<br />",$message);
66 echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
69 mail($To,$Subject,$message);
73 function is_trump($c) { return (($c<27) ? 1:0);}
74 function is_club($c) { return (in_array($c,array('27','28','29','30','31','32','33','34')));}
75 function is_spade($c) { return (in_array($c,array('35','36','37','38','39','40','41','42')));}
76 function is_heart($c) { return (in_array($c,array('43','44','45','46','47','48')));}
78 function compare_cards($a,$b)
80 /* if a is higher than b return 1, else 0, a being the card first played */
82 /* first map all cards to the odd number */
83 if( $a/2 - (int)($a/2) != 0.5)
85 if( $b/2 - (int)($b/2) != 0.5)
88 if(is_trump($a) && $a<=$b)
90 else if(is_trump($a) && $a>$b)
93 { /*$a is not a trump */
99 if( is_club($a) && is_club($b))
105 if( is_spade($a) && is_spade($b))
111 if( is_heart($a) && is_heart($b))
122 function get_winner($p)
124 /* get all 4 cards played in a trick */
130 /* find out who won */
131 if( compare_cards($c1,$c2) && compare_cards($c1,$c3) && compare_cards($c1,$c4) )
133 if( compare_cards($c2,$c3) && compare_cards($c2,$c4) )
135 if( compare_cards($c3,$c4) )
140 function parse_status()
142 global $game,$history,$player,$hash,$lines;
145 $game["solo-who"] = -1;
146 $game["solo-what"] = "todo";
147 $game["wedding"] = -1;
148 $game["poverty"] = "";
150 $game["startplayer"] = 0;
154 $tmp = explode( ":",$lines[$i]);
156 $player[$tmp[0]]["number"] = $i;
157 $player[$tmp[0]]["hash"] = $tmp[0];
158 $player[$tmp[0]]["name"] = $tmp[1];
159 $player[$tmp[0]]["email"] = $tmp[2];
160 $player[$tmp[0]]["option"] = $tmp[3];
161 $player[$tmp[0]]["points"] = $tmp[4];
162 $player[$tmp[0]]["cards"] = $tmp[5];
163 if(ereg("s",$tmp[3])) $game["init"]++; /* how many players are ready? */
164 if(ereg("P",$tmp[3])) $game["poverty"].= $i; /* players with poverty, could be two, so use a string */
165 if(ereg("N",$tmp[3])) $game["nines"] = $i; /* the player with too many nines, only one possible */
166 if(ereg("W",$tmp[3])) $game["wedding"] = $i; /* the player with the wedding, also only one possible */
167 if(ereg("([OSQJCAH])",$tmp[3],$match) && ($game["solo-who"]<0) )
169 $game["solo-who"] = $i;
170 $game["startplayer"] = $i;
174 $game["solo-what"] = "No Trump";
176 $game["solo-what"] = "Trump";
178 $game["solo-what"] = "Queen";
180 $game["solo-what"] = "Jack";
182 $game["solo-what"] = "Club";
184 $game["solo-what"] = "Spade";
186 $game["solo-what"] = "Heart";
191 /* save the game history */
192 for($i=4;$i<sizeof($lines);$i++)
193 if(!ereg("^[[:space:]]*$",trim($lines[$i])))
194 $history[] = $lines[$i];
196 if(sizeof($history)==0 || (sizeof($history)==1 && strlen($history[0])==3 ))
197 $history[0] = $game["startplayer"].":";
202 function count_nines($cards)
204 $card = explode(";",$cards);
209 if($c == "25" || $c == "26") $nines++;
210 else if($c == "33" || $c == "34") $nines++;
211 else if($c == "41" || $c == "42") $nines++;
212 else if($c == "47" || $c == "48") $nines++;
218 function check_wedding($cards)
220 $card = explode(";",$cards);
222 if( in_array("3",$card) && in_array("2",$card) )
228 function count_trump($cards)
230 $card = explode(";",$cards);
233 /* count each trump */
239 if( in_array("19",$card))
241 if( in_array("20",$card) )
243 /* add one, in case the player has both foxes (schweinchen) */
244 if( in_array("19",$card) && in_array("20",$card) )
250 function card_to_name($card)
256 return "ten of hearts";
259 return "queen of clubs";
262 return "queen of spades";
265 return "queen of hearts";
268 return "queen of diamonds";
271 return "jack of clubs";
274 return "jack of spades";
277 return "jack of hearts";
280 return "jack of diamonds";
283 return "ace of diamonds";
286 return "ten of diamonds";
289 return "king of diamonds";
292 return "nine of diamonds";;
295 return "ace of clubs";
298 return "ten of clubs";
301 return "king of clubs";
304 return "nine of clubs";
307 return "ace of spades";
310 return "ten of spades";
313 return "king of spades";
316 return "nine of spades";
319 return "ace of hearts";
322 return "king of hearts";
325 return "nine of hearts";
327 return "something went wrong, please contact the admin. Error: code1.";
331 function card_value($card)
344 case 9: /* diamonds */
347 case 11: /* clubes */
349 case 13: /* spades */
351 case 15: /* hearts */
353 case 17: /* diamonds */
356 case 19: /* diamonds */
360 case 35: /* spades */
362 case 43: /* hearts */
365 case 21: /* diamonds */
369 case 37: /* spades */
372 case 23: /* diamonds */
376 case 39: /* spades */
378 case 45: /* hearts */
381 case 25: /* diamonds */
385 case 41: /* spades */
387 case 47: /* hearts */
391 echo "something went wrong, please contact the admin. ErrorCode: 2<br>";
396 function display_card($card)
398 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
399 * convert even cards to the matching odd value */
401 if( $card/2 - (int)($card/2) == 0.5)
402 echo "<img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
404 echo "<img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
409 function display_link_card($card,$me)
411 if( $card/2 - (int)($card/2) == 0.5)
412 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
414 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
418 function save_status()
420 global $player,$game,$hash,$history;
422 $output = fopen("status.txt","w");
425 foreach($hash as $key)
427 /* sorting the options, not sure why I do that actually */
429 if( ereg("i",$player[$key]["option"]) )
431 if( ereg("s",$player[$key]["option"]) )
433 if( ereg("t",$player[$key]["option"]) )
435 if( ereg("c",$player[$key]["option"]) )
437 if( ereg("N",$player[$key]["option"]) )
439 if( ereg("W",$player[$key]["option"]) )
441 if( ereg("P",$player[$key]["option"]) )
443 if( ereg("O",$player[$key]["option"]) )
445 if( ereg("S",$player[$key]["option"]) )
447 if( ereg("Q",$player[$key]["option"]) )
449 if( ereg("J",$player[$key]["option"]) )
451 if( ereg("C",$player[$key]["option"]) )
453 if( ereg("A",$player[$key]["option"]) )
455 if( ereg("H",$player[$key]["option"]) )
457 $player[$key]["option"]=$tmp;
459 /* saving the player stats */
460 fwrite($output,"".$player[$key]["hash"].":" );
461 fwrite($output,"".$player[$key]["name"].":" );
462 fwrite($output,"".$player[$key]["email"].":" );
463 fwrite($output,"".$player[$key]["option"].":" );
464 fwrite($output,"".$player[$key]["points"].":" );
465 fwrite($output,"".$player[$key]["cards"] .":");
466 fwrite($output,"\n");
468 fwrite($output,"\n");
469 foreach($history as $line)
470 fwrite($output,$line);
472 fwrite($output,"\n");
476 echo "can't open file for writing, please inform the admin.errorcode3";
481 /***************** M A I N **************************/
486 /* check for status file and read it, if possible */
488 if(file_exists("status.txt"))
489 $lines = file("status.txt");
493 /* check if we want to start a new game */
494 if( isset($_REQUEST["PlayerA"]) &&
495 isset($_REQUEST["PlayerB"]) &&
496 isset($_REQUEST["PlayerC"]) &&
497 isset($_REQUEST["PlayerD"]) &&
498 isset($_REQUEST["EmailA"]) &&
499 isset($_REQUEST["EmailB"]) &&
500 isset($_REQUEST["EmailC"]) &&
501 isset($_REQUEST["EmailD"]) && sizeof($lines<2))
503 $PlayerA = $_REQUEST["PlayerA"];
504 $PlayerB = $_REQUEST["PlayerB"];
505 $PlayerC = $_REQUEST["PlayerC"];
506 $PlayerD = $_REQUEST["PlayerD"];
507 $EmailA = $_REQUEST["EmailA"] ;
508 $EmailB = $_REQUEST["EmailB"] ;
509 $EmailC = $_REQUEST["EmailC"] ;
510 $EmailD = $_REQUEST["EmailD"] ;
512 $hashA = md5("AGameOfDoko".$PlayerA.$EmailA);
513 $hashB = md5("AGameOfDoko".$PlayerB.$EmailB);
514 $hashC = md5("AGameOfDoko".$PlayerC.$EmailC);
515 $hashD = md5("AGameOfDoko".$PlayerD.$EmailD);
517 /* send out email, check for error with email */
520 "you are invited to play a game of DoKo (that is to debug the program ;).\n".
521 "Place comments and bug reports here:\n".
522 "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
523 "The whole round would consist of the following players:\n".
528 "If you want to join this game, please follow this link:\n\n".
531 mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
532 mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
533 mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
534 mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
536 /* read in random.txt */
537 if(file_exists("random.txt"))
538 $random = file("random.txt");
540 die("no random file");
542 $randomNR = explode( ":", $random[2] );
544 /* write initial status into file */
545 $output = fopen("status.txt","w");
548 fwrite($output, "$hashA:$PlayerA:$EmailA:::" );
550 fwrite($output,"$randomNR[$i];" );
551 fwrite($output,"$randomNR[11]:" ); $i++;
552 fwrite($output,"\n");
554 fwrite($output, "$hashB:$PlayerB:$EmailB:::" );
556 fwrite($output,"$randomNR[$i];" );
557 fwrite($output,"$randomNR[23]:" ); $i++;
558 fwrite($output,"\n");
560 fwrite($output, "$hashC:$PlayerC:$EmailC:::" );
562 fwrite($output,"$randomNR[$i];" );
563 fwrite($output,"$randomNR[35]:" ); $i++;
564 fwrite($output,"\n");
566 fwrite($output, "$hashD:$PlayerD:$EmailD:::");
568 fwrite($output,"$randomNR[$i];" );
569 fwrite($output,"$randomNR[47]:" );
570 fwrite($output,"\n");
575 echo "can't open file for writing";
578 if(file_exists("status.txt"))
579 $lines = file("status.txt");
583 /* test if a game is running, else output everything for a new game */
587 <p> no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct! </p>
588 <form action="index.php" method="post">
589 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
590 Email: <input name="EmailA" type="text" size="20" maxlength="30" /> <br />
592 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
593 Email: <input name="EmailB" type="text" size="20" maxlength="30" /> <br />
595 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
596 Email: <input name="EmailC" type="text" size="20" maxlength="30" /> <br />
598 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
599 Email: <input name="EmailD" type="text" size="20" maxlength="30" /> <br />
601 <input type="submit" value="start game" />
606 { /* load game status */
613 * check if a player wants to accept a game
615 if(isset($_REQUEST["a"]))
619 if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
621 echo "just wait for the game to start";
623 else if( !ereg("[is]",$player[$a]["option"]) )
626 <form action="index.php" method="post">
627 Do you want to play a game of DoKo?
628 yes<input type="radio" name="in" value="yes" />
629 no<input type="radio" name="in" value="no" /> <br />
631 Do you want to get an email for every card played or only if it your move?
632 every card<input type="radio" name="update" value="card" />
633 only on my turn<input type="radio" name="update" value="turn" /> <br />
635 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
637 echo "<input type=\"submit\" value=\"count me in\" />\n";
646 * yes? email him his hand, ask for solo, poverty, email every move or every card?
648 if(isset($_REQUEST["b"]))
652 if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
653 { /* the player already filled out everything */
654 echo "just wait for the game to start";
656 else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
657 { /* the player didn't fill out the form at "a" correctly */
659 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
662 { /* show the hand and check if the player is sick*/
663 if($_REQUEST["in"]=="no")
664 { /* player doesn't want to play, cancel the game */
667 $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
668 "the game has been canceled due to the request of one of the players.\n";
669 mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
671 /* canceling the game is as easy as removing the contents of the status file*/
672 $output = fopen("status.txt","w");
676 echo "problem opening file";
680 /* player wants to play, save information from "a"*/
681 if($_REQUEST["update"]=="card")
682 $player[$b]["option"] .= "c";
684 $player[$b]["option"] .= "t";
686 $player[$b]["option"] .= "i"; /* player finished stage "a" */
690 $allcards = $player[$b]["cards"];
691 $mycards = explode(";",$allcards);
694 echo "<p class=\"mycards\">your cards are: <br />\n";
695 foreach($mycards as $card)
699 <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>
701 <form action="index.php" method="post">
703 do you want to play solo?
704 <select name="solo" size="1">
706 <option>No trump</option>
707 <option>Normal solo</option>
708 <option>Queen solo</option>
709 <option>Jack solo</option>
710 <option>Club solo</option>
711 <option>Spade solo</option>
712 <option>Heart solo</option>
719 if(check_wedding($player[$b]["cards"]))
721 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
722 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
726 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
729 echo "do you have poverty?";
730 if(count_trump($player[$b]["cards"])<4)
732 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
733 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
737 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
740 echo "do you have too many nines?";
741 if(count_nines($player[$b]["cards"])>4)
743 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
744 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
748 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
751 echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
752 echo "<input type=\"submit\" value=\"count me in\" />\n";
759 if(isset($_REQUEST["c"]))
764 if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
765 { /* the player already filled out everything */
766 echo "<p>just wait for the game to start</p>\n";
768 else if(!isset($_REQUEST["solo"]) ||
769 !isset($_REQUEST["wedding"]) ||
770 !isset($_REQUEST["poverty"]) ||
771 !isset($_REQUEST["nines"]) )
772 {/* player still needs to fill out the form */
774 echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
776 else if($game["init"]<4)
777 { /* save information */
778 if( $_REQUEST["solo"]!="No")
780 switch($_REQUEST["solo"])
783 $player[$c]["option"].="O";
786 $player[$c]["option"].="S";
789 $player[$c]["option"].="Q";
792 $player[$c]["option"].="J";
795 $player[$c]["option"].="C";
798 $player[$c]["option"].="A";
801 $player[$c]["option"].="H";
805 else if($_REQUEST["wedding"] == "yes")
807 echo "wedding was chosen<br />\n";
808 $player[$c]["option"].="W";
810 else if($_REQUEST["poverty"] == "yes")
812 echo "poverty was chosen<br />\n";
813 $player[$c]["option"].="P";
815 else if($_REQUEST["nines"] == "yes")
817 echo "nines was chosen<br />\n";
818 $player[$c]["option"].="N";
821 /* player finished setup */
822 $player[$c]["option"].="s";
825 /* reread status file, to get the correct startplayer, etc */
826 if(file_exists("status.txt"))
827 $lines = file("status.txt");
832 if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
834 echo "<p> The game can start now, it's your turn, please use this <a href=\"".
835 $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
837 else if($game["init"]==4)
839 $message = "The game can start now, it's your turn, please use this link to play a card:\n".
840 $host."?me=".$hash[$game["startplayer"]]."\n";
841 mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
842 echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
846 echo "<p>You're in. Once everyone has filled out the form, ".
847 "the game will start and you'll get an eamil on your turn.</p>\n";
856 /* check for sickness, only would need to do this on the first trick really...*/
857 /***** someone has 5 nines and no one is playing solo => cancel game */
858 if($game["nines"]>=0 && $game["solo-who"]<0)
860 $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
862 mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
864 $output = fopen("status.txt","w");
868 echo "problem opening file";
871 /* who is requesting this*/
872 if(!isset($_REQUEST["me"]))
874 if(!isset($_REQUEST["recovery"]))
876 echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
877 echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
879 <form action="index.php" method="post">
880 recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
881 <input type="submit" value="get me back into the game" />
887 $recovery = $_REQUEST["recovery"];
890 if(trim($recovery)==trim($player[$hash[$i]]["email"]))
894 $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
895 "\n if this doesn't work, contact the admin.error4\n";
896 mymail($recovery,"[DoKo-Debug] recovery ",$message);
897 echo "<p> An email with the game information has been sent.</p>\n";
901 echo "<p> can't find this email address, sorry.</p>\n";
907 $me = $_REQUEST["me"];
910 /* old tricks as list */
911 echo "<ul class=\"oldtrick\">\n";
912 echo " <li> History: </li>\n";
914 foreach($history as $play)
917 $trick = explode(":",$play);
919 /* found old trick, display it */
920 if(sizeof($trick)==5)
921 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";
924 /* display current trick */
925 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\" />";
927 for($i=0;$i<sizeof($trick)-1;$i++)
932 /* has a card been played? */
935 $tmp = explode("->",$card);
937 echo " <div class=\"card".$tmp[0]."\">\n";
939 if(strlen($tmp[2])>0)
940 echo " <span class=\"comment\">";
943 echo $player[$hash[$tmp[0]]]["name"];
944 /* check for comment */
945 if(strlen($tmp[2])>0)
946 echo "<span>".$tmp[2]."</span>";
949 display_card($tmp[1]);
956 echo " </div>\n </li>\n";
960 echo "<div class=\"line\"></div>";
962 /* output if we are playing a solo or a wedding */
963 echo "<div class=\"info\">";
964 if($game["solo-who"]>=0)
965 echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
966 else if($game["wedding"]>=0)
967 echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
969 echo "<div class=\"bug\"> Poverty not working yet! <br />".
970 " Schweinchen not working yet <br />".
971 "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 />".
972 "If you find more bugs, please list them in the <a href=\"".$wiki.
973 "\">wiki</a>.Hit shift reload every now and then too.</div>\n";
976 /* figure out who needs to play next */
981 /* if no one has played yet or we are at the start of a new trick */
983 $next = $history[sizeof($history)-1][0];
985 /* are we trying to play a card? */
986 if(isset($_REQUEST["card"]))
988 if($hash[$next]==$me)
990 $card = $_REQUEST["card"];
991 $mycards = explode(";",$player[$me]["cards"]);
992 $comment = $_REQUEST["comment"];
993 $comment = str_replace(":","",$comment); /*can't have ":" in comments */
995 /* do we have that card */
996 if(in_array($card,$mycards))
998 /* delete card from array */
1000 foreach($mycards as $m)
1005 for($i=0;$i<sizeof($tmp)-1;$i++)
1007 $tmp2.=$tmp[$i].";";
1010 $player[$me]["cards"]=$tmp2;
1012 /* add card to history, special case if this is the first card */
1015 $history[sizeof($history)-1]="".$player[$me]["number"]."->".$card."->$comment:\n";
1019 $tmp = explode(":",$history[sizeof($history)-1]);
1020 $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card."->$comment:";
1021 $history[sizeof($history)-1]=join(":",$tmp);
1025 echo "<div class=\"card\">";
1026 echo " you played <br />";
1027 display_card($card);
1030 /* send out email to players who want/need to get informed */
1031 /* check if we are in a trick, if trick is done, this needs to be handelt in the
1032 * who-won-the-trick section further down */
1033 $tmp = explode(":",$history[sizeof($history)-1]);
1037 $mynext = $next+1; if($mynext>3)$mynext-=4;
1039 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
1041 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1045 $message .= "it's your turn now.\n".
1046 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1048 $message .= $player[$me]["name"]." has played the following card ".
1049 card_to_name($card)."\n";
1051 if($game["solo-who"]>=0)
1052 $message .= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1053 $game["solo-what"]." solo!\n";
1055 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1058 echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
1063 echo "seems like you don't have that card<br />\n";
1065 } /* end if card is set */
1066 if(substr_count($history[sizeof($history)-1],":")==4)
1067 { /* count points, email winner */
1071 $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
1073 /* get player and cards of last trick */
1076 $tmp2 = explode("->",$tmp[$i]);
1081 $win = $p[get_winner($c)];
1083 if(strlen($player[$hash[0]]["cards"]))
1084 $history[] = "\n".$win.":\n"; /* not sure why I need the first \n here */
1086 /* email the player who needs to move next*/
1089 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
1091 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1095 $message .= "You won the last trick,it's your turn now.\n".
1096 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1099 $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
1100 "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
1102 if($game["solo-who"]>=0)
1103 $message.= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1104 $game["solo-what"]." solo!\n";
1106 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1109 echo "<a href=\"index.php?me=".$hash[$win]."\"> next player </a> <br />\n";
1113 /* count points of the last trick */
1116 $tmp = explode(":",$history[sizeof($history)-2]);
1119 $tmp2 = explode("->",$tmp[$i]);
1121 $points += card_value($c);
1123 $player[$hash[$win]]["points"] += $points;
1124 echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
1127 }; /* end if win is set */
1130 /* check if game is done */
1133 if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
1138 echo "<br /> game over, count points <br />\n";
1141 echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
1144 /* check end of game */
1146 /* do we still have cards? display them */
1147 if(strlen(trim($player[$me]["cards"]))>0 )
1149 $allcards = trim($player[$me]["cards"]);
1150 $mycards = explode(";",$allcards);
1154 echo "<div class=\"mycards\">\n";
1155 /* is it our turn? */
1156 if($hash[$next]==$me && !isset($_REQUEST["card"]))
1158 echo "Hello ".$player[$me]["name"].", it's your turn! <br />\n";
1159 echo "Your cards are: <br />\n";
1160 echo "<form action=\"index.php\" method=\"post\">\n";
1161 foreach($mycards as $card)
1162 display_link_card($card,$me);
1164 <br />A short comment:<input name="comment" type="text" size="30" maxlength="50" />
1165 <input type="hidden" name="me" value="<?php echo $me; ?>" />
1166 <input type="submit" value="move" />
1171 { /* not our turn, just show the hand */
1172 echo "Your cards are: <br />\n";
1173 foreach($mycards as $card)
1174 display_card($card);