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>
</html>
</body>
</html>

@ -26,23 +26,23 @@
$hptemp = explode(",", $my_charz['hp']);
$hpleft[$char_zahl] = $hptemp['0'] / $hptemp['1'] * 100;
$mptemp = explode(",", $my_charz['mp']);
$mpleft[$char_zahl] = $mptemp['0'] / $mptemp['1'] * 100;
$mpleft[$char_zahl] = $mptemp['0'] / $mptemp['1'] * 100;
$exptemp = explode(",", $my_charz['exp']);
$room = mysql_query('SELECT ci.name FROM clan_item ci inner join clan_ware cw on ci.id = cw.item_id WHERE cw.id='.$my_charz['clan_train']);
$clanroom=mysql_fetch_assoc($room);
if($clanroom['name']=="")
$clanroom['name']="kein";
$clanroom['name']="kein";
$temproom="<br><a href=index.php?as=clan/c_ware&char_id=$my_charz[id] id=popup> Trainingsraum: ".$clanroom['name']."</a>";
$hp = "HP: ".$hptemp['0']." / ".$hptemp['1'];
if($my_charz['status'] == "Schatz Suche"){
$statustemp = "Schatz%20Suche";
} else{
$statustemp = $my_charz['status'];
}
if($my_charz['kampf_item'] != NULL && $my_charz['kampf_item'] != ',,,,'){
// echo 'Problematic Entry = '.$chara_1['kampf_item'].'<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'] . ')'));
@ -52,7 +52,7 @@
$c_speed = $char1_buffs['speed']==0?$my_charz['speed']:($my_charz['speed']).' (+'.$char1_buffs['speed'].')';
$c_ausdauer = $char1_buffs['ausdauer']==0?$my_charz['ausdauer']:($my_charz['ausdauer']).' (+'.$char1_buffs['ausdauer'].')';
$c_glueck = $char1_buffs['glueck']==0?$my_charz['glueck']:($my_charz['glueck']).' (+'.$char1_buffs['glueck'].')';
$mp = "MP: ".$mptemp['0']." / ".$mptemp['1'];
$exp = "Exp: ".$exptemp['0']." / ".$exptemp['1'];
if($my_charz['status'] == 'Frei' ){
@ -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 = '';
@ -68,7 +70,7 @@
$werte = "St&auml;rke: ".$c_starke."<br>Verteidigung: ".$c_verteidigung."<br>Geschwindigkeit: ".$c_speed."<br>Ausdauer: ".$c_ausdauer."<br>Gl&uuml;ck: ".$c_glueck;
$lp = "<br><a href=index.php?as=lernpunkte&char_id=".$my_charz['id']." id=popup>Lernpunkte: ".$my_charz['lernpunkte']."</a>";
$tp = "<a href=index.php?as=training&char_id=".$my_charz['id']." id=popup>Trainingspunkte: ".$my_charz['training_points']."</a>".$temproom;
//$temp = $statustemp."";
$temp2 = "Level: ".$my_charz['level']."<br>Powerlevel: $POWERLEVEL5<br>Typ: ".$my_charz['type']."<br>Rasse: ".$my_charz['rasse'].$fusi.$frucht.$lp."<br>$tp<p>$hp<br>$mp<br>$exp<p>$werte";
@ -78,7 +80,7 @@
$char_zahl++;
}
$visiblechars = 8;
for($i=$char_zahl;$i<$visiblechars;$i++){
$CHARAKTER_NAME[$i] = "Kein Charakter";
$CHARAKTER_VERWALTUNG[$i] = "none";
@ -139,7 +141,7 @@ echo getHorizontalAdvertisement();
}
}
echo '<tr><td></td></tr><tr>';
for($i=0;$i<=3;$i++)
for($i=0;$i<=3;$i++)
{
if($chars_bilds[$i]!='design/bilder/avatare/Char.gif')
{
@ -151,7 +153,7 @@ echo getHorizontalAdvertisement();
echo '</tr></table></td>';
}
}
?>
</table>
<hr id="hrc">
@ -193,7 +195,7 @@ echo getHorizontalAdvertisement();
}
}
echo '<tr><td></td></tr><tr>';
for($i=4;$i<=7;$i++)
for($i=4;$i<=7;$i++)
{
if($chars_bilds[$i]!='design/bilder/avatare/Char.gif')
{

@ -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