2 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
3 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
7 <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
8 <link rel="stylesheet" type="text/css" href="standard.css" />
12 <h1> Welcome to E-Doko </h1>
13 <p>(please hit shift-reload:))</p>
20 $host = "http://doko.nubati.net/index.php";
21 $wiki = "http://wiki.nubati.net/index.php?title=EmailDoko";
31 function mymail($To,$Subject,$message)
37 $message = str_replace("\n","<br />",$message);
38 echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
41 mail($To,$Subject,$message);
45 function parse_status()
47 global $game,$history,$player,$hash,$lines;
50 $game["solo-who"] = -1;
51 $game["solo-what"] = "todo";
52 $game["wedding"] = -1;
53 $game["poverty"] = "";
55 $game["startplayer"] = 0;
59 $tmp = explode( ":",$lines[$i]);
61 $player[$tmp[0]]["number"] = $i;
62 $player[$tmp[0]]["hash"] = $tmp[0];
63 $player[$tmp[0]]["name"] = $tmp[1];
64 $player[$tmp[0]]["email"] = $tmp[2];
65 $player[$tmp[0]]["option"] = $tmp[3];
66 $player[$tmp[0]]["points"] = $tmp[4];
67 $player[$tmp[0]]["cards"] = $tmp[5];
68 if(ereg("s",$tmp[3])) $game["init"]++; /* how many players are ready? */
69 if(ereg("P",$tmp[3])) $game["poverty"].= $i; /* players with poverty, could be two, so use a string */
70 if(ereg("N",$tmp[3])) $game["nines"] = $i; /* the player with too many nines, only one possible */
71 if(ereg("W",$tmp[3])) $game["wedding"] = $i; /* the player with the wedding, also only one possible */
72 if(ereg("([OSQJCAH])",$tmp[3],$match) && ($game["solo-who"]<0) )
74 $game["solo-who"] = $i;
75 $game["startplayer"] = $i;
79 $game["solo-what"] = "No Trump";
81 $game["solo-what"] = "Trump";
83 $game["solo-what"] = "Queen";
85 $game["solo-what"] = "Jack";
87 $game["solo-what"] = "Club";
89 $game["solo-what"] = "Spade";
91 $game["solo-what"] = "Heart";
96 /* save the game history */
97 for($i=4;$i<sizeof($lines);$i++)
99 if(!ereg("^[[:space:]]*$",trim($lines[$i])))
101 $history[] = $lines[$i];
105 if(sizeof($history)==0 || (sizeof($history)==1 && strlen($history[0])==3 ))
106 $history[0] = $game["startplayer"].":";
111 function count_nines($cards)
113 $card = explode(";",$cards);
119 if($c == "25" || $c == "26") $nines++;
120 else if($c == "33" || $c == "34") $nines++;
121 else if($c == "41" || $c == "42") $nines++;
122 else if($c == "47" || $c == "48") $nines++;
128 function check_wedding($cards)
130 $card = explode(";",$cards);
134 if( in_array("3",$card) && in_array("2",$card) )
140 function count_trump($cards)
142 $card = explode(";",$cards);
146 /* count each trump */
152 if( in_array("19",$card))
154 if( in_array("20",$card) )
156 /* add one, in case the player has both foxes (schweinchen) */
157 if( in_array("19",$card) && in_array("20",$card) )
163 function card_to_name($card)
169 return "ten of hearts";
172 return "queen of clubs";
175 return "queen of spades";
178 return "queen of hearts";
181 return "queen of diamonds";
184 return "jack of clubs";
187 return "jack of spades";
190 return "jack of hearts";
193 return "jack of diamonds";
196 return "ace of diamonds";
199 return "ten of diamonds";
202 return "king of diamonds";
205 return "nine of diamonds";;
208 return "ace of clubs";
211 return "ten of clubs";
214 return "king of clubs";
217 return "nine of clubs";
220 return "ace of spades";
223 return "ten of spades";
226 return "king of spades";
229 return "nine of spades";
232 return "ace of hearts";
235 return "king of hearts";
238 return "nine of hearts";
240 return "something went wrong, please contact the admin. Error: code1.";
244 function card_value($card)
315 echo "something went wrong, please contact the admin. ErrorCode 2<br>";
320 function display_card($card)
322 if( $card/2 - (int)($card/2) == 0.5)
323 echo "<img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
325 echo "<img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
329 function display_link_card($card,$me)
331 if( $card/2 - (int)($card/2) == 0.5)
332 echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" /></a>\n";
334 echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" /></a>\n";
338 function save_status()
340 global $player,$game,$hash,$history;
342 $output = fopen("status.txt","w");
345 foreach($hash as $key)
347 /* sorting the options, not sure why I do that actually */
349 if( ereg("i",$player[$key]["option"]) )
351 if( ereg("s",$player[$key]["option"]) )
353 if( ereg("t",$player[$key]["option"]) )
355 if( ereg("c",$player[$key]["option"]) )
357 if( ereg("N",$player[$key]["option"]) )
359 if( ereg("W",$player[$key]["option"]) )
361 if( ereg("P",$player[$key]["option"]) )
363 if( ereg("O",$player[$key]["option"]) )
365 if( ereg("S",$player[$key]["option"]) )
367 if( ereg("Q",$player[$key]["option"]) )
369 if( ereg("J",$player[$key]["option"]) )
371 if( ereg("C",$player[$key]["option"]) )
373 if( ereg("A",$player[$key]["option"]) )
375 if( ereg("H",$player[$key]["option"]) )
377 $player[$key]["option"]=$tmp;
379 /* saving the player stats */
380 fwrite($output,"".$player[$key]["hash"].":" );
381 fwrite($output,"".$player[$key]["name"].":" );
382 fwrite($output,"".$player[$key]["email"].":" );
383 fwrite($output,"".$player[$key]["option"].":" );
384 fwrite($output,"".$player[$key]["points"].":" );
385 fwrite($output,"".$player[$key]["cards"] .":");
386 fwrite($output,"\n");
388 fwrite($output,"\n");
389 foreach($history as $line)
390 fwrite($output,$line);
392 fwrite($output,"\n");
396 echo "can't open file for writing, please inform the admin.errorcode3";
401 /***************** M A I N **************************/
403 echo "<p>If you find bugs, please list them in the <a href=\"".$wiki."\">wiki</a>.</p>\n";
405 echo "<p> Names that are underlined have a comment, which you can access by hovering over the name with your mouse ;)</p>\n";
413 /* check for status file and read it, if possible */
415 if(file_exists("status.txt"))
416 $lines = file("status.txt");
420 /* check if we want to start a new game */
421 if( isset($_REQUEST["PlayerA"]) &&
422 isset($_REQUEST["PlayerB"]) &&
423 isset($_REQUEST["PlayerC"]) &&
424 isset($_REQUEST["PlayerD"]) &&
425 isset($_REQUEST["EmailA"]) &&
426 isset($_REQUEST["EmailB"]) &&
427 isset($_REQUEST["EmailC"]) &&
428 isset($_REQUEST["EmailD"]) && sizeof($lines<2))
430 $PlayerA = $_REQUEST["PlayerA"];
431 $PlayerB = $_REQUEST["PlayerB"];
432 $PlayerC = $_REQUEST["PlayerC"];
433 $PlayerD = $_REQUEST["PlayerD"];
434 $EmailA = $_REQUEST["EmailA"] ;
435 $EmailB = $_REQUEST["EmailB"] ;
436 $EmailC = $_REQUEST["EmailC"] ;
437 $EmailD = $_REQUEST["EmailD"] ;
439 $hashA = md5("AGameOfDoko".$PlayerA.$EmailA);
440 $hashB = md5("AGameOfDoko".$PlayerB.$EmailB);
441 $hashC = md5("AGameOfDoko".$PlayerC.$EmailC);
442 $hashD = md5("AGameOfDoko".$PlayerD.$EmailD);
444 /* send out email, check for error with email */
447 "you are invited to play a game of DoKo (that is to debug the program ;).\n".
448 "Place comments and bug reports here:\n".
449 "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
450 "The whole round would consist of the following players:\n".
455 "If you want to join this game, please follow this link:\n\n".
458 mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
459 mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
460 mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
461 mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
463 /* read in random.txt */
464 if(file_exists("random.txt"))
465 $random = file("random.txt");
467 die("no random file");
469 $randomNR = explode( ":", $random[2] );
471 /* write initial status into file */
472 $output = fopen("status.txt","w");
475 fwrite($output, "$hashA:$PlayerA:$EmailA:::" );
477 fwrite($output,"$randomNR[$i];" );
478 fwrite($output,"$randomNR[11]:" ); $i++;
479 fwrite($output,"\n");
481 fwrite($output, "$hashB:$PlayerB:$EmailB:::" );
483 fwrite($output,"$randomNR[$i];" );
484 fwrite($output,"$randomNR[23]:" ); $i++;
485 fwrite($output,"\n");
487 fwrite($output, "$hashC:$PlayerC:$EmailC:::" );
489 fwrite($output,"$randomNR[$i];" );
490 fwrite($output,"$randomNR[35]:" ); $i++;
491 fwrite($output,"\n");
493 fwrite($output, "$hashD:$PlayerD:$EmailD:::");
495 fwrite($output,"$randomNR[$i];" );
496 fwrite($output,"$randomNR[47]:" );
497 fwrite($output,"\n");
502 echo "can't open file for writing";
505 if(file_exists("status.txt"))
506 $lines = file("status.txt");
510 /* test if a game is running, else output everything for a new game */
514 <p> no game in progress, please input 4 names and email addresses, please make sure that the addresses are correct! </p>
515 <form action="index.php" method="post">
516 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
517 Email: <input name="EmailA" type="text" size="20" maxlength="30" /> <br />
519 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
520 Email: <input name="EmailB" type="text" size="20" maxlength="30" /> <br />
522 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
523 Email: <input name="EmailC" type="text" size="20" maxlength="30" /> <br />
525 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
526 Email: <input name="EmailD" type="text" size="20" maxlength="30" /> <br />
528 <input type="submit" value="start game" />
533 { /* load game status */
540 * check if a player wants to accept a game
542 if(isset($_REQUEST["a"]))
546 if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
548 echo "just wait for the game to start";
550 else if( !ereg("[is]",$player[$a]["option"]) )
553 <form action="index.php" method="post">
554 Do you want to play a game of DoKo?
555 yes<input type="radio" name="in" value="yes" />
556 no<input type="radio" name="in" value="no" /> <br />
558 Do you want to get an email for every card played or only if it your move?
559 every card<input type="radio" name="update" value="card" />
560 only on my turn<input type="radio" name="update" value="turn" /> <br />
562 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
564 echo "<input type=\"submit\" value=\"count me in\" />\n";
573 * yes? email him his hand, ask for solo, poverty, email every move or every card?
575 if(isset($_REQUEST["b"]))
579 if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
580 { /* the player already filled out everything */
581 echo "just wait for the game to start";
583 else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
584 { /* the player didn't fill out the form at "a" correctly */
586 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
589 { /* show the hand and check if the player is sick*/
590 if($_REQUEST["in"]=="no")
591 { /* player doesn't want to play, cancel the game */
594 $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
595 "the game has been canceled due to the request of one of the players.\n";
596 mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
598 /* canceling the game is as easy as removing the contents of the status file*/
599 $output = fopen("status.txt","w");
603 echo "problem opening file";
607 /* player wants to play, save information from "a"*/
608 if($_REQUEST["update"]=="card")
609 $player[$b]["option"] .= "c";
611 $player[$b]["option"] .= "t";
613 $player[$b]["option"] .= "i"; /* player finished stage "a" */
617 $allcards = $player[$b]["cards"];
618 $mycards = explode(";",$allcards);
621 echo "<p class=\"mycards\">your cards are: <br />\n";
622 foreach($mycards as $card)
626 <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>
628 <form action="index.php" method="post">
630 do you want to play solo?
631 <select name="solo" size="1">
633 <option>No trump</option>
634 <option>Normal solo</option>
635 <option>Queen solo</option>
636 <option>Jack solo</option>
637 <option>Club solo</option>
638 <option>Spade solo</option>
639 <option>Heart solo</option>
646 if(check_wedding($player[$b]["cards"]))
648 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
649 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
653 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
656 echo "do you have poverty?";
657 if(count_trump($player[$b]["cards"])<4)
659 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
660 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
664 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
667 echo "do you have too many nines?";
668 if(count_nines($player[$b]["cards"])>4)
670 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
671 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
675 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
678 echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
679 echo "<input type=\"submit\" value=\"count me in\" />\n";
686 if(isset($_REQUEST["c"]))
691 if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
692 { /* the player already filled out everything */
693 echo "<p>just wait for the game to start</p>\n";
695 else if(!isset($_REQUEST["solo"]) ||
696 !isset($_REQUEST["wedding"]) ||
697 !isset($_REQUEST["poverty"]) ||
698 !isset($_REQUEST["nines"]) )
699 {/* player still needs to fill out the form */
701 echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
703 else if($game["init"]<4)
704 { /* save information */
705 if( $_REQUEST["solo"]!="No")
707 switch($_REQUEST["solo"])
710 $player[$c]["option"].="O";
713 $player[$c]["option"].="S";
716 $player[$c]["option"].="Q";
719 $player[$c]["option"].="J";
722 $player[$c]["option"].="C";
725 $player[$c]["option"].="A";
728 $player[$c]["option"].="H";
732 else if($_REQUEST["wedding"] == "yes")
734 echo "wedding was chosen<br />\n";
735 $player[$c]["option"].="W";
737 else if($_REQUEST["poverty"] == "yes")
739 echo "poverty was chosen<br />\n";
740 $player[$c]["option"].="P";
742 else if($_REQUEST["nines"] == "yes")
744 echo "nines was chosen<br />\n";
745 $player[$c]["option"].="N";
748 /* player finished setup */
749 $player[$c]["option"].="s";
752 /* reread status file, to get the correct startplayer, etc */
753 if(file_exists("status.txt"))
754 $lines = file("status.txt");
759 if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
761 echo "<p> The game can start now, it's your turn, please use this <a href=\"".
762 $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
764 else if($game["init"]==4)
766 $message = "The game can start now, it's your turn, please use this link to play a card:\n".
767 $host."?me=".$hash[$game["startplayer"]]."\n";
768 mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
769 echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
773 echo "<p>You're in. Once everyone has filled out the form, ".
774 "the game will start and you'll get an eamil on your turn.</p>\n";
783 /* check for sickness, only would need to do this on the first trick really...*/
784 /***** someone has 5 nines and no one is playing solo => cancel game */
785 if($game["nines"]>=0 && $game["solo-who"]<0)
787 $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
789 mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
791 $output = fopen("status.txt","w");
795 echo "problem opening file";
798 /* who is requesting this*/
799 if(!isset($_REQUEST["me"]))
801 if(!isset($_REQUEST["recovery"]))
803 echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
804 echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
806 <form action="index.php" method="post">
807 recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
808 <input type="submit" value="get me back into the game" />
814 $recovery = $_REQUEST["recovery"];
817 if(trim($recovery)==trim($player[$hash[$i]]["email"]))
821 $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
822 "\n if this doesn't work, contact the admin.error4\n";
823 mymail($recovery,"[DoKo-Debug] recovery ",$message);
824 echo "<p> An email with the game information has been sent.</p>\n";
828 echo "<p> can't find this email address, sorry.</p>\n";
834 $me = $_REQUEST["me"];
836 /* output if we are playing a solo or a wedding */
837 if($game["solo-who"]>=0)
838 echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
839 else if($game["wedding"]>=0)
840 echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
843 foreach($history as $play)
845 $trick = explode(":",$play);
847 /* found old trick, display it */
848 if(sizeof($trick)==5)
849 echo "<div class=\"oldtrick background".$play[0]."\"><div class=\"table\">\n";
851 echo "<div class=\"trick back".$play[0]."\"><div class=\"table\">\n";
852 for($i=0;$i<sizeof($trick)-1;$i++)
857 /* has a card been played? */
860 $tmp = explode("->",$card);
862 echo "<div class=\"card".$tmp[0]."\">";
864 if(strlen($tmp[2])>0)
865 echo "<span class=\"comment\">";
868 echo $player[$hash[$tmp[0]]]["name"];
869 /* check for comment */
870 if(strlen($tmp[2])>0)
871 echo " <span>".$tmp[2]."</span>";
874 display_card($tmp[1]);
880 echo "</div></div>\n";
883 /* figure out who needs to play next */
888 /* if no one has played yet or we are at the start of a new trick */
889 if(strlen($history[sizeof($history)-1])==3)
890 $next = $history[sizeof($history)-1][0];
892 /* are we trying to play a card? */
893 if(isset($_REQUEST["card"]))
895 if($hash[$next]==$me)
897 $card = $_REQUEST["card"];
898 $mycards = explode(";",$player[$me]["cards"]);
900 /* do we have that card */
901 if(in_array($card,$mycards))
903 /* delete card from array */
905 foreach($mycards as $m)
910 for($i=0;$i<sizeof($tmp)-1;$i++)
915 $player[$me]["cards"]=$tmp2;
917 /* add card to history, special case if this is the first card */
920 $history[sizeof($history)-1]="".$player[$me]["number"]."->".$card.":\n";
924 $tmp = explode(":",$history[sizeof($history)-1]);
925 $tmp[sizeof($tmp)-1] = "".$player[$me]["number"]."->".$card.":";
926 $history[sizeof($history)-1]=join(":",$tmp);
930 echo "<div class=\"card\">";
931 echo " you played <br />";
936 <form action="index.php" method="post">
937 A short comment:<input name="comment" type="text" size="30" maxlength="50" />
938 <input type="hidden" name="me" value="<?php echo $me; ?>" />
939 <input type="submit" value="submit comment" />
942 /* send out email to players who want/need to get informed */
943 /* check if we are in a trick, if trick is done, this needs to be handelt in the
944 * who-won-the-trick section further down */
945 $tmp = explode(":",$history[sizeof($history)-1]);
949 $mynext = $next+1; if($mynext>3)$mynext-=4;
951 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
953 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
957 $message .= "it's your turn now.\n".
958 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
960 $message .= $player[$me]["name"]." has played the following card ".
961 card_to_name($card)."\n";
963 if($game["solo-who"]>=0)
964 $message .= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
965 $game["solo-what"]." solo!\n";
967 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
970 echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
975 echo "seems like you don't have that card<br />\n";
979 } /* end if card is set */
980 else if(isset($_REQUEST["comment"]))
982 $comment = $_REQUEST["comment"];
983 $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
984 $tmp2 = explode("->",$tmp[sizeof($tmp)-2]); /*last played card */
986 $comment = str_replace(":","",$comment); /*can't have ":" in comments */
989 $tmp[sizeof($tmp)-2] .= "->".$comment;
990 $history[sizeof($history)-1]=join(":",$tmp);
994 else if(isset($_REQUEST["win"]) && strlen($history[sizeof($history)-1])>3)
995 { /* count points, email winner */
996 $win = $_REQUEST["win"];
998 if(strlen($player[$hash[0]]["cards"]))
999 $history[] = $win.":\n";
1001 /* email the player who needs to move next*/
1004 if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
1006 $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
1010 $message .= "You won the last trick,it's your turn now.\n".
1011 "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
1014 $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
1015 "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
1017 if($game["solo-who"]>=0)
1018 $message.= $player[$hash[$game["solo-who"]]]["name"]." is playing a ".
1019 $game["solo-what"]." solo!\n";
1021 mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
1024 echo "<a href=\"index.php?me=".$hash[$win]."\"> next player </a> <br />\n";
1028 /* count points of the last trick */
1031 $tmp = explode(":",$history[sizeof($history)-2]);
1034 $tmp2 = explode("->",$tmp[$i]);
1036 $points += card_value($c);
1038 $player[$hash[$win]]["points"] += $points;
1039 echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
1042 }; /* end if win is set */
1045 /* check last history entry: end of a trick? ask who won it, unless it was the last trick */
1046 $tmp = explode(":",$history[sizeof($history)-1]);
1047 if(sizeof($tmp)==5 && strlen($player[$hash[0]]["cards"]))
1050 <form action="index.php" method="post">
1054 echo $player[$hash[$i]]["name"]." <input type=\"radio\" name=\"win\" value=\"$i\" />";
1055 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />";
1057 <input type="submit" value="submit" />
1062 else if(sizeof($tmp)<5 && 1<sizeof($tmp) && !isset($_REQUEST["card"]))
1064 if(sizeof($tmp)==2 && strlen($tmp[0])==1)
1069 echo "DEBUG: the next move is for <a href=\"index.php?me=".$hash[$next]."\">the next player</a><br />\n";
1070 if(strlen(trim($player[$me]["cards"]))==0)
1072 echo "<br /> game over, count points <br />\n";
1075 echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
1080 } /* end check for winner */
1082 /* do we still have cards? display them */
1083 if(strlen(trim($player[$me]["cards"]))>0 )
1085 $allcards = trim($player[$me]["cards"]);
1086 $mycards = explode(";",$allcards);
1090 echo "<p class=\"mycards\">\n";
1091 /* is it our turn? */
1092 if($hash[$next]==$me && !isset($_REQUEST["card"]) && !isset($_REQUEST["win"]))
1094 echo "ITS YOUR TURN! <br />\n";
1095 echo "Your cards are: <br />\n";
1096 foreach($mycards as $card)
1097 display_link_card($card,$me);
1100 { /* not our turn, just show the hand */
1101 echo "Your cards are: <br />\n";
1102 foreach($mycards as $card)
1103 display_card($card);