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);
$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);
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;
}
$lasthash=$hash;
}
$i--;
- echo "This is game number $j of <a href=\"{$INDEX}?action=game&me=$lasthash\">$i</a> in session $session.";
+ if(isset($_SESSION['id']) && $_SESSION['id']==$myid)
+ echo "This is game number $j of <a href=\"{$INDEX}?action=game&me=$lasthash\">$i</a> in session $session.";
+ else
+ echo "This is game number $j of $i in session $session.";
echo "</div>\n";
}
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! ';
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
echo "<input type=\"submit\" value=\"submit\" />\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 "<p>See how other played the same hand: <br />\n";
+ foreach($other_game_ids as $id)
+ {
+ $otherhash = DB_get_hash_from_game_and_pos($id,$mypos);
+ $othername = DB_get_name('hash',$otherhash);
+ echo "<a href=\"$INDEX?action=game&me=$otherhash\">$othername</a><br />";
+ }
+ echo "</p>\n";
+ }
+
echo "</div>\n";
echo "</form>\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".