You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.2 KiB
63 lines
2.2 KiB
13 years ago
|
<?php
|
||
|
|
||
|
include('db.php');
|
||
|
include('path.inc.php');
|
||
|
include_once(ROOT_PATH.'/include/clan.inc.php');
|
||
|
include_once(ROOT_PATH.'/include/elo.inc.php');
|
||
|
include_once(ROOT_PATH.'/include/semaphore.inc.php');
|
||
|
|
||
|
|
||
|
$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<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']);
|
||
|
}
|
||
|
|
||
|
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']);
|
||
|
}
|
||
|
}
|
||
|
semaphoreDown($ressource);
|
||
|
}
|
||
|
|
||
|
|
||
|
?>
|