BUGFIX: fixed selection of spade and heart solo
[e-DoKo.git] / include / game.php
index a50b247d0adc76e90fdc0b363940950f5393b2a0..86fd53ccf4c7066afc50a88bc469202e499c0a4a 100644 (file)
@@ -46,6 +46,7 @@ global $GAME,$RULES,$CARDS;
 /**************************************
  * get some information from the DB
  **************************************/
+start:
 $gameid   = DB_get_gameid_by_hash($me);
 $myname   = DB_get_name('hash',$me);
 $mystatus = DB_get_status_by_hash($me);
@@ -333,7 +334,7 @@ if($session)
     echo '    '._('Game')." $session.$j";
     if($gamestatus != 'pre')
       if($gametype_raw != 'normal') /* only show when needed */
-       if(!($gametype_raw == 'solo' && $gametyep_solo == 'silent') )
+       if(!($gametype_raw == 'solo' && $gametype_solo == 'silent') )
          echo " ($GT)";
 
     if(isset($_SESSION['id']) && $_SESSION['id']==$myid)
@@ -395,7 +396,7 @@ switch($mystatus)
 
     /* output vorbehalte */
     if($gametype_raw != 'normal') /* only show when needed */
-      if(!($gametype_raw == 'solo' && $gametyep_solo == 'silent') )
+      if(!($gametype_raw == 'solo' && $gametype_solo == 'silent') )
        echo "  <li onclick=\"hl(0);\" class=\"old\"><a href=\"#\">Pre</a></li>\n";
 
     $result = DB_query('SELECT Trick.id'.
@@ -561,9 +562,7 @@ switch($mystatus)
            break;
          }
        else
-         {
-           /* everything is ok, save what user said and proceed */
-           $messages[] = _('Processing what you selected in the last step...');
+         { /* everything is ok, save what user said and proceed */
 
            /* check if this sickness needs to be handled first */
            $startplayer = DB_get_startplayer_by_gameid($gameid); /* need this to check which solo goes first */
@@ -572,6 +571,17 @@ switch($mystatus)
              {
                /* user wants to play a solo */
 
+               /* double check input value */
+               $s = $_REQUEST['solo'];
+               $solos = array('trumpless','jack','queen','trump','club','spade','heart');
+               if (!in_array($s, $solos))
+                 {
+                   $messages[] = sprintf(_('There is a problem with the type of solo you selected (%s does not exist), please go back '.
+                                           'and answer the <a href="%s">question</a> again.'),
+                                         $s,$INDEX.'?action=game&amp;me=$me&amp;in=yes');
+                   break;
+                 }
+
                /* store the info in the user's hand info */
                DB_set_solo_by_hash($me,$_REQUEST['solo']);
                DB_set_sickness_by_hash($me,'solo');
@@ -634,13 +644,6 @@ switch($mystatus)
      * this can therefore only be handled once all players finished the last stage
      */
 
-    $messages[] = _('Checking if someone else selected solo, nines, wedding or poverty.');
-
-    /* in case the user can go do the next stage, we want to skip the break statement at the
-     * end. We keep track of these cases using this variable
-     */
-    $nobreak=0;
-
     /* check if everyone has reached this stage */
     $userids = DB_get_all_userid_by_gameid($gameid);
     $ok = 1;
@@ -668,8 +671,6 @@ switch($mystatus)
         * are playing, in case there are any solos this already
         * will have the correct information in it */
 
-       $messages[] = _('Ok, everyone is done... figuring out what kind of game we are playing.');
-
        /* gametype for displaying it (hides hidden solo)*/
        $GT          = get_display_gametype($gameid);
 
@@ -796,7 +797,6 @@ switch($mystatus)
            $gametype     = 'wedding';
          };
        /* now the gametype is set correctly in the database */
-       $messages[] = _('Got it').' :)';
 
        /* loop over all players, set re/contra if possible and start the game if possible */
        $userids = DB_get_all_userid_by_gameid($gameid);
@@ -895,9 +895,8 @@ switch($mystatus)
              }
            else
              {
-               $messages[] = sprintf(_('Please, <a href="%s">start</a> the game.'),$INDEX."?action=game&amp;me=$me").
-                 "<br />\n";
-               $nobreak=1;
+               $mystatus = 'play';
+               goto play;
              }
          }
        else
@@ -909,9 +908,8 @@ switch($mystatus)
            $whoid = DB_get_userid('gameid-position',$gameid,$who);
            if($whoid==$myid)
              {
-               $messages[] = sprintf(_('Please, <a href="%s">start</a> the game.'),$INDEX."?action=game&amp;me=$me").
-                 "<br /\n";
-               $nobreak=1;
+               $mystatus = 'poverty';
+               goto poverty;
              }
            else
              {
@@ -930,10 +928,10 @@ switch($mystatus)
              }
          }
       }
-    if(!$nobreak)
-      break;
+    break;
 
   case 'poverty':
+  poverty:
     /* user only gets here in a poverty game, several things have to be handled here:
      * A) ask, if user wants to take trump
      *      yes-> take trump,
@@ -950,11 +948,6 @@ switch($mystatus)
      * it is easier to check B) first
      */
 
-    /* in case the user can go do the next stage, we want to skip the break statement at the
-     * end. We keep track of these cases using this variable
-     */
-    $nobreak=0;
-
     set_gametype($gametype); /* this sets the $CARDS variable */
     $myparty = DB_get_party_by_hash($me);
 
@@ -1008,7 +1001,10 @@ switch($mystatus)
              }
          }
        else
-         $messages[]= sprintf(_('Please, <a href="%s">start</a> the game.'),$INDEX."?action=game&amp;me=$me");
+         {
+           $mystatus = 'play';
+           goto play;
+         }
       }
 
     /* the following is part A) of what needs to be done */
@@ -1207,14 +1203,13 @@ switch($mystatus)
                  }
              }
            $messages[] = sprintf(_('Please, <a href="%s">continue</a> here'),$INDEX."?action=game&amp;me=$me");
-           $nobreak = 1;
          }
       }
-    if(!$nobreak)
-      break;
+    break;
 
   case 'play':
   case 'gameover':
+  play:
     /* both entries here,  so that the tricks are visible for both.
      * in case of 'play' there is a break later that skips the last part
      */