BUGFIX: show schweinchen has highest trump in your hand
[e-DoKo.git] / include / game.php
index b41ca26382b2b45283622106b7b2f6a019cbc6c8..0ec52e2da554c5a13f387dc557b2d7380647243d 100644 (file)
@@ -63,9 +63,18 @@ if($gametype=="solo")
  * save information in $GAME
  */
 $ok=0;
-if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' )
-  if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) )
-     $ok=1;
+if( $gamestatus == 'pre' )
+  {
+    /* always need to use Schweinchen to figure out for example who has poverty */
+    $ok=1;
+  }
+else
+  {
+    /* in a game Schweinchen is not valid in all types of games */
+    if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' )
+      if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) )
+       $ok=1;
+  }
 
 if($ok)
 {
@@ -87,6 +96,8 @@ else
 }
 /* end check for Schweinchen */
 
+set_gametype($gametype); /* this sets the $CARDS variable */
+
 /* put everyting in a form */
 echo "<form action=\"index.php?action=game&me=$me\" method=\"post\">\n";
 
@@ -202,7 +213,7 @@ switch($mystatus)
   case 'init':
     /* here we ask the player if he is sick */
     $mycards = DB_get_hand($me);
-    sort($mycards);
+    $mycards = mysort($mycards,$gametype);
 
     /* output sickness of other playes, in case the already selected and are sitting in front of the current player */
     echo "\n<ul class=\"tricks\">\n";
@@ -324,7 +335,7 @@ switch($mystatus)
     if($mystatus=='check')
       {
        $mycards = DB_get_hand($me);
-       sort($mycards);
+       $mycards = mysort($mycards,$gametype);
 
        /* output sickness of other playes, in case the already selected and are sitting in front of the current player */
        echo "\n<ul class=\"tricks\">\n";
@@ -1713,7 +1724,10 @@ switch($mystatus)
 
          foreach($mycards as $card)
            {
-             if($followsuit && !same_type($card,$firstcard))
+             if( ($followsuit && !same_type($card,$firstcard)) ||
+                 ( (int)($card)==19 && ($RULES['schweinchen']=='second'||$RULES['schweinchen']=='secondaftercall')
+                   && $GAME['schweinchen-who']==$me && !$GAME['schweinchen-first'] )
+                 )
                display_card($card,$PREF["cardset"]);
              else
                display_link_card($card,$PREF["cardset"]);