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!
function displayFinalResult($items, $exp, $money, $final_result){
function displayFinalResult($items, $exp, $money, $final_result){
@ -132,11 +196,11 @@ echo '<tr>' .
'<tdclass="bold">';
'<tdclass="bold">';
// Letze Eintrag von Items ist false!!
// Letze Eintrag von Items ist false!!
if(!$items[0]){
if(!$items[0]){
echo ' ';
echo ' ';
} else{
} else{
for($i=0;$items[$i];$i++){
for($i=0;$items[$i];$i++){
echo $items[$i]['name'].'<br>';
echo $items[$i]['name'].'<br>';
}
}
}
}
echo'</td></tr>';
echo'</td></tr>';
echo '</table>' .
echo '</table>' .
@ -169,25 +233,25 @@ function displaySchatzSuche($char){
echo '<tr><thclass="top"colspan="3">Schatzsuche in '.$ort['stadt'].'</th></tr>';
echo '<tr><thclass="top"colspan="3">Schatzsuche in '.$ort['stadt'].'</th></tr>';
// Hole die Ergebnisse die auch in die Datenbank eingetragen werden muessen!
// Hole die Ergebnisse die auch in die Datenbank eingetragen werden muessen!
$row = mysql_fetch_assoc(mysql_query('Select sum(exp) as exp, sum(geld) as geld, count(*) as anzahl from quest_fights where charid = '.$char['id']));
$row = mysql_fetch_assoc(mysql_query('Select sum(exp) as exp, sum(geld) as geld, count(*) as anzahl from quest_fights where charid = '.$char['id']));
// Ermittle den Endzustand des Chars
// Ermittle den Endzustand des Chars
$end_qf = mysql_fetch_assoc(mysql_query('select max(fightnr) as mf from quest_fights where charid = '.$char['id']));
$end_qf = mysql_fetch_assoc(mysql_query('select max(fightnr) as mf from quest_fights where charid = '.$char['id']));
$end_qr = mysql_fetch_assoc(mysql_query('select max(roundnr) as mr from quest_rounds where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$end_qr = mysql_fetch_assoc(mysql_query('select max(roundnr) as mr from quest_rounds where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_round = mysql_fetch_assoc(mysql_query('Select * from quest_rounds where roundnr = '.$end_qr['mr'].' and fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_round = mysql_fetch_assoc(mysql_query('Select * from quest_rounds where roundnr = '.$end_qr['mr'].' and fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_fight = mysql_fetch_assoc(mysql_query('Select * from quest_fights where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_fight = mysql_fetch_assoc(mysql_query('Select * from quest_fights where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
// Ermittle die Reqs des Chars!
// Ermittle die Reqs des Chars!
$sql = 'SELECT c_attack as a_name, count(*) as anzahl FROM quest_rounds q where roundnr > 0 and charid = '.$char['id'].' group by c_attack';
$sql = 'SELECT c_attack as a_name, count(*) as anzahl FROM quest_rounds q where roundnr > 0 and charid = '.$char['id'].' group by c_attack';
// echo $sql.'<br>';
// echo $sql.'<br>';
$reqs = mysql_query($sql);
$reqs = mysql_query($sql);
while($row_r = mysql_fetch_assoc($reqs)){
while($row_r = mysql_fetch_assoc($reqs)){
$c_attacken[] = $row_r;
$c_attacken[] = $row_r;
// print_r($c_attacken);
// print_r($c_attacken);
// echo '<br>';
// echo '<br>';
}
}
if($last_fight['sieger'] == $char['id']){
if($last_fight['sieger'] == $char['id']){
$final_result = 'won';
$final_result = 'won';
// Nur wer gewinnt bekommt was!
// Nur wer gewinnt bekommt was!
@ -201,19 +265,19 @@ function displaySchatzSuche($char){
$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)';