$qry = db_query ( 'SELECT * from tournament_types' );
$types = array ();
while ( $row = mysqli_fetch_assoc ( $qry ) ) {
$types [$row ['id']] = $row;
}
return $types;
}
/**
*
* @param int $id the id of the tournament_type
* @return array
*/
function getTournamentType($id) {
$qry = db_query ( 'SELECT * from tournament_types WHERE id = ' . $id );
return mysqli_fetch_assoc ( $qry );
}
/**
* Calling this method will run all scheduled tournaments for this hour.
*/
function runScheduledTournaments() {
$hour_of_day = date('G');
$day_of_week = date('N');
$day_of_month = date('j');
$sql = 'SELECT id FROM tournament_types WHERE (day_of_week = '.$day_of_week.' OR day_of_week is NULL) AND (day_of_month = '.$day_of_month.' or day_of_month is NULL) AND hour_of_day = '.$hour_of_day.' AND id NOT IN (SELECT type from tournament where ausgewertet = FALSE)';
$subselect = 'SELECT ec.char_id from event_chars ec inner join tournament t on ec.event_id = t.event_id WHERE t.type = '.$tournament_type['id'].' GROUP by ec.char_id HAVING count(*) >= '.$exclude_fusi_count;
$exclusions[] = '( '.$prefix.'fusion = \'nein\' OR '.$prefix.'id NOT IN ( '.$subselect.' ) )';
}
// Es sollen keine NPC mitmachen :) und nicht die Spezial Wanted NPCs
$exclude_race_ids = array();
$npc_race = getRaceTypeName('NPC');
$races = getRacesByType($npc_race); // remove all NPC
foreach($races as $race) {
$exclude_race_ids[] = '\''.$race['id'].'\'';
}
if($special != 1){
$races = getSpecialRaceIds();
$npc_race = getRaceTypeName('NPC'); // do not remove npc (there is a separate setting for this)
foreach($races as $race) {
if($race['type'] != $npc_race['id']) {
$exclude_race_ids[] = '\''.$race['id'].'\'';
}
}
}
if(count($exclude_race_ids)) {
$exclusions[] = $prefix.'rasse NOT IN('.implode(',',$exclude_race_ids).') ';
}
if(is_numeric($minlevel)){
$exclusions[] = $prefix.'level >= '.$minlevel;
}
if(is_numeric($maxlevel)){
$exclusions[] = $prefix.'level <= '.$maxlevel;
}
if ($exclude_winners == 1) {
$exclusions[] = $prefix.'id NOT IN( SELECT charid FROM highscore WHERE art = "'.$name.'" AND charid IS NOT NULL) ';
echo $name.' konnte nicht mit '.$anzahl.' Chars gestartet werden, da es nur '.$row['anzahl'].' von '.$anzahl.' nötigen Chars gibt!<br>';
$anzahl = pow(2, floor(log($row['anzahl'], 2)));
echo $name.' wird nun mit '.$anzahl.' Chars gestartet!<br>';
}
// Erstma nur die id auslesen (danach wird eh nochmal gemischt ;))
$cid = array();
if($gain == TOURNAMENT_GAIN_ANMELDUNG){
$sql = 'SELECT c.id FROM tournament_registration tr inner join chars as c ON tr.charakter = c.id WHERE tr.type='.$tournament_type['id'].' AND '.$filter_sql;