it is now stored which person has created the clanfight and which one has accepted. Also the elo updated when the fight is calculated!

main
hecht 13 years ago
parent eb8b667f29
commit 87723ea10f

@ -82,13 +82,13 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
$clan_challenges_my_clan = getOpenChallengeRequestCount($user['clan']); $clan_challenges_my_clan = getOpenChallengeRequestCount($user['clan']);
$clan_challenges_oth_clan = getOpenChallengeRequestCount($clanid); $clan_challenges_oth_clan = getOpenChallengeRequestCount($clanid);
if($clan_challenges_my_clan > MAX_OPEN_REQUESTS) { if($clan_challenges_my_clan >= MAX_OPEN_REQUESTS) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore! semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore! semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Dein Clan hat schon die maximale Anzahl von Herausforderungen offen!'; return 'Dein Clan hat schon die maximale Anzahl von Herausforderungen offen!';
} }
if($clan_challenges_oth_clan > MAX_OPEN_REQUESTS) { if($clan_challenges_oth_clan >= MAX_OPEN_REQUESTS) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore! semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore! semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Der Clan "'.$oclan['clanname'].'" hat schon die maximale Anzahl von Herausforderungen offen!'; return 'Der Clan "'.$oclan['clanname'].'" hat schon die maximale Anzahl von Herausforderungen offen!';
@ -128,7 +128,7 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
// Fordere heraus! // Fordere heraus!
mysql_query('INSERT INTO clan_challenge_requests(clan_requester, clan_challenged, type, challenged_time, anzahl_chars, active) VALUES('.$user['clan'].', '.$clanid.','.$type.' , TIMESTAMPADD(HOUR, CURRENT_TIMESTAMP, 4), '.$anzahl.', true)'); mysql_query('INSERT INTO clan_challenge_requests(clan_requester, clan_challenged, type, challenged_time, clan_challenge_creator, anzahl_chars, active) VALUES('.$user['clan'].', '.$clanid.','.$type.' , TIMESTAMPADD(HOUR, CURRENT_TIMESTAMP, 4), '.$user['id'].', '.$anzahl.', true)');
if(mysql_affected_rows() > 0) { if(mysql_affected_rows() > 0) {
if(is_numeric($oclan['leader'])) { if(is_numeric($oclan['leader'])) {
@ -218,8 +218,8 @@ function acceptChallengeRequest($challenged_clan, array $user) {
} }
// insert the participants :) // insert the participants :)
mysql_query('INSERT INTO clan_challenge_clans(clan_challenge_id, clan_id, elo) values('.$id.', '.$clan['id'].', '.$clan['elo'].')'); mysql_query('INSERT INTO clan_challenge_clans(clan_challenge_id, clan_id, clan_coordinator, elo) values('.$id.', '.$clan['id'].', '.$user['id'].', ' .$clan['elo'].')');
mysql_query('INSERT INTO clan_challenge_clans(clan_challenge_id, clan_id, elo) values('.$id.', '.$oclan['id'].', '.$clan['elo'].')'); mysql_query('INSERT INTO clan_challenge_clans(clan_challenge_id, clan_id, clan_coordinator, elo) values('.$id.', '.$oclan['id'].', ' .$clan_challenge['clan_challenge_creator'].', ' .$clan['elo'].')');
// we have everything we need for this challenge to be opened :) // we have everything we need for this challenge to be opened :)
@ -582,7 +582,14 @@ function calculateChallenge($clan_challenge_id) {
$event_id = createEvent(EVENT_CLAN_FIGHT); $event_id = createEvent(EVENT_CLAN_FIGHT);
foreach ($clan_ids as $clan_id) { foreach ($clan_ids as $clan_id) {
// get the actual elo !!
$clan_char_ids = getParticipatingCharIDs($clan_challenge_id, $clan_id); $clan_char_ids = getParticipatingCharIDs($clan_challenge_id, $clan_id);
$sql = 'update clan_challenge_clans ccc inner join clan c on c.id = clan_id SET ccc.elo = c.elo WHERE clan_id IN (' . implode(', ', $clan_ids) .')';
$res = mysql_query($sql);
if(!$res)
echo 'Could not execute QUERY : ' .$sql .'<br>';
foreach ($clan_char_ids as $slot => $char_id) { foreach ($clan_char_ids as $slot => $char_id) {
addParticipant($event_id, getChar($char_id)); addParticipant($event_id, getChar($char_id));
$clan_chars[$clan_id][$slot] = getChar($char_id); $clan_chars[$clan_id][$slot] = getChar($char_id);
@ -590,7 +597,7 @@ function calculateChallenge($clan_challenge_id) {
} }
$result = NULL; $result = NULL;
// okay now determine the type of fight // okay now determine the type of fight
switch($challenge['type']) { switch($challenge['type']) {
case DAVY_BACK_FIGHT: case DAVY_BACK_FIGHT:

Loading…
Cancel
Save