From f9ebada8e82bef69014f86b14b92534a266164bc Mon Sep 17 00:00:00 2001 From: arun Date: Wed, 22 Nov 2006 09:57:02 +0000 Subject: show cards every time, in case you are playing, make them links only if it is your turn; some clean up --- index.php | 146 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 84 insertions(+), 62 deletions(-) diff --git a/index.php b/index.php index 6406837..2eb0cf7 100644 --- a/index.php +++ b/index.php @@ -743,52 +743,53 @@ if(sizeof($lines)<2) /* who is requesting this*/ if(!isset($_REQUEST["me"])) - { - if(!isset($_REQUEST["recovery"])) - { - echo "a game is in progress, but you are not playing.
"; - echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:
"; -?> + { + if(!isset($_REQUEST["recovery"])) + { + echo "a game is in progress, but you are not playing.
"; + echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:
"; + ?>
recorvery:
=0) - { - $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n". - "\n if this doesn't work, contact the admin.\n"; - mymail($recovery,"[DoKo-Debug] recovery ",$message); - echo "email has been sent."; - } - else - { - echo "can't find this email address, sorry."; - }; - } - } + } + else + { + $recovery=$_REQUEST["recovery"]; + $ok=-1; + for($i=0;$i<4;$i++) + if(trim($recovery)==trim($player[$hash[$i]]["email"])) + $ok=$i; + if($ok>=0) + { + $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n". + "\n if this doesn't work, contact the admin.\n"; + mymail($recovery,"[DoKo-Debug] recovery ",$message); + echo "email has been sent."; + } + else + { + echo "can't find this email address, sorry."; + }; + } /* end recovery */ + } else - { + { /* $me is set */ $me = $_REQUEST["me"]; - + echo "game in progress and you are in it
"; if($game["solo-who"]>=0) echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!
"; else if($game["wedding"]>=0) echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!
"; + /* show history */ foreach($history as $play) { echo "
"; - + $trick = explode(":",$play); $last=-2; @@ -806,6 +807,7 @@ if(sizeof($lines)<2) } } + /* figure out who needs to play next */ $next = $last + 1; if ($next>=4) $next -= 4 ; @@ -813,20 +815,24 @@ if(sizeof($lines)<2) { $next=$history[sizeof($history)-1][0]; } - - + + /* are we trying to play a card? */ if(isset($_REQUEST["card"])) { if($hash[$next]==$me) { - $card=$_REQUEST["card"]; + $card = $_REQUEST["card"]; $mycards = explode(";",$player[$me]["cards"]); + + /* do we have that card */ if(in_array($card,$mycards)) { - $tmp=array(); + /* delete card from array */ + $tmp = array(); foreach($mycards as $m) - if($m!=$card) + if($m != $card) $tmp[]=$m; + $tmp2=""; for($i=0;$i".$card.":\n"; @@ -846,9 +853,10 @@ if(sizeof($lines)<2) $history[sizeof($history)-1]=join(":",$tmp); } save_status(); - + echo " you played "; display_card($card); + /* send out email to players who want/need to get informed */ for($i=0;$i<4;$i++) { @@ -856,19 +864,19 @@ if(sizeof($lines)<2) if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me) { $message = " Hello ".$player[$hash[$i]]["name"].",\n\n"; - + if($i==$mynext) - { - $message .= "it's your turn now.\n". - "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ; - } + { + $message .= "it's your turn now.\n". + "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ; + } $message .= $player[$me]["name"]. "has played the following card ".card_to_name($card)."\n"; if($game["solo-who"]>=0) $message.= $player[$hash[$game["solo-who"]]]." is playing a ".$game["solo-what"]." solo!\n"; - + mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message); - + if($debug) echo " next player
"; } @@ -876,10 +884,10 @@ if(sizeof($lines)<2) } else echo "seems like you don't have that card
"; - + } - } + } /* end if card is set */ else if(isset($_REQUEST["win"]) && strlen($history[sizeof($history)-1])>3) { $win=$_REQUEST["win"]; @@ -896,13 +904,14 @@ if(sizeof($lines)<2) } $player[$hash[$win]]["points"]+=$points; echo "
".$player[$hash[$win]]["name"]." won: $points Points
"; - + save_status(); - } + }; /* end if win is set */ echo "
"; $tmp = explode(":",$history[sizeof($history)-1]); + /* check last history entry: end of a trick? ask who won it */ if(sizeof($tmp)==5) { ?> @@ -917,16 +926,16 @@ who won? the next player
"; - + if(strlen(trim($player[$me]["cards"]))==0) { echo "
game over, count points
"; @@ -936,23 +945,36 @@ who won? } } } - if($hash[$next]==$me && strlen(trim($player[$me]["cards"]))>0 ) + echo "
"; + } /* end check for winner */ + + /* do we still have cards? display them */ + if(strlen(trim($player[$me]["cards"]))>0 ) + { + $allcards = trim($player[$me]["cards"]); + $mycards = explode(";",$allcards); + + sort($mycards); + + /* is it our turn? */ + if($hash[$next]==$me) { - - echo "ITS YOUR TURN
"; - $allcards = trim($player[$me]["cards"]); - $mycards = explode(";",$allcards); - - sort($mycards); - echo "your cards are
"; + echo "ITS YOUR TURN
"; + echo "your cards are:
"; foreach($mycards as $card) { display_link_card($card,$me); } - echo "
\n"; } - echo "
"; - + else + { /* not our turn, just show the hand */ + echo "your cards are:
"; + foreach($mycards as $card) + { + display_card($card); + } + } + echo "
\n"; } } } -- cgit v1.2.3-18-g5258