X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=cef2c6537c2a11141a38ac387f546943f8624b1b;hp=cafa02658c6e308bc86a60fd65564dff18078de2;hb=bb25d07c113ba90c830b3a005f0297599bfad2ed;hpb=1d7d5131dff614192a146b839e2781e8a65fdc03 diff --git a/include/game.php b/include/game.php index cafa026..cef2c65 100644 --- a/include/game.php +++ b/include/game.php @@ -43,11 +43,12 @@ if(!$myid) global $GAME,$RULES,$CARDS; -/* get some information from the DB */ +/************************************** + * get some information from the DB + **************************************/ $gameid = DB_get_gameid_by_hash($me); $myname = DB_get_name('hash',$me); $mystatus = DB_get_status_by_hash($me); -$origmystatus = DB_get_status_by_hash($me); /* to show "it's your turn" menu when game has just finished */ $mypos = DB_get_pos_by_hash($me); $myhand = DB_get_handid('hash',$me); $myparty = DB_get_party_by_hash($me); @@ -79,6 +80,9 @@ if( $gamestatus == 'pre' ) { /* always need to use Schweinchen to figure out for example who has poverty */ $ok=1; + /* unless the gametype is set and we know that we are in poverty were schweinchen is not valid */ + if( in_array( $gametype,array('poverty','dpoverty') )) + $ok=0; } else { @@ -114,11 +118,8 @@ if($ok) */ set_gametype('normal'); -/* put everyting in a form */ -echo "
\n"; - /* handle user notes (only possible while game is running)*/ -if( $mystatus!='gameover' ) +if( $mystatus!='gameover' ) if(myisset('note')) { $note = $_REQUEST['note']; @@ -127,19 +128,21 @@ if( $mystatus!='gameover' ) DB_insert_note($note,$gameid,$myid); }; -/* make sure that we don't show the notes to the wrong person - * (e.g. other people looking at an old game) - */ -if( $mystatus != 'gameover' || - ( $mystatus == 'gameover' && - isset($_SESSION['id']) && - $myid == $_SESSION['id'])) - output_user_notes($myid,$gameid,$mystatus); - /* handle calls, output a comment to show when the call was made */ /* initialize comments */ $comment = ''; +/* get information needed to submit comment */ +$playid = DB_get_current_playid($gameid); + +/* set comment */ +if($comment != '') + DB_insert_comment($comment,$playid,$myid); +/* clear up */ +unset($comment); +/* end check for calls */ + + /* check for calls, set comment */ if(myisset('call') && $_REQUEST['call'] == '120' && can_call(120,$me)) { @@ -170,61 +173,82 @@ if(myisset('call') && $_REQUEST['call'] == '0' && can_call(0,$me)) $comment .= "Zero"; } -/* get information needed to submit comment */ -$playid = DB_get_current_playid($gameid); -/* set comment */ -if($comment != '') - DB_insert_comment($comment,$playid,$myid); -/* clear up */ -unset($comment); -/* end check for calls */ +/***************************************************************** + * output other games where it is the users turn + * make sure that the people looking at old games don't see the wrong games here + *****************************************************************/ -/* output extra division in case this game is part of a session */ +if( $gamestatus != 'gameover' && isset($_SESSION['id']) ) + { + /* game isn't over, only valid user can get here, so show menu */ + display_user_menu($myid, $me); + } +else if( $mystatus == 'gameover' && isset($_SESSION['id']) ) + { + /* user is looking at someone else's game, show the menu for the correct user */ + display_user_menu($_SESSION['id'],$me); + } +else + { + echo "
\n"; + echo "It's your turn in these games: \n"; + echo "Please log in to see this information.\n"; + echo "
\n\n"; + } + +/***************************************************************** + * output extra division in case this game is part of a session + *****************************************************************/ if($session) { echo "
\n"; - echo '
'._('Rules').': '; + + /* output rule set */ + echo "
\n "._('Rules').":\n"; switch($RULES['dullen']) { case 'none': - echo " \""._('no\n"; break; + echo " \""._('no\n"; break; case 'firstwins': - echo " \""._('ten\n"; break; + echo " \""._('ten\n"; break; case 'secondwins': - echo " \""._('second\n"; break; + echo " \""._('second\n"; break; } switch($RULES['schweinchen']) { case 'none': - echo " \""._('no\n"; break; case 'both': - echo " \""._('two\n"; break; case 'second': - echo " \"".('second\n"; break; case 'secondaftercall': - echo " \""._('second\n"; break; } switch($RULES['call']) { case '1st-own-card': - echo " \""._('1st-own-card')."\"\n"; break; + echo " \""._('1st-own-card')."\"\n"; break; case '5th-card': - echo " \""._('5th-card')."\"\n"; break; + echo " \""._('5th-card')."\"\n"; break; case '9-cards': - echo " \""._('9-cards')."\"\n"; break; + echo " \""._('9-cards')."\"\n"; break; } - echo "
\n"; - echo ' '._('10ofhearts').": {$RULES['dullen']}
\n"; - echo ' '._('schweinchen').": {$RULES['schweinchen']}
\n"; - echo ' '._('call').": {$RULES['call']}
\n"; - echo ' '._('lowtrump').": {$RULES['lowtrump']}
\n"; - echo "
\n
\n"; + echo "
\n"; + echo ' '._('10ofhearts').": {$RULES['dullen']}
\n"; + echo ' '._('schweinchen').": {$RULES['schweinchen']}
\n"; + echo ' '._('call').": {$RULES['call']}
\n"; + echo ' '._('lowtrump').": {$RULES['lowtrump']}
\n"; + echo "
\n
\n"; /* show score */ @@ -239,7 +263,7 @@ if($session) if($finalscore) { - echo "Score: \n"; + echo _('Score').": \n"; foreach($finalscore as $user=>$value) { $name = DB_get_name('userid',$user); @@ -280,21 +304,180 @@ if($session) else $next = NULL; + /* check for solo, add game type to session number */ + echo " Game $session.$j"; + if($GT !='normal') + echo " ($GT)"; if(isset($_SESSION['id']) && $_SESSION['id']==$myid) { if($previous) - echo ""._('previous game')."    \n"; - echo "This is game number $j of $i in session $session.\n"; + echo "   "._('previous')." \n"; if($next) - echo "   "._('next game')." \n"; + echo "   "._('next')." \n"; } - else - echo "This is game number $j of $i in session $session."; + if($j != $i ) + echo "   last \n"; + echo "\n
\n"; } +/* the user has done something, update the timestamp. Use $myid in + * active games and check for session-id in old games (myid might be wrong in that case) + */ +if($mystatus!='gameover') + DB_update_user_timestamp($myid); + else + if(isset($_SESSION['id'])) + DB_update_user_timestamp($_SESSION['id']); + + +/****************************************************************************** + * Output menu for selecting tricks + ******************************************************************************/ + +switch($mystatus) + { + case 'start': + break; + case 'init': + case 'check': + /* output sickness of other playes, in case they already selected and are sitting in front of the current player */ + echo "\n\n"; /* end div trick, end li trick , end tricks*/ + /* end displaying sickness */ + break; + case 'poverty': + /* output pre-game trick in case user reloads, + * only needs to be done when a team has been formed */ + if($myparty=='re' || $myparty=='contra') + { + echo "\n\n\n"; /* end div trick, end li trick , end ul tricks */ + } + /* end output pre-game trick */ + break; + case 'play': + case 'gameover': + + echo "\n\n\n"; + + break; + default: + } + + +/****************************************************************************** + * Output tricks played, table, messages, and cards (depending on game status) + ******************************************************************************/ + +/* put everyting in a form */ +echo "\n"; + /* display the table and the names */ -display_table(); +display_table_begin(); + + +/****************************** + * Output pre-trick if needed * + ******************************/ + +switch($mystatus) + { + case 'start': + break; + case 'init': + case 'check': + /* output sickness of other playes, in case they already selected and are sitting in front of the current player */ + echo "\n
\n"; + echo "
\n"; + + for($pos=1;$pos<5;$pos++) + { + $usersick = DB_get_sickness_by_pos_and_gameid($pos,$gameid); + $userid = DB_get_userid('gameid-position',$gameid,$pos); + $userstatus = DB_get_hand_status_by_userid_and_gameid($userid,$gameid); + + if($userstatus=='start' || $userstatus=='init') + echo "
still needs
to decide
\n"; /* show this to everyone */ + else + if($usersick!=NULL) /* in the init-phase we only showed players with $pos<$mypos, now we can show all */ + echo "
sick
\n"; + else + echo "
healthy
\n"; + } + echo "
\n
\n"; /* end div trick, end li trick , end tricks*/ + /* end displaying sickness */ + break; + case 'poverty': + /* output pre-game trick in case user reloads, + * only needs to be done when a team has been formed */ + if($myparty=='re' || $myparty=='contra') + { + echo "\n