X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=302ec69054b52d748b5eea1eb6cc665929ea86df;hp=eded836ac1c86f532853864c5cecc121c2269720;hb=618acae3ad3b85d79d68124e7793aa858daed7c3;hpb=0dd96314cb0fc3d40502d87f354c6fd61f35a3cd diff --git a/index.php b/index.php index eded836..302ec69 100644 --- a/index.php +++ b/index.php @@ -229,6 +229,19 @@ else if(myisset("me")) echo "schweinchen: ".$r[3]."
"; 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 @@ -486,17 +499,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 +521,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": @@ -567,7 +580,7 @@ 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); @@ -660,6 +673,10 @@ else if(myisset("me")) $trick = $r[3]; $comment = $r[4]; + /* check if first schweinchen has been played */ + if($r[0] == 19 || $r[0] == 20 ) + $GAME["schweinchen"]++; + /* save card to be able to find the winner of the trick later */ $play[$seq] = array("card"=>$r[0],"pos"=>$pos); @@ -744,10 +761,24 @@ else if(myisset("me")) if($handcardid) { + $comment = ""; + /* mark card as played */ mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=". DB_quote_smart($card)); + /* check for schweinchen */ + echo "schweinchen = ".$GAME["schweinchen"]." --$card-
"; + if($card == 19 || $card == 20 ) + { + $GAME["schweinchen"]++; + if($GAME["schweinchen"]==3 && $RULES["schweinchen"]=="second" ) + $comment="Schweinchen! "; + if($RULES["schweinchen"]=="both" ) + $comment="Schweinchen! "; + echo "schweinchen = ".$GAME["schweinchen"]." ---
"; + } + /* get trick id or start new trick */ $a = DB_get_current_trickid($gameid); $trickid = $a[0]; @@ -758,9 +789,11 @@ else if(myisset("me")) /* check for coment */ if(myisset("comment")) { - DB_insert_comment($_REQUEST["comment"],$playid,$myid); + $comment.=$_REQUEST["comment"]; }; - + if($comment != "") + DB_insert_comment($comment,$playid,$myid); + /* display played card */ echo "
"; echo " you played
";