X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fgame.php;h=7109c11e1ca3560aa25ee7e4db88056b0a1fb1ce;hp=4c7710d96932baeae22ac897a123e960f5ec4cc3;hb=c3b1dec40c80f8a18f0102505c9f47a2b0d1b335;hpb=c85a02555f543be61a122001bd430070dc45ba1d diff --git a/include/game.php b/include/game.php index 4c7710d..7109c11 100644 --- a/include/game.php +++ b/include/game.php @@ -25,7 +25,8 @@ if(!$myid) global $GAME,$RULES,$CARDS; /* the user has done something, update the timestamp */ -DB_update_user_timestamp($myid); +if(isset($_SESSION['id'])) + DB_update_user_timestamp($_SESSION['id']); /* get some information from the DB */ $gameid = DB_get_gameid_by_hash($me); @@ -36,7 +37,7 @@ $myhand = DB_get_handid('hash',$me); $session = DB_get_session_by_gameid($gameid); /* get prefs and save them in a variable*/ -$PREF = DB_get_PREF($myid); +$PREF = DB_get_PREF(isset($_SESSION['id'])?$_SESSION['id']:$myid); /* get rule set for this game */ $RULES = DB_get_RULES($gameid); @@ -65,7 +66,7 @@ if( $gamestatus == 'pre' ) else { /* in a game Schweinchen is not valid in all types of games */ - if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' ) + if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' || $gametype=='wedding') if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) ) $ok=1; } @@ -179,7 +180,10 @@ if($session) $lasthash=$hash; } $i--; - echo "This is game number $j of $i in session $session."; + if(isset($_SESSION['id']) && $_SESSION['id']==$myid) + echo "This is game number $j of $i in session $session."; + else + echo "This is game number $j of $i in session $session."; echo "\n"; } @@ -297,7 +301,7 @@ switch($mystatus) $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 */ + echo "
still needs
to decide
\n"; /* show this to everyone */ else if($usersick!=NULL && $pos<=$mypos ) /* only show this for people sitting before the player */ echo "
sick
\n"; @@ -414,7 +418,7 @@ switch($mystatus) $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 */ + 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"; @@ -1320,7 +1324,11 @@ switch($mystatus) else $GAME['schweinchen-second'] = 1; /* this must be the second fox */ - if( ($GAME['schweinchen-second']==1 && $RULES['schweinchen']=='second') || $RULES['schweinchen']=='both') + if( $RULES['schweinchen']=='both' || + ($RULES['schweinchen']=='second' && $GAME['schweinchen-second']==1 )|| + ($RULES['schweinchen']=='secondaftercall' && $GAME['schweinchen-second']==1 && + (DB_get_call_by_hash($GAME['schweinchen-who']) || DB_get_partner_call_by_hash($GAME['schweinchen-who']) )) + ) { DB_insert_comment('Schweinchen! ',$playid,$myid); $commentSchweinchen = 'Schweinchen! '; @@ -1751,27 +1759,26 @@ switch($mystatus) $message .= "Score Table:\n"; $message .= format_score_table_ascii($score); + $message .= "Use these links to have a look at game ".DB_format_gameid($gameid).": \n" /* send out final email */ $all = array(); - foreach($userids as $user) - $all[] = DB_get_email('userid',$user); - $To = implode(",",$all); - - $help = "\n\n (you can use reply all on this email to reach all the players.)\n"; - mymail($To,$EmailName."game over (game ".DB_format_gameid($gameid).") part 1(2)",$message.$help); - foreach($userids as $user) { - $To = DB_get_email('userid',$user); + $all[] = DB_get_email('userid',$user); + + /* add links for all players */ $hash = DB_get_hash_from_gameid_and_userid($gameid,$user); + $name = DB_get_name('userid',$user); - $link = "Use this link to have a look at game ".DB_format_gameid($gameid).": ". - $HOST.$INDEX."?action=game&me=".$hash."\n\n" ; - if( DB_get_email_pref_by_uid($user) != 'emailaddict' ) - mymail($To,$EmailName."game over (game ".DB_format_gameid($gameid).") part 2(2)",$link); + $link = "$name: ".$HOST.$INDEX."?action=game&me=".$hash."\n" ; + $message .= $link; } + $To = implode(",",$all); + + $message .= "\n\n (you can use reply all on this email to reach all the players.)\n"; + mymail($To,$EmailName."Game over (game ".DB_format_gameid($gameid).") ",$message); } } else @@ -1867,9 +1874,15 @@ switch($mystatus) foreach($mycards as $card) { + /* display only cards that the player is allowed to play as links, the rest just display normal + * also check if we have both schweinchen, in that case only display on of them as playable + */ if( ($followsuit && !same_type($card,$firstcard)) || - ( (int)($card)==19 && ($RULES['schweinchen']=='second'||$RULES['schweinchen']=='secondaftercall') - && $GAME['schweinchen-who']==$me && !$GAME['schweinchen-first'] ) + ( (int)($card)==19 && !$GAME['schweinchen-first'] && + ($RULES['schweinchen']=='second'|| + ( $RULES['schweinchen']=='secondaftercall' && + (DB_get_call_by_hash($GAME['schweinchen-who']) || DB_get_partner_call_by_hash($GAME['schweinchen-who']) ))) + && $GAME['schweinchen-who']==$me ) ) display_card($card,$PREF['cardset']); else @@ -1946,11 +1959,26 @@ if($gamestatus == 'play' || $gameend < 60*60*24*7) echo "\n"; +/* has this hand been played by others? */ +$other_game_ids = DB_played_by_others($gameid); +if(sizeof($other_game_ids)>0 && $mystatus=='gameover') + { + $mypos = DB_get_pos_by_hash($me); + echo "

See how other played the same hand:
\n"; + foreach($other_game_ids as $id) + { + $otherhash = DB_get_hash_from_game_and_pos($id,$mypos); + $othername = DB_get_name('hash',$otherhash); + echo "$othername
"; + } + echo "

\n"; + } + echo "\n"; echo "\n"; -if($mystatus=='gameover' && DB_get_game_status_by_gameid($gameid)=='gameover' ) +if($mystatus=='gameover' && DB_get_game_status_by_gameid($gameid)=='gameover' && isset($_SESSION['id']) && $_SESSION['id']==$myid) { $session = DB_get_session_by_gameid($gameid); $result = DB_query("SELECT id,create_date FROM Game".