X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=bbaa5b3500a2e945c5d4a2b113806b0cdb4f2d40;hp=5f2c0029f85ccab90300e06e39a3898925a283b9;hb=e525ec3c4a6e6234fd63caad097845cc2935fc1b;hpb=5973166a4b936e2f8e2d923bc6dcb8bc3db89d85 diff --git a/include/game.php b/include/game.php index 5f2c002..bbaa5b3 100644 --- a/include/game.php +++ b/include/game.php @@ -57,18 +57,46 @@ 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; + } + +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; +} +else +{ + /* no need to check for Schweinchen */ + $GAME['schweinchen-who']=NULL; +} +/* end check for Schweinchen */ + +set_gametype($gametype); /* this sets the $CARDS variable */ /* put everyting in a form */ echo "
\n"; @@ -185,7 +213,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