diff options
author | Arun Persaud <arun@nubati.net> | 2007-06-17 18:57:21 +0200 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2007-06-17 18:57:21 +0200 |
commit | 7128076b9409b55551f206d875218fc8f70bb273 (patch) | |
tree | c353754505d3e5edb47eae4c6bf338995d8caa68 | |
parent | 9afea8fd89c0c849f361d488569612b5b3fa3c34 (diff) | |
parent | 44adf43ccb058fb76e7bdbb18917ca86a7f7ec29 (diff) | |
download | e-DoKo-7128076b9409b55551f206d875218fc8f70bb273.tar.gz e-DoKo-7128076b9409b55551f206d875218fc8f70bb273.tar.bz2 e-DoKo-7128076b9409b55551f206d875218fc8f70bb273.zip |
Merge branch 'dealing-reuse'
-rw-r--r-- | db.php | 15 | ||||
-rw-r--r-- | functions.php | 15 | ||||
-rw-r--r-- | index.php | 2 |
3 files changed, 29 insertions, 3 deletions
@@ -764,4 +764,19 @@ function DB_get_PREF($myid) return; } +function DB_get_unused_randomnumbers($userstr) +{ + $queryresult = mysql_query("SELECT randomnumbers,Game.id FROM Game ". + " LEFT JOIN Hand ON Hand.game_id=Game.id ". + " AND user_id not in (".$userstr.")". + " GROUP BY Game.id ". + " HAVING num=4"); + + $r = mysql_fetch_array($queryresult,MYSQL_NUM); + if($r) + return $r[0]; + else + return ""; +} + ?>
\ No newline at end of file diff --git a/functions.php b/functions.php index 39cc2a5..3a650a2 100644 --- a/functions.php +++ b/functions.php @@ -422,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; @@ -445,10 +445,21 @@ function create_array_of_random_numbers() } 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; @@ -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 */ |