highlight the call if this is the last round where you can make this call
authorArun Persaud <arun@nubati.net>
Wed, 3 Feb 2010 04:19:43 +0000 (20:19 -0800)
committerArun Persaud <arun@nubati.net>
Wed, 3 Feb 2010 04:19:43 +0000 (20:19 -0800)
also added some more comments

css/standard023.css [moved from css/standard022.css with 99% similarity]
include/functions.php
include/game.php
include/output.php
index.php

similarity index 99%
rename from css/standard022.css
rename to css/standard023.css
index 79dfeea8515367bc3ad6423b9ec6d543309f31bb..7c8450791f73c6af11b3f7556758683e15e4ecb6 100644 (file)
@@ -649,4 +649,8 @@ div.table div img.gravatar, img.gravatar  {
     width:  4em;
     height: 4em;
     border: 3px solid #aaa;
-}
\ No newline at end of file
+}
+
+.highcall {
+    background-color: #fc3;
+}
index 63216eb3d44bbcf91374961ef7da24d337c01a0c..eca0155f3e2de43cc22cdb11b91c9d8e4907dd02 100644 (file)
@@ -708,19 +708,36 @@ function sort_comp_low_high($a,$b)
 
 function can_call($what,$hash)
 {
+  /* figure out if a person can make a call:
+   $what in 0,30,60,90,120 = points of the call
+   $hash                   = the hash of the person who wants to make the call
+
+   return values:
+   0   can't make that call
+   1   can make the call
+   2   can make the call, but this is the last chance to do so...
+   */
+
   global $RULES;
 
+  /* get some information
+   */
   $gameid   = DB_get_gameid_by_hash($hash);
   $gametype = DB_get_gametype_by_gameid($gameid);
-  $oldcall  = DB_get_call_by_hash($hash);
-  $pcall    = DB_get_partner_call_by_hash($hash);
+  $oldcall  = DB_get_call_by_hash($hash); /* did the person already made a call? */
+  $pcall    = DB_get_partner_call_by_hash($hash); /* did the partner already made a call */
+
 
-  if( ($pcall!=NULL && $what >= $pcall) ||
-      ($oldcall!=NULL && $what >=$oldcall) )
+  /* you're call must be better than the one you or your partner already made
+   */
+  if( ($pcall!=NULL && ($what >= $pcall))
+      || ($oldcall!=NULL && ($what >=$oldcall)) )
     {
       return 0;
     }
 
+  /* for some rules we need to know how many cards people have
+   */
   $NRcards  = count(DB_get_hand($hash));
 
   $NRallcards = 0;
@@ -730,7 +747,8 @@ function can_call($what,$hash)
       $NRallcards  += count(DB_get_hand($user));
     };
 
-  /* in case of a wedding, everything will be delayed by an offset */
+  /* in case of a wedding, everything will be delayed by an offset
+   */
   $offset = 0;
   if($gametype=="wedding")
     {
@@ -739,18 +757,34 @@ function can_call($what,$hash)
        return 0;
     };
 
