Bugfix: Now the chars can be fetched. There is a change in determining the status of the char (inverted). Also if the clanfight hasn't started the "clanfight" status should not be "clickable"

main
hecht 13 years ago
parent 32a1d640bc
commit 4a727df644

@ -108,8 +108,8 @@ echo "<b> $kampf_a1[name] vs. $kampf_a2[name]";
}
#######################Clan Kampf
if($ab == "Clanfight" && isEventToFetchAwaiting($char_id)) {
if($ab == "Clanfight") {
if(isEventToFetchAwaiting($char_id)) {
echo "<SCRIPT language='JavaScript'>";
?>
function showfight(){
@ -135,6 +135,9 @@ $zeit_in_sek = getEventStatusBlocked($char_id);
?>
</div>
<?php
} else {
echo '<p align="center">Im Moment muss der Char vom Clanfight noch nicht abgeholt werden!</p>';
}
}

@ -88,7 +88,7 @@ foreach($chars as $my_charz){
$zeit_in_sek[$char_zahl] = getEventStatusBlocked($my_charz['id']);
$temp = '<a href="index.php?as=abholen&ab='.$statustemp.'&char_id='.$my_charz['id'].'" id="popup">Status: '.$my_charz['status'].'</a><br /><span id="timer_'.$char_zahl.'"></span>';
} else {
$temp = '<a href="index.php?as=abholen&ab='.$statustemp.'&char_id='.$my_charz['id'].'" id="popup">Status: '.$my_charz['status'].'</a>';
$temp = '<span id="popup">Status: '.$my_charz['status'].'</span>';
}
}
$werte = "St&auml;rke: ".$c_starke."<br>Verteidigung: ".$c_verteidigung."<br>Geschwindigkeit: ".$c_speed."<br>Ausdauer: ".$c_ausdauer."<br>Gl&uuml;ck: ".$c_glueck;

@ -11,28 +11,47 @@ include_once (ROOT_PATH . '/include/char.inc.php');
include_once(ROOT_PATH.'/include/kampf_anzeige.inc.php');
include_once (ROOT_PATH . '/include/event.inc.php');
include_once (ROOT_PATH . '/include/parse.inc.php');
function fetchProcessing($user, $char) {
$char_id = $char['id'];
$event_ids = getEventIdsToFetch($char_id);
foreach ($event_ids as $event_id) {
$fight_ids = abholenChar($user, $event_id, $char_id);
if(!is_array($fight_ids)) {
echo $fight_ids . '<br>';
continue;
}
foreach ($fight_ids as $event_fight_id) {
displayEventFight($event_id, $event_fight_id);
}
}
return NULL;
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="design/FightStyle.css">
</head>
<body>
<head>
<link rel="stylesheet" type="text/css" href="design/FightStyle.css">
</head>
<body>
<?php
$char_id = validateUnsignedInteger($_GET['char_id'], null);
$char = getChar($char_id);
if($char['besitzer'] != $user_ida['id']) {
echo 'Du kannst den char nicht abholen, da er dir nicht geh&ouml;rt!';
} else {
$res = fetchProcessing($user_ida, $char);
if($res != NULL) {
echo $res;
}
}
//function abholenChar(array $user, $event_id, $char_id) {
//function getEventIdsToFetch($charid) {
$event_ids = getEventIdsToFetch($char_id);
foreach ($event_ids as $event_id) {
$fight_ids = getEventFightIdsByChar($event_id, $char_id);
foreach ($fight_ids as $event_fight_id) {
displayEventFight($event_id, $event_fight_id);
}
}
?>
</body>
</body>
</html>

@ -61,6 +61,8 @@
} else if($my_charz['status'] == 'Turnier' OR $my_charz['status'] == 'Kampf Erstellt'){
$temp = 'Status: '.$my_charz['status'];
$quicklink = '';
} else if($my_charz['status'] == 'Clanfight' && !isEventToFetchAwaiting($my_charz['id'])) {
$temp = 'Status: '.$my_charz['status'];
} else{
$temp = "<a href=index.php?as=abholen&ab=".$statustemp."&char_id=".$my_charz['id']." id=popup>Status: ".$my_charz['status']."</a>";
$quicklink = '';

@ -57,8 +57,8 @@ function addParticipant($event_id, array $char) {
$hp = explode(',', $char['hp']);
$mp = explode(',', $char['mp']);
$sql = 'INSERT INTO event_chars(event_id, event_char_id, char_id, char_name, char_bild, user_id, user_name, hp, mp, strength, speed, defense, luck, stamina, block_begin, block_end)';
$sql .= ' value('. $event_id . ', '.$char['id'] .', '.$char['id'] .', \''.$char['name'].'\', \''.$char['bild'].'\', '.$char['besitzer'].', \''.$user['nickname'].'\', '.$hp[1].', '.$mp[1].', '.$char['starke'].', '.$char['speed'].', '.$char['verteidigung'].', '.$char['glueck'].', '.$char['ausdauer'].', now(), TIMESTAMPADD(Minute, 1, now()))';
$sql = 'INSERT INTO event_chars(event_id, event_char_id, char_id, char_name, char_bild, user_id, user_name, hp, mp, strength, speed, defense, luck, stamina, block_begin, block_end, abgeholt)';
$sql .= ' value('. $event_id . ', '.$char['id'] .', '.$char['id'] .', \''.$char['name'].'\', \''.$char['bild'].'\', '.$char['besitzer'].', \''.$user['nickname'].'\', '.$hp[1].', '.$mp[1].', '.$char['starke'].', '.$char['speed'].', '.$char['verteidigung'].', '.$char['glueck'].', '.$char['ausdauer'].', now(), TIMESTAMPADD(Minute, 1, now()), FALSE)';
// echo $sql . '<br>';
@ -141,7 +141,7 @@ 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() or abgeholt = 1) 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 = FALSE) and char_id = ' . $charid;
// echo $sql . '<br>';
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
@ -173,15 +173,16 @@ function getEventStatusBlocked($charid) {
}
function isEventToFetchAwaiting($charid) {
$sql = 'SELECT count(*) FROM event_chars e WHERE abgeholt = 1 AND char_id = ' .$charid;
$sql = 'SELECT count(*) FROM event_chars e WHERE abgeholt = FALSE AND char_id = ' .$charid;
$row = mysql_fetch_row(mysql_query($sql));
return $row[0] > 0;
}
function getEventIdsToFetch($charid) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end < now() and abgeholt = 1 AND char_id = ' .$charid;
function getEventIdsToFetch($char_id) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end < now() and abgeholt = FALSE AND char_id = ' .$char_id . ' ORDER BY event_id ASC';
$qry = mysql_query($sql);
if(!$qry)
echo $sql . '<br>';
$result = array();
while ($row = mysql_fetch_row($qry)) {
@ -192,12 +193,12 @@ function getEventIdsToFetch($charid) {
function abholenChar(array $user, $event_id, $char_id) {
// okay, first checking the basic things
$char = getChar($charid);
if($char['besitzer'] != $user) {
$char = getChar($char_id);
if($char['besitzer'] != $user['id']) {
return 'Du kannst den Char nicht abholen weil er dir nicht gehört!!';
}
$ressource = 'User:'.$user_ida['id'];
$ressource = 'User:'.$user['id'];
if(!semaphoreUP($ressource)){ // TRUE, diese Anfrage darf bearbeitet werden
return 'Verarbeitung gerade in Gange, bitte warten...';
}
@ -229,13 +230,13 @@ function abholenChar(array $user, $event_id, $char_id) {
$fight = getEventFight($event_id, $fight_id);
$fight_meta = getEventFightMetaData($event_id, $fight_id);
if($fight['host'] == $char_id) {
$char_exp += $fight_meta['KEY_EXP_CHAR1'];
$char_aexp += $fight_meta['KEY_AXP_CHAR1'];
$char_geld += $fight_meta['KEY_GELD_CHAR1'];
$char_exp += $fight_meta[KEY_EXP_CHAR1];
$char_aexp += $fight_meta[KEY_AXP_CHAR1];
$char_geld += $fight_meta[KEY_GELD_CHAR1];
} else {
$char_exp += $fight_meta['KEY_EXP_CHAR2'];
$char_aexp += $fight_meta['KEY_AXP_CHAR2'];
$char_geld += $fight_meta['KEY_GELD_CHAR2'];
$char_exp += $fight_meta[KEY_EXP_CHAR2];
$char_aexp += $fight_meta[KEY_AXP_CHAR2];
$char_geld += $fight_meta[KEY_GELD_CHAR2];
}
}
// add the experience to the char
@ -247,9 +248,10 @@ function abholenChar(array $user, $event_id, $char_id) {
addMoneyToUser($char['besitzer'], $char_geld);
// Okay and now we want to learn the attacks :)
$sql = 'SELECT attack, count(attack) as anzahl FROM event_fight_rounds e group by attack where event_id = ' . $event_id . ' AND event_char_id = ' . $char_id;
$sql = 'SELECT attack, count(attack) as anzahl FROM event_fight_rounds e where event_id = ' . $event_id . ' AND event_char_id = ' . $char_id . ' group by attack';
$qry = mysql_query($sql);
if(!$qry)
echo $sql .'<br>';
$attacken_usage = array();
while($row = mysql_fetch_assoc($qry)) {
@ -258,6 +260,12 @@ function abholenChar(array $user, $event_id, $char_id) {
addAttackUsageToChar($char_id, $attacken_usage);
$sql = 'UPDATE event_chars SET abgeholt = TRUE WHERE char_id = ' . $char_id . ' AND event_id = ' . $event_id;
$qry = mysql_query($sql);
if(!$qry)
echo $sql .'<br>';
semaphoreDown($ressource); // free the previously reserved semaphore!
return $fight_ids; // Return the fight ids that the char has participated in!
}
@ -303,8 +311,10 @@ function getEventFightIds($event_id) {
// this is more tricky XD
function getEventFightIdsByChar($event_id, $event_char_id) {
$sql = 'SELECT event_fight_id FROM event_fight_rounds where event_id = ' . $event_id . ' AND event_char_id = ' . $event_char_id . ' AND `round` = 0';
$sql = 'SELECT event_fight_id FROM event_fight_rounds where event_id = ' . $event_id . ' AND event_char_id = ' . $event_char_id . ' AND `round` = 0 ORDER BY event_fight_id ASC';
$qry = mysql_query($sql);
if(!$qry)
echo $sql . '<br>';
while($row = mysql_fetch_assoc($qry)) {
$result[]= $row['event_fight_id'];
}

Loading…
Cancel
Save