From: Arun Persaud Date: Sun, 17 Jun 2007 16:57:21 +0000 (+0200) Subject: Merge branch 'dealing-reuse' X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=7128076b9409b55551f206d875218fc8f70bb273;hp=-c Merge branch 'dealing-reuse' --- 7128076b9409b55551f206d875218fc8f70bb273 diff --combined functions.php index 39cc2a5,4f33f1e..3a650a2 --- a/functions.php +++ b/functions.php @@@ -9,6 -9,7 +9,6 @@@ function mymail($To,$Subject,$message,$ $message = str_replace("\n","
\n",$message); $message = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "\\0", $message); - //$message = ereg_replace("(http.*)[ <>]","\\1 ",$message); echo "
To: $To
"; 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; @@@ -445,10 -446,21 +445,21 @@@ } 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 291d930,fa828da..dd1ce58 --- a/index.php +++ 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 { @@@ -102,12 -102,12 +102,12 @@@ $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();