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.

111 lines
1.8 KiB

<?php
/*
*
* @copyright (c) 2010 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
set_time_limit(0);
$art_1 ="chu_pruef";
function rand_array($array)
{
$maxarray=count($array)-1;
mt_srand((double)microtime()*1000000);
for($i=$maxarray; $i>=0; $i--)
{
if($i>0) $zufall=mt_random_wrapper(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 = mysqli_num_rows(db_query("SELECT id FROM n_turnier_reg LIMIT 16"));
if($max_charakter<16) {
echo "Turnier kann nicht beginn.";
exit;
}
db_query("DELETE FROM turnier_kampf WHERE art='$art_1'");
$char1 = db_query("SELECT charakter FROM n_turnier_reg ORDER BY id ASC LIMIT 16");
while($row=mysqli_fetch_array($char1))
{
$test2[]=$row['charakter'];
}
$test2 = rand_array($test2);
$test3=$test2;
reset($test3);
while(current($test3)!=end($test2))
{
if(empty($list)) $list=current($test3);
else $list.=','.next($test3);
}
$result=db_query("SELECT * FROM chars WHERE id IN(".$list.") LIMIT 16");
while($row=mysqli_fetch_array($result))
{
$charas[$row['id']]=$row;
}
$a8=0;
$b8=1;
$round = 1;
while($a8 < 16)
{
$chara_1 = $charas[$test2[$a8]];
$chara_2 = $charas[$test2[$b8]];
include "turnier_kampf.php";
$a8+=2;
$b8+=2;
}
while($round < 4)
{
unset($test9);
$chars_win = db_query("SELECT win FROM turnier_kampf WHERE round='$round' AND art='$art_1'");
while($row9 = mysqli_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;
}
}
db_query("DELETE FROM n_turnier_reg ORDER BY id ASC LIMIT 16");
?>