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"
@ -141,7 +141,7 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
function getEventStatus($charid) {
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>';
// echo $sql . '<br>';
$qry = mysql_query($sql);
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$row = mysql_fetch_assoc($qry);
@ -173,15 +173,16 @@ function getEventStatusBlocked($charid) {
}
}
function isEventToFetchAwaiting($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));
$row = mysql_fetch_row(mysql_query($sql));
return $row[0] > 0;
return $row[0] > 0;
}
}
function getEventIdsToFetch($charid) {
function getEventIdsToFetch($char_id) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end <now()andabgeholt =1ANDchar_id ='.$charid;
$sql = 'SELECT event_id FROM event_chars e WHERE block_end <now()andabgeholt =FALSEANDchar_id =' .$char_id . ' ORDERBYevent_idASC';
$qry = mysql_query($sql);
$qry = mysql_query($sql);
if(!$qry)
echo $sql . '<br>';
$result = array();
$result = array();
while ($row = mysql_fetch_row($qry)) {
while ($row = mysql_fetch_row($qry)) {
@ -192,12 +193,12 @@ function getEventIdsToFetch($charid) {
function abholenChar(array $user, $event_id, $char_id) {
function abholenChar(array $user, $event_id, $char_id) {
// okay, first checking the basic things
// okay, first checking the basic things
$char = getChar($charid);
$char = getChar($char_id);
if($char['besitzer'] != $user) {
if($char['besitzer'] != $user['id']) {
return 'Du kannst den Char nicht abholen weil er dir nicht gehört!!';
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
if(!semaphoreUP($ressource)){ // TRUE, diese Anfrage darf bearbeitet werden
return 'Verarbeitung gerade in Gange, bitte warten...';
return 'Verarbeitung gerade in Gange, bitte warten...';
}
}
@ -229,13 +230,13 @@ function abholenChar(array $user, $event_id, $char_id) {
@ -247,9 +248,10 @@ function abholenChar(array $user, $event_id, $char_id) {
addMoneyToUser($char['besitzer'], $char_geld);
addMoneyToUser($char['besitzer'], $char_geld);
// Okay and now we want to learn the attacks :)
// 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);
$qry = mysql_query($sql);
if(!$qry)
echo $sql .'<br>';
$attacken_usage = array();
$attacken_usage = array();
while($row = mysql_fetch_assoc($qry)) {
while($row = mysql_fetch_assoc($qry)) {
@ -258,6 +260,12 @@ function abholenChar(array $user, $event_id, $char_id) {
addAttackUsageToChar($char_id, $attacken_usage);
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!
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
// this is more tricky XD
function getEventFightIdsByChar($event_id, $event_char_id) {
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';