+  /* now check if the call is allowed depending on the rule set
+   */
   switch ($RULES["call"])
     {
     case "1st-own-card":
-      if( 4-($what/30) >= 12 - ($NRcards + $offset))
+      /* calls can be made before/while you play your card...
+       * first card = 120, second card = 90, etc.
+       */
+      if( 4-($what/30) == 12 - ($NRcards + $offset))
+       return 2;
+      if( 4-($what/30) > 12 - ($NRcards + $offset))
        return 1;
       break;
     case "5th-card":
-      if( 27+4*($what/30) <= $NRallcards + $offset*4)
+      /* you can make the first call anytime during the first trick
+       */
+      if( 27+4*($what/30) == $NRallcards + $offset*4)
+       return 2;
+      if( 27+4*($what/30) < $NRallcards + $offset*4)
        return 1;
       break;
     case "9-cards":
+      /* you can call 120 with 12 cards, 90 with 9 or more cards, 60 with 6 or more, etc.
+       * you can't skip a call though
+       */
 
+      /* figure out last call
+       */
       if($oldcall!=NULL && $pcall!=NULL)
        $mincall = ($oldcall>$pcall) ? $pcall : $oldcall;
       else if($oldcall!=NULL)
@@ -760,26 +794,51 @@ function can_call($what,$hash)
       else
        $mincall = -1;
 
-      if( 12 <= ($NRcards + $offset))
+
+      if( 12 == ($NRcards + $offset))
+       {
+         return 2;
+       }
+      else if( 12 < ($NRcards + $offset))
        {
          return 1;
        }
-      else if ( 9 <= ($NRcards + $offset))
+      else if ( 9 == ($NRcards + $offset))
+       {
+         if( ($mincall>=0 && $mincall==120) )
+           return 2;
+       }
+      else if ( 9 < ($NRcards + $offset))
        {
          if( ($mincall>=0 && $mincall==120) )
            return 1;
        }
-      else if ( 6 <= ($NRcards + $offset))
+      else if ( 6 == ($NRcards + $offset))
+       {
+         if( ($mincall>=0 && $mincall<=90 && $what<=60 ) )
+           return 2;
+       }
+      else if ( 6 < ($NRcards + $offset))
        {
          if( ($mincall>=0 && $mincall<=90 && $what<=60 ) )
            return 1;
        }
-      else if ( 3 <= ($NRcards + $offset))
+      else if ( 3 == ($NRcards + $offset))
+       {
+         if( ($mincall>=0 && $mincall<=60 && $what<=30 ) )
+           return 2;
+       }
+      else if ( 3 < ($NRcards + $offset))
        {
          if( ($mincall>=0 && $mincall<=60 && $what<=30 ) )
            return 1;
        }
-      else if ( 0 <= ($NRcards + $offset))
+      else if ( 0 == ($NRcards + $offset))
+       {
+         if( ($mincall>=0 && $mincall<=30 && $what==0 ) )
+           return 2;
+       }
+      else if ( 0 < ($NRcards + $offset))
        {
          if( ($mincall>=0 && $mincall<=30 && $what==0 ) )
            return 1;
@@ -822,7 +881,7 @@ function display_table ()
       $call      = $r[5];
       $hash      = $r[7];
       $timezone  = $r[8];
-      $email     = $r[9];      
+      $email     = $r[9];
       $wins      = DB_get_number_of_tricks($gameid,$pos);
       date_default_timezone_set($defaulttimezone);
       $lastlogin = strtotime($r[6]);
index 30abe7d53687d8600f0c0ef51a6cc57c988e5f66..de19cabb8b0c20b7a36bb4b3bedc5abdc9d20d3f 100644 (file)
@@ -1420,7 +1420,10 @@ switch($mystatus)
                $play   = DB_get_cards_by_trick($trickid);
                $winner = get_winner($play,$gametype); /* returns the position */
 
-               /* check if someone caught a fox */
+               /*
+                * check if someone caught a fox
+                *******************************/
+
                /* first check if we should account for solos at all,
                 * since it doesn't make sense in some games
                 */
@@ -1453,7 +1456,10 @@ switch($mystatus)
                          }
                    }
 
-               /* check for karlchen (jack of clubs in the last trick)*/
+               /*
+                * check for karlchen (jack of clubs in the last trick)
+                ******************************************************/
+
                /* 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 */
@@ -1478,7 +1484,10 @@ switch($mystatus)
                          DB_query("INSERT INTO Score".
                                   " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
                        }
-               /* check for doppelopf (>40 points)*/
+               /*
+                * check for doppelopf (>40 points)
+                ***********************************/
+
                $points = 0;
                foreach($play as $played)
                  {
@@ -1493,6 +1502,10 @@ switch($mystatus)
                             " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'doko')");
                  }
 
