From 7fc421699aaf330cee2d176f2443ff8ae3346bc9 Mon Sep 17 00:00:00 2001 From: hecht Date: Wed, 21 Dec 2011 22:05:09 +0000 Subject: [PATCH] added the restrictions and bonus features for clan level --- ag/clan/clan_info.php | 99 ++++++++++++++++++++++++++--------------- ag/include/clan.inc.php | 40 +++++++++++++++-- 2 files changed, 99 insertions(+), 40 deletions(-) diff --git a/ag/clan/clan_info.php b/ag/clan/clan_info.php index 7228342..629b32e 100644 --- a/ag/clan/clan_info.php +++ b/ag/clan/clan_info.php @@ -209,6 +209,7 @@ function displayClanProfileReadOnly($clan, $ownclan, $userid){   @@ -236,6 +237,17 @@ function displayClanProfileReadOnly($clan, $ownclan, $userid){ + +   + + + Clannachrichten erst ab Level verfügbar + + @@ -385,33 +397,48 @@ function displayClanProfileEditable($clan, $userid){ href="javascript:if(confirm('Wirklich auflösen? der Clan kann ggf. durch jemand übernommen werden!')==true) window.location.href='index.php?as=clan/clan_info&action=kill'">Clan auflösen (Achtung! Clans ggf. nur geleert!) - -   - - - -
- - - - - - - - - - - -
Nachricht an alle Clanmember schicken
 
 
-
- - - - + + +   + + + +
+ + + + + + + + + + + +
Nachricht an alle Clanmember schicken
 
 
+
+ + + + +   + + + Clannachrichten erst ab Level verfügbar + + + first filter the values of value2 that are in value1 $value2 = array_diff($value2, $value1); $clan = getClan($clanid); - + // now kick some asses ;) foreach($value1 as $member) { if($clan['leader'] == $member || $clan['coleader'] == $member) { @@ -492,7 +519,7 @@ function setProfile($user, $what, $value1, $value2, $clanid, $rootlvl){ fireMember($user, $member); } updateAuthorizedClanfightCoordinators($clanid, $value2); - + displayEdit($what, $clanid, $rootlvl); return NULL; default: @@ -563,20 +590,20 @@ function displayEdit($what, $clanid, $rootlvl){ $member[] = $row; } } - + $i = 0; - + // Kay, first display the chief if($leader != NULL) { $content .= '' . $leader['nickname'] . ''.PHP_EOL; $i++; } - + if($coleader != null) { $content .= '' . $coleader['nickname'] . ''.PHP_EOL; $i++; } - + foreach($member as $memb) { if(in_array($memb['id'], $authorized)) { $checked = 'checked="checked"'; @@ -585,11 +612,11 @@ function displayEdit($what, $clanid, $rootlvl){ } $content .= '' . $memb['nickname'] . ''.PHP_EOL; $i++; - } - + } + $content .= '
'.PHP_EOL; $content .= ''.PHP_EOL.''; - + break; case 'ERROR': break; diff --git a/ag/include/clan.inc.php b/ag/include/clan.inc.php index f1c6c2f..ac994cb 100644 --- a/ag/include/clan.inc.php +++ b/ag/include/clan.inc.php @@ -9,7 +9,10 @@ include_once (ROOT_PATH . '/include/defines.inc.php'); include_once (ROOT_PATH . '/include/clan_fights.inc.php'); include_once (ROOT_PATH . '/include/exp.inc.php'); +include_once (ROOT_PATH . '/include/messagefunctions.inc.php'); +include_once (ROOT_PATH . '/include/designfunctions.inc.php'); +defineIfNotDefined('CLAN_LVL_NEWSLETTER', 2); defineIfNotDefined('MAX_CHARS_CLANSIGN', 8); $GLOBALS['clan_buffered_instances'] = array (); @@ -67,6 +70,21 @@ function getClanMemberBonusByLevel($level) { } } + +function getMoneyBonusByLevel($level) { + switch($level) { + case 12: + case 14: + case 16: + case 17: + return 100000; + default: + return 0; + } +} + + + function getMaximumMembers($clanid) { // okay, this is a more tricky calculation as this requires the information (are leader and co_leader the same person??) // the second parameter is the clan level. Each 2 levels (where the maximum clan level is about 20) one more member can @@ -310,10 +328,17 @@ function setMeAsLeader($user){ } -function sendClanNewsletter($user, $text){ - $qry = mysql_query('SELECT * FROM clan WHERE id = ' . $user['clan']); - $clan = mysql_fetch_assoc($qry); +function isClanNewsletterAvailable($clanid) { + $clan = getClan($clanid); + return $clan['level'] >= CLAN_LVL_NEWSLETTER; +} +function sendClanNewsletter($user, $text){ + $clan = getClan($user['clan']); + if(!isClanNewsletterAvailable($clan['id'])) { + displayErrorMessage(NULL,'Dein Clan hat noch nicht das ausreichende Level um Clannachrichten zu senden!', 'weiter...'); + return; + } $errors = FALSE; $sql = 'SELECT id FROM user WHERE clan='.$user['clan']; $clans = mysql_query($sql); @@ -328,6 +353,7 @@ function sendClanNewsletter($user, $text){ } + function addClanExp($clan_id, $exp) { $clan = getClan($clan_id, false); if($clan['level'] == 18) @@ -342,8 +368,14 @@ function addClanExp($clan_id, $exp) { mysql_query('UPDATE clan SET exp = ' .$n_exp. ', level = ' .$n_level . ' WHERE id = ' .$clan_id . ' AND exp = ' .$clan['exp'] . ' AND level = ' .$clan['level']); if(mysql_affected_rows() == 0) { echo 'Fehler beim zuweisen der Clanexp, dadurch sind dem Clan mit der ID ' . $clan['level'] . ' ' .$exp . ' exp fl&omul;ten gegangen!! Neue exp wären ' . $n_exp . ' bei level ' .$n_level; + } else { + $money = getMoneyBonusByLevel($n_level); + if($money > 0) { + // nice we can give the clan some money :D + insertClanTickerMessage($clan_id, 'Durch Erreichen von Level ' .$n_level . ' habt ihr ' . displayMoney($money) . ' bekommen!!'); + mysql_query('UPDATE clan SET geld = geld + ' . $money . ' WHERE id = ' .$clan_id ); + } } } - ?>