the clan fights will now distribute the prices from the clan league ;)

main
hecht 13 years ago
parent b2b62cb65e
commit fc92c91c0b

@ -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 . ' <br>';
mysql_query($sql);
insertClanTickerMessage($clan['id'], 'Das Preisgeld von '.$points.' f&uuml;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';

@ -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');
?>
Loading…
Cancel
Save