From da71cd39b01b271f3f3fb156494a371c4e747c0f Mon Sep 17 00:00:00 2001 From: radiskull Date: Wed, 30 Nov 2011 19:31:15 +0000 Subject: [PATCH] kleine Anpassungen, (User und Char anklickbar) --- ag/clan/kampf_info.php | 161 ++++++++++++++++++++++++++++++---------- ag/include/user.inc.php | 19 +++++ 2 files changed, 140 insertions(+), 40 deletions(-) diff --git a/ag/clan/kampf_info.php b/ag/clan/kampf_info.php index a585864..db36287 100644 --- a/ag/clan/kampf_info.php +++ b/ag/clan/kampf_info.php @@ -11,6 +11,7 @@ include_once(ROOT_PATH.'/include/clan.inc.php'); include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php'); include_once(ROOT_PATH.'/include/parse.inc.php'); include_once(ROOT_PATH.'/include/char.inc.php'); +include_once(ROOT_PATH.'/include/user.inc.php'); defineIfNotDefined('DENY_CHALLENGE', 1); defineIfNotDefined('WITHDRAW_CHALLENGE', 2); @@ -25,6 +26,7 @@ $challangedclan_id = validateUnsignedInteger($_GET['challangedclan_id'], null); $inquirychallenge_clanid = validateUnsignedInteger($_GET['clanid'], null); $clan_challange_id = validateUnsignedInteger($_GET['challenge'], null); $char_id = validateUnsignedInteger($_GET['char'], null); +$type = validateUnsignedInteger($_GET['type'], null); //unkritisch if($action == null) { @@ -84,13 +86,28 @@ function displayDenyChallenge($clan_id, $type) { - ja';?> + ja';?> nein';?> - -
Slot '.$i.''; if($user_clan_chars[$i] != null) { $char = getChar($user_clan_chars[$i]); - echo ''.$char['name'].''; + $char_owner = getOwnerOfChar($char['id']); + echo ''.$char['name'].' '; + echo '('.$char_owner['nickname'].')'; if(isUserOwnerOf($user['id'], $char['id'])) { echo 'abmelden'; } @@ -270,7 +288,7 @@ function displayJoinChallenge($user, $clan_challenge_id, $char_id, $slot) { exit; } else { echo 'Der Charakter wurde erfoglreich angemeldet.

'; - echo 'weiter'; + echo 'weiter'; } } @@ -289,7 +307,43 @@ function displayLeaveChallenge($user, $clan_challenge_id, $char_id) { exit; } else { echo 'Der Charakter wurde erfoglreich abgemeldet.

