a really basic way to be able to watch the clan fights

main
hecht 13 years ago
parent b394bbf80a
commit cd406ecbb8

@ -68,7 +68,7 @@ function displayChallengeAccepted($user, $clan_id) {
function displayDenyChallenge($clan_id) { function displayDenyChallenge($clan_id) {
if(!is_numeric($clan_id)) { if(!is_numeric($clan_id)) {
displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink()); displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink());
exit; return;
} }
?> ?>
<table> <table>
@ -91,7 +91,7 @@ function displayShowChallenge($clan_challenge_id, $user) {
if(!in_array($clan_challenge_id, $open_challenge_ids)) { if(!in_array($clan_challenge_id, $open_challenge_ids)) {
displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink()); displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink());
exit; return;
} }
//initialisieren von wichtigen variablen //initialisieren von wichtigen variablen
@ -191,6 +191,69 @@ function displayShowChallenge($clan_challenge_id, $user) {
<?php <?php
} }
function displayShowOldChallenge($clan_challenge_id, array $user) {
$user_clan = getClan($user['clan']);
$challenge = getChallenge($clan_challenge_id);
$clans = getParticipatingClanIDs($clan_challenge_id);
if(!in_array($user['clan'] , $clans)) {
displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink());
return;
}
if($challenge['calculated'] == FALSE) {
displayErrorMessage(NULL, 'Der Clankampf ist noch nicht soweit!!', displayHistoryBackLink());
return;
}
//print_r($challenge);
// Get the Event
$event_id = $challenge['event_id'];
$event = getEvent($event_id);
if($event['event_type'] != EVENT_CLAN_FIGHT) {
displayErrorMessage(NULL, 'Das Event is garkein Clan-Kampf!!', displayHistoryBackLink());
return;
}
$fight_ids = getEventFightIds($event_id);
echo '<table>';
echo '<tr><th align="center" width="100">Kampf</th><th>Ansehen</th></tr>';
foreach($fight_ids as $fight_id) {
$event_fight = getEventFight($event_id, $fight_id);
$round_data = getEventFightRoundData($event_id, $event_fight['event_fight_id'], 0); // get participants of fight
$host_char_id = NULL;
$guest_char_id = NULL;
foreach($round_data as $key => $value) {
if($event_fight['host'] == $key) {
$host_char_id = $key;
} else {
$guest_char_id = $key;
}
}
// Key now lets read out the event_chars ...
$host_char = getEventChar($event_id, $host_char_id);
$guest_char = getEventChar($event_id, $guest_char_id);
// TODO: Check if the fight is already "visible"
echo '<tr>';
echo '<td align="center">';
if($host_char['char_id'] !== NULL)
echo displayCharLink($host_char['char_id'], $host_char['char_name']);
else
echo $host_char['char_name'];
echo ' vs. ';
if($guest_char['char_id'] !== NULL)
echo displayCharLink($guest_char['char_id'], $guest_char['char_name']);
else
echo $guest_char['char_name'];
echo '</td>';
echo '<td><a href="event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$event_fight['event_fight_id'].'" target="_blank">anschauen</a></td>';
echo '</tr>';
}
echo '</table>';
}
function displayJoinChallenge($user, $clan_challenge_id, $char_id, $slot) { function displayJoinChallenge($user, $clan_challenge_id, $char_id, $slot) {
$success = joinChallenge($clan_challenge_id, $user, $char_id, $slot); $success = joinChallenge($clan_challenge_id, $user, $char_id, $slot);
if($success != null) { if($success != null) {
@ -242,6 +305,7 @@ function displayClanFightMenu($user) {
} }
$open_challenge_requests = getOpenChallengeRequests($user_clan['id']); $open_challenge_requests = getOpenChallengeRequests($user_clan['id']);
$open_challenge_ids = getOpenChallengeIDs($user_clan['id']); $open_challenge_ids = getOpenChallengeIDs($user_clan['id']);
$old_challenge_ids = getHistoricalChallengeIDs($user_clan['id']);
?> ?>
<div align="center"> <div align="center">
<table width="100%" border="1"> <table width="100%" border="1">
@ -291,39 +355,76 @@ function displayClanFightMenu($user) {
<th height="30" colspan="2" align="center">offene Herausforderungen</th> <th height="30" colspan="2" align="center">offene Herausforderungen</th>
</tr> </tr>
<?php <?php
foreach ($open_challenge_ids as $oci) { if(count($open_challenge_ids) == 0) {
$participating_clan_ids = getParticipatingClanIDs($oci); ?><td height="20" colspan="2" align="center">Keine</td><?php
foreach ($participating_clan_ids as $pci) } else {
if($pci != $user_clan['id']) { foreach ($open_challenge_ids as $oci) {
$challenged_clan = getClan($pci); $participating_clan_ids = getParticipatingClanIDs($oci);
echo '<tr>'; foreach ($participating_clan_ids as $pci)
echo '<td> '.$challenged_clan['clanname'].'</td>'; if($pci != $user_clan['id']) {
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showchallenge&challenge='.$oci.'">'.anzeigen.'</a></td>'; $challenged_clan = getClan($pci);
echo '</tr>'; echo '<tr>';
echo '<td> '.$challenged_clan['clanname'].'</td>';
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showchallenge&challenge='.$oci.'">'.anzeigen.'</a></td>';
echo '</tr>';
}
}
}
?>
<tr>
<th height="30" colspan="2" align="center">Beendete Herausforderungen</th>
</tr>
<tr>
<?php
if(count($old_challenge_ids) == 0) {
?><td height="20" colspan="2" align="center">Keine</td><?php
} else {
foreach ($old_challenge_ids as $oci) {
$participating_clan_ids = getParticipatingClanIDs($oci);
foreach ($participating_clan_ids as $pci)
if($pci != $user_clan['id']) {
$challenged_clan = getClan($pci);
echo '<tr>';
echo '<td> '.$challenged_clan['clanname'].'</td>';
echo '<td align="center"><a href="index.php?as=clan/kampf_info&action=showoldchallenge&challenge='.$oci.'">'.anzeigen.'</a></td>';
echo '</tr>';
}
} }
} }
?> ?>
</tr>
</table> </table>
</div> </div>
<?php <?php
} }
if($action == 'challengeclan') { switch($action) {
displayChallengeClan($user_ida, $challangedclan_id); case 'challengeclan':
} else if($action == 'acceptchallenge') { displayChallengeClan($user_ida, $challangedclan_id);
displayChallengeAccepted($user_ida, $inquirychallenge_clanid); break;
} else if($action == 'q_denychallenge') { case 'acceptchallenge':
displayDenyChallenge($inquirychallenge_clanid); displayChallengeAccepted($user_ida, $inquirychallenge_clanid);
} else if($action == 'denychallenge') { break;
denyChallengeRequest($inquirychallenge_clanid, $user_ida); case 'q_denychallenge':
displayClanFightMenu($user_ida); displayDenyChallenge($inquirychallenge_clanid);
} else if($action == 'showchallenge') { break;
displayShowChallenge($clan_challange_id, $user_ida); case 'denychallenge':
} else if($action == 'joinchallenge') { denyChallengeRequest($inquirychallenge_clanid, $user_ida);
displayJoinChallenge($user_ida, $clan_challange_id, $char_id, $slot); displayClanFightMenu($user_ida);
} else if($action == 'leavechallenge') { break;
displayLeaveChallenge($user_ida, $clan_challange_id, $char_id); case 'showchallenge':
} else if ($action == NULL) { displayShowChallenge($clan_challange_id, $user_ida);
displayClanFightMenu($user_ida); break;
case 'showoldchallenge':
displayShowOldChallenge($clan_challange_id, $user_ida);
break;
case 'joinchallenge':
displayJoinChallenge($user_ida, $clan_challange_id, $char_id, $slot);
break;
case 'leavechallenge':
displayLeaveChallenge($user_ida, $clan_challange_id, $char_id);
break;
default:
displayClanFightMenu($user_ida);
} }
?> ?>

@ -284,4 +284,22 @@ function getEventFightIdsByChar($event_id, $event_char_id) {
return $result; return $result;
} }
?> function getEventFightRoundData($event_id, $event_fight_id, $round) {
$sql = 'SELECT * FROM event_fight_rounds WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id . ' AND `round` = ' .$round;
$qry = mysql_query($sql);
if(!$qry) {
echo $sql . '<br>';
return;
}
while($row = mysql_fetch_assoc($qry)) {
$result[$row['event_char_id']] = $row;
}
return $result;
}
?>

Loading…
Cancel
Save