X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=8d59103707e20d9166ef976a9a0b084fcc046f70;hp=668aa1fe06096a59d2e2512116fe0e135a74b3b0;hb=36b10f3b006cfc919fdb657e1f06f41969082f0e;hpb=2a2c6ad2b883e1f0c9a2f5bf3f742452ce7ef540 diff --git a/include/game.php b/include/game.php index 668aa1f..8d59103 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"]); @@ -76,6 +78,11 @@ else $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 */ @@ -89,33 +96,53 @@ 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"; +echo "\n"; -/* output game */ +/* handle user notes (only possible while game is running)*/ +if( $mystatus!='gameover' ) + if(myisset("note")) +{ + $note = $_REQUEST['note']; + + if($note != "") + DB_insert_note($note,$gameid,$myid); +}; +output_user_notes($myid,$gameid,$mystatus); /* output extra division in case this game is part of a session */ if($session) { - echo "
\n". - "This game is part of session $session: \n"; + echo "
\n"; + echo "
Rules (+icons fur rules) \n"; + echo "
\n"; + echo " 10ofhearts : ".$RULES["dullen"] ."
\n"; + echo " schweinchen: ".$RULES["schweinchen"] ."
\n"; + echo " call: ".$RULES["call"] ."
\n"; + echo "
\n
\n"; + echo "
Score \n"; + $score = generate_score_table($session); + echo format_score_table_html($score,$myid); + echo "
\n"; $hashes = DB_get_hashes_by_session($session,$myid); $i = 1; foreach($hashes as $hash) { - if($hash == $me) - echo "$i \n"; - else - echo "$i \n"; - $i++; + if($hash == $me) + $j=$i; + $i++; + $lasthash=$hash; } + $i--; + echo "This is game number $j of $i in session $session."; echo "
\n"; } @@ -134,7 +161,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); @@ -143,7 +174,7 @@ switch($mystatus) else { /* check the result, if player wants to join, got next stage, else cancel game */ - if($_REQUEST["in"] == "no") + if(!$skip && $_REQUEST["in"] == "no" ) { /* cancel the game */ $message = "Hello, \n\n". @@ -181,6 +212,7 @@ switch($mystatus) /* whos turn is it? */ DB_set_player_by_gameid($gameid,$user); $ok = 0; + break; } }; if($ok) @@ -211,7 +243,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 \n"; /* end div trick, end li trick */ } - + echo "
  • prev
  • \n"; + echo "
  • next
  • \n"; echo "\n"; /* end ul tricks*/ - echo "
    Personal notes:
    \n"; - $notes = DB_get_notes_by_userid_and_gameid($myid,$gameid); - foreach($notes as $note) - echo "$note
    \n"; - echo "Insert note:\n"; - echo "
    \n"; - $mycards = DB_get_hand($me); $mycards = mysort($mycards,$gametype); echo "
    \n"; @@ -1722,7 +1741,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"]); @@ -1823,15 +1845,6 @@ switch($mystatus) /* display rule set for this game */ echo "
    \n"; - if($gamestatus != 'pre') - echo " Gametype: $GT
    \n"; - - echo "Rules:
    \n"; - echo "10ofhearts : ".$RULES["dullen"] ."
    \n"; - echo "schweinchen: ".$RULES["schweinchen"] ."
    \n"; - echo "call: ".$RULES["call"] ."
    \n"; - - echo "
    \n"; if($gamestatus == 'play' ) output_form_calls($me); @@ -1842,15 +1855,9 @@ switch($mystatus) if($gamestatus == 'play' || $gameend < 60*60*24*7) { echo "
    \nA short comment:\n"; - echo "
    "; } - echo "\n
    \n"; - - $session = DB_get_session_by_gameid($gameid); - $score = generate_score_table($session); - - echo $score; + echo "\n"; echo "
    \n"; @@ -1888,7 +1895,6 @@ switch($mystatus) } } - output_footer(); DB_close(); exit();