From fd894c9dc5ce32c1631b70e9770f220d2f093d06 Mon Sep 17 00:00:00 2001 From: hecht Date: Fri, 1 Sep 2017 07:58:47 +0000 Subject: [PATCH] added exclusion filters for tournament and created generic tournament post processing --- cronjob/Turnier2.php | 39 --------- cronjob/generic_turnier.php | 63 ++++++++++++-- cronjob/generic_turnier_auswertung.php | 51 ++++++++++++ cronjob/gross_Turnier2.php | 75 ----------------- cronjob/grossst_Turnier2.php | 79 ------------------ cronjob/inclu/halloffame.inc.php | 68 --------------- cronjob/klein_Turnier2.php | 44 ---------- cronjob/pruf_Turnier2.php | 52 ------------ cronjob/pruf_turnier.php | 111 ------------------------- cronjob/wochenst_Turnier2.php | 42 ---------- 10 files changed, 109 insertions(+), 515 deletions(-) delete mode 100644 cronjob/Turnier2.php create mode 100644 cronjob/generic_turnier_auswertung.php delete mode 100644 cronjob/gross_Turnier2.php delete mode 100644 cronjob/grossst_Turnier2.php delete mode 100644 cronjob/inclu/halloffame.inc.php delete mode 100644 cronjob/klein_Turnier2.php delete mode 100644 cronjob/pruf_Turnier2.php delete mode 100644 cronjob/pruf_turnier.php delete mode 100644 cronjob/wochenst_Turnier2.php diff --git a/cronjob/Turnier2.php b/cronjob/Turnier2.php deleted file mode 100644 index b081a6b..0000000 --- a/cronjob/Turnier2.php +++ /dev/null @@ -1,39 +0,0 @@ -= mt_random_wrapper(1, 100)) { - ////////////////FRUCHT ARRAY - //include "array.php"; - distributeFruit($rang1['besitzer']); - -} - -$prices[] = 50; // 1. -$prices[] = 40; // 2. -$prices[] = 30; // 3. + 4. -$prices[] = 20; // 5. - 8. - -distributeShopPoints($prices, $results, 'Wochenturnier'); diff --git a/cronjob/generic_turnier.php b/cronjob/generic_turnier.php index 17a0802..74118a9 100644 --- a/cronjob/generic_turnier.php +++ b/cronjob/generic_turnier.php @@ -45,10 +45,32 @@ 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'); +include_once(ROOT_PATH.'/include/items.inc.php'); defineIfNotDefined('ATTACK_SET_TOURNAMENT', 1); defineIfNotDefined('TOURNAMENT_FIGHT_DURATION', 5); + +function getFruitItem( $fruit_type, $drop_chance ) { + $item_hash = NULL; + if ( $drop_chance == 0 ) { + return NULL; + } else if($drop_chance >= 100 || $drop_chance >= mt_random_wrapper(1, 100)) { + if ($fruit_type == 'natur') { + $sql = 'SELECT id FROM wochen_markt WHERE art=\''.$fruit_type.'\' order by rand() LIMIT 1'; + } else { + $sql = 'SELECT id FROM wochen_markt WHERE kategorie=\''.$fruit_type.'\' order by rand() LIMIT 1'; + } + + $qry = db_query($sql); + $id = mysqli_fetch_row($qry)[0]; + + $item_hash = item2Value(array('id' => $id, 'table_name' => 'wochen_markt')); + } + return $item_hash; +} + + $name = $_GET['name']; // Name des Turniers (benötigt) $anzahl = $_GET['anzahl']; // Anzahl (benötigt) @@ -65,6 +87,10 @@ $maxlevel = $_GET['maxlevel']; // selbsterklärend $gain = $_GET['gain']; // ('Anmeldung', 'PL', 'Level') $randomize = $_GET['randomize']; // 1 für nach jeder Runde die reihenfolge setzen $itemless = $_GET['itemless']; // gibt an ob das turnier die items ingorieren soll (standard sind items aktiv) +$fruit_chance = $_GET['fruit']; // gibt die prozentuale chance auf eine frucht an +$fruit_type = isset($_GET['fruit_type']) ? $_GET['fruit_type'] : 'natur'; // gibt den typ der frucht an +$exclude_winners = isset($_GET['exclude_winners']) && $_GET['exclude_winners']; // gibt an ob gewinner vorheriger turniere des typs ausgeschlossen werden +$exclude_fusi_count = $_GET['exclude_fusi_count']; $npc = $_GET['npc']; @@ -98,12 +124,13 @@ if($gruppenphase == 1){ } } -$race_type = getRaceTypeName("NPC"); - $auswahl_kriteria = '1'; if($fusion != 1){ - $auswahl_kriteria .= ' AND fusion_rasse = \'0\' '; + $auswahl_kriteria .= ' AND fusion = \'nein\' '; +} else if(is_numeric($exclude_fusi_count) && $exclude_fusi_count > 0) { + $subselect = 'SELECT ec.char_id from event_chars ec inner join turniere t on ec.event_id = t.event_id WHERE art = \''.$name.'\' GROUP by ec.char_id HAVING count(*) >= '.$exclude_fusi_count; + $auswahl_kriteria .= ' AND (fusion = \'nein\' OR id NOT IN ( '.$subselect.' ) )'; } // Es sollen keine NPC mitmachen :) und nicht die Spezial Wanted NPCs @@ -142,10 +169,15 @@ if(is_numeric($maxlevel)){ $auswahl_kriteria .= ' AND level <= '.$maxlevel.' '; } +if ($exclude_winners == 1) { + $auswahl_kriteria .= ' AND id NOT IN( SELECT charid FROM highscore WHERE art = "'.$name.'") '; +} + + // Erstma checken ob es überhaupt genug chars gibt ;) $sql = 'SELECT count(*) as anzahl from chars where '.$auswahl_kriteria; -echo $sql.'
'; +// echo $sql.'
'; $qry = db_query($sql); $row = mysqli_fetch_assoc($qry); @@ -182,9 +214,13 @@ if($gain == 'Anmeldung'){ exit; } -echo $sql.'
'; +// echo $sql.'
'; $qry = db_query($sql); while(($row = mysqli_fetch_assoc($qry)) && count($cid) < $anzahl){ + + // exclude winners of old tournaments in case requested + // exclude fusions that have participated multiple times in tournaments in case requested + // echo $row['id'].'
'; $cid[] = $row['id']; } @@ -205,6 +241,11 @@ while($row = mysqli_fetch_assoc($qry)){ } else { $char_data = getCharWithBuffs($row['id']); // Equip für Turniere!! } + $max_hp = explode(',', $char_data['hp'])[1]; + $char_data['hp'] = join(',', array($max_hp, $max_hp)); + $max_mp = explode(',', $char_data['mp'])[1]; + $char_data['mp'] = join(',', array($max_mp, $max_mp)); + addParticipant($event_id, $char_data); $char_array[] = $char_data; @@ -242,3 +283,15 @@ while(count($char_array) > 1){ // Solange bis nur ein Char übrig bleibt } $char_array = $n_chars; } + +$end_time = $start_time + $counter * $duration; +$end_time_str = date("Y-m-d H:i:s",$end_time); +db_query('UPDATE event_chars SET block_begin = \''.$end_time_str.'\', block_end = \''.$end_time_str.'\' WHERE event_id = '.$event_id); + +// Seems that we have a winner :D +$fruit_item_str = getFruitItem($fruit_type, $fruit_chance); +if ($fruit_item_str !== NULL) { + // add item in event_char_metadata + db_query('INSERT INTO event_char_metadata(event_id, event_char_id, `key`, `value`) values('.$event_id.','.$char_array[0]['id'].',\''.KEY_ITM_CHAR1.'\',\''.$fruit_item_str.'\')'); +} + diff --git a/cronjob/generic_turnier_auswertung.php b/cronjob/generic_turnier_auswertung.php new file mode 100644 index 0000000..8444a68 --- /dev/null +++ b/cronjob/generic_turnier_auswertung.php @@ -0,0 +1,51 @@ + 0) { + db_query('UPDATE turniere SET ausgewertet = TRUE WHERE id IN ('.join(',', $tournaments_done).')'); +} diff --git a/cronjob/gross_Turnier2.php b/cronjob/gross_Turnier2.php deleted file mode 100644 index 089fe0d..0000000 --- a/cronjob/gross_Turnier2.php +++ /dev/null @@ -1,75 +0,0 @@ - diff --git a/cronjob/grossst_Turnier2.php b/cronjob/grossst_Turnier2.php deleted file mode 100644 index a1a8a49..0000000 --- a/cronjob/grossst_Turnier2.php +++ /dev/null @@ -1,79 +0,0 @@ - diff --git a/cronjob/inclu/halloffame.inc.php b/cronjob/inclu/halloffame.inc.php deleted file mode 100644 index 482a255..0000000 --- a/cronjob/inclu/halloffame.inc.php +++ /dev/null @@ -1,68 +0,0 @@ -'; - $row = mysqli_fetch_assoc(db_query('Select max(id) as round from online')); - $char = getChar($charid); - $user = mysqli_fetch_assoc(db_query('Select * from user where id = '.$userid)); - - if(!$row){ - echo 'insertIntoHallOfFame failed as the basic methods failed!
'; - return false; - } - - return insertIntoHallOfFameFull($row['round'], $title, $charid, $char['name'], $userid, $user['nickname'], 'CURRENT_DATE'); -} - -function insertIntoHallOfFameFull($round = '', $title = '', $charid = '', $charname = '', $userid = '', $username = '', $date = ''){ - echo 'insertIntoHallOfFame('.$title.', '.$charid.', '.$charname.', '.$username.', '.$userid.', '.$date.')
'; - // These Entries may not be '' - if(!is_numeric($round) || $date == '' || $title == ''){ - echo 'insertIntoHallOfFame failed as the extended methods failed!
'; - return false; - } - - $columns = 'art, runde, datum, charname, username'; - $values = '\''.$title.'\','.$round.','.$date.',\''.$charname.'\',\''.$username.'\''; - - if(is_numeric($charid)){ - $columns .= ',charid'; - $values .= ','.$charid; - } - if(is_numeric($userid)){ - $columns .= ',userid'; - $values .= ','.$userid; - } - $sql = 'INSERT INTO highscore('.$columns.') values('.$values.')'; -// echo $sql.'
'; - $qry = db_query($sql); - return db_affected_rows() > 0; -} - -function getHallOfFame($title, $userid) { - $row = mysqli_fetch_assoc(db_query('Select max(id) as round from online')); - return getHallOfFameFull($row['round'],$title, $userid); -} - -function getHallOfFameFull($round = '', $title = '', $userid = '') { - $sql = 'select count(*) from highscore where runde='.$round.' and userid='.$userid; - $row = mysqli_fetch_row($sql); - return $row[0]; -} - -?> \ No newline at end of file diff --git a/cronjob/klein_Turnier2.php b/cronjob/klein_Turnier2.php deleted file mode 100644 index f498064..0000000 --- a/cronjob/klein_Turnier2.php +++ /dev/null @@ -1,44 +0,0 @@ -= 2) { - // remove all chars that are registered - db_query('DELETE FROM turnier1 WHERE art = \'klein\' AND besitzer = '.$rang1['besitzer']); -} -*/ - - -// Now distribute the shop points ;) - -$prices[] = 25; // 1. (max win) -$prices[] = 20; // 2. (max win - 1) -$prices[] = 15; // 3. + 4. (max win -2) - -distributeShopPoints($prices, $results, 'Anfängerturnier'); - -?> diff --git a/cronjob/pruf_Turnier2.php b/cronjob/pruf_Turnier2.php deleted file mode 100644 index 7cc9d90..0000000 --- a/cronjob/pruf_Turnier2.php +++ /dev/null @@ -1,52 +0,0 @@ - \ No newline at end of file diff --git a/cronjob/pruf_turnier.php b/cronjob/pruf_turnier.php deleted file mode 100644 index 1f3ccdb..0000000 --- a/cronjob/pruf_turnier.php +++ /dev/null @@ -1,111 +0,0 @@ -=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"); - -?> \ No newline at end of file diff --git a/cronjob/wochenst_Turnier2.php b/cronjob/wochenst_Turnier2.php deleted file mode 100644 index 0b55411..0000000 --- a/cronjob/wochenst_Turnier2.php +++ /dev/null @@ -1,42 +0,0 @@ -= mt_random_wrapper(1, 100)) { - ////////////////FRUCHT ARRAY - //include "array.php"; - distributeParamecia($rang1['besitzer']); - -} - -$prices[] = 50; // 1. -$prices[] = 40; // 2. -$prices[] = 30; // 3. + 4. -$prices[] = 20; // 5. - 8. - -distributeShopPoints($prices, $results, $turnier_name);