BUGFIX: a comment for schweinchen was issued even in solo games without schweinchen
[e-DoKo.git] / index.php
index f0a434f57db42b528cfc55b5b4fb701c281571e1..0f94dcf6c6b2d2eac9f1d56d96eb49cc8cb5f505 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1381,8 +1381,12 @@ else if(myisset("me"))
 
              $playid = DB_play_card($trickid,$handcardid,$sequence);
 
-             /* check for schweinchen */
-             if($GAME["schweinchen"] && ($card == 19 || $card == 20) )
+             /* check special output for schweinchen in case: 
+              * schweinchen is in the rules, a fox has been played and the gametype is correct
+              */
+             if( $GAME["schweinchen"] && 
+                 ($card == 19 || $card == 20) && 
+                 ($gametype == "normal" || $gametype == "silent"|| $gametype=="trump"))
                {
                  $GAME["schweinchen"]++; // count how many have been played including this one
                  if($GAME["schweinchen"]==3 && $RULES["schweinchen"]=="second" )
@@ -1436,7 +1440,20 @@ else if(myisset("me"))
                  $winner = get_winner($play,$gametype); /* returns the position */
 
                  /* check if someone caught a fox */
-                 if(DB_get_gametype_by_gameid($gameid)!="solo")
+                 /* first check if we should account for solos at all, 
+                  * since it doesn't make sense in some games
+                  */
+                 $ok = 0; /* fox shouldn't be counted */
+                 if(DB_get_gametype_by_gameid($gameid)=="solo")
+                   {
+                     $solo = DB_get_solo_by_gameid($gameid);
+                     if($solo == "trump" || $solo == "silent")
+                       $ok = 1; /* for trump solos and silent solos, foxes are ok */
+                   }
+                 else
+                   $ok = 1; /* for all other games (not solos) foxes are ok too */
+                 
+                 if($ok==1)
                    foreach($play as $played)
                      {
                        if ( $played['card']==19 || $played['card']==20 )
@@ -1454,8 +1471,21 @@ else if(myisset("me"))
                                            " VALUES( NULL,NULL,$gameid,'$party1',$uid1,$uid2,'fox')");
                            }
                      }
+                 
                  /* check for karlchen (jack of clubs in the last trick)*/
-                 if(DB_get_gametype_by_gameid($gameid)!="solo" && $tricknr == 12)
+                 /* same as for foxes, karlchen doesn't always make sense
+                  * check what kind of game it is and set karlchen accordingly */
+                 $ok = 1; /* default: karlchen should be accounted for */
+                 if($tricknr != 12 )
+                   $ok = 0; /* Karlchen works only in the last trick */
+                 if($ok && DB_get_gametype_by_gameid($gameid)=="solo" )
+                   {
+                     $solo = DB_get_solo_by_gameid($gameid);
+                     if($solo == "trumpless" || $solo == "jack" || $solo == "queen" )
+                       $ok = 0; /* no Karlchen in these solos */
+                   }
+                 
+                 if($ok)
                    foreach($play as $played)
                      if ( $played['card']==11 || $played['card']==12 )
                        if ($played['pos'] == $winner )