|
|
|
@ -11,7 +11,7 @@ function getClanRanking() {
|
|
|
|
|
$clan_ids = array();
|
|
|
|
|
while($res = mysql_fetch_row($qry))
|
|
|
|
|
$clan_ids[] = $res;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $clan_ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -34,7 +34,7 @@ $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']);
|
|
|
|
@ -58,42 +58,57 @@ if(!semaphoreUP($ressource)) {
|
|
|
|
|
echo 'Werte Clanfight mit ID ' . $id . ' aus<br>';
|
|
|
|
|
$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 . '<br>';
|
|
|
|
|
mysql_query($sql);
|
|
|
|
|
addClanExp($clan1['id'], $expClan1);
|
|
|
|
|
mysql_query('UPDATE clan SET elo = elo + ' .$eloClan1 . ' WHERE id = ' . $clan1['id']);
|
|
|
|
|
$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 . '<br>';
|
|
|
|
|
mysql_query($sql);
|
|
|
|
|
addClanExp($clan2['id'], $expClan1);
|
|
|
|
|
mysql_query('UPDATE clan SET elo = elo + ' .$eloClan2 . ' WHERE id = ' . $clan2['id']);
|
|
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|