X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=4a38ed8c9bde2ba498a86c0266c7aab1d9afe85c;hp=a2366ed6fda7c54d88a8cdd1538bfa7f01fc46e4;hb=0a660193fde766fcb6703f73c9bd68ed1c972c0c;hpb=9197d1d5144a1d281db321fbaa523172c88da07e diff --git a/index.php b/index.php index a2366ed..4a38ed8 100644 --- a/index.php +++ b/index.php @@ -6,412 +6,138 @@
If you find bugs, please list them in the wiki
\n"; - -$history=array(); +DB_open(); -/* check for status file and read it, if possible */ +/* end header */ -if(file_exists("status.txt")) - $lines = file("status.txt"); - else - die("no file"); +/***************** M A I N **************************/ /* check if we want to start a new game */ -if( isset($_REQUEST["PlayerA"]) && +if(isset($_REQUEST["new"])) + { +?> +Please add 4 names, please make sure that the names are correct!
+ +\n"; + echo "perhaps the game has been cancled."; + exit(); + } + + DB_update_user_timestamp($myid); + $myname = DB_get_name_by_hash($me); + $mystatus = DB_get_status_by_hash($me); + + /* get game id */ + $gameid = DB_get_gameid_by_hash($me); - /* write initial status into file */ - $output = fopen("status.txt","w"); - if ($output) + switch($mystatus) { - fwrite($output, "$hashA:$PlayerA:$EmailA:::" ); - for($i=0;$i<11;$i++) - fwrite($output,"$randomNR[$i];" ); - fwrite($output,"$randomNR[11]:" ); $i++; - fwrite($output,"\n"); + case 'start': + check_want_to_play($me); + DB_set_hand_status_by_hash($me,'init'); + break; + + case 'init': + if( !isset($_REQUEST["in"]) || !isset($_REQUEST["update"])) + { + DB_set_hand_status_by_hash($me,'start'); + echo "you need to answer both question"; + } + else + { + if($_REQUEST["in"] == "no") + { + echo "TODO: email everyone that the game has been canceldyour cards are:
\n";
+ foreach($mycards as $card)
+ display_card($card);
+ echo "
these are the games you are playing in:
\n";
+ $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" );
+ while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ echo "game #".$r[1]."
";
+ echo "
registered players:
\n";
+ foreach ($names as $name)
+ echo "$name
\n";
+ echo "
Want to start a new game? remember 4 names from the list above and visit ". + "this page.
"; } else - echo "can't open file for writing"; - }; - -/* test if a game is running, else output everything for a new game */ -if(sizeof($lines)<2) + { + echo "sorry email and password don't matchno game in progress, please input 4 names and email addresses, please make sure that the addresses are correct!
- + - \n"; - } - } + } +else if(isset($_REQUEST["Rfullname"]) && + isset($_REQUEST["Remail"] ) && + isset($_REQUEST["Rpassword"]) && + isset($_REQUEST["Rtimezone"]) ) + { + $ok=1; + if(DB_get_userid_by_name($_REQUEST["Rfullname"])) + { + echo "please chose another nameIf you want to play a game of Doppelkopf, you found the right place ;)
+ Please register, in case you haven't done yet
+ or login with you email-address or name and password here:
+
aehm... at the moment please just answer everything with no, still need to implement this
- \n"; - } - } - } - if(isset($_REQUEST["c"])) - { - $c=$_REQUEST["c"]; - - if(!isset($_REQUEST["solo"])|| !isset($_REQUEST["wedding"])|| !isset($_REQUEST["poverty"]) || !isset($_REQUEST["nines"]) ) - { - echo "go back to "; - echo " here and fill out the form\n";
- /* is it our turn? */
- if($hash[$next]==$me)
- {
- echo "ITS YOUR TURN
\n";
- echo "your cards are:
\n";
- foreach($mycards as $card)
- {
- display_link_card($card,$me);
- }
- }
- else
- { /* not our turn, just show the hand */
- echo "your cards are:
\n";
- foreach($mycards as $card)
- {
- display_card($card);
- }
- }
- echo "