+               /*
+                * set winner (for this trick)
+                */
+
                if($winner>0)
                  DB_query("UPDATE Trick SET winner='$winner' WHERE id='$trickid'");
                else
index 9e87de34658ec5a7fea1012a7c8086c41eda9703..57b3152c035ea29efc511af39670308606951e23 100644 (file)
@@ -247,30 +247,61 @@ function output_check_for_sickness($me,$mycards)
 
 function output_form_calls($me,$myparty)
 {
-  if( can_call(120,$me) )
+  $highstart = "<span class=\"highcall\">";
+  $highend   = "</span>";
+
+  $tmp = can_call(120,$me);
+  if( $tmp )
+    {
+      if($tmp==2) echo $highstart;
+      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\" />";
+      if($tmp==2) echo $highend;
+      echo "<br />\n";
+    }
+  $tmp =  can_call(90,$me);
+  if( $tmp )
+    {
+      if($tmp==2) echo $highstart;
+      echo " 90:".
+       " <input type=\"radio\" name=\"call\" value=\"90\" />";
+      if($tmp==2) echo $highend;
+      echo "<br />\n";
+    }
+  $tmp = can_call(60,$me);
+  if( $tmp )
+    {
+      if($tmp==2) echo $highstart;
+      echo " 60:".
+       " <input type=\"radio\" name=\"call\" value=\"60\" />";
+      if($tmp==2) echo $highend;
+      echo "<br />\n";
+    }
+  $tmp = can_call(30,$me);
+  if( $tmp )
+    {
+      if($tmp==2) echo $highstart;
+      echo " 30:".
+       " <input type=\"radio\" name=\"call\" value=\"30\" />";
+      if($tmp==2) echo $highend;
+      echo "<br />\n";
+    }
+  $tmp = can_call(0,$me);
+  if( $tmp )
     {
-    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($tmp==2) echo $highstart;
+      echo " 0:".
+       " <input type=\"radio\" name=\"call\" value=\"0\" />";
+      if($tmp==2) echo $highend;
+      echo "<br />\n".
+       " no call:".
+       " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
     }
-  if( can_call(90,$me) )
-    echo " 90:".
-      " <input type=\"radio\" name=\"call\" value=\"90\" /> <br />";
-  if( can_call(60,$me) )
-    echo " 60:".
-      " <input type=\"radio\" name=\"call\" value=\"60\" /> <br />";
-  if( can_call(30,$me) )
-    echo " 30:".
-      " <input type=\"radio\" name=\"call\" value=\"30\" /> <br />";
-  if( can_call(0,$me) )
-    echo " 0:".
-      " <input type=\"radio\" name=\"call\" value=\"0\" /> <br />".
-      " no call:".
-      " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
 }
 
 function output_check_want_to_play($me)
@@ -301,7 +332,7 @@ 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/standard022.css" />
+     <link rel="stylesheet" type="text/css" href="css/standard023.css" />
      <script type="text/javascript" src="include/game.js"> </script>
      <script type="text/javascript" src="include/jquery.js"> </script>
      <script type="text/javascript" src="include/jquery.tablesorter.js"></script>
index 97028006cca1882ba7769b82d2ba8b6f4c70909d..d92f4787d9755b5c266faa276f88f8eddd2861b5 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2,7 +2,7 @@
 error_reporting(E_ALL);
 
 /* start a session, if it is not already running.
- * This way people don't have to log in all the times. 
+ * This way people don't have to log in all the times.
  * The session variables can also be read out from different
  * php scripts, so that the code can be easily split up across several files
  */
@@ -50,11 +50,11 @@ switch($action)
     require './include/reminder.php';
     break;
   case 'logout':
-    require './include/logout.php'; 
+    require './include/logout.php';
     require './include/welcome.php';
     break;
   case 'login':
-    require './include/login.php'; 
+    require './include/login.php';
     require './include/user.php';
     break;
   case 'register':