From 4ae745090ccf8d4ade4b9d648efd1a459031a0ee Mon Sep 17 00:00:00 2001 From: arun Date: Mon, 20 Nov 2006 08:38:11 +0000 Subject: [PATCH] solo should be working, >5 nines too --- index.php | 291 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 202 insertions(+), 89 deletions(-) diff --git a/index.php b/index.php index 99ef805..ff9af46 100644 --- a/index.php +++ b/index.php @@ -3,24 +3,139 @@ "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> - Doko via email + e-Doko

Welcome to E-Doko

To: $To
Subject: $Subject
$message
"; + { + str_replace("\n","
",$message); + echo "
To: $To
Subject: $Subject
$message
"; + } else mail($To,$Subject,$message); return; } +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 here and fill out the form
"; @@ -544,19 +598,41 @@ if(sizeof($lines)<2)
- do you have a wedding? - yes - no
+"; + echo " no
"; + } + else + { + echo " no
"; + }; - do you have poverty? - yes - no
+ echo "do you have poverty?"; + if(count_trump($player[$b]["cards"])<4) + { + echo " yes"; + echo " no
"; + } + else + { + echo " no
"; + }; + + echo "do you have too many nines?"; + if(count_nines($player[$b]["cards"])>4) + { + echo " yes"; + echo " no
"; + } + else + { + echo " no
"; + }; - do too many nines? - yes - no
- -\n"; echo "\n"; @@ -579,7 +655,6 @@ if(sizeof($lines)<2) } else if($game["init"]<4) { - echo "handle krankheit
"; if( $_REQUEST["solo"]!="No") { switch($_REQUEST["solo"]) @@ -622,25 +697,60 @@ if(sizeof($lines)<2) echo "nines was chosen
"; $player[$c]["option"].="N"; } + $message = "you're in. once everyone has filled out the form,". "the game will start and you'll get an eamil on your turn\n"; mymail($player[$c]["email"],"[DoKo] the game will start soon",$message); - - $player[$c]["option"].="s"; + $player[$c]["option"].="s"; save_status(); + if(file_exists("status.txt")) + $lines = file("status.txt"); + else + die("no file"); + parse_status(); + + if($game["init"]==4) +3 { + $message = "The game can start now, it's your turn, please use this link to play a card:\n". + $host."?me=".$hash[$game["startplayer"]]."\n"; + mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo] let's go",$message); + } + } } if($game["init"]==4) { + /* check for sickness*/ + /***** someone has 5 nines and no one is playing solo=> cancel game */ + if($game["nines"]>=0 && $game["solo-who"]<0) + { + $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n"; + for($i=0;$i<4;$i++) + { + mymail($player[$hash[$i]]["email"],"[DoKo] the game has been canceled",$message); + } + $output = fopen("status.txt","w"); + if($output) + fclose($output); + else + echo "problem opening file"; + } + + /* who is requesting this*/ if(!isset($_REQUEST["me"])) echo "a game is in progress, but you are not playing"; else { $me = $_REQUEST["me"]; - echo "game in progress and you are in it
"; - foreach($history as $play) + 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!
"; + + foreach($history as $play) { echo "
"; @@ -716,6 +826,9 @@ if(sizeof($lines)<2) $message .= "it's your turn now.\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] a card has been played",$message); echo " next player
"; } @@ -754,13 +867,13 @@ if(sizeof($lines)<2) { ?>
- +who won? "; echo ""; ?> - +
the next player
"; - */ + if($debug) + echo "DEBUG: the next move is for the next player
"; + if(strlen(trim($player[$me]["cards"]))==0) { echo "
game over, count points
"; -- 2.25.1