You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.3 KiB

<?php
/*
*
* @copyright (c) 2010 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
$art_1 ="wochen";
//set_time_limit(0);
function rand_array($array)
{
$maxarray=count($array)-1;
mt_srand((double)microtime()*1000000);
for($i=$maxarray; $i>=0; $i--)
{
if($i>0) $zufall=mt_rand(0,$i);
else $zufall=0;
$temp=$array[$i];
$array[$i]=$array[$zufall];
$array[$zufall]=$temp;
$newarray[]=$array[$i];
array_pop($array);
}
return $newarray;
}
include "db.php";
$max_charakter = mysql_num_rows(mysql_query("SELECT id FROM chars LIMIT 64"));
if($max_charakter<64) {
exit;
}
mysql_query("DELETE FROM turnier_kampf WHERE art='$art_1'");
$char1 = mysql_query("SELECT charakter FROM turnier1 WHERE art='$art_1'");
while($row=mysql_fetch_array($char1))
{
$test2[]=$row['charakter'];
}
do
{
if(count($test2)<64)
{ // WHERE status='Frei'
list($count) = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM chars"));
if(($count+count($test2))>=64)
{
$result = mysql_query("SELECT id FROM chars WHERE status='Frei' AND rasse !='NPC' ORDER BY RAND() LIMIT ".(64-count($test2)));
while($char_name2=mysql_fetch_array($result))
{
$test2[]=$char_name2['id'];
}
}
}
$test2 = rand_array($test2);
$test2 = array_unique($test2);
}
while(count($test2)<64);
$test3=$test2;
reset($test3);
while(current($test3)!=end($test2))
{
if(empty($list)) $list=current($test3);
else $list.=','.next($test3);
}
$result=mysql_query("SELECT * FROM chars WHERE id IN(".$list.") LIMIT 64");
while($row=mysql_fetch_array($result))
{
$charas[$row['id']]=$row;
}
$a8=0;
$b8=1;
$round = 1;
while($a8 < 64)
{
$chara_1 = $charas[$test2[$a8]];
$chara_2 = $charas[$test2[$b8]];
include "turnier_kampf.php";
$a8+=2;
$b8+=2;
}
while($round < 6)
{
unset($test9);
$chars_win = mysql_Query("SELECT win FROM turnier_kampf WHERE round='$round' AND art='$art_1'");
while($row9 = mysql_fetch_array($chars_win))
{
$test9[]=$row9['win'];
}
$round++;
$k9=0;
$l9=1;
while($k9 < count($test9))
{
$chara_1 = $charas[$test9[$k9]];
$chara_2 = $charas[$test9[$l9]];
include "turnier_kampf.php";
$k9+=2;
$l9+=2;
}
}
mysql_query("DELETE FROM turnier1 WHERE art='$art_1' ");
?>