From 06e3937d96e11a04cdc6c6f6432536f98f089331 Mon Sep 17 00:00:00 2001 From: hecht Date: Fri, 20 Oct 2017 13:17:52 +0000 Subject: [PATCH] fixed attack set and tournament generation --- ag/include/attackenset.inc.php | 11 +++++++++-- ag/include/kampf/ausdauer.php | 10 +++++----- ag/include/tournament.inc.php | 5 +++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ag/include/attackenset.inc.php b/ag/include/attackenset.inc.php index 2805f21..77ecd9f 100644 --- a/ag/include/attackenset.inc.php +++ b/ag/include/attackenset.inc.php @@ -17,6 +17,8 @@ defineIfNotDefined('CLANKAMPF', 2); //Anzahl der Runden pro Kampf defineIfNotDefined('KAMPF_RUNDEN', 10); +$GLOBALS['char_buffered_attackset'] = array(); + function createAttackSet($char_id, $type) { if(!is_numeric($char_id) || !is_numeric($type)) { return false; @@ -42,16 +44,20 @@ function deleteAttackSet($char_id, $type) { return db_query($qry); } -function getAttackSet($char_id, $type) { +function getAttackSet($char_id, $type, $buffer_enabled = true) { if(!is_numeric($char_id) || !is_numeric($type)) { return false; } + if (isset($GLOBALS['char_buffered_attackset'][$char_id]) && isset($GLOBALS['char_buffered_attackset'][$char_id][$type]) && $buffer_enabled) { + return $GLOBALS['char_buffered_attackset'][$char_id][$type]; + } $qry = db_query('SELECT attack_id, round FROM attackenset WHERE char_id = '.$char_id.' AND type = '.$type); $set = array(); while ($result = mysqli_fetch_assoc($qry)) { $set[$result['round']] = $result['attack_id']; } + $GLOBALS['char_buffered_attackset'][$char_id][$type] = $set; return $set; } @@ -59,7 +65,7 @@ function updateAttackSet($char_id, $type, $newSet) { if(!is_numeric($char_id) || !is_numeric($type) || !is_array($newSet) || count($newSet) == 0) { return false; } - $oldset = getAttackSet($char_id, $type); + $oldset = getAttackSet($char_id, $type, false); for ($i = 1; $i < KAMPF_RUNDEN + 1; $i++) { if($oldset[$i] != $newSet[$i]) { @@ -67,6 +73,7 @@ function updateAttackSet($char_id, $type, $newSet) { db_query($qry); } } + unset($GLOBALS['char_buffered_attackset'][$char_id][$type]); return true; } diff --git a/ag/include/kampf/ausdauer.php b/ag/include/kampf/ausdauer.php index 1217715..007a2f6 100644 --- a/ag/include/kampf/ausdauer.php +++ b/ag/include/kampf/ausdauer.php @@ -11,19 +11,19 @@ if($x > 0) { ################### PLAYER 1 -$k_starke[0] = round($k_starke[0] + (($k_ausdauer[0] / 20))-($k_starke[0]/50)); +$k_starke[0] = round($k_starke[0] + ($k_ausdauer[0] / 10)); $k_speed[0] = round($k_speed[0] + ($k_ausdauer[0] / 10)); -$k_ver[0] = round($k_ver[0] + ($k_ausdauer[0] / 10)); +$k_ver[0] = round($k_ver[0] + ($k_ausdauer[0] / 20)-($k_ver[0]/50)); $k_ausdauer[0] = round($k_ausdauer[0] - ($k_ausdauer[0] /20)); ################### PLAYER 2 -$k_starke[1] = round($k_starke[1] + (($k_ausdauer[1] / 20))-($k_starke[1]/50)); +$k_starke[1] = round($k_starke[1] + ($k_ausdauer[1] / 10)); $k_speed[1] = round($k_speed[1] + ($k_ausdauer[1] / 10)); -$k_ver[1] = round($k_ver[1] + ($k_ausdauer[1] / 10)); +$k_ver[1] = round($k_ver[1] + ($k_ausdauer[1] / 20)-($k_ver[1]/50)); $k_ausdauer[1] = round($k_ausdauer[1] - ($k_ausdauer[1] /20)); } -?> \ No newline at end of file +?> diff --git a/ag/include/tournament.inc.php b/ag/include/tournament.inc.php index 1ece3c3..81a466c 100644 --- a/ag/include/tournament.inc.php +++ b/ag/include/tournament.inc.php @@ -243,6 +243,7 @@ function createTournament($tournament_type) { function calculateTournament($tournament, $participants) { shuffle($participants); + $tournament_type = getTournamentType($tournament['type']); $event_id = $tournament['event_id']; @@ -275,7 +276,7 @@ function calculateTournament($tournament, $participants) { } // echo 'nxt round
'; $round++; - if($tournament['randomize'] == 1) { + if($tournament_type['randomize'] == 1) { shuffle($n_chars); } $char_array = $n_chars; @@ -286,7 +287,7 @@ function calculateTournament($tournament, $participants) { 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($tournament['fruit_type'], $tournament['fruit_chance']); + $fruit_item_str = getFruitItem($tournament_type['fruit_type'], $tournament_type['fruit_chance']); if ($fruit_item_str !== NULL) { // add item in event_char_metadata