checked in the current state of the clan fights. most of the functions are not yet tested and may contain bugs! The databases are sill work in progress (e.g. the codebase for blocking the char is not yet started). But it is a really good point to begin the implementation of the presentation!

main
hecht 13 years ago
parent 0535167230
commit f6fea3bfa0

@ -7,6 +7,7 @@
*/ */
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan.inc.php'); include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan_fights.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/fehlerausgabe.inc.php'); include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/fehlerausgabe.inc.php');
@ -52,7 +53,7 @@ if(isset($_GET['value1']) || isset($_GET['value2'])) {
break; break;
case 'Clanzeichen': case 'Clanzeichen':
$value1 = validateString($_GET['value1']); $value1 = validateString($_GET['value1']);
$value2 = validateString($_GET['value2']); $value2 = validateString($_GET['value2']);
break; break;
case 'Leadership': case 'Leadership':
$value1 = validateUnsignedInteger($_GET['value1'], NULL); $value1 = validateUnsignedInteger($_GET['value1'], NULL);
@ -68,7 +69,7 @@ function displayClanProfileReadOnly($clan, $ownclan, $userid){
$count = mysql_num_rows($member_qry); $count = mysql_num_rows($member_qry);
$member = array(); $member = array();
while($row = mysql_fetch_assoc($member_qry)){ while($row = mysql_fetch_assoc($member_qry)){
$tmp = displayUserLinkByID($row['id']); $tmp = generateUserLinkByID($row['id']);
if($row['id'] == $userid){ if($row['id'] == $userid){
$member[] = $tmp.' (<a href="index.php?as=clan/clan_info&action=fire&member='.$row['id'].'">verlassen</a>)'; $member[] = $tmp.' (<a href="index.php?as=clan/clan_info&action=fire&member='.$row['id'].'">verlassen</a>)';
} else{ } else{
@ -86,9 +87,25 @@ function displayClanProfileReadOnly($clan, $ownclan, $userid){
$invited = array(); $invited = array();
while($row = mysql_fetch_assoc($inv_qry)) { while($row = mysql_fetch_assoc($inv_qry)) {
$invited[] = displayUserLinkByID($row['userid']) . ' (noch ' . $row['till'] . 'h gültig)'; $invited[] = generateUserLinkByID($row['userid']) . ' (noch ' . $row['till'] . 'h gültig)';
}
if(count($invited) == 0) {
$invited[] = 'Keine';
}
$openChallengeRequests = getOpenChallengeRequests($clan['id']);
// okay now we split into challenges we have done and we have received
foreach($openChallengeRequests as $request) {
if($request['clan_requester'] != $clan['id']) {
$openChallengeRequestsDisplay[] = displayClanLink($request['clan_requester']) ;
} else {
$openChallengeRequestsDisplay[] = displayClanLink($request['clan_challenged']) ;
}
} }
?> ?>
<div align="center"> <div align="center">
<table width="100%"> <table width="100%">
@ -137,27 +154,38 @@ function displayClanProfileReadOnly($clan, $ownclan, $userid){
<td><?php echo join('<br>',$member); ?></td> <td><?php echo join('<br>',$member); ?></td>
</tr> </tr>
<?php <?php
if($ownclan) { if($ownclan && count($invited) > 0) {
?> ?>
<tr> <tr>
<th align="Left">Eingeladen</th> <th align="Left">Eingeladen:</th>
<td><?php echo join('<br>', $invited); ?></td> <td><?php echo join('<br>', $invited); ?></td>
</tr> </tr>
<?php <?php
} }
?> ?>
<?php
if(count($openChallengeRequestsDisplay) > 0) {
?>
<tr>
<th align="Left">Herausforderungen:</th>
<td><?php echo join('<br>', $openChallengeRequestsDisplay); ?></td>
</tr>
<?php
}
?>
<tr> <tr>
<th align="Left" height="25">Level:</th> <th align="Left" height="25">Level:</th>
<td><?php echo $clan['level']; ?></td> <td><?php echo $clan['level']; ?></td>
</tr> </tr>
<tr> <tr>
<th align="Left" height="25">Erfahrung: </th> <th align="Left" height="25">Erfahrung:</th>
<td><?php echo $clan['exp'].' / '.getRequiredClanExp($clan['level']); ?></td> <td><?php echo $clan['exp'].' / '.getRequiredClanExp($clan['level']); ?>
</td>
</tr>
<tr>
<th align="Left" height="25">ELO-Wertung:</th>
<td><?php echo $clan['elo']; ?></td>
</tr> </tr>
<tr>
<th align="Left" height="25">ELO-Wertung: </th>
<td><?php echo $clan['elo']; ?></td>
</tr>
<tr> <tr>
<th width="96" height="25" align="Left">Homepage:</th> <th width="96" height="25" align="Left">Homepage:</th>
<?php <?php
@ -175,7 +203,9 @@ function displayClanProfileReadOnly($clan, $ownclan, $userid){
<?php <?php
if($ownclan) { if($ownclan) {
?> ?>
<tr><td>&nbsp;</td></tr> <tr>
<td>&nbsp;</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
@ -236,7 +266,23 @@ function displayClanProfileEditable($clan, $userid){
$invited = array(); $invited = array();
while($row = mysql_fetch_assoc($inv_qry)) { while($row = mysql_fetch_assoc($inv_qry)) {
$invited[] = displayUserLinkByID($row['userid']) . ' (noch ' . $row['till'] . 'h gültig, <a href="index.php?as=clan/clan_info&action=reject&member='.$row['userid'].'">zurückziehen</a>)'; $invited[] = generateUserLinkByID($row['userid']) . ' (noch ' . $row['till'] . 'h gültig, <a href="index.php?as=clan/clan_info&action=reject&member='.$row['userid'].'">zurückziehen</a>)';
}
if(count($invited) == 0) {
$invited[] = 'Keine';
}
$openChallengeRequests = getOpenChallengeRequests($clan['id']);
// okay now we split into challenges we have done and we have received
foreach($openChallengeRequests as $request) {
if($request['clan_requester'] != $clan['id']) {
$openChallengeRequestsDisplay[] = displayClanLink($request['clan_requester']) . ' (annehmen)';
} else {
$openChallengeRequestsDisplay[] = displayClanLink($request['clan_challenged']) . ' (zur&uuml;ckziehen)';
}
} }
@ -274,25 +320,42 @@ function displayClanProfileEditable($clan, $userid){
<td><?php echo $clan['clanz_pre'].' '.$clan['clanz_suff']; ?></td> <td><?php echo $clan['clanz_pre'].' '.$clan['clanz_suff']; ?></td>
</tr> </tr>
<tr> <tr>
<th align="Left">Member (<?php echo $count.'/'.getMaximumMembers($clan['id']); ?>):</th> <th align="Left">Member (<?php echo $count.'/'.getMaximumMembers($clan['id']); ?>):</th>
<td><?php echo join('<br>',$member); ?></td> <td><?php echo join('<br>',$member); ?></td>
</tr> </tr>
<?php
if(count($invited) > 0) {
?>
<tr> <tr>
<th align="Left">Eingeladen</th> <th align="Left">Eingeladen:</th>
<td><?php echo join('<br>', $invited); ?></td> <td><?php echo join('<br>', $invited); ?></td>
</tr> </tr>
<?php
}
?>
<?php
if(count($openChallengeRequestsDisplay) > 0) {
?>
<tr>
<th align="Left">Herausforderungen:</th>
<td><?php echo join('<br>', $openChallengeRequestsDisplay); ?></td>
</tr>
<?php
}
?>
<tr> <tr>
<th align="Left" height="25">Level:</th> <th align="Left" height="25">Level:</th>
<td><?php echo $clan['level']; ?></td> <td><?php echo $clan['level']; ?></td>
</tr> </tr>
<tr> <tr>
<th align="Left" height="25">Erfahrung: </th> <th align="Left" height="25">Erfahrung:</th>
<td><?php echo $clan['exp'].' / '.getRequiredClanExp($clan['level']); ?></td> <td><?php echo $clan['exp'].' / '.getRequiredClanExp($clan['level']); ?>
</tr> </td>
<tr> </tr>
<th align="Left" height="25">ELO-Wertung: </th> <tr>
<td><?php echo $clan['elo']; ?></td> <th align="Left" height="25">ELO-Wertung:</th>
</tr> <td><?php echo $clan['elo']; ?></td>
</tr>
<tr> <tr>
<th align="Left" height="25">Homepage:<a <th align="Left" height="25">Homepage:<a
href="index.php?as=clan/clan_info&action=edit&what=Homepage">(edit)</a> href="index.php?as=clan/clan_info&action=edit&what=Homepage">(edit)</a>
@ -316,7 +379,9 @@ function displayClanProfileEditable($clan, $userid){
href="javascript:if(confirm('Wirklich l&ouml;schen?')==true) window.location.href='index.php?as=clan/clan_info&action=kill'">Clan href="javascript:if(confirm('Wirklich l&ouml;schen?')==true) window.location.href='index.php?as=clan/clan_info&action=kill'">Clan
l&ouml;schen</a></td> l&ouml;schen</a></td>
</tr> </tr>
<tr><td>&nbsp;</td></tr> <tr>
<td>&nbsp;</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
@ -346,7 +411,7 @@ function displayClanProfileEditable($clan, $userid){
function displayClanProfile($clanid, $user){ function displayClanProfile($clanid, $user){
$clan = getClan($clanid, FALSE); $clan = getClan($clanid, FALSE);
if(!$clan) { if(!$clan) {
echo displayErrorMessage(NULL, 'Es gibt den Clan mit der ID ' .$clanid.' nicht oder nicht mehr!', displayHistoryBackLink()); echo displayErrorMessage(NULL, 'Es gibt den Clan mit der ID ' .$clanid.' nicht oder nicht mehr!', displayHistoryBackLink());
return; return;
} }
@ -432,9 +497,9 @@ function setProfile($what, $value1, $value2, $clanid, $rootlvl){
function displayEdit($what, $clanid, $rootlvl){ function displayEdit($what, $clanid, $rootlvl){
if($rootlvl < 1) { if($rootlvl < 1) {
$content = '<tr><td colspan="2">Du hast keine Rechte um diese Aktion auszuf&uuml;hren!</td></tr>'; $content = '<tr><td colspan="2">Du hast keine Rechte um diese Aktion auszuf&uuml;hren!</td></tr>';
$what = 'ERROR'; $what = 'ERROR';
} }
$clan = getCLan($clanid); $clan = getCLan($clanid);
$content = ''; $content = '';
@ -501,26 +566,6 @@ function displayEdit($what, $clanid, $rootlvl){
<?php <?php
} }
function fireMember($user, $member){
$row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user['clan']));
if($member != $row['leader'] && $member != $row['co_leader'] && ($user['id'] == $row['leader'] || $user['id'] == $row['co_leader'] || $member == $user['id'])){
$sql = 'Update user set clan = NULL where id = '.$member.' AND clan = '.$user['clan'];
// echo $sql.'<br>';
mysql_query($sql);
if(mysql_affected_rows() > 0){ // Soll nur ausgeführt werden, wenn member wirklich gekickt wurde!!
$sql = 'Update chars set clan_train = NULL where besitzer = '.$member;
mysql_query($sql);
if($user['id'] != $member) {
sendMessage($user['nickname'], $member, 'Clan rauswurf!', 'Du wurdest von '.$user['nickname'].' aus deinem Clan geworfen. Du wirst dir wohl einen neuen suchen m&uuml;ssen!');
} else if(getClanMembersCount($user['clan']) == 0) {
mysql_query('DELETE FROM clan WHERE id =' .$user['clan']);
}
}
} else{
echo displayErrorMessage(NULL, 'Du kannst den Member nicht feuern!', displayHistoryBackLink());
}
}
function deleteClan($user){ function deleteClan($user){
$row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user['clan'])); $row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user['clan']));
if($user['id'] == $row['leader']){ if($user['id'] == $row['leader']){
@ -561,9 +606,9 @@ if($action !== NULL) { // this is done to not require to reprogramm the whole st
$displayMore = false; $displayMore = false;
} }
if($errorMsg !== NULL) { if($errorMsg !== NULL) {
echo displayErrorMessage(NULL, $errorMsg, displayHistoryBackLink()); echo displayErrorMessage(NULL, $errorMsg, displayHistoryBackLink());
$displayMore = false; $displayMore = false;
} }
break; break;
case 'fire': case 'fire':

@ -11,7 +11,7 @@ $GLOBALS['clan_buffered_instances'] = array ();
function getClan($clanid, $buffer = TRUE) { function getClan($clanid, $buffer = TRUE) {
if(!is_numeric($clanid)) { return NULL; } if(!is_numeric($clanid) || $clanid === NULL) { return NULL; }
if(buffer && isset($GLOBALS['clan_buffered_instances'][$clanid])) { if(buffer && isset($GLOBALS['clan_buffered_instances'][$clanid])) {
return $GLOBALS['clan_buffered_instances'][$clanid]; // okay, we already buffered the clan :) return $GLOBALS['clan_buffered_instances'][$clanid]; // okay, we already buffered the clan :)
} }
@ -160,149 +160,28 @@ function inviteUser(array $user, $userid, array $clan = NULL){
} }
} }
define("DAVY_BACK_FIGHT", 1); function fireMember($user, $member){
define("SURVIVAL", 2); $row = mysql_fetch_assoc(mysql_query('SELECT leader, co_leader from clan where id = '.$user['clan']));
if($member != $row['leader'] && $member != $row['co_leader'] && ($user['id'] == $row['leader'] || $user['id'] == $row['co_leader'] || $member == $user['id'])){
/** $sql = 'Update user set clan = NULL where id = '.$member.' AND clan = '.$user['clan'];
* // echo $sql.'<br>';
* Challenge an other clan (Davy Back Fight) mysql_query($sql);
* @param array $user the user array if(mysql_affected_rows() > 0){ // Soll nur ausgeführt werden, wenn member wirklich gekickt wurde!!
* @param int $clanid the id of the clan to challenge $sql = 'Update chars set clan_train = NULL where besitzer = '.$member;
* @param int $validTime the amount of hours that the challenge is valid mysql_query($sql);
*/ if($user['id'] != $member) {
function challengeClan(array $user, $clanid, $type = DAVY_BACK_FIGHT, $anzahl, $validTime = 24) { sendMessage($user['nickname'], $member, 'Clan rauswurf!', 'Du wurdest von '.$user['nickname'].' aus deinem Clan geworfen. Du wirst dir wohl einen neuen suchen m&uuml;ssen!');
$qry = mysql_query('SELECT * FROM clan WHERE id = ' . $user['clan']); } else if(getClanMembersCount($user['clan']) == 0) {
$clan = mysql_fetch_assoc($qry); mysql_query('DELETE FROM clan WHERE id =' .$user['clan']);
}
$oclan = mysql_fetch_assoc(mysql_query('SELECT * FROM clan WHERE id = ' . $clanid));
// delete the participation in open clan fights! Thats tricky because the user itself is not stored in the database!!
if(!$clan || !$oclan) { mysql_query('DELETE FROM clan_challenge_participants WHERE clan_challenge_id in (SELECT clan_challenge_id FROM clan_challenge where calculated = FALSE) and char_id IN (Select id FROM chars where besitzer = '.$user['id'].')');
return 'Entweder bist du nicht in einem Clan oder der andere Clan existiert nicht mehr!!'; }
} } else{
echo displayErrorMessage(NULL, 'Du kannst den Member nicht feuern!', displayHistoryBackLink());
if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){ }
return 'Nur der Leader, bzw. der Co-Leader kann andere Clans herausfordern!!';
}
// Fordere heraus!
mysql_query('INSERT INTO clan_challenge(clan_requester, clan_challenged, type, anzahl, valid, accepted) VALUES('.$user['clan'].', '.$clanid.','.$type.' , TIMESTAMPADD(HOUR, CURRENT_TIMESTAMP, 4), '.$anzahl.', false)');
if(mysql_affected_rows() > 0) {
if(is_numeric($oclan['leader'])) {
sendMessage($user['nickname'], $oclan['leader'], 'Davy Back Fight Herausforderung', 'Der Clan '.$oclan['clanname'].' hat euch zu einem Davy Back Fight herausgefordert! Über "Mein Clan" könnt ihr die Herausforderung annehmen!');
}
if(is_numeric($oclan['co_leader']) && $oclan['leader'] != $oclan['co_leader']) {
sendMessage($user['nickname'], $oclan['co_leader'], 'Davy Back Fight Herausforderung', 'Der Clan '.$oclan['clanname'].' hat euch zu einem Davy Back Fight herausgefordert! Über "Mein Clan" könnt ihr die Herausforderung annehmen!');
}
} else {
return 'Konnte den anderen Clan nicht herausfordern!!';
}
return NULL;
}
function acceptChallenge($challengeid, array $user) {
$qry = mysql_query('Select * from clan where id = ' . $user['clan']);
$clan = mysql_fetch_assoc($qry);
if(!$clan) {
return 'Du bist in keinem Clan!!';
}
if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){
return 'Nur der Leader, bzw. der Co-Leader kann herausforderungen anderer Clans annehmen!!';
}
$clan_challenge = mysql_fetch_assoc(mysql_query('SELECT * FROM clan_challenge WHERE clan_challenge_id = ' .$challengeid));
if($user['clan'] != $clan_challenge['clan_challenged']) {
return 'Du kannst die Herausforderung nicht annehmen, da du nicht im herausgeforderten Clan bist!';
}
// The user must be in the challanged clan
$oclan = mysql_fetch_assoc('SELECT * FROM clan WHERE id = '.$clan_challenge['clan_requester']);
mysql_query('UPDATE clan_challenge SET accepted = TRUE WHERE clan_challenge_id = ' .$challengeid);
if(mysql_affected_rows() > 0) {
if(is_numeric($oclan['leader'])) {
sendMessage($user['nickname'], $oclan['leader'], 'Davy Back Fight', 'Der Clan '.$oclan['clanname'].' hat eure Herausforderungen zu einem Davy Back Fight angenommen! Über "Mein Clan" könnt ihr nun Chars anmelden!');
}
if(is_numeric($oclan['co_leader']) && $oclan['leader'] != $oclan['co_leader']) {
sendMessage($user['nickname'], $oclan['co_leader'], 'Davy Back Fight', 'Der Clan '.$oclan['clanname'].' hat eure Herausforderungen zu einem Davy Back Fight angenommen! Über "Mein Clan" könnt ihr nun Chars anmelden!');
}
} else {
return 'Du kannst die Herausforderungen nicht annehmen. Wurde die Herausforderung schon angenommen?';
}
return NULL;
}
function getOpenChallengesByUser(array $user) {
$qry = mysql_query('SELECT * FROM clan_challenge WHERE accepted = FALSE AND clan_requester = '.$user['clan'].' OR clan_challenged = '.$user['clan']);
$array = array();
while($row = mysql_fetch_assoc($qry)) {
$array[] = $row;
}
return $array;
}
function getOpenChallengesByClanId($clanid) {
$qry = mysql_query('SELECT * FROM clan_challenge WHERE accepted = FALSE AND clan_requester = '.$clanid.' OR clan_challenged = '.$clanid);
$array = array();
while($row = mysql_fetch_assoc($qry)) {
$array[] = $row;
}
return $array;
}
/**
* This function lets a user take part in the clan fight! The clan fight will be calculated if all chars have been registered.
* A challenge can only be joined if there is no other char of the same user joined. If the given slot is free and the challangeid is valid.
* @param int $challengeid the id of the challenge
* @param array $user the user array
* @param int $charid the id of the char that should join
*/
function joinChallenge($challengeid, array $user, $charid, $slot ) {
$qry = mysql_query('Select * from clan where id = ' . $user['clan']);
$clan = mysql_fetch_assoc($qry);
if(!$clan) {
return 'Du bist in keinem Clan!!';
}
$clan_challenge = mysql_fetch_assoc(mysql_query('SELECT * FROM clan_challenge WHERE clan_challenge_id = ' .$challengeid));
if($user['clan'] != $clan_challenge['clan_challenged'] && $user['clan'] != $clan_challenge['clan_requester'] ) {
return 'Du kannst an der Herausforderung nicht teilnehmen, da du nicht in einem teilnehmenden Clan bist!';
}
$char = getChar($charid);
if($user['id'] != $char['besitzer']) {
return 'Du kannst den Char nicht an der Herausforderung teilnehmen lassen, da er dir nicht gehört!';
}
// query all clan_challange_participants to see if the user already has a char in competition!
}
/**
* This function does the calculation of the clan fight.
* @param int $challengeid the id of the challenge
*/
function calculateChallenge($challengeid) {
} }
?> ?>

@ -0,0 +1,502 @@
<?php
/*
*
* @copyright (c) 2011 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/clan.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/semaphore.inc.php');
define("MIN_MEMBERS", 5);
define("MAX_OPEN_REQUESTS", 3);
define("DAVY_BACK_FIGHT", 1);
define("SURVIVAL", 2);
define("ATTACK_SET_DAVY_BACK_FIGHT", 2);
define("ATTACK_SET_SURVIVAL", 2);
$GLOBALS['clan_challenge_buffered_instances'] = array ();
// Methods required within the request/accept phase
/**
*
* Challenge an other clan (Davy Back Fight)
* @param array $user the user array
* @param int $clanid the id of the clan to challenge
* @param int $validTime the amount of hours that the challenge is valid
*/
function challengeClan(array $user, $clanid, $type = DAVY_BACK_FIGHT, $anzahl, $validTime = 24) {
$clan = getClan($user['clan']);
$oclan = getClan($clanid);
$ressource_clan1 = 'Clan:' . $user['clan'];
$ressource_clan2 = 'Clan:' . $clanid;
if(!$clan || !$oclan) {
return 'Entweder bist du nicht in einem Clan oder der andere Clan existiert nicht mehr!!';
}
if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){
return 'Nur der Leader, bzw. der Co-Leader kann andere Clans herausfordern!!';
}
if(isClanLocked($user['clan']) || isClanLocked($clanid)) {
// okay we cannot accept the challenge so make it inactive!
mysql_query('UPDATE clan_challenge_requests SET active = FALSE WHERE clan_challenge_id = ' .$clan_challenge_id);
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! ';
}
if(!semaphoreUP($ressource_clan2)) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
return 'Fehler beim Verarbeiten der Anfrage für \'' . $oclan['clanname'] . '\' versuche es bitte nochmal! ';
}
// okay we have both semaphores :)
$clan_challenges_my_clan = getOpenChallengesRequestCount($user['clan']);
$clan_challenges_oth_clan = getOpenChallengesRequestCount($clanid);
if($clan_challenges_my_clan > MAX_OPEN_REQUESTS) {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Dein Clan hat schon die maximale Anzahl von Herausforderungen offen!';
}
if($clan_challenges_oth_clan > MAX_OPEN_REQUESTS) {
semaphoreDown($ressource_clan1); // 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!';
}
// select count(*) from clan_challenge_requests where challenged_time > TIMESTAMPADD(day, -1, now()) and active = TRUE
// Fordere heraus!
mysql_query('INSERT INTO clan_challenge(clan_requester, clan_challenged, type, anzahl, valid, accepted) VALUES('.$user['clan'].', '.$clanid.','.$type.' , TIMESTAMPADD(HOUR, CURRENT_TIMESTAMP, 4), '.$anzahl.', false)');
if(mysql_affected_rows() > 0) {
if(is_numeric($oclan['leader'])) {
sendMessage($user['nickname'], $oclan['leader'], 'Clan-Fight Herausforderung', 'Der Clan '.$oclan['clanname'].' hat euch zu einem Clan-Fight herausgefordert! Über "Mein Clan" könnt ihr die Herausforderung annehmen!');
}
if(is_numeric($oclan['co_leader']) && $oclan['leader'] != $oclan['co_leader']) {
sendMessage($user['nickname'], $oclan['co_leader'], 'Clan-Fight Herausforderung', 'Der Clan '.$oclan['clanname'].' hat euch zu einem Clan-Fight herausgefordert! Über "Mein Clan" könnt ihr die Herausforderung annehmen!');
}
} else {
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return 'Konnte den anderen Clan nicht herausfordern!!';
}
semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
return NULL;
}
/**
* With this function the actual user accepts the challenge request from another clan!
* @param int $clan_challenge_id
* @param array $user
*/
function acceptChallengeRequest($clan_challenge_id, array $user) {
$clan = getClan($user['clan']);
if(!$clan) {
return 'Du bist in keinem Clan!!';
}
if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){
return 'Nur der Leader, bzw. der Co-Leader kann herausforderungen anderer Clans annehmen!!';
}
$clan_challenge = mysql_fetch_assoc(mysql_query('SELECT * FROM WHERE clan_challenge_id = ' .$clan_challenge_id));
if($user['clan'] != $clan_challenge['clan_challenged']) {
return 'Du kannst die Herausforderung nicht annehmen, da du nicht im herausgeforderten Clan bist!';
} else if ($clan_challenge['active'] != 1) {
return 'Du kannst die Herausforderung nicht annehmen, da diese schon angenommen wurde!';
}
if(isClanLocked($clan_challenge['clan_challenged']) || isClanLocked($clan_challenge['clan_requester'])) {
// okay we cannot accept the challenge so make it inactive!
mysql_query('UPDATE clan_challenge_requests SET active = FALSE WHERE clan_challenge_id = ' .$clan_challenge_id);
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
$oclan = getClan($clan_challenge['clan_requester']);
mysql_query('UPDATE clan_challenge_requests SET accepted = TRUE WHERE clan_challenge_id = ' .$clan_challenge_id);
if(mysql_affected_rows() > 0) {
if(is_numeric($oclan['leader'])) {
sendMessage($user['nickname'], $oclan['leader'], 'Clan-Fight', 'Der Clan '.$oclan['clanname'].' hat eure Herausforderungen zu einem Clan-Fight angenommen! Über "Mein Clan" könnt ihr nun Chars anmelden!');
}
if(is_numeric($oclan['co_leader']) && $oclan['leader'] != $oclan['co_leader']) {
sendMessage($user['nickname'], $oclan['co_leader'], 'Clan-Fight', 'Der Clan '.$oclan['clanname'].' hat eure Herausforderungen zu einem Clan-Fight angenommen! Über "Mein Clan" könnt ihr nun Chars anmelden!');
}
$finished = FALSE;
$id = -1;
// get id
while(!$finished) {
$row = mysql_fetch_row(mysql_query('select IFNULL(max(clan_challenge_id),0) + 1 from clan_challenge'));
mysql_query('INSERT INTO clan_challenge(clan_challenge_id) values('.$row[0].')');
$finished = mysql_affected_rows();
$id = $row[0];
}
// 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, elo) values('.$id.', '.$oclan['id'].', '.$clan['elo'].')');
// we have everything we need for this challenge to be opened :)
} else {
return 'Du kannst die Herausforderungen nicht annehmen. Wurde die Herausforderung schon angenommen?';
}
return NULL;
}
/**
* With this function the actual user from the challenged clan denies the challenge request!
* @param int $clan_challenge_id
* @param array $user
*/
function denyChallengeRequest($clan_challenge_id, array $user) {
$clan = getClan($user['clan']);
if(!$clan) {
return 'Du bist in keinem Clan!!';
}
if($clan['leader'] != $user['id'] && $clan['co_leader'] != $user['id']){
return 'Nur der Leader, bzw. der Co-Leader kann Herausforderungen anderer Clans ablehnen!!';
}
$clan_challenge = mysql_fetch_assoc(mysql_query('SELECT * FROM WHERE clan_challenge_id = ' .$clan_challenge_id));
if($user['clan'] != $clan_challenge['clan_challenged']) {
return 'Du kannst die Herausforderung nicht ablehnen, da du nicht im herausgeforderten Clan bist!';
} else if ($clan_challenge['active'] != 1) {
return 'Du kannst die Herausforderung nicht ablehnen, da diese schon angenommen wurde!';
}
// okay seems to be okay
mysql_query('UPDATE clan_challenge_requests SET active = FALSE WHERE clan_challenge_id = ' .$clan_challenge_id);
return NULL;
}
/**
* Reads out the given date from the table "clan_challenge"
* @param int $challenge_id
* @param bool $buffer
*/
function getChallenge($challenge_id, $buffer = TRUE) {
if(buffer && isset($GLOBALS['clan_challenge_buffered_instances'][$challenge_id])) {
return $GLOBALS['clan_challenge_buffered_instances'][$challenge_id]; // okay, we already buffered the clan :)
}
}
function getOpenChallengeRequests($clanid) {
$array = array();
if(isClanLocked($clanid)) {
return $array;
}
$sql = 'SELECT * from clan_challenge_requests where challenged_time > TIMESTAMPADD(day, -1, now()) and active = TRUE AND clan_requester = '.$clanid.' OR clan_challenged = '.$clanid;
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
$array[] = $row;
}
return $array;
}
function getOpenChallengeRequestCount($clanid) {
if(isClanLocked($clanid)) {
return 0;
}
$sql = 'SELECT count(*) from clan_challenge_requests where challenged_time > TIMESTAMPADD(day, -1, now()) and active = TRUE AND clan_requester = '.$clanid.' OR clan_challenged = '.$clanid;
$row = mysql_fetch_row(mysql_query($sql));
return $row[0];
}
// this method returns the challenge ids for open fights
function getOpenChallengeIDs($clanid) {
// before doing anything check if we are locked
$array = array();
if(isClanLocked($clanid)) {
return $array;
}
$sql = 'SELECT cc.clan_challenge_id FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE clan_id = ' . $clanid . ' AND calculated = FALSE';
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$array[] = $row[0];
}
// return the ids
return $array;
}
function getParticipatingClanIDs($clan_challenge_id) {
$array = array();
$sql = 'SELECT clan_id FROM clan_challenge_clans AS ccp WHERE clan_challenge_id = ' . $clan_challenge_id;
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$array[] = $row[0];
}
// return the ids
return $array;
}
function getParticipatingCharIDs($clan_challenge_id, $clan_id) {
$array = array();
$sql = 'SELECT char_id, slot FROM clan_challenge_participants WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = ' .$clan_id;
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
$array['slot'] = $row['char_id'];
}
// return the ids
return $array;
}
// returns the last challenge ids (beginning with the latest to the first)
function getHistoricalChallengeIDs($clanid, $limit = NULL) {
$addition = '';
if($limit !== null && is_numeric($limit)) {
$addition = ' LIMIT ' .$limit;
}
$sql = 'SELECT cc.clan_challenge_id FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE clan_id = ' . $clanid . ' AND calculated = TRUE ORDER BY cc.date DESC ' . $addition;
$qry = mysql_query($sql);
while($row = mysql_fetch_row($qry)) {
$array[] = $row[0];
}
// return the ids
return $array;
}
// Checks if the clan is locked, will lock it if required!
function isClanLocked($clanid) {
// we really want to know if we are locked at the moment. So readout everything at once ;), right join so we always have a row :D
$sql = 'SELECT *, locked_until < now(), (Select count(id) from user where clan = c2.id) as members FROM clan_locked right join clan c2 on c2.id = clan_locked.clanid where c2.id = ' . $clanid;
$lock = mysql_fetch_assoc(mysql_query($sql));
if($lock['lock'] == 0) { // don't matter if it is 0 or NULL
// we do not have data in the clan locked table so we are not locked :D
// or
// we do have data but it seems we are not locked anymore ;)
// are we still having enough members??
if($lock['members'] >= MIN_MEMBERS) {
// key so every thing seems to be fine :)
return false; // the only case we may return false!
} else if($lock['lock'] === NULL){ // we need to insert a row
// INSERT
mysql_query('INSERT INTO clan_locked(clanid, locked_until) values('.$clanid.', TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP)');
} else { // we have to update the actual row
// UPDATE
mysql_query('UPDATE clan_locked set locked_until = TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP) WHERE clanid = ' .$clanid);
}
}
return true;
}
/**
* This function lets a user take part in the clan fight! The clan fight will be calculated if all chars have been registered.
* A challenge can only be joined if there is no other char of the same user joined. If the given slot is free and the challangeid is valid.
* @param int $clan_challenge_id the id of the challenge
* @param array $user the user array
* @param int $charid the id of the char that should join
*/
function joinChallenge($clan_challenge_id, array $user, $charid, $slot ) {
$clan = getClan($user['clan']);
$char = getChar($charid);
if(!$clan) {
return 'Du bist in keinem Clan!!';
}
if($char['besitzer'] != $user['id']) {
return 'Du kannst den Char nicht an dem Kampf teilnehmen lassen, da er dir nicht gehört!';
}
$clan_challenge = getChallenge($clan_challenge_id);
$clan_ids = getParticipatingClanIDs($clan_challenge['clan_challenge_id']);
if(array_search($user['clan'], $clan_ids) === FALSE) {
// the clan does not match a participant!!
return 'Du bist in keinem Clan der an dieser Challenge teilnimmt!';
}
// block the user actions so we can ensure he won't register multiple of its chars here!
$resource = 'User:'.$user['id'];
if(!semaphoreUP($ressource)) {
return 'Du kannst den Char nicht an dem Kampf teilnehmen lassen, da du scheinbar gerade auch mit was anderem beschäftigt bist, versuche es bitte nochmal!';
}
foreach ($clan_ids as $clan_id) {
if(isClanLocked($clan_id)) {
mysql_query('DELETE FROM clan_challenges WHERE clan_challenge_id = '.$clan_challenge_id);
semaphoreDown($ressource);
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
}
// okay, now try to update the challenge to close the challenge and to start the calculating (as long we can do it ;))
$sql = 'update clan_challenges AS cc SET calculated = TRUE WHERE '.
'(SELECT count(*) FROM clan_challenge_participants AS ccp ' .
'WHERE ccp.clan_challenge_id = cc.clan_challenge_id AND clan_id = '.$clan_ids[0].
') = ' . $clan_challenge['anzahl_chars'] .
' AND ' .
'(SELECT count(*) FROM clan_challenge_participants AS ccp ' .
'WHERE ccp.clan_challenge_id = cc.clan_challenge_id AND clan_id = '.$clan_ids[1].
') = ' . $clan_challenge['anzahl_chars'];
mysql_query($sql);
$rows = mysql_affected_rows();
semaphoreDown($ressource);
if($rows > 0) {
// okay we now have a complete competition and the challenge is closed :)
calculateChallenge($clan_challenge_id);
}
}
/**
*
* Lets the user to remove his char from the challenge
* @param integer $clan_challenge_id
* @param array $user
* @param integer $charid
*/
function leaveChallenge($clan_challenge_id, array $user, $charid) {
$clan = getClan($user['clan']);
$char = getChar($charid);
if(!$clan) {
return 'Du bist in keinem Clan!!';
}
if($char['besitzer'] != $user['id']) {
return 'Du kannst den Char nicht vom Kampf zurückziehen, da er dir nicht gehört!';
}
// Okay, the rest we can check with the delete statement much easier!
// basically the check consists of a) is the challenge not yet calculated b) is char active in the challenge?
$sql = 'DELETE FROM clan_challenge_participants WHERE (SELECT calculated FROM clan_challenges AS cc WHERE cc.clan_challenge_id = clan_challenge_participants.clan_challenge_id) = FALSE AND char_id = ' . $charid;
mysql_query($sql);
if(mysql_affected_rows() == 0) {
return 'Der Char kann nicht aus dem Kampf zurückgezogen werden.';
}
return NULL;
}
/**
* This function does the calculation of the clan fight.
* @param int $clan_challenge_id the id of the challenge
*/
function calculateChallenge($clan_challenge_id) {
$challenge = getChallenge($clan_challenge_id);
// okay the calculated flag is already set so readout all the required data for further processing!
$clan_ids = getParticipatingClanIDs($clan_challenge_id);
$clan_chars = array();
foreach ($clan_ids as $clan_id) {
$clan_char_ids = getParticipatingCharIDs($clan_challenge_id, $clan_id);
foreach ($clan_char_ids as $slot => $char_id) {
$clan_chars[$clan_id][$slot] = getChar($char_id);
}
}
// okay now determine the type of fight
switch($challenge['type']) {
case DAVY_BACK_FIGHT:
return calculateDavyBackClanFight($clan_ids, $clan_chars);
break;
case SURVIVAL:
return calculateSurvivalClanFight($clan_ids, $clan_chars);
break;
default:
// cannot create anything -.-
return 'Der Clanfight Typ "'.$challenge['type'].'" wird nicht unterstützt, bitte melde dich beim Administrator!' ;
}
return NULL;
}
function calculateDavyBackClanFight(array $clan_ids, array $clan_char_array) {
// okay, davy back fights are 1 vs. 1 and the winner is the one that has won the most fights.
if(count($clan_char_array) != 2) {
return 'Davy Back Fights können nur zwischen 2 Clans ausgetragen werden und nicht von ' . count($clan_char_array);
}
if(count($clan_char_array[$clan_ids[0]]) != count($clan_char_array[$clan_ids[1]])) {
return 'Davy Back Fights können nur zwischen Clans mit der selben Anzahl von Chars ausgetragen werden!';
}
$count_chars = count($clan_char_array[$clan_ids[0]]);
// okay ... now do the calculation!
for($runde = 0; $runde<$count_chars;$runde++) {
$char_clan_1 = $clan_char_array[$clan_ids[0]][$runde];
$char_clan_2 = $clan_char_array[$clan_ids[1]][$runde];
// we do not need to know right now who won the battle! This is required in the post processing (cronjob)!
battle($char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT);
}
}
function calculateSurvivalClanFight(array $clan_ids, array $clan_char_array) {
// okay, survival fights are 1 vs. 1 and the winner is the one that has the last man standing.
if(count($clan_char_array) != 2) {
return 'Survival Fights können nur zwischen 2 Clans ausgetragen werden und nicht von ' . count($clan_char_array);
}
if(count($clan_char_array[$clan_ids[0]]) != count($clan_char_array[$clan_ids[1]])) {
return 'Survival Fights können nur zwischen Clans mit der selben Anzahl von Chars ausgetragen werden!';
}
$count_chars = count($clan_char_array[$clan_ids[0]]);
$counter_clan_1 = 0;
$counter_clan_2 = 0;
$char_clan_1 = $clan_char_array[$clan_ids[0]][0];
$char_clan_2 = $clan_char_array[$clan_ids[1]][0];
// As long as char 1 and char 2 are set
while($char_clan_1 != NULL && $char_clan_2 != NULL) {
$sieger = battle($char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL);
if($sieger['id'] != $char_clan_1['id']) {
// the loser is of clan 1
$char_clan_1 = $clan_char_array[$clan_ids[0]][++$counter_clan_1];
$char_clan_2 = $sieger; // the new array contains the adjusted health parameter
} else {
// the loser is of clan 2
$char_clan_2 = $clan_char_array[$clan_ids[1]][++$counter_clan_2];
$char_clan_1 = $sieger; // the new array contains the adjusted health parameter
}
}
}
/**
* This function calculates the battle between two chars.
* @param array $char1
* @param array $char2
* @param int $attack_set the attack set that should be used!
* @return the winners array
*/
function battle(array $char1, array $char2, $attack_set) {
// TODO: Implement the single fight ...
}
?>

@ -1,749 +0,0 @@
<?php
/*
*
* @copyright (c) 2009 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
/******
Funktionen fuer die Clanfights
Muss noch bearbeitet werden !!
******/
include_once($_SERVER['DOCUMENT_ROOT'].'/ag/include/config.inc.php');
function getClanMember($clanid) {
//$sql = 'SELECT * FROM user where clan = '.$clanid;
$qry = mysql_query('SELECT * FROM user where clan = '.$clanid);
$options = '';
while ($row = mysql_fetch_assoc($qry)) {
$options .= '<option value="'.$row['id'].'">'.$row['nickname'].'</option>';
}
return $options;
}
function getMemberCharacters($userid) {
$qry = mysql_query('SELECT * FROM chars where besitzer = '.$userid);
$options = '';
while ($row = mysql_fetch_assoc($qry)) {
$options .= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
return $options;
}
function getClans($clanid) {
$qry= mysql_query('SELECT clanname, id FROM clan WHERE id != '.$clanid.' ORDER BY clanname ASC');
#$qry= mysql_query('SELECT clanname, id FROM clan ORDER BY clanname ASC');
$options = '';
while ($row = mysql_fetch_assoc($qry)) {
$options .= '<option value="'.$row['id'].'">'.$row['clanname'].'</option>';
}
return $options;
}
function displayClanFights($userid) {
$clanid = getClanOfUser($userid);
$claninfos= getClanInformation($clanid);
?>
<table width="548" cellspacing="0" cellpadding="0" border="0">
<tr>
<th height="29" valign="top" colspan="2">Clan K&auml;mpfe</td>
</tr>
<tr>
<td colspan="2">
<?php echo getActualClanChallengeInformation($clanid,$userid); ?>
</td>
</tr>
<?php
if ($claninfos['leader'] == $userid OR $claninfos['co_leader'] == $userid) {
$anzahl_herausforderungen= mysql_num_rows(mysql_query('SELECT id FROM clan_fight_list WHERE clan='.$clanid.' AND status<2'));
if ($anzahl_herausforderungen == 3) {
?>
<tr>
<th height="29" valign="top" colspan="2">Dein Clan hat bereits 3 Herausforderungen. Mehr sind nicht m&ouml;glich.</td>
</tr>
<?php
} else {
?>
<tr>
<th height="29" valign="top" colspan="2"><a href="index.php?as=clan/c_kampf&id=create">Clan herausfordern</a></td>
</tr>
<?php
}
}
?>
</table>
<?php
}
function displayClanFightType($userid) {
$clanid = getClanOfUser($userid);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
<input type="hidden" name="id" value="1">
<table width="548" cellspacing="0" cellpadding="0" border="0">
<tr>
<th>Kampftyp: </th>
<td height="25">
<select class="input" name="clanfighttyp">
<option value="1">1 vs. 1</option>
<option value="2">Survival</option>
<!--<option value="4">2 vs. 2</option>
<option value="7">4 vs. 4</option>
<option value="12">7 vs. 7</option>-->
</select>
</td>
</tr>
<tr>
<td height="25" align="center">
<input id="input" type="submit" value="weiter">
</td>
</tr>
</table>
</form>
<?php
}
function displaySelectNumberOfFighter($clanfighttyp) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
<input type="hidden" name="id" value="2">
<input type="hidden" name="clanfighttyp" value="<?php echo $clanfighttyp; ?>">
<table width="548" cellspacing="0" cellpadding="0" border="0">
<tr>
<th>Anzahl K&auml;mpfer: </th>
<td height="25">
<select class="input" name="numberoffighter">
<?php
switch ($clanfighttyp) {
case "1":
?>
<option value="4">4 K&auml;mpfer</option>
<option value="6">6 K&auml;mpfer</option>
<?php
break;
case "2":
?>
<option value="4">4 K&auml;mpfer</option>
<option value="6">6 K&auml;mpfer</option>
<?php
break;
}
?>
</select>
</td>
</tr>
<tr>
<td height="25" align="center">
<input id="input" type="submit" value="weiter">
</td>
</tr>
</table>
</form>
<?php
}
function displayClanUser($userid,$numberoffighter,$clanfighttyp,$type){
$clanid = getClanOfUser($userid);
$optionen = getCharacterOptions($clanid);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
<?php
if ($type == 'create') {
echo '<input type="hidden" name="id" value="3">';
} elseif ($type == 'accept') {
echo '<input type="hidden" name="id" value="acc2">';
echo '<input type="hidden" name="kid" value="'.$_GET['kid'].'">';
}
?>
<input type="hidden" name="numberoffighter" value="<?php echo $numberoffighter;?>">
<?php
if (!empty($clanfighttyp)) {
?>
<input type="hidden" name="clanfighttyp" value="<?php echo $clanfighttyp; ?>">
<?php
}
?>
<table width="548" cellspacing="0" cellpadding="0" border="0">
<?php
for($i=1;$i<=$numberoffighter;$i++){
?>
<tr>
<th>User <?php echo $i; ?></th>
<td height="25">
<select class="input" name="user[<?php echo $i; ?>]">
<option value="-1">User w&auml;hlen...
<?php echo getClanMember($clanid); ?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td height="25" align="center">
<input id="input" type="submit" value="weiter">
</td>
</tr>
</table>
</form>
<?php
}
function displayCharsOfClanUser($userid, $wahluser, $numberoffighter, $clanfighttyp='', $type){
$anzahl_gewaehlt= 0;
for($i=1;$i<count($wahluser)+1;$i++) {
if($wahluser[$i] != -1) {
$anzahl_gewaehlt++;
}
}
$count_member_array= array_count_values($wahluser);
for($i=1;$i<count($wahluser)+1;$i++) {
if($wahluser[$i] == -1) {
$errmsg .= '<p>Es sind nicht genug Clanmitglieder ausgew&auml;hlt worden f&uuml;r einen Clankampf!</p>';
$errmsg .= '<p>Leider nur '.$anzahl_gewaehlt.' von '.count($wahluser).' Clanmitglieder ausgew&auml;hlt!</p>';
break;
}
}
foreach ($count_member_array as $key => $value) {
if ($value > 1 AND $key != -1) {
$errmsg .= '<p>Du hast leider ein Clanmitglied mehrfach ausgew&auml;hlt!</p>';
break;
}
}
$clanid = getClanOfUser($userid);
$optionen = getCharacterOptions($clanid);
if (empty($errmsg)) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
<?php
if ($type == 'create') {
echo '<input type="hidden" name="id" value="4">';
echo '<input type="hidden" name="numberoffighter" value="'.$numberoffighter.'">';
echo '<input type="hidden" name="clanfighttyp" value="'.$clanfighttyp.'">';
} elseif ($type == 'accept') {
echo '<input type="hidden" name="id" value="acc_fin">';
echo '<input type="hidden" name="kid" value="'.$_POST['kid'].'">';
}
?>
<table width="548" cellspacing="0" cellpadding="0" border="0">
<?php
for($i=1;$i<=$numberoffighter;$i++){
?>
<tr>
<th>User <?php echo $i; ?></th>
<td height="25">
<select class="input" name="char[<?php echo $i; ?>]">
<option value="0">Charakter w&auml;hlen...
<?php echo getMemberCharacters($wahluser[$i]); ?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td height="25" align="center">
<input id="input" type="submit" value="weiter">
</td>
</tr>
</table>
</form>
<?php
} else {
$errmsg .= '<div style="text-align:center;"><input type="button" value="Zur&uuml;ck" onClick="history.back()"></div>';
echo $errmsg1;
echo $errmsg;
}
}
function displaySelectClanToFight($userid,$numberoffighter,$clanfighttyp) {
$clanid = getClanOfUser($userid);
/*for ($i=1;$i<sizeof($_POST['char'])+1;$i++) {
if (getStatusOfChar($_POST['char'][$i]) != 'Frei') {
$fehlerhafter_status += 1;
$chars_mit_falschem_status[]= $_POST['char'][$i];
}
}
if (isset($fehlerhafter_status)) {
echo '<div style="text-align:center;"><input type="button" value="Zur&uuml;ck" onClick="history.back()"></div>';
echo '<p>Folgende Charaktere sind nicht verf&uuml;gbar:</p>';
echo '<ul>';
for ($i=0;$i<count($chars_mit_falschem_status);$i++) {
echo '<li>'.getNameOfChar($chars_mit_falschem_status[$i]).'</li>';
}
echo '</ul>';
exit;
}*/
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
<input type="hidden" name="id" value="5">
<input type="hidden" name="chars" value=<?php echo serialize($_POST['char']);?>>
<input type="hidden" name="numberoffighter" value="<?php echo $numberoffighter;?>">
<input type="hidden" name="clanfighttyp" value="<?php echo $clanfighttyp;?>">
<table width="548" cellspacing="0" cellpadding="0" border="0">
<tr>
<th>Clan: </th>
<td height="25">
<select class="input" name="clan">
<option value="0">Clan w&auml;hlen...
<?php echo getClans($clanid); ?>
</select>
</td>
</tr>
<tr>
<th>Datum: </th>
<td height="25">
<select class="input" name="datum">
<?php
$timestamp= time();
for ($i=0;$i<14;$i++) {
$datum= date("d.m.Y",$timestamp+$i*60*60*24);
$timestamp_changed= strtotime(date("d.m.Y",$timestamp+$i*60*60*24));
echo '<option value="'.$timestam_changed.'">'.$datum.'</datum>';
}
?>
</select>
</td>
</tr>
<tr>
<th>Zeitpunkt: </th>
<td height="25">
<select class="input" name="zeitpunkt">
<option value="0">nachts (0 Uhr)</option>
<option value="8">morgens (8 Uhr)</option>
<option value="16">nachmittags (16 Uhr)</option>
</select>
</td>
</tr>
<!--<tr>
<th>Ausr&uuml;stung: </th>
<td height="25">
<select class="input" name="ausruestung">
<option value="1">mit Ausr&uuml;stung</option>
<option value="0">ohne Ausr&uuml;stung</option>
</select>
</td>
</tr>-->
<tr>
<td height="25" align="center">
<input id="input" type="submit" value="weiter">
</td>
</tr>
</table>
</form>
<?php
}
function declineClanfight($clanfightid,$true='') {
if (empty($true)) {
echo '<p>Willst du den Clankamp wirklich ablehnen?</p>';
echo '<p><a href="index.php?as=clan/c_kampf&id=dec&kid='.$clanfightid.'&true=1">Ja</a> | <a href="index.php?as=clan/c_kampf">Nein</a></p>';
} else {
$clankampf_loeschen= mysql_query('DELETE FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1');
echo '<p>Clankampf erfolgreich abgelehnt!</p>';
echo '<p><a href="index.php?as=clan/c_kampf">zur&uuml;ck zur &Uuml;bersicht</a></p>';
}
}
function checkIfChallengeTimedOut($userid) {
$clanid= getClanOfUser($userid);
$qry = mysql_query('SELECT id, zeitpunkt, status FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid);
while($row = mysql_fetch_assoc($qry)){
if ($row['zeitpunkt'] <= time() AND $row['status'] == 0) {
$status_updaten= mysql_query('UPDATE clan_fight_list SET status=3 WHERE id='.$row['id'].' LIMIT 1');
}
}
}
function termineBereitsBelegt($clanid,$gclanid,$timestamp) {
global $errmsg;
$clan_qry= mysql_num_rows(mysql_query('SELECT id FROM clan_fight_list WHERE clan = '.$clanid.' AND status != 3 AND zeitpunkt = '.$timestamp));
$gclan_qry= mysql_num_rows(mysql_query('SELECT id FROM clan_fight_list WHERE gclan = '.$gclanid.' AND status != 3 AND zeitpunkt = '.$timestamp));
if ($clan_qry AND $gclan_qry) {
$errmsg= 'Dein Clan und der herausgeforderte Clan haben zu diesem Zeitpunkt bereits einen Clankampf!';
$err= 1;
} elseif ($clan_qry) {
$errmsg= 'Dein Clan hat zu diesem Zeitpunkt bereits einen Clankampf!';
$err= 1;
} elseif ($gclan_qry) {
$errmsg= 'Der herausgeforderte Clan hat zu diesem Zeitpunkt bereits einen Clankampf!';
$err= 1;
} else {
$err= 0;
}
return $err;
}
function clanfightFromOwnClan($clanfightid,$userid='') {
$clanid= getClanOfUser($userid);
$clanfightcheck= mysql_fetch_assoc(mysql_query('SELECT clan from clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
if ($clanfightcheck['clan'] == $clanid) {
return 1;
} else {
global $errmsg;
$errmsg= '<p>Dieser Clankampf ist nicht von deinem Clan erstellt und kann somit nicht zur&uuml;ckgezogen werden!</p>';
return 0;
}
}
function clanfightToOwnClan($clanfightid,$userid='') {
$clanid= getClanOfUser($userid);
$clanfightcheck= mysql_fetch_assoc(mysql_query('SELECT gclan from clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
if ($clanfightcheck['gclan'] == $clanid) {
return 1;
} else {
global $errmsg;
$errmsg= '<p>Die Herausforderung von diesem Clankampf ist nicht an deinem Clan gerichtet!</p>';
return 0;
}
}
function checkClanfight($clanfightid,$type='') {
if (is_numeric($clanfightid)) {
$clanfightcheck= mysql_fetch_assoc(mysql_query('SELECT status FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
if ($clanfightcheck) {
if ($clanfightcheck['status'] == 2 AND ($type == 'look' OR $type == 'look_survival')) {
return 1;
} elseif ($clanfightcheck['status'] != 0) {
global $errmsg;
$errmsg= '<p>Der Clankampf wurde bereits angenommen / abgelehnt!</p>';
return 0;
} else {
return 1;
}
} else {
global $errmsg;
$errmsg= '<p>Diesen Clankampf gibt es nicht!</p>';
return 0;
}
} else {
global $errmsg;
$errmsg= '<p>Die ID des Clankampfes ist kein numerischer Wert!</p>';
return 0;
}
}
function getNumberOfFightersByClanfightID($clanfightid) {
$clankampf_informationen= mysql_fetch_assoc(mysql_query('SELECT numberoffighter FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
return $clankampf_informationen['numberoffighter'];
}
function acceptClanfight($clanfightid,$chars) {
$chars= implode(",",$chars);
$status_pruefen= mysql_fetch_assoc(mysql_query('SELECT status FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
if ($status_pruefen['status'] == 0) {
$datensatz_updaten= mysql_query('UPDATE clan_fight_list SET gfighter="'.$chars.'", status=1 WHERE id='.$clanfightid) or die(mysql_error());
echo '<p>Der Clankampf wurde erfolgreich angenommen!</p>';
echo '<a href="index.php?as=clan/c_kampf">zur&uuml;ck zur &Uuml;bersicht</a>';
} else {
echo '<p>Dieser Clankampf kann nichtmehr angenommen werden. Er wurde bereits angenommen!</p>';
echo '<a href="index.php?as=clan/c_kampf">zur&uuml;ck zur &Uuml;bersicht</a>';
}
}
function deleteClanFight($clanfightid) {
$clankampf_loeschen= mysql_query('DELETE FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1');
echo '<p>Herausforderung erfolgreich zur&uuml;ckgezogen!</p>';
echo '<a href="index.php?as=clan/c_kampf">zur&uuml;ck zur &Uuml;bersicht</a>';
}
function getClanOptions(){
$sql = 'SELECT clanname, id FROM clan order by clanname';
$qry = mysql_query($sql);
$options = '';
while($row = mysql_fetch_assoc($qry)){
$options .= '<option value="'.$row[id].'">'.$row[clanname].'</option>';
}
return $options;
}
// Diese Funktion liefert alle Karaktaere des Clans mit der id $clanid.
// Sortiert werden die Eintraege nach Trainer und Charname
function getCharacterOptions($clanid){
$sql = 'SELECT c.name, c.id, u.nickname FROM chars c LEFT JOIN user u ON (u.id=c.besitzer) WHERE u.clan='.$clanid.' ORDER BY u.nickname, c.name ASC';
$qry = mysql_query($sql);
$options = '';
while($row = mysql_fetch_assoc($qry)){
$options .= '<option value='.$row[id].'>'.$row[name].' ('.$row[nickname].')</option>';
}
return $options;
}
function getActualClanChallengeInformation($clanid,$userid){
$string = '<table>';
#$kaempfe = mysql_query('SELECT u.aktiv, u.besitzer, c.clanname, c2.clanname as clanname2, u.tick, u.id FROM clan_k_list u LEFT JOIN clan c ON(u.besitzer=c.id) LEFT JOIN clan c2 ON(u.an = c2.id )WHERE u.an='.$clanid.' OR u.besitzer='.$clanid.' ORDER BY tick ASC');
$kaempfe_query= mysql_query('SELECT * FROM clan_fight_list WHERE (clan='.$clanid.' OR gclan='.$clanid.') AND status=0 ORDER BY zeitpunkt DESC');
$informationen_eigener_clan= getClanInformation($clanid);
while($row = mysql_fetch_assoc($kaempfe_query)) {
if($row['clan'] == $clanid) {
$claninformationen= getClanInformation($row['gclan']);
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (<a href="index.php?as=clan/c_kampf&id=del&kid='.$row['id'].'">zur&uuml;ckziehen</a>) </td></tr>';
} else {
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (zur&uuml;ckziehen) </td></tr>';
}
} else {
$claninformationen= getClanInformation($row['clan']);
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(<a href="index.php?as=clan/c_kampf&id=acc&kid='.$row['id'].'">annehmen</a> | <a href="index.php?as=clan/c_kampf&id=dec&kid='.$row['id'].'">ablehnen</a>)</td></tr>';
} else {
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(annehmen | ablehnen)</td></tr>';
}
}
}
$string .= '</table>';
return $string;
}
function getActualClanFightInformation($clanid,$userid){
$string = '<table>';
#$kaempfe = mysql_query('SELECT u.aktiv, u.besitzer, c.clanname, c2.clanname as clanname2, u.tick, u.id FROM clan_k_list u LEFT JOIN clan c ON(u.besitzer=c.id) LEFT JOIN clan c2 ON(u.an = c2.id )WHERE u.an='.$clanid.' OR u.besitzer='.$clanid.' ORDER BY tick ASC');
$kaempfe_query= mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid.' ORDER BY zeitpunkt DESC');
$informationen_eigener_clan= getClanInformation($clanid);
while($row = mysql_fetch_assoc($kaempfe_query)) {
if($row['clan'] == $clanid) {
$claninformationen= getClanInformation($row['gclan']);
if ($row['status'] == 1) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
} elseif ($row['status'] == 2) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
}
} else {
$claninformationen= getClanInformation($row['clan']);
if ($row['status'] == 1) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
} elseif ($row['status'] == 2) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
}
}
}
$string .= '</table>';
return $string;
}
function getClanInformation($clanid){
return mysql_fetch_array(mysql_query('SELECT clanname, leader, id, co_leader FROM clan WHERE id='.$clanid));
}
function getClanOfUser($userid){
$sql = 'SELECT clan FROM user WHERE id = '.$userid;
$row = mysql_fetch_assoc(mysql_query($sql));
return $row[clan];
}
function getStatusOfChar($charid) {
$sql= 'SELECT status FROM chars WHERE id='.$charid;
$row= mysql_fetch_assoc(mysql_query($sql));
return $row[status];
}
function getNameOfChar($charid) {
$sql= 'SELECT status, name FROM chars WHERE id='.$charid;
$row= mysql_fetch_assoc(mysql_query($sql));
return 'Char: '.$row[name].' - Status: '.$row[status];
}
function erstelleClanKampf($userid, $clanid, $time, $chars, $numberoffighter, $clanfighttyp) {
$chars= implode(",",$chars);
$own_clan = getClanOfUser($userid);
$claninfo = getClanInformation($own_clan);
$claninfo2 = getClanInformation($clanid);
$anfrage_an_clan_bereits_vorhanden= mysql_num_rows(mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$claninfo['id'].' AND gclan='.$claninfo2['id'].' AND zeitpunkt='.$time.' AND status=0'));
if ($anfrage_an_clan_bereits_vorhanden == 1) {
echo '<div style="text-align:center;"><input type="button" value="Zur&uuml;ck" onClick="history.back()"></div>';
echo '<p>Eine Anfrage f&uuml;r den '.date("d.m.Y H:i:s",$time).' an den Clan "'.$claninfo2['clanname'].'" wurde bereits gestellt!</p>';
exit;
}
$anfrage_von_clan_bereits_vorhanden= mysql_num_rows(mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$claninfo2['id'].' AND gclan='.$claninfo['id'].' AND zeitpunkt='.$time.' AND status=0'));
if ($anfrage_von_clan_bereits_vorhanden == 1) {
echo '<div style="text-align:center;"><input type="button" value="Zur&uuml;ck" onClick="history.back()"></div>';
echo '<p>Eine Herausforderung f&uuml;r den '.date("d.m.Y H:i:s",$time).' vom Clan "'.$claninfo2['clanname'].'" wurde bereits an deinen Clan gestellt!</p>';
exit;
}
if($claninfo2 == null){
return 'Der herauszufordernde Clan existiert nicht (mehr!';
}
if($userid != $claninfo[leader] && $userid != $claninfo[co_leader]){
return 'Nur der Leader, bzw. der Co-Leader kann Clan-k&auml;mpfe erstellen!';
}
$clankampfanfrage_eintragen = mysql_query("INSERT INTO clan_fight_list (id,clan,gclan,fighter,clanfighttyp,numberoffighter,zeitpunkt,status) VALUES ('','".$claninfo['id']."','".$claninfo2['id']."','".$chars."','".$clanfighttyp."','".$numberoffighter."','".$time."',0)");
if(!$foo){
return 'Error by sql: '.$sql.'<br>';
}
}
function loescheKampf($userid, $kampfid){
if(!is_numeric($userid) || !is_numeric($kampfid)){
return 'Fehler beim &Uuml;bertragen der Daten aufgetreten!';
}
$clanid = getClanOfUser($userid);
$claninfo = getClanInformation($clanid);
if($userid != $claninfo[leader] && $userid != $claninfo[co_leader]){
return 'Nur der Leader, bzw. der Co-Leader kann das!';
}
$pruef = mysql_num_rows(mysql_query('SELECT id FROM clan_k_list WHERE (besitzer='.$clanid.' OR an='.$clanid.') AND id='.$kampfid));
if($pruef == 1){
if(mysql_query('DELETE FROM clan_k_list WHERE id = '.$kampfid)){
return '';
} else{
return 'Fehler beim l&ouml;schen in der Datenbank';
}
}
}
function nehmeKampfAn($userid, $kampfid, $chars){
if(!is_numeric($userid) || !is_numeric($kampfid) || !is_array($chars)){
return 'Fehler beim &Uml;bertragen der Daten augetreten!';
}
$clanid = getClanOfUser($userid);
$claninfo = getClanInformation($clanid);
if($userid != $claninfo[leader] && $userid != $claninfo[co_leader]){
return 'Nur der Leader, bzw. der Co-Leader kann das!';
}
$error = checkCharArray($clanid, $chars);
if($error != ''){
return $error;
}
$sql = 'Update clan_k_list SET aktiv = 1, gcharakter1 = '.$chars[1].', gcharakter2 = '.$chars[2].', gcharakter3 = '.$chars[3].', gcharakter4 = '.$chars[4].', gcharakter5 = '.$chars[5].', gcharakter6 = '.$chars[6].' WHERE aktiv = 0 and id = '.$kampfid.' and an='.$clanid;
if(mysql_query($sql)){
return '';
} else{
return 'Fehler beim einfuegen in der Datenbank';
}
}
function checkIfClanFightsToExecute($userid) {
$clanid= getClanOfUser($userid);
$qry = mysql_query('SELECT id, zeitpunkt, status FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid);
while($row = mysql_fetch_assoc($qry)){
if ($row['zeitpunkt'] <= time() AND $row['status'] == 1) {
$status_updaten= mysql_query('UPDATE clan_fight_list SET status=2 WHERE id='.$row['id'].' LIMIT 1');
clanFightExecute($row['id']);
}
}
}
function starteClanFight($chara_1, $chara_2, $clanfight_id, $runde, $kampf){
global $sieger, $verlierer;
include 'kampf_clan.php';
}
function clanFightExecute($id) {
$pkt_a_satz= 0;
$pkt_b_satz= 0;
$pkt_runde_a= 0;
$pkt_runde_b= 0;
$rundenzaehler= 1;
$kampfzaehler= 1;
$clanfight_daten= mysql_fetch_assoc(mysql_query('SELECT fighter, gfighter, numberoffighter FROM clan_fight_list WHERE id='.$id.' LIMIT 1'));
$fighter_a_array= explode(",",$clanfight_daten['fighter']);
$fighter_b_array= explode(",",$clanfight_daten['gfighter']);
for ($x=1;;$x++) {
/*if ($rundenzaehler == 7) {
break;
}*/
$fighter_a= mt_rand(0, count($fighter_a_array)-1);
$fighter_b= mt_rand(0, count($fighter_b_array)-1);
$char_a= getChar2($fighter_a_array[$fighter_a]);
$char_b= getChar2($fighter_b_array[$fighter_b]);
starteClanFight($char_a, $char_b, $id, $rundenzaehler, $kampfzaehler);
$kampfzaehler++;
if ($fighter_a_array[$fighter_a] == $sieger) {
$pkt_a_satz++;
} else {
$pkt_b_satz++;
}
unset($fighter_a_array[$fighter_a]);
unset($fighter_b_array[$fighter_b]);
sort($fighter_a_array);
sort($fighter_b_array);
#if ($pkt_a_satz == 3 OR $pkt_b_satz == 3) {
if ($pkt_a_satz + $pkt_b_satz == $clanfight_daten['numberoffighter']) {
if ($pkt_a_satz > $pkt_b_satz) {
$pkt_runde_a++;
} elseif ($pkt_a_satz < $pkt_b_satz) {
$pkt_runde_b++;
}
$fighter_a_array= explode(",",$clanfight_daten['fighter']);
$fighter_b_array= explode(",",$clanfight_daten['gfighter']);
$rundenzaehler++;
$kampfzaehler= 1;
$pkt_a_satz= 0;
$pkt_b_satz= 0;
if ($pkt_runde_a + $pkt_runde_b == 6) {
break;
}
}
}
}
### old function ###
/*function getActualClanFightInformation($clanid,$userid){
$string = '<table>';
#$kaempfe = mysql_query('SELECT u.aktiv, u.besitzer, c.clanname, c2.clanname as clanname2, u.tick, u.id FROM clan_k_list u LEFT JOIN clan c ON(u.besitzer=c.id) LEFT JOIN clan c2 ON(u.an = c2.id )WHERE u.an='.$clanid.' OR u.besitzer='.$clanid.' ORDER BY tick ASC');
$kaempfe_query= mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid.' ORDER BY zeitpunkt DESC');
$informationen_eigener_clan= getClanInformation($clanid);
while($row = mysql_fetch_assoc($kaempfe_query)){
if($row['clan'] == $clanid) {
$claninformationen= getClanInformation($row['gclan']);
if($row['status'] == 0){
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (<a href="index.php?as=clan/c_kampf&id=del&kid='.$row['id'].'">zur&uuml;ckziehen</a>) </td></tr>';
} else {
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (zur&uuml;ckziehen) </td></tr>';
}
} elseif ($row['status'] == 1) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
} elseif ($row['status'] == 2) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
}
} else{
$claninformationen= getClanInformation($row['clan']);
if($row['status'] == 0){
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(<a href="index.php?as=clan/c_kampf&id=acc&kid='.$row['id'].'">annehmen</a> | <a href="index.php?as=clan/c_kampf&id=dec&kid='.$row['id'].'">ablehnen</a>)</td></tr>';
} else {
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(annehmen | ablehnen)</td></tr>';
}
} elseif ($row['status'] == 1) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
} elseif ($row['status'] == 2) {
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
}
}
}
$string .= '</table>';
return $string;
}*/
?>

@ -2249,7 +2249,7 @@ ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci; CHARACTER SET utf8 COLLATE utf8_general_ci;
DROP TABLE IF EXISTS `attackenset`; DROP TABLE IF EXISTS `attackenset`;
CREATE TABLE `test_ag`.`attackenset` ( CREATE TABLE `attackenset` (
`Char_ID` INT NOT NULL, `Char_ID` INT NOT NULL,
`Attack_ID` INT NOT NULL, `Attack_ID` INT NOT NULL,
`Type` INT NOT NULL DEFAULT 1, `Type` INT NOT NULL DEFAULT 1,
@ -2267,7 +2267,7 @@ CREATE TABLE `test_ag`.`attackenset` (
ENGINE = InnoDB ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_unicode_ci; CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE TABLE `test_ag`.`attack_conditions` ( CREATE TABLE `attack_conditions` (
`ID` INT NOT NULL AUTO_INCREMENT, `ID` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(20) NOT NULL, `Name` VARCHAR(20) NOT NULL,
`Formula` VARCHAR(255) NOT NULL, `Formula` VARCHAR(255) NOT NULL,
@ -2276,6 +2276,110 @@ CREATE TABLE `test_ag`.`attack_conditions` (
ENGINE = InnoDB ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_unicode_ci; CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--
-- Definition of table `clan_challenge_clans`
--
DROP TABLE IF EXISTS `clan_challenge_clans`;
CREATE TABLE `clan_challenge_clans` (
`clan_challenge_id` int(11) NOT NULL,
`clan_id` int(11) NOT NULL,
`elo` int(11) NOT NULL,
PRIMARY KEY (`clan_id`,`clan_challenge_id`),
KEY `clan_ch_clans_ch_id` (`clan_challenge_id`),
CONSTRAINT `clan_ch_clans_ch_id` FOREIGN KEY (`clan_challenge_id`) REFERENCES `clan_challenges` (`clan_challenge_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `clan_challenge_clans`
--
/*!40000 ALTER TABLE `clan_challenge_clans` DISABLE KEYS */;
LOCK TABLES `clan_challenge_clans` WRITE;
INSERT INTO `clan_challenge_clans` VALUES (1,786,400);
UNLOCK TABLES;
/*!40000 ALTER TABLE `clan_challenge_clans` ENABLE KEYS */;
--
-- Definition of table `clan_challenge_participants`
--
DROP TABLE IF EXISTS `clan_challenge_participants`;
CREATE TABLE `clan_challenge_participants` (
`clan_challenge_id` int(11) NOT NULL,
`clan_id` int(11) NOT NULL,
`char_id` int(11) NOT NULL,
`slot` int(11) NOT NULL,
PRIMARY KEY (`clan_challenge_id`,`clan_id`,`slot`),
KEY `clan_challenge_participants_clan_id` (`clan_id`),
KEY `clan_challenge_participants_char_id` (`char_id`),
CONSTRAINT `clan_challenge_participants_char_id` FOREIGN KEY (`char_id`) REFERENCES `chars` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `clan_challenge_participants_clan_id` FOREIGN KEY (`clan_challenge_id`, `clan_id`) REFERENCES `clan_challenge_clans` (`clan_challenge_id`, `clan_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `clan_challenge_participants`
--
/*!40000 ALTER TABLE `clan_challenge_participants` DISABLE KEYS */;
LOCK TABLES `clan_challenge_participants` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `clan_challenge_participants` ENABLE KEYS */;
--
-- Definition of table `clan_challenge_requests`
--
DROP TABLE IF EXISTS `clan_challenge_requests`;
CREATE TABLE `clan_challenge_requests` (
`clan_requester` int(11) NOT NULL,
`clan_challenged` int(11) NOT NULL,
`challenged_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`type` int(11) NOT NULL,
`anzahl_chars` int(11) NOT NULL DEFAULT '5',
`active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`clan_requester`,`clan_challenged`,`challenged_time`),
KEY `fk_clan_challenge_requests_challenged` (`clan_challenged`),
CONSTRAINT `fk_clan_challenge_requests_challenged` FOREIGN KEY (`clan_challenged`) REFERENCES `clan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_clan_challenge_requests_requester` FOREIGN KEY (`clan_requester`) REFERENCES `clan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `clan_challenge_requests`
--
/*!40000 ALTER TABLE `clan_challenge_requests` DISABLE KEYS */;
LOCK TABLES `clan_challenge_requests` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `clan_challenge_requests` ENABLE KEYS */;
--
-- Definition of table `clan_challenges`
--
DROP TABLE IF EXISTS `clan_challenges`;
CREATE TABLE `clan_challenges` (
`clan_challenge_id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`calculated` tinyint(1) NOT NULL,
`type` int(11) NOT NULL,
`anzahl_chars` int(11) NOT NULL,
PRIMARY KEY (`clan_challenge_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `clan_challenges`
--
/*!40000 ALTER TABLE `clan_challenges` DISABLE KEYS */;
LOCK TABLES `clan_challenges` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `clan_challenges` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

Loading…
Cancel
Save