X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=3bbfccd6d7096e5e2829859f65b019e362110ce3;hp=b41ca26382b2b45283622106b7b2f6a019cbc6c8;hb=1132ca2ccda76df5ed2b1bea6b64015d4dc86880;hpb=f922adf616e3a3effca51f85edfdbc11eef91799 diff --git a/include/game.php b/include/game.php index b41ca26..3bbfccd 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"]); @@ -63,9 +65,23 @@ if($gametype=="solo") * save information in $GAME */ $ok=0; -if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' ) - if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) ) - $ok=1; +if( $gamestatus == 'pre' ) + { + /* 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) { @@ -80,13 +96,14 @@ if($ok) $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 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"; @@ -125,7 +142,11 @@ display_table(); switch($mystatus) { case 'start': - if( !myisset("in") ) + /* don't ask if user has autosetup set to yest */ + $skip = 0; + if($PREF['autosetup']=='yes') $skip = 1; + + if( !myisset("in") && !$skip) { /* asks the player, if he wants to join the game */ output_check_want_to_play($me); @@ -134,7 +155,7 @@ switch($mystatus) else { /* check the result, if player wants to join, got next stage, else cancel game */ - if($_REQUEST["in"] == "no") + if($_REQUEST["in"] == "no" && !$skip) { /* cancel the game */ $message = "Hello, \n\n". @@ -172,6 +193,7 @@ switch($mystatus) /* whos turn is it? */ DB_set_player_by_gameid($gameid,$user); $ok = 0; + break; } }; if($ok) @@ -202,7 +224,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\n"; /* end ul tricks*/ echo "
Personal notes:
\n"; $notes = DB_get_notes_by_userid_and_gameid($myid,$gameid); @@ -1713,7 +1761,10 @@ switch($mystatus) foreach($mycards as $card) { - if($followsuit && !same_type($card,$firstcard)) + if( ($followsuit && !same_type($card,$firstcard)) || + ( (int)($card)==19 && ($RULES['schweinchen']=='second'||$RULES['schweinchen']=='secondaftercall') + && $GAME['schweinchen-who']==$me && !$GAME['schweinchen-first'] ) + ) display_card($card,$PREF["cardset"]); else display_link_card($card,$PREF["cardset"]);