new feature: added checks for re/contra/90 etc. ; fixed: some measages were outdated
authorarun <arun@nubati.net>
Sat, 2 Jun 2007 15:40:16 +0000 (15:40 +0000)
committerarun <arun>
Sat, 2 Jun 2007 15:40:16 +0000 (15:40 +0000)
functions.php
index.php
output.php

index f33dd1c19b128a29bc0373495c100d6c34f5c240..418591dd2d04537a3cb9582a9ee3e745f5871fa8 100644 (file)
@@ -649,7 +649,48 @@ function sort_comp($a,$b)
 
 function can_call($what,$hash)
 {
 
 function can_call($what,$hash)
 {
-  return 1;
+  global $RULES;
+
+  /*TODO: check if this already has been call by teammate */
+  
+  $gameid   = DB_get_gameid_by_hash($hash);
+  $gametype = DB_get_gametype_by_gameid($gameid);
+
+  $NRcards  = count(DB_get_hand($me));
+  
+  $NRallcards = 0;
+  for ($i=1;$i<5;$i++)
+    {
+      $user         = DB_get_hash_from_game_and_pos($gameid,$i);
+      $NRallcards  += count(DB_get_hand($user));
+    };
+  
+  /* in case of a wedding, everything will be delayed by an offset */
+  $offset = 0;
+  if($gametype=="wedding")
+    {
+      $offset = DB_get_sickness_by_gameid($gameid); 
+      if ($offset <0) /* not resolved */
+       return 0;
+    };
+
+  switch ($RULES["call"])
+    {
+    case "1st-own-card":
+      if( 4-($what/30) >= 12 - $NRcards + $offset)
+       return 1;
+      break;
+    case "5th-card":
+      if( 27+4*($what/30)) <= $NRallcards + $offset*4)
+       return 1;
+      break;
+    case "9-cards":
+      if( ($what/10) <= $NRcards + $offset)
+       return 1;
+      break;
+    }
+
+  return 0;
 }
 
 }
 
-?>
\ No newline at end of file
+?>
index 8e21ae620399c846c3e3716f35a7f01e6de9cfc5..10416f1610974a33588be7dcaeff8aed745c3bcb 100644 (file)
--- a/index.php
+++ b/index.php
@@ -243,7 +243,9 @@ else if(myisset("me"))
 
     $RULES["dullen"]      = $r[2];
     $RULES["schweinchen"] = $r[3];
 
     $RULES["dullen"]      = $r[2];
     $RULES["schweinchen"] = $r[3];
-    
+    $RULES["call"]        = "1st-own-card";
+
+
     /* get some infos about the game */
     $gametype   = DB_get_gametype_by_gameid($gameid);
     $gamestatus = DB_get_game_status_by_gameid($gameid);
     /* get some infos about the game */
     $gametype   = DB_get_gametype_by_gameid($gameid);
     $gamestatus = DB_get_game_status_by_gameid($gameid);
@@ -333,7 +335,7 @@ else if(myisset("me"))
                  display_card($card,$PREF["cardset"]);
                echo "</p>\n";   
                
                  display_card($card,$PREF["cardset"]);
                echo "</p>\n";   
                
-               check_for_sickness($me,$mycards);
+               output_check_for_sickness($me,$mycards);
                
                /* move on to the next stage*/
                DB_set_hand_status_by_hash($me,'check');
                
                /* move on to the next stage*/
                DB_set_hand_status_by_hash($me,'check');
@@ -1461,7 +1463,9 @@ else if(myisset("me"))
                " <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
          if( can_call(0,$me) )
              echo " 0:".
                " <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
          if( can_call(0,$me) )
              echo " 0:".
-               " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ";
+               " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ".
+               " no call:".
+               " <input type=\"radio\" name=\"call0\" value=\"no\" /> ";
 
          echo "<br />\nA short comments:<input name=\"comment\" type=\"text\" size=\"30\" maxlength=\"50\" />\n";
          echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
 
          echo "<br />\nA short comments:<input name=\"comment\" type=\"text\" size=\"30\" maxlength=\"50\" />\n";
          echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
index 8288ee2dbb2dee36204916c831d38f65785950fe..75d013523cd1aef535e48bf76f227d2eb3330c13 100644 (file)
@@ -106,6 +106,7 @@ function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES["dullen"]."\" />\n";
   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES["dullen"]."\" />\n";
   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
+  echo "  <input type=\"hidden\" name=\"call\" value=\"".$RULES["call"]."\" />\n";
   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
   echo "  <input type=\"submit\" value=\"keep playing\" />\n";
   echo "</form>\n";
   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
   echo "  <input type=\"submit\" value=\"keep playing\" />\n";
   echo "</form>\n";
@@ -161,7 +162,16 @@ function output_form_for_new_game($names)
         </li>
         </ul>
       </p>
         </li>
         </ul>
       </p>
-      
+      <p> Call Re/Contra, etc.: 
+        <ul>
+           <li><input type="radio" name="call" value="1st-own-card" checked="checked" />
+                Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
+           <li><input type="radio" name="call" value="5th-card" /> 
+                Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
+           <li><input type="radio" name="call" value="9-cards"  /> 
+                Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
+        </ul>
+      </p>      
    <input type="submit" value="start game" />
  </form>
 <?php
    <input type="submit" value="start game" />
  </form>
 <?php
@@ -189,11 +199,9 @@ function display_link_card($card,$dir="english",$type="card")
   return;
 }
 
   return;
 }
 
-function check_for_sickness($me,$mycards)
+function output_check_for_sickness($me,$mycards)
 {
  ?>
 {
  ?>
-  <p> Solo will work, but the first player will not change. Nothing else implemented. </p>               
-
   <form action="index.php" method="post">
 
     do you want to play solo? 
   <form action="index.php" method="post">
 
     do you want to play solo? 
@@ -211,7 +219,7 @@ function check_for_sickness($me,$mycards)
 
  <?php   
       
 
  <?php   
       
-  echo "wedding?";
+  echo "Wedding?";
   if(check_wedding($mycards))
      {
        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
   if(check_wedding($mycards))
      {
        echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
@@ -222,7 +230,7 @@ function check_for_sickness($me,$mycards)
        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
      };
 
        echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
      };
 
-  echo "do you have poverty?";
+  echo "Do you have poverty?";
   if(count_trump($mycards)<4)
     {
       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
   if(count_trump($mycards)<4)
     {
       echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
@@ -233,7 +241,7 @@ function check_for_sickness($me,$mycards)
       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
     };
 
       echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
     };
 
-   echo "do you have too many nines?";
+   echo "Do you have too many nines?";
   if(count_nines($mycards)>4)
      {
        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
   if(count_nines($mycards)>4)
      {
        echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";