diff --git a/cronjob/generic_turnier.php b/cronjob/generic_turnier.php index 95925dc..17a0802 100644 --- a/cronjob/generic_turnier.php +++ b/cronjob/generic_turnier.php @@ -43,7 +43,11 @@ include('path.inc.php'); include_once (ROOT_PATH.'/include/sqlwrapper.inc.php'); include_once(ROOT_PATH.'/include/char.inc.php'); include_once(ROOT_PATH.'/include/rassen.inc.php'); +include_once(ROOT_PATH.'/include/define.inc.php'); +include_once(ROOT_PATH.'/include/event.inc.php'); +defineIfNotDefined('ATTACK_SET_TOURNAMENT', 1); +defineIfNotDefined('TOURNAMENT_FIGHT_DURATION', 5); $name = $_GET['name']; // Name des Turniers (benötigt) $anzahl = $_GET['anzahl']; // Anzahl (benötigt) @@ -69,38 +73,6 @@ $gruppenphase = $_GET['gruppenphase']; // Flag für Gruppenphase (1 für aktiv) $grp_size = $_GET['grp_size']; // Anzahl der Teilnehmer in einer Gruppe $grp_proceed = $_GET['grp_proceed']; // Anzahl der Teilnehmer die Gruppenphase verlassen (1 nur Sieger, 2 Sieger und Zweiter ..) -/** - * Berechnet ein Kampf zwischen zwei chars - * @param int $char1_id die id des ersten chars - * @param int $char2_id die id des zweiten chars - * @param String $art der name des turniers (für die sql-Anfrage wichtig) - * @param int $round rundennummer (0,1,2...) - * @return int die id des siegenden chars - */ -function turnierfight($char1_id, $char2_id, $art_1, $round, $itemless){ - // Gotta replace this later -.- - echo 'Fight between '.$char1_id.' and '.$char2_id .', items = ' . ($itemless == 1?'TRUE':'FALSE') . '
' . "\n" ; - - $chara_1 = null; - $chara_2 = null; - if($itemless == 1) { - $chara_1 = getChar($char1_id); // ohne Equip für Turniere!! - $chara_2 = getChar($char2_id); // ohne Equip für Turniere!! - } else { - $chara_1 = getCharWithBuffs($char1_id); // Equip für Turniere!! - $chara_2 = getCharWithBuffs($char2_id); // Equip für Turniere!! - } - include "turnier_kampf.php"; - - echo ', Sieger '.$sieger.'
'. "\n" ; -// in $sieger steht die id des gewinners - if($char1_id == $sieger){ - return $char1_id; - } - return $char2_id; -} - - // Auswerten der Eingaben if($gruppenphase == 1){ if(is_null($grp_size)){ // Wenn es nicht gesetzt ist @@ -126,8 +98,6 @@ if($gruppenphase == 1){ } } -db_query('DELETE FROM turnier_kampf WHERE art=\''.$name.'\''); - $race_type = getRaceTypeName("NPC"); $auswahl_kriteria = '1'; @@ -221,28 +191,49 @@ while(($row = mysqli_fetch_assoc($qry)) && count($cid) < $anzahl){ //print_r($cid); +$event_id = createEvent(EVENT_TURNIER); +db_query('INSERT into turniere(art, event_id) values("'.$name.'", '.$event_id.')'); + $sql = 'SELECT id FROM chars WHERE id IN('.join(', ',$cid).') ORDER BY RAND()'; // Mischen der Teilnehmer //echo $sql.'
'; $qry = db_query($sql); $char_array = array(); while($row = mysqli_fetch_assoc($qry)){ - $char_array[] = $row['id']; + $char_data = NULL; + if($itemless == 1) { + $char_data = getChar($row['id']); // ohne Equip für Turniere!! + } else { + $char_data = getCharWithBuffs($row['id']); // Equip für Turniere!! + } + addParticipant($event_id, $char_data); + + $char_array[] = $char_data; } // So alle chars sind jetzt in den Arrays $round = 1; - //print_r($chars); -echo '
'; +//echo '
'; // Hier Gruppenphase berechnen und die Chars für die Endrunde in $chars speichern +$start_time = time(); +$counter = 1; +$duration = TOURNAMENT_FIGHT_DURATION * 60; // Beginn der Endrunde while(count($char_array) > 1){ // Solange bis nur ein Char übrig bleibt $n_chars = array(); for($i=0;$i $round)); + if ($winner['id'] == $char_array[$i]['id']) { + $n_chars[] = $char_array[$i]; + } else { + $n_chars[] = $char_array[$i+1]; + } // echo 'Berechne fight zwischen '.$char_array[$i].'und '.$char_array[$i+1].'('.$i.'/'.count($char_array).')
'; - $n_chars[] = turnierfight($char_array[$i], $char_array[$i+1], $name, $round, $itemless); + $counter++; } // echo 'nxt round
'; $round++;