Merge branch 'dealing-reuse'
authorArun Persaud <arun@nubati.net>
Sun, 17 Jun 2007 16:57:21 +0000 (18:57 +0200)
committerArun Persaud <arun@nubati.net>
Sun, 17 Jun 2007 16:57:21 +0000 (18:57 +0200)
1  2 
functions.php
index.php

diff --combined functions.php
index 39cc2a5555c8d9ddc23503b01a1f33bd4263bad9,4f33f1e41c00019c5e569621f2193d14b2db6e03..3a650a2d94ca3dadb31f418595a962b84d528719
@@@ -9,6 -9,7 +9,6 @@@ function mymail($To,$Subject,$message,$
        $message = str_replace("\n","<br />\n",$message);
        $message = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
                       "<a href=\"\\0\">\\0</a>", $message);
 -      //$message = ereg_replace("(http.*)[ <>]","<a href=\"\\1\">\\1 </a>",$message);
        
        echo "<br />To: $To<br />";
        if($header != "") 
@@@ -422,7 -423,7 +422,7 @@@ function card_value($card
  }
  
  
- function  create_array_of_random_numbers()
+ function  create_array_of_random_numbers($useridA,$useridB,$useridC,$useridD)
  {
    global $debug;
  
      }
    else
      {
+       /* check if we can find a game were non of the player was involved and return 
+        * cards insted 
+        */
+       $userstr = implode(",",array($useridA,$useridB,$useridC,$useridD));
+       $randomnumbers = DB_get_unused_randomnumbers($userstr);
+       $randomnumbers = explode(":",$randomnumbers);
+       
+       if(sizeof($randomnumbers)==48)
+       return $randomnumbers;
+       
+       /* need to create new numbers */
        for($i=0;$i<48;$i++)
        $r[$i]=$i+1;
        
-       shuffle($r);
+       shuffle($r); 
      };
  
    return $r;
@@@ -676,7 -688,7 +687,7 @@@ function can_call($what,$hash
    switch ($RULES["call"])
      {
      case "1st-own-card":
 -      if( 4-($what/30) >= 12 - $NRcards + $offset)
 +      if( 4-($what/30) >= 12 - ($NRcards + $offset))
        return 1;
        break;
      case "5th-card":
diff --combined index.php
index 291d93097e1699c1165eb543d16205c8400ef2aa,fa828daabfb498aba84c089247b07cc680ab1f40..dd1ce58889d298ef2ef1ba658b8be8ec21fa19b9
+++ b/index.php
@@@ -72,7 -72,7 +72,7 @@@ if(myisset("new")
      $useridD  = DB_get_userid_by_name($PlayerD);
      
      /* create random numbers */
-     $randomNR       = create_array_of_random_numbers();
+     $randomNR       = create_array_of_random_numbers($useridA,$useridB,$useridC,$useridD);
      $randomNRstring = join(":",$randomNR);
      
      /* get ruleset information or create new one */
@@@ -94,7 -94,7 +94,7 @@@
        $ruleset = DB_get_ruleset_by_gameid($followup); /* just copy ruleset from old game, 
                                                         this way no manipulation is possible */
        if($session)
 -        mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1','pre',".
 +        mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1','1','pre',".
                      "'$ruleset','$session' ,NULL)");
        else
          {
            $max = DB_get_max_session();
            $max++;
            mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
 -          mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1','pre',".
 +          mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1','1','pre',".
                        "'$ruleset','$max' ,NULL)");
          }
        }
      else
 -      mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1','pre', ".
 +      mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1','1','pre', ".
                  "'$ruleset',NULL ,NULL)");
      $game_id = mysql_insert_id();