X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=a7af6df27cc811852adb8b15eb2373f8e650b946;hp=4e890fa60e4da03ccdcd4dbd12e2b20341ba8d56;hb=8536c1e008f33b07bd3e0a9bbb0feb98043cb021;hpb=81d298869d56d991ba3551b1b1413d3ca195eb86 diff --git a/index.php b/index.php index 4e890fa..a7af6df 100644 --- a/index.php +++ b/index.php @@ -8,21 +8,22 @@ +

Welcome to E-Doko

",$message); + $message = str_replace("\n","
",$message); echo "
To: $To
Subject: $Subject
$message
\n"; } else @@ -141,19 +142,21 @@ function count_trump($cards) /* count each trump */ foreach($card as $c) - { - if( (int)($c) <27) $trump++; - } + if( (int)($c) <27) + $trump++; - /* subtract one, in case player has both foxes */ - if( in_array("19",$card) && in_array("20",$card) ) + /* subtract foxes */ + if( in_array("19",$card)) + $trump--; + if( in_array("20",$card) ) $trump--; + /* add one, in case the player has both foxes (schweinchen) */ + if( in_array("19",$card) && in_array("20",$card) ) + $trump++; return $trump; } - - function card_to_name($card) { switch($card) @@ -314,18 +317,18 @@ function card_value($card) function display_card($card) { if( $card/2 - (int)($card/2) == 0.5) - echo "\"".card_to_name($card)."\"\n"; + echo "\"".card_to_name($card)."\"\n"; else - echo "\"".card_to_name($card-1)."\"\n"; + echo "\"".card_to_name($card-1)."\"\n"; return; } function display_link_card($card,$me) { if( $card/2 - (int)($card/2) == 0.5) - echo "\"".card_to_name($card)."\"\n"; + echo "\"".card_to_name($card)."\"\n"; else - echo "\"".card_to_name($card-1)."\"\n"; + echo "\"".card_to_name($card-1)."\"\n"; return; } @@ -392,9 +395,15 @@ function save_status() return; } -echo "

If you find bugs, please list them in the wiki

\n"; +/***************** M A I N **************************/ + +echo "

If you find bugs, please list them in the wiki.

\n"; -echo "

Cards that have a green background have a comment, which you can access by hovering over the card with your mouse ;)

\n"; +echo "

Names that are underlined have a comment, which you can access by hovering over the name with your mouse ;)

\n"; +echo "
\n"; + +/* end header */ + $history=array(); @@ -402,8 +411,8 @@ $history=array(); if(file_exists("status.txt")) $lines = file("status.txt"); - else - die("no file"); +else + die("no file"); /* check if we want to start a new game */ if( isset($_REQUEST["PlayerA"]) && @@ -443,10 +452,10 @@ if( isset($_REQUEST["PlayerA"]) && "If you want to join this game, please follow this link:\n\n". " ".$host."?a="; - mymail($EmailA,"Invite for a game of DoKo","Hello $PlayerA,\n".$message.$hashA); - mymail($EmailB,"Invite for a game of DoKo","Hello $PlayerB,\n".$message.$hashB); - mymail($EmailC,"Invite for a game of DoKo","Hello $PlayerC,\n".$message.$hashC); - mymail($EmailD,"Invite for a game of DoKo","Hello $PlayerD,\n".$message.$hashD); + mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA); + mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB); + mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC); + mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD); /* read in random.txt */ if(file_exists("random.txt")) @@ -489,6 +498,11 @@ if( isset($_REQUEST["PlayerA"]) && else echo "can't open file for writing"; }; +/* reread file */ +if(file_exists("status.txt")) + $lines = file("status.txt"); + else + die("no file"); /* test if a game is running, else output everything for a new game */ if(sizeof($lines)<2) @@ -512,9 +526,9 @@ if(sizeof($lines)<2)
Do you want to play a game of DoKo? @@ -550,7 +562,6 @@ if(sizeof($lines)<2) echo "
\n"; } } - /* *** * * * * *** @@ -560,56 +571,59 @@ if(sizeof($lines)<2) */ if(isset($_REQUEST["b"])) { - $b=$_REQUEST["b"]; + $b = $_REQUEST["b"]; if( ereg("s",$player[$b]["option"]) && $game["init"]<4) - { + { /* the player already filled out everything */ echo "just wait for the game to start"; } else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"])) - { + { /* the player didn't fill out the form at "a" correctly */ echo "go back to "; echo " here and fill out the form
\n"; } else - { /* show the hand */ + { /* show the hand and check if the player is sick*/ if($_REQUEST["in"]=="no") - { + { /* player doesn't want to play, cancel the game */ for($i=0;$i<4;$i++) { $message = "Hello ".$player[$hash[$i]]["name"].",\n\n". "the game has been canceled due to the request of one of the players.\n"; mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message); } - $output = fopen("status.txt","w"); - if($output) - fclose($output); - else - echo "problem opening file"; + /* canceling the game is as easy as removing the contents of the status file*/ + $output = fopen("status.txt","w"); + if($output) + fclose($output); + else + echo "problem opening file"; } else { - if($_REQUEST["update"]=="card") $player[$b]["option"].="c"; - if($_REQUEST["update"]=="turn") $player[$b]["option"].="t"; + /* player wants to play, save information from "a"*/ + if($_REQUEST["update"]=="card") + $player[$b]["option"] .= "c"; + else + $player[$b]["option"] .= "t"; - $player[$b]["option"].="i"; + $player[$b]["option"] .= "i"; /* player finished stage "a" */ save_status(); $allcards = $player[$b]["cards"]; - $mycards = explode(";",$allcards); + $mycards = explode(";",$allcards); sort($mycards); - echo "your cards are
\n"; + echo "

your cards are:
\n"; foreach($mycards as $card) - { - display_card($card); - } - echo "
\n"; + display_card($card); + echo "

\n"; ?> -

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

+

aehm... at the moment poverty is not implented. so I guess you need to play a normal game, even if you have less than 3 trump :(...sorry

+
- + do you want to play solo?