CLEANUP: fixed a typo, changed copyright, added Jeff for database scheme
[e-DoKo.git] / include / output.php
index e57ed04cad615c53a182cab0170086ffad5578ff..48f31e4ac73ff3b5b80f74d7f12ea36c1c16d81b 100644 (file)
@@ -28,6 +28,10 @@ function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
 
 function output_form_for_new_game($names)
 {
+  $copy_names = $names; /* local copy, so that we can delete names from it
+                        * after we selected them to make sure that each name
+                        * only shows up once
+                        */
 ?>
   <form action="index.php?action=new" method="post">
     <h2> Select players (Remember: you need to be one of the players) </h2>
@@ -35,13 +39,30 @@ function output_form_for_new_game($names)
    <div class="table">
      <img class="table" src="pics/table.png" alt="table" />
 <?php
-    /* ask for player names */
-    $i=0;
+
+  /* ask player for names */
+
+  $i=0;
+
+  /* delete players name, since he will be on position D anyway */
+  unset($copy_names[array_search($_SESSION["name"],$copy_names)]);
+
+  srand((float) microtime() * 10000000);
   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
     {
-      srand((float) microtime() * 10000000);
-      $randkey = array_rand($names);
-      $rand = $names[$randkey];
+      /* pick 3 names at random and put the players name on position D*/
+      if($i<3)
+       {
+         $randkey = array_rand($copy_names);
+         $rand = $copy_names[$randkey];
+         /* delete this name from the list of possible names */
+         unset($copy_names[$randkey]);
+       }
+      else
+       {
+         $rand = $_SESSION["name"];
+       }
+
       echo  "     <div class=\"table".$i."\">\n";
       $i++;
       echo "       <select name=\"$player\" size=\"1\">  \n";
@@ -75,8 +96,8 @@ function output_form_for_new_game($names)
         </li>
         <li> <input type="radio" name="schweinchen" value="second" />
              first one normal, second one becomes highest (call during the game) </li>
-        <li> <input type="radio" name="schweinchen" value="secondaftercall"  disabled="disabled" />
-             second one become highest only in case re/contra was announced (not working yet)
+        <li> <input type="radio" name="schweinchen" value="secondaftercall" />
+             second one become highest only in case re/contra was announced
         </li>
       </ul>
       <p> Call Re/Contra, etc.: </p>
@@ -143,7 +164,7 @@ function display_card($card,$dir="english")
   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
    * convert even cards to the matching odd value */
 
-  if( $card/2 - (int)($card/2) == 0.5)
+  if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
     echo "<img src=\"cards/".$dir."/".$card.".png\"  alt=\"".DB_get_card_name($card)."\" />\n";
   else
     echo "<img src=\"cards/".$dir."/".($card-1).".png\"  alt=\"".DB_get_card_name($card-1)."\" />\n";
@@ -221,11 +242,18 @@ function output_check_for_sickness($me,$mycards)
   return;
 }
 
-function output_form_calls($me)
+function output_form_calls($me,$myparty)
 {
   if( can_call(120,$me) )
-    echo " re/contra (120):".
-      " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
+    {
+    if($myparty=='re')
+      echo "re (120):";
+    else if ($myparty=='contra')
+      echo "contra (120):";
+    else
+      echo " re/contra (120):";
+    echo " <input type=\"radio\" name=\"call\" value=\"120\" /> <br />";
+    }
   if( can_call(90,$me) )
     echo " 90:".
       " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
@@ -270,48 +298,12 @@ function output_header()
      <title>e-Doko</title>
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
      <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
-     <link rel="stylesheet" type="text/css" href="css/standard008.css" />
-     <script type="text/javascript">
-       var current=0;
-       function hl(num) {
-         if(document.getElementById){
-          var i;
-          for(i=1;i<14;i++){
-            if(document.getElementById("trick"+i))
-              document.getElementById("trick"+i).style.display = 'none';
-          }
-          document.getElementById("trick"+num).style.display = 'block';
-          current=num;
-        }
-       }
-       function high_last(){
-        if(document.getElementById){
-          var i;
-          for(i=13;i>=0;i--) {
-            if(document.getElementById("trick"+i))
-              {
-                hl(i);
-                current=i;
-                break;
-              }
-          }
-        }
-       }
-       function hl_next()
-        {
-          if(document.getElementById("trick"+(current+1)))
-            hl(current+1);
-        }
-       function hl_prev()
-        {
-          if(document.getElementById("trick"+(current-1)))
-            hl(current-1);
-        }
-     </script>
+     <link rel="stylesheet" type="text/css" href="css/standard017.css" />
+     <script type="text/javascript" src="include/game.js"> </script>
   </head>
 <body onload="high_last();">
 <div class="header">
-<h1> Welcome to E-Doko <sup style="color:#888;">(beta)</sup> </h1>
+<h1> Welcome to E-Doko </h1>
 </div>
 <?php
 
@@ -325,11 +317,11 @@ function output_footer()
 
   echo "</div>\n\n";
   echo "<div class=\"footer\">\n";
-  echo "  <p class=\"left\"> copyright 2006-2008 Arun Persaud, Lance Thornton <br />\n".
+  echo "  <p class=\"left\"> copyright 2006-2009 Arun Persaud, Lance Thornton(graphics), Jeff Zerger(database support) <br />\n".
     "  Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
     "  - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
     "  a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
- echo "  <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
+ echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
     "  via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
     "  <a href=\"http://www.dreamhost.com/green.cgi\">\n".
     "  <img  border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
@@ -371,8 +363,14 @@ function output_status()
        $unixtime = strtotime($time);
        date_default_timezone_set($zone);
 
-       echo "<div class=\"lastlogin\">last login: ".date("r",$unixtime)."</div>\n";
-     };
+       echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n";
+     }
+   else
+     {
+       echo "\n<div class=\"status\">\n";
+       echo "<a href=\"".$INDEX."\">login</a>\n";
+       echo "</div>\n";
+     }
   return;
 }
 
@@ -428,4 +426,18 @@ function output_password_recovery($email,$password)
 
 <?php
 }
+
+function output_user_notes($userid,$gameid,$userstatus)
+{
+  echo "<div class=\"notes\"> Personal notes: <br />\n";
+  $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
+  foreach($notes as $note)
+    echo "$note <hr />\n";
+  if($userstatus!='gameover')
+    echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
+  echo "</div> \n";
+
+  return;
+}
+
 ?>
\ No newline at end of file