@ -108,27 +108,21 @@ echo "<b> $kampf_a1[name] vs. $kampf_a2[name]";
}
#######################Clan Kampf
if($ab == "Clan Kampf") {
if($ab == "Clanfight") {
echo "<SCRIPTlanguage='JavaScript'>";
?>
function showfight(){
var Info = window.open("./clan_kampf.php?char_id=<?phpecho$char_id;?>","","status=no,hotkeys=no,Height=600,Width=820,scrollbars=yes");
var Info = window.open("./event_abholen.php?<?phpecho$abholstring;?>","","status=no,hotkeys=no,Height=600,Width=820,scrollbars=yes");
}
<?php
echo "</SCRIPT>";
$kampf_a = mysql_fetch_array(mysql_query("SELECT c1.name AS c1name, c2.name, k.id, k.dauer FROM clan_kampf k LEFT JOIN chars c1 ON(k.char1=c1.id) LEFT JOIN chars c2 ON(k.char2=c2.id) WHERE k.db_satz='$char_id' LIMIT 1"));
$zeit_in_sek = $kampf_a[dauer] - time();
$zeit_in_sek = getEventStatusBlocked($char_id);
?>
<palign=center><b>Clan Kampf</b><br> <br>
<?php
echo "<b> $kampf_a[c1name] vs. $kampf_a[name] </b><br> <br>";
$char1_buffs = mysql_fetch_assoc(mysql_query('SELECT sum(i.hp) as hp, sum(i.mp) as mp, sum(i.starke) as starke, sum(i.verteidigung) as verteidigung, sum(i.speed) as speed FROM ware w LEFT JOIN item i ON(i.id=w.item_id) WHERE w.id IN (' . $my_charz['kampf_item'] . ')'));
$char1_buffs = mysql_fetch_assoc(mysql_query('SELECT sum(i.hp) as hp, sum(i.mp) as mp, sum(i.starke) as starke, sum(i.verteidigung) as verteidigung, sum(i.speed) as speed FROM ware w LEFT JOIN item i ON(i.id=w.item_id) WHERE w.id IN (' . $my_charz['kampf_item'] . ')'));
// okay does this user already has a char in the fight??
$qry = mysql_query('SELECT count(*) as anzahl FROM clan_challenge_participants ccp inner join chars c on ccp.char_id = c.id WHERE besitzer = ' .$user['id']);
$qry = mysql_query('SELECT count(*) as anzahl FROM clan_challenge_participants ccp inner join chars c on ccp.char_id = c.id WHERE besitzer = ' .$user['id'] . ' AND clan_challenge_id = ' . $clan_challenge_id);
$row = mysql_fetch_assoc($qry);
if($row['anzahl'] != 0) {
@ -588,7 +590,7 @@ function calculateChallenge($clan_challenge_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>';
echo 'Could not execute QUERY : ' .$sql .'<br>';
foreach ($clan_char_ids as $slot => $char_id) {
addParticipant($event_id, getChar($char_id));
@ -776,16 +778,16 @@ function isAuthorizedClanfightCoordinator($clan_id, $user_id, $clan_fight_id = N
// it is a more general thing ;)
$sql = 'SELECT COUNT(*) FROM `clan_challenge_whitelist` WHERE `user_id` = ' .$user_id. ' AND `clan_id` = '.$clan_id;
@ -141,8 +141,8 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
function getEventStatus($charid) {
$sql = 'SELECT event_type FROM event_chars ec inner join events e on ec.event_id = e.event_id where block_end > now() and char_id = ' . $charid;
$sql = 'SELECT event_type FROM event_chars ec inner join events e on ec.event_id = e.event_id where (block_end > now() or abgeholt = 1) and char_id = ' . $charid;
// echo $sql . '<br>';
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
switch ($row['event_type']) {
@ -161,6 +161,27 @@ function getEventStatus($charid) {
case EVENT_CLAN_FIGHT:
return 'Clanfight';
}
return NULL;
}
function getEventStatusBlocked($charid) {
$sql = 'SELECT Timestampdiff(Second,now(),MAX(block_end)) FROM event_chars WHERE char_id = ' . $charid;
// echo $sql . '<br>';
$row = mysql_fetch_row(mysql_query($sql));
return $row[0];
}
function getEventIdsToFetch($charid) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end <now()andabgeholt =1ANDchar_id ='.$charid;
$qry = mysql_query($sql);
$result = array();
while ($row = mysql_fetch_row($qry)) {
$result[] = $row[0];
}
return $result;
}
function abholenChar(array $user, $event_id, $char_id) {