BUGFIX: fixed some html validation errors
[e-DoKo.git] / include / game.php
index aa2561699b15a43a74ec8b26f30b69da056b43ed..cd77bf323b215fb4a19241bd2cf56568ebe14e78 100644 (file)
@@ -531,7 +531,7 @@ switch($mystatus)
     $mycards = DB_get_hand($me);
     $mycards = mysort($mycards,$gametype);
 
-    /* output sickness of other playes, in case the already selected and are sitting in front of the current player */
+    /* output sickness of other playes, in case they already selected and are sitting in front of the current player */
     echo "\n<ul class=\"tricks\">\n";
     echo "  <li class=\"nohighlight\"> Game ".DB_format_gameid($gameid).": </li>\n";
     echo "  <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n".
@@ -1291,17 +1291,19 @@ switch($mystatus)
     echo '  <li class="nohighlight"> '._('Game').' '.DB_format_gameid($gameid).": </li>\n";
 
     /* output vorbehalte */
-    $mygametype =  DB_get_gametype_by_gameid($gameid);
-    if($mygametype != 'normal' && $mygametype != 'silent') /* only show when needed */
-      {
-       echo "  <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n".
-            "    <div class=\"trick\" id=\"trick0\">\n";
+    $mygametype = DB_get_gametype_by_gameid($gameid);
+    $mygamesolo = DB_get_solo_by_gameid($gameid);
+    if($mygametype != 'normal') /* only show when needed */
+      if(!( $mygametype == 'solo' && $mygamesolo == 'silent') )
+       {
+         echo "  <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n".
+           "    <div class=\"trick\" id=\"trick0\">\n";
 
-       /* get information so show the cards that have been handed over in a poverty game */
-       output_exchanged_cards();
+         /* get information so show the cards that have been handed over in a poverty game */
+         output_exchanged_cards();
 
-       echo "    </div>\n  </li>\n";  /* end div trick, end li trick */
-      }
+         echo "    </div>\n  </li>\n";  /* end div trick, end li trick */
+       }
 
     /* output tricks */
     while($r = DB_fetch_array($result))
@@ -1988,6 +1990,39 @@ switch($mystatus)
        if(have_suit($mycards,$firstcard))
          $followsuit = 1;
 
+       /* count how many cards we can play, so that we can pre-select it if there is only one */
+       $howmanycards = 0;
+       foreach($mycards as $card)
+         {
+           if($howmanycards>1)
+             break;
+
+           /* 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 &&
+                 !$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'))
+                 )
+               )
+             continue;
+           else
+             $howmanycards++;
+         }
+
+       if($howmanycards==1)
+         $howmanycards=1;
+       else
+         $howmanycards=0;
+
        foreach($mycards as $card)
          {
            /* display only cards that the player is allowed to play as links, the rest just display normal
@@ -2008,7 +2043,7 @@ switch($mystatus)
                )
              display_card($card,$PREF['cardset']);
            else
-             display_link_card($card,$PREF['cardset']);
+             display_link_card($card,$PREF['cardset'],$type='card',$selected=$howmanycards);
          }
       }
     else if($mystatus=='play' )
@@ -2095,41 +2130,51 @@ else
     echo "</div>\n";
   }
 
-/* display rule set for this game */
+/*
+ * display gameinfo: re/contra, comment-box, play-card button, games played by others
+ */
+
 echo "<div class=\"gameinfo\">\n";
 
+/* get time from the last action of the game */
+$r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " );
+$gameend = time() - strtotime($r[0]);
+
+/* comment box */
+if($gamestatus == 'play' || $gameend < 60*60*24*7)
+  {
+    echo '  '._('A short comment').":<input name=\"comment\" type=\"text\" size=\"20\" maxlength=\"100\" />\n";
+  }
+
+/* re-contra */
 if($gamestatus == 'play' )
   {
     $myparty = DB_get_party_by_hash($me);
     output_form_calls($me,$myparty);
   }
-/* get time from the last action of the game */
-$r = DB_query_array("SELECT mod_date from Game WHERE id='$gameid' " );
-$gameend = time() - strtotime($r[0]);
 
+/* play-card button */
 if($gamestatus == 'play' || $gameend < 60*60*24*7)
   {
-    echo "<br />\n"._('A short comment').":<input name=\"comment\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
+    echo "  <input type=\"submit\" value=\""._('submit')."\" />\n";
   }
 
-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";
+    echo "  <p>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 "<a href=\"$INDEX?action=game&amp;me=$otherhash\">$othername</a><br />";
+       echo "    <a href=\"$INDEX?action=game&amp;me=$otherhash\">$othername</a> ";
       }
-    echo "</p>\n";
+    echo "  </p>\n";
   }
 
-echo "</div>\n";
+echo "</div>\n"; /* end gameinfo */
 
 echo "</form>\n";