'; - echo 'weiter'; + echo 'weiter'; + } +} + +function displayCancelChallenge($user, $clan_challange_id) { + if(!is_numeric($clan_challange_id)) { + displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink()); + return; + } + + ?> + + + + + + + + +
Clankampf wirklich abbrechen?
ja';?> + nein';?> +
+
- + @@ -348,37 +404,40 @@ function displayClanFightMenu($user) { + '; - echo ''; - echo ''; - } else { - echo ''; - echo ''; - echo ''; + if(count($open_challenge_requests) == 0) { + echo ''; + } else { + foreach ($open_challenge_requests as $challenge) { + $requester_clan = getClan($challenge['clan_requester']); + $challenged_clan = getClan($challenge['clan_challenged']); + + //unterscheidung zwischen herausforder und herausgeforderter + if($user_clan['id'] == $challenge['clan_requester']) { + echo ''; + echo ''; + echo ''; + } else { + echo ''; + echo ''; + echo ''; + } } } ?> +
HerausforderungenHerausforderungen
Clan herausfordernAnzahl Status
'.$challenged_clan['clanname'].''.formatTimestamp($challenge['challenged_time']).''.getFightType($challenge['type']).''.$challenge['anzahl_chars'].'ausstehend (zurückziehen)
'.$requester_clan['clanname'].''.formatTimestamp($challenge['challenged_time']).''.getFightType($challenge['type']).''.$challenge['anzahl_chars'].'annehmen |'; - echo 'ablehnen
Keine
'.$challenged_clan['clanname'].''.formatTimestamp($challenge['challenged_time']).''.getFightType($challenge['type']).''.$challenge['anzahl_chars'].'ausstehend (zurückziehen)
'.$requester_clan['clanname'].''.formatTimestamp($challenge['challenged_time']).''.getFightType($challenge['type']).''.$challenge['anzahl_chars'].'annehmen |'; + echo 'ablehnen
- offene Herausforderungen + offene Herausforderungen - - Keine - Keine'; } else { foreach ($open_challenge_ids as $oci) { $participating_clan_ids = getParticipatingClanIDs($oci); @@ -388,30 +447,47 @@ function displayClanFightMenu($user) { echo ''; echo ' '.$challenged_clan['clanname'].''; echo ''.anzeigen.''; + echo ''.abbrechen.''; echo ''; } } } ?> + + + Laufende Herausforderungen + + Keine'; + } else { + foreach ($active_clan_challange_ids as $acci) { + $participating_clan_ids = getParticipatingClanIDs($acci); + foreach ($participating_clan_ids as $pci) + if($pci != $user_clan['id']) { + $challenged_clan = getClan($pci); + echo ' '.$challenged_clan['clanname'].''; + //TODO: hier muss javascript fenster aufgerufen werden + echo ''.anzeigen.''; + } + } + } + ?> - Beendete Herausforderungen + Beendete Herausforderungen - Keine - Keine'; } 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 ''; - echo ' '.$challenged_clan['clanname'].''; - echo ''.anzeigen.''; - echo ''; + echo ' '.$challenged_clan['clanname'].''; + echo ''.anzeigen.''; } } } @@ -426,18 +502,17 @@ switch($action) { case 'challengeclan': displayChallengeClan($user_ida, $challangedclan_id); break; - case 'acceptchallenge': + case 'acceptclanchallenge': displayChallengeAccepted($user_ida, $inquirychallenge_clanid); break; - case 'q_denychallenge': + case 'q_denyclanchallenge': displayDenyChallenge($inquirychallenge_clanid, DENY_CHALLENGE); break; - case 'q_withdrawchallenge': + case 'q_withdrawclanchallenge': displayDenyChallenge($inquirychallenge_clanid, WITHDRAW_CHALLENGE); break; case 'denychallenge': - denyChallengeRequest($inquirychallenge_clanid, $user_ida); - displayClanFightMenu($user_ida); + denyChallenge($type, $inquirychallenge_clanid, $user_ida); break; case 'showchallenge': displayShowChallenge($clan_challange_id, $user_ida); @@ -451,6 +526,12 @@ switch($action) { case 'leavechallenge': displayLeaveChallenge($user_ida, $clan_challange_id, $char_id); break; + case 'q_cancelclanchallenge': + displayCancelChallenge($user_ida, $clan_challange_id); + break; + case 'cancelchallenge': + cancelThisChallenge($user_ida, $clan_challange_id); + break; default: displayClanFightMenu($user_ida); } diff --git a/ag/include/user.inc.php b/ag/include/user.inc.php index 072de70..1aed720 100644 --- a/ag/include/user.inc.php +++ b/ag/include/user.inc.php @@ -25,6 +25,25 @@ function getUser($userid, $buffer_enabled = true) { return $GLOBALS['user_buffered_instances'][$userid]; } +/** + * + * Returns the user of the Character. (attributes of the user-table should be added here if needed) + * @param unknown_type $charid + * @param unknown_type $buffer_enabled + */ +function getOwnerOfChar($charid, $buffer_enabled = true) { + // Fehlerkontrolle + if(!is_numeric($charid)){ + return null; + } + // Wenn Char nicht im Puffer ist, oder nicht gepuffert werden soll + if ($GLOBALS['user_buffered_instances'][$userid] == null || !$buffer_enabled) { + $user = mysql_fetch_assoc(mysql_query('SELECT u.nickname, u.id FROM user u INNER JOIN chars ch ON ch.besitzer=u.id WHERE ch.id = '.$charid)); + $GLOBALS['user_buffered_instances'][$userid] = $user; + } + return $GLOBALS['user_buffered_instances'][$userid]; +} + function addMoneyToUser($userid, $amount) { mysql_query('update user set geld = geld + ' . $amount . ' WHERE id = ' .$userid); }