Fixed #56 - it is not now possible anymore to challange a clan if there is a open challenge available!

main
hecht 13 years ago
parent 6db4d35cd0
commit 2e081818e2

@ -65,8 +65,6 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
if(!semaphoreUP($ressource_clan1)) {
return 'Fehler beim Verarbeiten der Anfrage für \'' . $clan['clanname'] . '\' versuche es bitte nochmal! ';
}
@ -78,7 +76,9 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
// okay we have both semaphores :)
$clan_challenges_my_clan = getOpenChallengeRequestCount($user['clan']) + count(getOpenChallengeIDs($user['clan']));
$myOpenChallengeIDs = getOpenChallengeIDs($user['clan']);
$clan_challenges_my_clan = getOpenChallengeRequestCount($user['clan']) + count($myOpenChallengeIDs);
$clan_challenges_oth_clan = getOpenChallengeRequestCount($clanid) + count(getOpenChallengeIDs($clanid));
if($clan_challenges_my_clan >= MAX_OPEN_REQUESTS) {
@ -93,6 +93,17 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
return 'Der Clan "'.$oclan['clanname'].'" hat schon die maximale Anzahl von Herausforderungen offen!';
}
// check if we have a open challenge with this clan ...
foreach ($myOpenChallengeIDs as $clan_challenge_id) {
$challenge_clans = getParticipatingClanIDs($clan_challenge_id);
if(in_array($user['clan'],$challenge_clans) && in_array($clanid,$challenge_clans)) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Der Clan kann derzeit nicht herausgefordert werden, da noch ein offener Clan-Fight mit diesem Clan besteht!';
}
}
// check if both clans have already been challengeing each other since 24h?
$sql = 'SELECT count(*) as anzahl FROM clan_challenge_requests WHERE clan_requester IN ('.$user['clan'].', '.$clanid.') AND clan_challenged IN ('.$user['clan'].', '.$clanid.') AND challenged_time > TIMESTAMPADD(day, -1, now())';
$qry = mysql_query($sql);

Loading…
Cancel
Save