NEW FEATURE: use gravatars as icons for players
[e-DoKo.git] / include / game.php
index 5c367e954891bdcc3b583ee0926e854477e37233..30abe7d53687d8600f0c0ef51a6cc57c988e5f66 100644 (file)
@@ -67,7 +67,7 @@ if( $gamestatus == 'pre' )
 else
   {
     /* in a game Schweinchen is not valid in all types of games */
-    if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' || $gametype=='wedding')
+    if( in_array($gametype,array('normal','wedding','trump','silent') ))
       if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) )
        $ok=1;
   }
@@ -210,16 +210,19 @@ if($session)
     echo "  </div>\n  </div>\n";
 
     /* show score */
+
+    echo "  <div class=\"sessionscore\">";
+
     $score   = generate_score_table($session);
+
+    /* get the last entry to show on the main page */
     $tmpscore= $score;
     $finalscore = array_pop($tmpscore);
     $finalscore = $finalscore['players'];
 
-    echo "  <div class=\"sessionscore\">";
     if($finalscore)
       {
        echo "Score: \n";
-       /* output the final score on the front page */
        foreach($finalscore as $user=>$value)
          {
            $name = DB_get_name('userid',$user);
@@ -232,10 +235,13 @@ if($session)
        echo "&nbsp;";
       }
 
+    /* output all games for the score table */
     echo format_score_table_html($score,$myid);
     echo "  </div>\n";
 
-    /* figure out which game in a session we are in and link to the previous and next game if possible */
+    /* figure out which game in a session we are in and link to the
+     * previous and next game if possible
+     */
     $hashes = DB_get_hashes_by_session($session,$myid);
     $next     = NULL;
     $i = 1;
@@ -589,8 +595,8 @@ switch($mystatus)
        else if($nines)
          {
            /* cancel game */
-           $message = "the game has been canceled because ".DB_get_name('userid',$nines).
-             "has five or more nines and nobody is playing solo.\n\n".
+           $message = "The game has been canceled because ".DB_get_name('userid',$nines).
+             " has five or more nines and nobody is playing solo.\n\n".
              "To redeal either start a new game or, in case the game was part of a tournament,\n".
              "go to the last game and use the link at the bottom of the page to redeal.\n\n";
 
@@ -604,9 +610,10 @@ switch($mystatus)
            /* update game status */
            cancel_game('nines',$gameid);
 
-           echo "The game has been canceled because ".DB_get_name('userid',$nines).
-             " has five or more nines and nobody is playing solo.\n";
-           return;
+           echo "<p>The game has been canceled because ".DB_get_name('userid',$nines).
+             " has five or more nines and nobody is playing solo.</p>\n";
+           echo "</div>\n";
+           break;
          }
        else if($poverty==1) /* one person has poverty */
          {
@@ -951,8 +958,8 @@ switch($mystatus)
                /* update game status */
                cancel_game('trump',$gameid);
 
-               echo "<p style=\"background-color:red\";>Game ".DB_format_gameid($gameid)." has been canceled.<br /><br /></p>";
-               return;
+               echo "<p class=\"message\";>Game ".DB_format_gameid($gameid)." has been canceled.<br /><br /></p>";
+               break;
              }
            else
              {
@@ -1909,11 +1916,17 @@ switch($mystatus)
             * 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 && !$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  )
+               ( (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 &&
+                 in_array($gametype,array('normal','wedding','trump','silent'))
+                 )
                )
              display_card($card,$PREF['cardset']);
            else