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="http://doko.nubati.net/css/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 $base = "http://doko.nubati.net/";
44 $host = $base."index.php";
45 $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=\"".$base."cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
404 echo "<img src=\"".$base."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=\"".$base."cards/".$card.".png\" alt=\"\" />\n";
414 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"".$base."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 **************************/
485 /* check for status file and read it, if possible */
487 if(file_exists("status.txt"))
488 $lines = file("status.txt");
492 /* check if we want to start a new game */
493 if( isset($_REQUEST["PlayerA"]) &&
494 isset($_REQUEST["PlayerB"]) &&
495 isset($_REQUEST["PlayerC"]) &&
496 isset($_REQUEST["PlayerD"]) &&
497 isset($_REQUEST["EmailA"]) &&
498 isset($_REQUEST["EmailB"]) &&
499 isset($_REQUEST["EmailC"]) &&
500 isset($_REQUEST["EmailD"]) && sizeof($lines<2))
502 $PlayerA = $_REQUEST["PlayerA"];
503 $PlayerB = $_REQUEST["PlayerB"];
504 $PlayerC = $_REQUEST["PlayerC"];
505 $PlayerD = $_REQUEST["PlayerD"];
506 $EmailA = $_REQUEST["EmailA"] ;
507 $EmailB = $_REQUEST["EmailB"] ;
508 $EmailC = $_REQUEST["EmailC"] ;
509 $EmailD = $_REQUEST["EmailD"] ;
511 $hashA = md5("AGameOfDoko".$PlayerA.$EmailA);
512 $hashB = md5("AGameOfDoko".$PlayerB.$EmailB);
513 $hashC = md5("AGameOfDoko".$PlayerC.$EmailC);
514 $hashD = md5("AGameOfDoko".$PlayerD.$EmailD);
516 /* send out email, check for error with email */
519 "you are invited to play a game of DoKo (that is to debug the program ;).\n".
520 "Place comments and bug reports here:\n".
521 "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
522 "The whole round would consist of the following players:\n".
527 "If you want to join this game, please follow this link:\n\n".
530 mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
531 mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
532 mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
533 mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
535 /* read in random.txt */
536 if(file_exists("random.txt"))
537 $random = file("random.txt");
539 die("no random file");
541 $randomNR = explode( ":", $random[4] );
543 /* write initial status into file */
544 $output = fopen("status.txt","w");
547 fwrite($output, "$hashA:$PlayerA:$EmailA:::" );
549 fwrite($output,"$randomNR[$i];" );
550 fwrite($output,"$randomNR[11]:" ); $i++;
551 fwrite($output,"\n");
553 fwrite($output, "$hashB:$PlayerB:$EmailB:::" );
555 fwrite($output,"$randomNR[$i];" );
556 fwrite($output,"$randomNR[23]:" ); $i++;
557 fwrite($output,"\n");
559 fwrite($output, "$hashC:$PlayerC:$EmailC:::" );
561 fwrite($output,"$randomNR[$i];" );
562 fwrite($output,"$randomNR[35]:" ); $i++;
563 fwrite($output,"\n");
565 fwrite($output, "$hashD:$PlayerD:$EmailD:::");
567 fwrite($output,"$randomNR[$i];" );
568 fwrite($output,"$randomNR[47]:" );
569 fwrite($output,"\n");
574 echo "can't open file for writing";
577 if(file_exists("status.txt"))
578 $lines = file("status.txt");
582 /* test if a game is running, else output everything for a new game */
586 <p> no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct! </p>
587 <form action="index.php" method="post">
588 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
589 Email: <input name="EmailA" type="text" size="20" maxlength="30" /> <br />
591 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
592 Email: <input name="EmailB" type="text" size="20" maxlength="30" /> <br />
594 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
595 Email: <input name="EmailC" type="text" size="20" maxlength="30" /> <br />
597 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
598 Email: <input name="EmailD" type="text" size="20" maxlength="30" /> <br />
600 <input type="submit" value="start game" />
605 { /* load game status */
612 * check if a player wants to accept a game
614 if(isset($_REQUEST["a"]))
618 if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
620 echo "just wait for the game to start";
622 else if( !ereg("[is]",$player[$a]["option"]) )
625 <form action="index.php" method="post">
626 Do you want to play a game of DoKo?
627 yes<input type="radio" name="in" value="yes" />
628 no<input type="radio" name="in" value="no" /> <br />
630 Do you want to get an email for every card played or only if it your move?
631 every card<input type="radio" name="update" value="card" />
632 only on my turn<input type="radio" name="update" value="turn" /> <br />
634 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
636 echo "<input type=\"submit\" value=\"count me in\" />\n";
645 * yes? email him his hand, ask for solo, poverty, email every move or every card?
647 if(isset($_REQUEST["b"]))
651 if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
652 { /* the player already filled out everything */
653 echo "just wait for the game to start";
655 else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
656 { /* the player didn't fill out the form at "a" correctly */
658 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
661 { /* show the hand and check if the player is sick*/
662 if($_REQUEST["in"]=="no")
663 { /* player doesn't want to play, cancel the game */
666 $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
667 "the game has been canceled due to the request of one of the players.\n";
668 mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
670 /* canceling the game is as easy as removing the contents of the status file*/
671 $output = fopen("status.txt","w");
675 echo "problem opening file";
679 /* player wants to play, save information from "a"*/
680 if($_REQUEST["update"]=="card")
681 $player[$b]["option"] .= "c";
683 $player[$b]["option"] .= "t";
685 $player[$b]["option"] .= "i"; /* player finished stage "a" */
689 $allcards = $player[$b]["cards"];
690 $mycards = explode(";",$allcards);
693 echo "<p class=\"mycards\">your cards are: <br />\n";
694 foreach($mycards as $card)
698 <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>
700 <form action="index.php" method="post">
702 do you want to play solo?
703 <select name="solo" size="1">
705 <option>No trump</option>
706 <option>Normal solo</option>
707 <option>Queen solo</option>
708 <option>Jack solo</option>
709 <option>Club solo</option>
710 <option>Spade solo</option>
711 <option>Heart solo</option>
718 if(check_wedding($player[$b]["cards"]))
720 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
721 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
725 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
728 echo "do you have poverty?";
729 if(count_trump($player[$b]["cards"])<4)
731 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
732 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
736 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
739 echo "do you have too many nines?";
740 if(count_nines($player[$b]["cards"])>4)
742 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
743 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
747 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
750 echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
751 echo "<input type=\"submit\" value=\"count me in\" />\n";
758 if(isset($_REQUEST["c"]))
763 if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
764 { /* the player already filled out everything */
765 echo "<p>just wait for the game to start</p>\n";
767 else if(!isset($_REQUEST["solo"]) ||
768 !isset($_REQUEST["wedding"]) ||
769 !isset($_REQUEST["poverty"]) ||
770 !isset($_REQUEST["nines"]) )
771 {/* player still needs to fill out the form */
773 echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
775 else if($game["init"]<4)
776 { /* save information */
777 if( $_REQUEST["solo"]!="No")
779 switch($_REQUEST["solo"])
782 $player[$c]["option"].="O";
785 $player[$c]["option"].="S";
788 $player[$c]["option"].="Q";
791 $player[$c]["option"].="J";
794 $player[$c]["option"].="C";
797 $player[$c]["option"].="A";
800 $player[$c]["option"].="H";
804 else if($_REQUEST["wedding"] == "yes")
806 echo "wedding was chosen<br />\n";
807 $player[$c]["option"].="W";
809 else if($_REQUEST["poverty"] == "yes")
811 echo "poverty was chosen<br />\n";
812 $player[$c]["option"].="P";
814 else if($_REQUEST["nines"] == "yes")
816 echo "nines was chosen<br />\n";
817 $player[$c]["option"].="N";
820 /* player finished setup */
821 $player[$c]["option"].="s";
824 /* reread status file, to get the correct startplayer, etc */
825 if(file_exists("status.txt"))
826 $lines = file("status.txt");
831 if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
833 echo "<p> The game can start now, it's your turn, please use this <a href=\"".
834 $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
836 else if($game["init"]==4)
838 $message = "The game can start now, it's your turn, please use this link to play a card:\n".
839 $host."?me=".$hash[$game["startplayer"]]."\n";
840 mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
841 echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
845 echo "<p>You're in. Once everyone has filled out the form, ".
846 "the game will start and you'll get an eamil on your turn.</p>\n";
855 /* check for sickness, only would need to do this on the first trick really...*/
856 /***** someone has 5 nines and no one is playing solo => cancel game */
857 if($game["nines"]>=0 && $game["solo-who"]<0)
859 $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
861 mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
863 $output = fopen("status.txt","w");
867 echo "problem opening file";
870 /* who is requesting this*/
871 if(!isset($_REQUEST["me"]))
873 if(!isset($_REQUEST["recovery"]))
875 echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
876 echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
878 <form action="index.php" method="post">
879 recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
880 <input type="submit" value="get me back into the game" />
886 $recovery = $_REQUEST["recovery"];
889 if(trim($recovery)==trim($player[$hash[$i]]["email"]))
893 $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
894 "\n if this doesn't work, contact the admin.error4\n";
895 mymail($recovery,"[DoKo-Debug] recovery ",$message);
896 echo "<p> An email with the game information has been sent.</p>\n";
900 echo "<p> can't find this email address, sorry.</p>\n";
906 $me = $_REQUEST["me"];
909 /* old tricks as list */
910 echo "<ul class=\"oldtrick\">\n";
911 echo " <li> History: </li>\n";
913 foreach($history as $play)
916 $trick = explode(":",$play);
918 /* found old trick, display it */
919 if(sizeof($trick)==5)
920 echo " <li onclick=\"hl('$j');\"><a href=\"#\">Trick $j</a>\n <div class=\"table\" id=\"trick".$j."\">\n <img class=\"table\" src=\"".$base."pics/table".$play[0].".png\" alt=\"table\" />\n";
923 /* display current trick */
924 echo "<li onclick=\"hl('$j');\"><a href=\"#\">Current Trick</a>\n <div class=\"table\" id=\"trick".$j."\">\n <img class=\"table\" src=\"".$base."pics/table".$play[0].".png\" alt=\"table\" />";
926 for($i=0;$i<sizeof($trick)-1;$i++)
931 /* has a card been played? */
934 $tmp = explode("->",$card);
936 echo " <div class=\"card".$tmp[0]."\">\n";
938 if(strlen($tmp[2])>0)
939 echo " <span class=\"comment\">";
942 echo $player[$hash[$tmp[0]]]["name"];
943 /* check for comment */
944 if(strlen($tmp[2])>0)
945 echo "<span>".$tmp[2]."</span>";
948 display_card($tmp[1]);
955 echo " </div>\n </li>\n";
957 echo "</ul> <hr />\n";
959 echo "<div class=\"line\"></div>";
961 /* output if we are playing a solo or a wedding */
962 echo "<div class=\"info\">";
963 if($game["solo-who"]>=0)
964 echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
965 else if($game["wedding"]>=0)
966 echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
968 echo "<div class=\"bug\"> Poverty not working yet! <br />".
969 " Schweinchen not working yet <br />".
970 "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 />".
971 "If you find more bugs, please list them in the <a href=\"".$wiki.
972 "\">wiki</a>.Hit shift reload every now and then too.</div>\n";
975 /* figure out who needs to play next */
980 /* if no one has played yet or we are at the start of a new trick */
982 $next = $history[sizeof($history)-1][0];
984 /* are we trying to play a card? */
985 if(isset($_REQUEST["card"]))
987 if($hash[$next]==$me)
989 $card = $_REQUEST["card"];
990 $mycards = explode(";",$player[$me]["cards"]);
991 $comment = $_REQUEST["comment"];
992 $comment = str_replace(":","",$comment); /*can't have ":" in comments */
994 /* do we have that card */
995 if(in_array($card,$mycards))
997 /* delete card from array */
999 foreach($mycards as $m)
1004 for($i=0;$i<sizeof($tmp)-1;$i++)
1006 $tmp2.=$tmp[$i].";";
1009 $player[$me]["cards"]=$tmp2;
1011 /* add card to history, special case if this is the first card */
1014 $history[sizeof($history)-1]="".$player[$me]["number"]."->".$card."->$comment:\n";
1018 $tmp = explode(":",$history[sizeof($history)-1]);
1019 $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card."->$comment:";
1020 $history[sizeof($history)-1]=join(":",$tmp);
1024 echo "<div class=\"card\">";
1025 echo " you played <br />";
1026 display_card($card);
1029 /* send out email to players who want/need to get informed */
1030 /* check if we are in a trick, if trick is done, this needs to be handelt in the
1031 * who-won-the-trick section further down */
1032 $tmp = explode(":",$history[sizeof($history)-1]);
1036 $mynext = $next+1; if($mynext>3)$mynext-=4;
1038 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
1040 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1044 $message .= "it's your turn now.\n".
1045 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1047 $message .= $player[$me]["name"]." has played the following card ".
1048 card_to_name($card)."\n";
1050 if($game["solo-who"]>=0)
1051 $message .= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1052 $game["solo-what"]." solo!\n";
1054 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1057 echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
1062 echo "seems like you don't have that card<br />\n";
1064 } /* end if card is set */
1065 if(substr_count($history[sizeof($history)-1],":")==4)
1066 { /* count points, email winner */
1070 $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
1072 /* get player and cards of last trick */
1075 $tmp2 = explode("->",$tmp[$i]);
1080 $win = $p[get_winner($c)];
1082 if(strlen($player[$hash[0]]["cards"]))
1083 $history[] = "\n".$win.":\n"; /* not sure why I need the first \n here */
1085 /* check if game is done */
1088 if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
1091 /* email the player who needs to move next*/
1095 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
1097 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1101 $message .= "You won the last trick,it's your turn now.\n".
1102 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1105 $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
1106 "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
1108 if($game["solo-who"]>=0)
1109 $message.= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1110 $game["solo-what"]." solo!\n";
1112 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1115 echo "<a href=\"index.php?me=".$hash[$win]."\"> next player </a> <br />\n";
1119 /* count points of the last trick */
1122 $tmp = explode(":",$history[sizeof($history)-2]);
1125 $tmp2 = explode("->",$tmp[$i]);
1127 $points += card_value($c);
1129 $player[$hash[$win]]["points"] += $points;
1130 echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
1133 }; /* end if win is set */
1136 /* check if game is done */
1139 if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
1144 echo "<br /> game over, count points <br />\n";
1147 echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
1150 /* check end of game */
1152 /* do we still have cards? display them */
1153 if(strlen(trim($player[$me]["cards"]))>0 )
1155 $allcards = trim($player[$me]["cards"]);
1156 $mycards = explode(";",$allcards);
1160 echo "<div class=\"mycards\">\n";
1161 /* is it our turn? */
1162 if($hash[$next]==$me && !isset($_REQUEST["card"]))
1164 echo "Hello ".$player[$me]["name"].", it's your turn! <br />\n";
1165 echo "Your cards are: <br />\n";
1166 echo "<form action=\"index.php\" method=\"post\">\n";
1167 foreach($mycards as $card)
1168 display_link_card($card,$me);
1170 <br />A short comment:<input name="comment" type="text" size="30" maxlength="50" />
1171 <input type="hidden" name="me" value="<?php echo $me; ?>" />
1172 <input type="submit" value="move" />
1177 { /* not our turn, just show the hand */
1178 echo "Your cards are: <br />\n";
1179 foreach($mycards as $card)
1180 display_card($card);