+function parse_status()
+{
+ global $game,$history,$player,$hash,$lines;
+
+ $game["init"] = 0;
+ $game["solo-who"] = -1;
+ $game["solo-what"] = "todo";
+ $game["wedding"] = -1;
+ $game["poverty"] = -1;
+ $game["nines"] = -1;
+ $game["startplayer"] = 0;
+
+ for($i=0;$i<4;$i++)
+ {
+ $tmp = explode( ":",$lines[$i]);
+ $hash[$i] = $tmp[0];
+ $player[$tmp[0]]["number"] = $i;
+ $player[$tmp[0]]["hash"] = $tmp[0];
+ $player[$tmp[0]]["name"] = $tmp[1];
+ $player[$tmp[0]]["email"] = $tmp[2];
+ $player[$tmp[0]]["option"] = $tmp[3];
+ $player[$tmp[0]]["points"] = $tmp[4];
+ $player[$tmp[0]]["cards"] = $tmp[5];
+ if(ereg("s",$tmp[3])) $game["init"]++;
+ if(ereg("P",$tmp[3])) $game["poverty"] = $i;
+ if(ereg("N",$tmp[3])) $game["nines"] = $i;
+ if(ereg("W",$tmp[3])) $game["wedding"] = $i;
+ if(ereg("[OSQJCAH]",$tmp[3]) && ($game["solo-who"]<0) )
+ {
+ $game["solo-who"] = $i;
+ $game["startplayer"] = $i;
+ }
+
+ }
+ /* save the game history */
+ for($i=4;$i<sizeof($lines);$i++)
+ {
+ if(!ereg("^[[:space:]]*$",trim($lines[$i])))
+ {
+ $history[] = $lines[$i];
+ }
+ }
+
+ if(sizeof($history)==0 || (sizeof($history)==1 && strlen($history[0])==3 ))
+ $history[0] = $game["startplayer"].":";
+
+ return;
+}
+
+function count_nines($cards)
+{
+ $card = explode(";",$cards);
+
+ $nines =0;
+
+ foreach($card as $c)
+ {
+ if($c == "25" || $c == "26") $nines++;
+ else if($c == "33" || $c == "34") $nines++;
+ else if($c == "41" || $c == "42") $nines++;
+ else if($c == "47" || $c == "48") $nines++;
+ }
+
+ return $nines;
+}
+
+function check_wedding($cards)
+{
+ $card = explode(";",$cards);
+
+ $count =0;
+
+ if( in_array("3",$card) && in_array("2",$card) )
+ $count=1;
+
+ return $count;
+}
+
+function count_trump($cards)
+{
+ $card = explode(";",$cards);
+
+ $trump =0;
+
+ /* count each trump */
+ foreach($card as $c)
+ {
+ if( (int)($c) <27) $trump++;
+ }
+
+ /* subtract one, in case player has both foxes */
+ if( in_array("19",$card) && in_array("20",$card) )
+ $trump--;
+
+ return $trump;
+}
+
+
+