X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=ff9af4622b2ee35b4d88e2b61e4f7da68a516122;hp=162656eb966568f87a54942959f24c940d30dd03;hb=4ae745090ccf8d4ade4b9d648efd1a459031a0ee;hpb=9632b3bc79abf72a127c4967ccc01663e0020481 diff --git a/index.php b/index.php index 162656e..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
"; @@ -471,9 +552,9 @@ if(sizeof($lines)<2) { for($i=0;$i<4;$i++) { - echo "Hello ".$player[$hash[$i]]["name"].",\n"; - echo "\n"; - echo "the game has been cancled due to the request of one of the players.\n"; + $message = "Hello ".$player[$hash[$i]]["name"].",\n\n". + "the game has been cancled due to the request of one of the players.\n"; + mymail($player[$hash[$i]]["email"],"[DoKo] the game has been cancled",$message); } $output = fopen("status.txt","w"); if($output) @@ -501,21 +582,57 @@ if(sizeof($lines)<2) } echo "
\n"; ?> +

aehm... at the moment please just answer everything with no, still need to implement this

- do you want to play solo? - yes - no
- - do you have a wedding? - yes - no
+ do you want to play solo? + +
- do you have poverty? - yes - no
- "; + echo " no
"; + } + else + { + echo " 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
"; + }; + echo "\n"; echo "\n"; @@ -527,7 +644,7 @@ if(sizeof($lines)<2) { $c=$_REQUEST["c"]; - if(!isset($_REQUEST["solo"])|| !isset($_REQUEST["wedding"])|| !isset($_REQUEST["poverty"]) ) + if(!isset($_REQUEST["solo"])|| !isset($_REQUEST["wedding"])|| !isset($_REQUEST["poverty"]) || !isset($_REQUEST["nines"]) ) { echo "go back to "; echo " here and fill out the form
"; @@ -538,27 +655,102 @@ if(sizeof($lines)<2) } else if($game["init"]<4) { - echo "handle krankheit
"; - + if( $_REQUEST["solo"]!="No") + { + switch($_REQUEST["solo"]) + { + case "No trump": + $player[$c]["option"].="O"; + break; + case "Normal solo": + $player[$c]["option"].="S"; + break; + case "Queen solo": + $player[$c]["option"].="Q"; + break; + case "Jack solo": + $player[$c]["option"].="J"; + break; + case "Club solo": + $player[$c]["option"].="C"; + break; + case "Spade solo": + $player[$c]["option"].="A"; + break; + case "Hear solo": + $player[$c]["option"].="H"; + break; + } + } + else if($_REQUEST["wedding"] == "yes") + { + echo "wedding was chosen
"; + $player[$c]["option"].="W"; + } + else if($_REQUEST["poverty"] == "yes") + { + echo "poverty was chosen
"; + $player[$c]["option"].="P"; + } + else if($_REQUEST["nines"] == "yes") + { + 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 "
"; @@ -634,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
"; } @@ -672,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
"; - for($i=0;$i>4;$i++) + for($i=0;$i<4;$i++) { echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."
"; }