BUGFIX: typo in javascript
[e-DoKo.git] / include / game.php
index 6d5b169119b0539828bb9cb8d1214ef329e27fbf..cef2c6537c2a11141a38ac387f546943f8624b1b 100644 (file)
@@ -183,12 +183,12 @@ if(myisset('call')  && $_REQUEST['call']  == '0' && can_call(0,$me))
 if( $gamestatus != 'gameover'  && isset($_SESSION['id']) )
   {
     /* game isn't over, only valid user can get here, so show menu */
-    display_user_menu($myid);
+    display_user_menu($myid, $me);
   }
 else if( $mystatus == 'gameover' && isset($_SESSION['id']) )
   {
     /* user is looking at someone else's game, show the menu for the correct user */
-    display_user_menu($_SESSION['id']);
+    display_user_menu($_SESSION['id'],$me);
   }
 else
   {
@@ -343,24 +343,9 @@ switch($mystatus)
   case 'check':
     /* 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 onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n".
-      "    <div class=\"trick\" id=\"trick0\">\n";
+    echo "  <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n";
 
-    for($pos=1;$pos<5;$pos++)
-      {
-       $usersick   = DB_get_sickness_by_pos_and_gameid($pos,$gameid);
-       $userid     = DB_get_userid('gameid-position',$gameid,$pos);
-       $userstatus = DB_get_hand_status_by_userid_and_gameid($userid,$gameid);
-
-       if($userstatus=='start' || $userstatus=='init')
-         echo " <div class=\"vorbehalt".($pos-1)."\"> still needs <br />to decide </div>\n"; /* show this to everyone */
-       else
-         if($usersick!=NULL) /* in the init-phase we only showed players with $pos<$mypos, now we can show all */
-           echo " <div class=\"vorbehalt".($pos-1)."\"> sick </div>\n";
-         else
-           echo " <div class=\"vorbehalt".($pos-1)."\"> healthy </div>\n";
-      }
-    echo "    </div>\n  </li>\n</ul>\n";  /* end div trick, end li trick , end tricks*/
+    echo "    </li>\n</ul>\n";  /* end div trick, end li trick , end tricks*/
     /* end displaying sickness */
     break;
   case 'poverty':
@@ -372,13 +357,8 @@ switch($mystatus)
 
        $mygametype =  DB_get_gametype_by_gameid($gameid);
 
-       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();
-
-       echo "    </div>\n  </li>\n</ul>\n\n";  /* end div trick, end li trick , end ul tricks */
+       echo "  <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n";
+       echo "  </li>\n</ul>\n\n";  /* end div trick, end li trick , end ul tricks */
       }
     /* end output pre-game trick */
     break;
@@ -405,6 +385,7 @@ switch($mystatus)
     /* output tricks */
     while($r = DB_fetch_array($result))
       {
+       $trick=$r[0];
        if($trick!=$lasttrick)
          echo "  <li onclick=\"hl('$trickNR');\" class=\"old\"><a href=\"#\">"._('Trick')." $trickNR</a></li>\n";
        else if($trick==$lasttrick)
@@ -437,6 +418,67 @@ echo "<form action=\"index.php?action=game&amp;me=$me\" method=\"post\">\n";
 /* display the table and the names */
 display_table_begin();
 
+
+/******************************
+ * Output pre-trick if needed *
+ ******************************/
+
+switch($mystatus)
+  {
+  case 'start':
+    break;
+  case 'init':
+  case 'check':
+    /* output sickness of other playes, in case they already selected and are sitting in front of the current player */
+    echo "\n<div class=\"tricks\">\n";
+    echo "    <div class=\"trick\" id=\"trick0\">\n";
+
+    for($pos=1;$pos<5;$pos++)
+      {
+       $usersick   = DB_get_sickness_by_pos_and_gameid($pos,$gameid);
+       $userid     = DB_get_userid('gameid-position',$gameid,$pos);
+       $userstatus = DB_get_hand_status_by_userid_and_gameid($userid,$gameid);
+
+       if($userstatus=='start' || $userstatus=='init')
+         echo " <div class=\"vorbehalt".($pos-1)."\"> still needs <br />to decide </div>\n"; /* show this to everyone */
+       else
+         if($usersick!=NULL) /* in the init-phase we only showed players with $pos<$mypos, now we can show all */
+           echo " <div class=\"vorbehalt".($pos-1)."\"> sick </div>\n";
+         else
+           echo " <div class=\"vorbehalt".($pos-1)."\"> healthy </div>\n";
+      }
+    echo "    </div>\n  </div>\n";  /* end div trick, end li trick , end tricks*/
+    /* end displaying sickness */
+    break;
+  case 'poverty':
+    /* output pre-game trick in case user reloads,
+     * only needs to be done when a team has been formed */
+    if($myparty=='re' || $myparty=='contra')
+      {
+       echo "\n<ul class=\"tricks\">\n";
+
+       $mygametype =  DB_get_gametype_by_gameid($gameid);
+
+       echo "    <div class=\"trick\" id=\"trick0\">\n";
+
+       /* get information so show the cards that have been handed over in a poverty game */
+       output_exchanged_cards();
+
+       echo "    </div>\n  </div>\n\n";  /* end div trick, end li trick , end ul tricks */
+      }
+    /* end output pre-game trick */
+    break;
+  case 'play':
+  case 'gameover':
+
+    /* taken care further down */
+    break;
+  default:
+  }
+
+
+
+
 /* mystatus gets the player through the different stages of a game.
  * start:    does the player want to play?
  * init:     check for sickness