From fc92c91c0bdac8acb135760f11c96ea9f7fdaa93 Mon Sep 17 00:00:00 2001 From: hecht Date: Wed, 7 Dec 2011 23:11:36 +0000 Subject: [PATCH] the clan fights will now distribute the prices from the clan league ;) --- cronjob/clan_fight_auswertung.php | 40 +++++++++++++++++++++++++++++++ cronjob/gross_Turnier2.php | 3 ++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/cronjob/clan_fight_auswertung.php b/cronjob/clan_fight_auswertung.php index 2e65a46..3582dac 100755 --- a/cronjob/clan_fight_auswertung.php +++ b/cronjob/clan_fight_auswertung.php @@ -6,6 +6,46 @@ include_once(ROOT_PATH.'/include/clan.inc.php'); include_once(ROOT_PATH.'/include/elo.inc.php'); include_once(ROOT_PATH.'/include/semaphore.inc.php'); +function getClanRanking() { + $qry = mysql_query('SELECT id from clan ORDER by elo desc LIMIT 10'); + $clan_ids = array(); + while($res = mysql_fetch_row($qry)) + $clan_ids[] = $res; + + return $clan_ids; +} + +function distributeClanPrices(array $prices, array $results) { + $n = min(count($prices), count($results)); + + for($i = 0; $i<$n; $i++) { + $points = $prices[$i]; + foreach($results[$i] as $winner) { + $clan = getClan($winner); // buffered so will not cause in a sql statement all the time! + $sql = 'UPDATE clan SET elo = 1000, geld = geld + ' . $points . ' WHERE id = ' . $clan['id']; + echo $sql . '
'; + mysql_query($sql); + insertClanTickerMessage($clan['id'], 'Das Preisgeld von '.$points.' für den '.$i.' Platz in der Clanliga erhalten!'); + } + } +} + +$time = date("Hid"); +if($time == 1) { + // okay it is 0:00 in the morning at the first day of the month! + $results = getClanRanking(); + + $sql2 = 'Select avg(level) as dlevel from chars order by level desc limit 100'; + $row = mysql_fetch_assoc(mysql_query($sql2)); + $dlevel = ceil($row['dlevel']); + $summe = 20000000/(1+exp(5-$dlevel/14)); + + for($i = 1; $i<=count($results) ; $i++) { + $cprices[] = ceil($summe/pow(2, $i)); + } + distributeClanPrices($cprices, $results); +} + $ressource = 'CLAN_AUSWERTUNG'; diff --git a/cronjob/gross_Turnier2.php b/cronjob/gross_Turnier2.php index a5156b2..654c645 100644 --- a/cronjob/gross_Turnier2.php +++ b/cronjob/gross_Turnier2.php @@ -65,6 +65,7 @@ $cprices[] = ceil($summe/4); $cprices[] = ceil($summe/8); distributeShopPoints($prices, $results, 'Weltturnier'); -distributeClanPrices($cprices, $results, 'Weltturnier'); +// clan prices are not distributed anymore!! +//distributeClanPrices($cprices, $results, 'Weltturnier'); ?> \ No newline at end of file