';
mysql_query($sql);
insertClanTickerMessage($clan['id'], 'Das Preisgeld von '.$points.' für den '.$i.' Platz in der Clanliga erhalten!');
}
}
mysql_query('UPDATE clan SET elo = 1000');
}
$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';
if(!semaphoreUP($ressource)) {
echo 'konnte den cronjob nicht starten weil dieser schon in Gange ist!';
} else {
$ids = getAwatingChallengeIDs();
foreach($ids as $id) {
echo 'Werte Clanfight mit ID ' . $id . ' aus
'.PHP_EOL;
$challenge = getChallenge($id);
$clan_ids = getParticipatingClanIDs($id);
$clan1 = getClan($clan_ids[0]);
$clan2 = getClan($clan_ids[1]);
$c_clan_data1 = getParticipatingClanData($id, $clan_ids[0]);
$c_clan_data2 = getParticipatingClanData($id, $clan_ids[1]);
if($c_clan_data1['points'] > $c_clan_data2['points']) {
$winner = $clan1['id'];
} else {
$winner = $clan2['id'];
}
$expClan1 = calculateClanExperience($clan1, $clan2, $winner);
$expClan2 = calculateClanExperience($clan2, $clan1, $winner);
$newEloClan1 = calculateElo($c_clan_data1['elo'], $c_clan_data2['elo'], $c_clan_data1['points'] - $c_clan_data2['points'], $challenge['anzahl_chars']);
$newEloClan2 = calculateElo($c_clan_data2['elo'], $c_clan_data1['elo'], $c_clan_data2['points'] - $c_clan_data1['points'], $challenge['anzahl_chars']);
$eloClan1 = ($newEloClan1 - $c_clan_data1['elo']);
$eloClan2 = ($newEloClan2 - $c_clan_data2['elo']);
if($_clan_data1['elo_change'] == null) {
$sql = 'UPDATE clan_challenge_clans SET elo_change = ' .$eloClan1 . ', exp_change = ' . $expClan1 . ' WHERE clan_challenge_id = ' . $id . ' AND clan_id = ' . $clan1['id'];
// echo $sql . '
';
mysql_query($sql);
addClanExp($clan1['id'], $expClan1);
$appendum = null;
if($winner == $clan1['id']) {
$appendum = ', siege = siege + 1';
} else {
$appendum = ', niederlagen = niederlagen + 1';
}
mysql_query('UPDATE clan SET elo = elo + ' .$eloClan1 . $appendum . ' WHERE id = ' . $clan1['id']);
}
if($_clan_data2['elo_change'] == null) {
$sql = 'UPDATE clan_challenge_clans SET elo_change = ' .$eloClan2 . ', exp_change = ' . $expClan2 . ' WHERE clan_challenge_id = ' . $id . ' AND clan_id = ' . $clan2['id'];
// echo $sql . '
';
mysql_query($sql);
addClanExp($clan2['id'], $expClan2);
$appendum = null;
if($winner == $clan2['id']) {
$appendum = ', siege = siege + 1';
} else {
$appendum = ', niederlagen = niederlagen + 1';
}
mysql_query('UPDATE clan SET elo = elo + ' .$eloClan2 . $appendum . ' WHERE id = ' . $clan2['id']);
}
}
semaphoreDown($ressource);
}
?>