\n";
for($i=0;$i
",$card);
+ echo "";
+
if(strlen($tmp[2])>0)
- echo "
";
+ echo "
\n";
+ echo "
\n";
}
/* figure out who needs to play next */
@@ -845,9 +880,7 @@ if(sizeof($lines)<2)
if ($next>=4)
$next -= 4 ;
if($last<0)
- {
- $next=$history[sizeof($history)-1][0];
- }
+ $next = $history[sizeof($history)-1][0];
/* are we trying to play a card? */
if(isset($_REQUEST["card"]))
@@ -888,7 +921,7 @@ if(sizeof($lines)<2)
save_status();
echo "
";
- echo " you played
";
+ echo " you played
";
display_card($card);
echo "
\n";
@@ -901,29 +934,36 @@ if(sizeof($lines)<2)
3)$mynext-=4;
- 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 .= $player[$me]["name"]." has played the following card ".card_to_name($card)."\n";
-
- if($game["solo-who"]>=0)
- $message.= $player[$hash[$game["solo-who"]]]["name"]." 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 \n";
- }
- }
+ /* check if we are in a trick, if trick is done, this needs to be handelt in the
+ * who-won-the-trick section further down */
+ $tmp = explode(":",$history[sizeof($history)-1]);
+ if(sizeof($tmp)<5)
+ for($i=0;$i<4;$i++)
+ {
+ $mynext = $next+1; if($mynext>3)$mynext-=4;
+
+ 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 .= $player[$me]["name"]." has played the following card ".
+ card_to_name($card)."\n";
+
+ if($game["solo-who"]>=0)
+ $message .= $player[$hash[$game["solo-who"]]]["name"]." 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 \n";
+ }
+ }
}
else
echo "seems like you don't have that card
\n";
@@ -932,12 +972,12 @@ if(sizeof($lines)<2)
} /* end if card is set */
else if(isset($_REQUEST["comment"]))
- {
+ { /*save comment */
$comment = $_REQUEST["comment"];
- $tmp = explode(":",$history[sizeof($history)-1]);
- $tmp2 = explode("->",$tmp[sizeof($tmp)-2]);
+ $tmp = explode(":",$history[sizeof($history)-1]); /*last played trick */
+ $tmp2 = explode("->",$tmp[sizeof($tmp)-2]); /*last played card */
- $comment = str_replace(":","",$comment);
+ $comment = str_replace(":","",$comment); /*can't have ":" in comments */
if(sizeof($tmp2)<=2)
$tmp[sizeof($tmp)-2] .= "->".$comment;
@@ -946,11 +986,41 @@ if(sizeof($lines)<2)
save_status();
}
else if(isset($_REQUEST["win"]) && strlen($history[sizeof($history)-1])>3)
- {
- $win=$_REQUEST["win"];
- $history[]=$win.":\n";
+ { /* count points, email winner */
+ $win = $_REQUEST["win"];
+
+ if(strlen($player[$hash[0]]["cards"]))
+ $history[] = $win.":\n";
+
+ /* email the player who needs to move next*/
+ for($i=0;$i<4;$i++)
+ {
+ if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
+ {
+ $message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
+
+ if($i == $win)
+ {
+ $message .= "You won the last trick,it's your turn now.\n".
+ "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
+ }
+ else
+ $message .= $player[$hash[$win]]["name"]." has won the last trick\n".
+ "Use this link to look at the game: ".$host."?me=".$hash[$i]."\n\n" ;
+
+ if($game["solo-who"]>=0)
+ $message.= $player[$hash[$game["solo-who"]]]["name"]." 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 \n";
+ }
+ }
+
/* count points of the last trick */
- $points=0;
+ $points = 0;
$tmp = explode(":",$history[sizeof($history)-2]);
for($i=0;$i<4;$i++)
@@ -959,17 +1029,16 @@ if(sizeof($lines)<2)
$c = $tmp2[1];
$points += card_value($c);
}
- $player[$hash[$win]]["points"]+=$points;
+ $player[$hash[$win]]["points"] += $points;
echo "
\n ".$player[$hash[$win]]["name"]." won: $points Points
\n";
save_status();
}; /* end if win is set */
echo "
\n";
+ /* check last history entry: end of a trick? ask who won it, unless it was the last trick */
$tmp = explode(":",$history[sizeof($history)-1]);
-
- /* check last history entry: end of a trick? ask who won it */
- if(sizeof($tmp)==5)
+ if(sizeof($tmp)==5 && strlen($player[$hash[0]]["cards"]))
{
?>