X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=4dbf68f0a6e291dd194c485d8844a4c8aa49bc2b;hp=5f2c0029f85ccab90300e06e39a3898925a283b9;hb=c956a58882bbfef255af6817d8f21432968ac785;hpb=5973166a4b936e2f8e2d923bc6dcb8bc3db89d85 diff --git a/include/game.php b/include/game.php index 5f2c002..4dbf68f 100644 --- a/include/game.php +++ b/include/game.php @@ -26,6 +26,8 @@ if(!$myid) exit(); } +global $GAME,$RULES,$CARDS; + /* user might get here by clicking on the link in an email, so session might not be set */ if(isset($_SESSION["name"])) output_status($_SESSION["name"]); @@ -57,18 +59,50 @@ if($gametype=="solo") $GT = $gametype." ".$GT; } -/* does anyone have both foxes */ -$GAME["schweinchen"]=0; -for($i=1;$i<5;$i++) +/* do we need to worry about Schweinchen? + * check gametype and rules + * if yes, figure out if someone actually has Schweinchen + * save information in $GAME + */ +$ok=0; +if( $gamestatus == 'pre' ) { - $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; - } - }; + /* always need to use Schweinchen to figure out for example who has poverty */ + $ok=1; + } +else + { + /* in a game Schweinchen is not valid in all types of games */ + if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' ) + if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) ) + $ok=1; + } + +/* these are the defaults */ +$GAME['schweinchen-who'] = NULL; +$GAME['schweinchen-first'] = NULL; +$GAME['schweinchen-second'] = NULL; + +if($ok) +{ + /* need to check for Schweinchen */ + 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-who']=$hash; + }; + $GAME['schweinchen-first'] = 0; /* to keep track if they have been played already */ + $GAME['schweinchen-second'] = 0; +} +/* end check for Schweinchen */ + +/* set the $CARDS variable, needed for sorting the cards + * we set it to normal so that the pre-game phase is handled ok + * and later set it to the correct game type that is played + */ +set_gametype('normal'); /* put everyting in a form */ echo "
\n"; @@ -155,6 +189,7 @@ switch($mystatus) /* whos turn is it? */ DB_set_player_by_gameid($gameid,$user); $ok = 0; + break; } }; if($ok) @@ -185,7 +220,7 @@ switch($mystatus) case 'init': /* here we ask the player if he is sick */ $mycards = DB_get_hand($me); - sort($mycards); + $mycards = mysort($mycards,$gametype); /* output sickness of other playes, in case the already selected and are sitting in front of the current player */ echo "\n