the clanfights have been adjusted to store the timestamp when the fight can be viewed. Also there is a new file that can be used to display event fights. The file can be executed like this -> event_kampf_anzeige.php?event_id=<event-id>&event_fight_id=<event-fight-id> and looks like any usual display :)
return 'Konnte den anderen Clan nicht herausfordern, da dieser Clan schoneinmal in den letzten 24 Stunden herausgefordert wurde!';
return 'Konnte den anderen Clan nicht herausfordern, da dieser Clan schoneinmal in den letzten 24 Stunden herausgefordert wurde!';
}
}
// it should not be possible to challenge a clan that already has an open match that is not yet calculated! ( not completely possible in sql)
$sql = 'select count(k.anzahl) as anzahl from (SELECT count(*) as anzahl FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where (calculated = 1 or enddate > now()) and clan_id IN ('.$user['clan'].', '.$clanid.') group by c.clan_challenge_id) k where k.anzahl = 0';
//echo $sql .'<br>';
$row = mysql_fetch_assoc(mysql_query($sql));
if($row['anzahl'] > 0) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Du kannst einen Clan nicht herausfordern, wenn derzeit gerade ein Clanfight zwischen euch läuft oder offen ist!';
}
// now calculate how many open fights we currently had or have!
$sql = 'select count(*) as anzahl from (SELECT count(*) as anz FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where calculated = 0 or TIMESTAMPADD(day, -1, now()) <enddateandclan_idIN('.$user['clan'].','.$clanid.')groupbyclan_id)kwherek.anz>= ' . CLANFIGHTS_MAX_FIGHTS_PER_24H;
//echo $sql .'<br>';
$row = mysql_fetch_assoc(mysql_query($sql));
if($row['anzahl'] > 0) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Einer der beiden Clans hat das Limit von ' . CLANFIGHTS_MAX_FIGHTS_PER_24H . ' offenen und abgeschlossenen Clanfights innerhalb von 24 erreicht. Daher kann die Herausforderung nicht versandt werden!';
@ -154,6 +182,15 @@ function acceptChallengeRequest($challenged_clan, array $user) {
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
}
// now calculate how many open fights we currently had or have! // FIXME: Good idea to pach this in a semaphore?
$sql = 'select count(*) as anzahl from (SELECT count(*) as anz FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where calculated = 0 or TIMESTAMPADD(day, -1, now()) <enddateandclan_idIN('.$clan_challenge['clan_challenged'].','.$clan_challenge['clan_requester'].')groupbyclan_id)kwherek.anz>= ' . CLANFIGHTS_MAX_FIGHTS_PER_24H;
// echo $sql . '<br>';
$row = mysql_fetch_assoc(mysql_query($sql));
if($row['anzahl'] > 0) {
return 'Einer der beiden Clans hat das Limit von ' . CLANFIGHTS_MAX_FIGHTS_PER_24H . ' offenen und abgeschlossenen Clanfights innerhalb von 24 erreicht. Daher kann die Herausforderung nicht angenommen werden!';
mysql_query('UPDATE clan_challenge_requests SET active = false WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenged_clan . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())');
mysql_query('UPDATE clan_challenge_requests SET active = false WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenged_clan . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())');
@ -483,6 +520,8 @@ function leaveChallenge($clan_challenge_id, array $user, $charid) {
function calculateChallenge($clan_challenge_id) {
function calculateChallenge($clan_challenge_id) {
$challenge = getChallenge($clan_challenge_id);
$challenge = getChallenge($clan_challenge_id);
$start_time = time();
// okay the calculated flag is already set so readout all the required data for further processing!
// okay the calculated flag is already set so readout all the required data for further processing!
$event_fight_data = mysql_fetch_assoc(mysql_query('SELECT *, visible <= now() as passed FROM event_fights WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id ));
// Okay and now get the data of the chars ;)
$sql = 'SELECT * FROM event_chars e where event_id = '.$event_id.' and event_char_id IN (SELECT event_char_id from event_fight_rounds where event_id = '.$event_id.' and event_fight_id = '.$event_fight_id.' and `round` = 0)';