X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=7addf0ef375a7f371238ffda434f372b3c2fbef9;hp=eded836ac1c86f532853864c5cecc121c2269720;hb=a0b3efd697ed19fe2bf204868ab5920e4af5d467;hpb=0dd96314cb0fc3d40502d87f354c6fd61f35a3cd diff --git a/index.php b/index.php index eded836..7addf0e 100644 --- a/index.php +++ b/index.php @@ -49,6 +49,7 @@ if(myisset("new")) if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="") { echo "couldn't find one of the names, please start a new game"; + output_footer(); exit(); } @@ -66,6 +67,7 @@ if(myisset("new")) if($ruleset <0) { echo "Error defining ruleset: $ruleset"; + output_footer(); exit(); }; @@ -157,6 +159,7 @@ else if(myisset("cancle","me")) { echo "Can't find you in the database, please check the url.
\n"; echo "perhaps the game has been cancled, check by login in here."; + output_footer(); exit(); } @@ -203,6 +206,7 @@ else if(myisset("me")) { echo "Can't find you in the database, please check the url.
\n"; echo "perhaps the game has been cancled, check by login in here."; + output_footer(); exit(); } @@ -214,21 +218,47 @@ else if(myisset("me")) $mystatus = DB_get_status_by_hash($me); $mypos = DB_get_pos_by_hash($me); - /* display the game number */ - echo "

Game $gameid

\n"; /* display rule set */ - echo "
\n Rules:
"; + echo "
\n"; $result = mysql_query("SELECT * FROM Rulesets LEFT JOIN Game ON Game.ruleset=Rulesets.id WHERE Game.id='$gameid'" ); $r = mysql_fetch_array($result,MYSQL_NUM); $RULES["dullen"]=$r[2]; $RULES["schweinchen"]=$r[3]; - - echo "10ofhearts : ".$r[2]."
"; - echo "schweinchen: ".$r[3]."
"; + + /* get some infos about the game */ + $gametype = DB_get_gametype_by_gameid($gameid); + $gamestatus = DB_get_game_status_by_gameid($gameid); + $GT = $gametype; + if($gametype=="solo") + { + $gametype = DB_get_solo_by_gameid($gameid); + $GT = $gametype." ".$GT; + } + else + $gametype="normal"; + + if($gamestatus != 'pre') + echo " Gametype: $GT
\n"; + + echo "Rules:
\n"; + echo "10ofhearts : ".$r[2]."
\n"; + echo "schweinchen: ".$r[3]."
\n"; echo "
\n"; + /* does anyone have both foxes */ + $GAME["schweinchen"]=0; + for($i=1;$i<5;$i++) + { + $hash = DB_get_hash_from_game_and_pos($gameid,$i); + $cards = DB_get_all_hand($hash); + if( in_array("19",$cards) && in_array("20",$cards) ) + { + $GAME["schweinchen"]=1; + $GAME["schweinchen-who"]=$hash; + } + }; /* mystatus gets the player through the different stages of a game. * start: yes/no @@ -400,6 +430,7 @@ else if(myisset("me")) /* delete everything from the dB */ DB_cancel_game($me); + output_footer(); exit(); } @@ -486,17 +517,16 @@ else if(myisset("me")) break; if($usersick == "solo" && $gametype =="solo") break; - }; + + }; + + if( $gametype != "solo") + if($GAME["schweinchen"] && $RULES["schweinchen"]=="both" ) + echo DB_get_name_by_hash($GAME["schweinchen-who"])." has Schweinchen.
"; + echo "
\n"; - /* check for Schweinchen (cards 21,22) */ - if($RULES["schweinchen"]=="both") - { - set_gametype($gametype); - echo "TODO: check if one user has both foxes and output here "; - } - - /* finished the setup, go to next stage unless there is a case of poverty*/ + /* finished the setup, set re/contra parties if possible, go to next stage unless there is a case of poverty*/ switch($gametype) { case "solo": @@ -509,7 +539,8 @@ else if(myisset("me")) DB_set_hand_status_by_hash($me,'play'); break; case "wedding": - echo "Don't know who will be Re and Contra, you need to figure that out at the end of the game yourself
\n"; + echo "Don't know who will be Re and Contra, you need to ". + "figure that out at the end of the game yourself
\n"; DB_set_hand_status_by_hash($me,'play'); break; case "normal": @@ -522,8 +553,23 @@ else if(myisset("me")) DB_set_hand_status_by_hash($me,'play'); break; case "poverty": + /* figure out who has poverty */ + /* check who was asked already + * everyone or trump was taken? + * trump was taken, start game + * trump was not taken, cancle game + * + * not everyone, figure out who is next in the list + * is the next person this one? + * no, display wait message, e.g. player X is asked at the moment + * yes, display trump, ask if he wants to take it + * no, set player asked to true, email next player + * yes, display all cards, ask for N return cards + * set re/contra + * + */ case "dpoverty": - echo "TODO: handle poverty here"; + echo "TODO: handle double poverty here"; DB_set_hand_status_by_hash($me,'play'); }; } @@ -567,37 +613,18 @@ else if(myisset("me")) else $gametype="normal"; - set_gametype($gametype); + set_gametype($gametype); /* this sets the $CARDS variable */ /* get some infos about the game */ $gamestatus = DB_get_game_status_by_gameid($gameid); /* display useful things in divs */ - /* display local time */ - echo "
\n Local times:"; - $users = array(); - $users = DB_get_all_userid_by_gameid($gameid); - foreach($users as $user) - { - $offset = DB_get_user_timezone($user); - $zone = return_timezone($offset); - date_default_timezone_set($zone); - $name = DB_get_name_by_userid($user); - - echo "\n"; - }; - echo "
$name ".date("Y-m-d H:i:s")."
\n
\n"; - - if($gamestatus != 'pre') - display_status($GT); - /* display links to the users status page */ $result = mysql_query("SELECT email,password from User WHERE id='$myid'" ); $r = mysql_fetch_array($result,MYSQL_NUM); - output_link_to_user_page($r[0],$r[1]); - display_news(); + display_links($r[0],$r[1]); /* end display useful things*/ @@ -611,7 +638,8 @@ else if(myisset("me")) /* display the table and the names */ $result = mysql_query("SELECT User.fullname as name,". - " Hand.position as position ". + " Hand.position as position, ". + " User.id ". "FROM Hand ". "LEFT JOIN User ON User.id=Hand.user_id ". "WHERE Hand.game_id='".$gameid."' ". @@ -623,11 +651,20 @@ else if(myisset("me")) { $name = $r[0]; $pos = $r[1]; - - echo " $name\n"; + $user = $r[2]; + + $offset = DB_get_user_timezone($user); + $zone = return_timezone($offset); + date_default_timezone_set($zone); + + echo " \n"; + echo " $name
\n"; + echo " local time: ".date("Y-m-d H:i:s")."\n"; + echo "
\n"; + } echo "
\n"; - + /* get everything relevant to display the tricks */ $result = mysql_query("SELECT Hand_Card.card_id as card,". " Hand.position as position,". @@ -651,7 +688,7 @@ else if(myisset("me")) $firstcard = ""; /* first card in a trick */ echo "\n