';
}
}
function displayFinalResult($items, $exp, $money, $final_result){
echo '
' .
'
';
echo '
Zusammenfassung
';
if($final_result == 'lost') {
echo '
Ihr müsst euch selbst eingestehen, dass diese Monster zu stark waren. Der Zweifel der euch plagt verringert eure Erfahrung und Diebe den Betrag in eurem Geldbeutel.
';
}
function displaySchatzSuche($char){
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/schatz.inc.php');
// Erstmal die Schatzsuche-stammdaten laden!
$sql = 'Select * from quests where charid ='.$char['id'].' and dauer < now()';
$quest = mysql_fetch_assoc(mysql_query($sql));
// echo $sql.' ';
if(!$quest){
return 'Schatzsuche noch nicht beendet!!';
}
// Uberschreibe die Char-Daten mit den Daten aus der Datenbank
$char['starke'] = $quest['st'];
$char['verteidigung'] = $quest['ver'];
$char['speed'] = $quest['sp'];
$char['glueck'] = $quest['gl'];
$char['ausdauer'] = $quest['aus'];
$char['hp_max'] = $quest['hp'];
$char['mp_max'] = $quest['mp'];
// Erstmal die Seite starten
echo '
';
// Einfach mal ne dicke Ueberschrift
$ort = mysql_fetch_assoc(mysql_query('select * from quest_ort where id = '.$quest['ortid']));
echo '
Schatzsuche in '.$ort['stadt'].'
';
// Hole die Ergebnisse die auch in die Datenbank eingetragen werden muessen!
$row = mysql_fetch_assoc(mysql_query('Select sum(exp) as exp, sum(geld) as geld, count(*) as anzahl from quest_fights where charid = '.$char['id']));
// Ermittle den Endzustand des Chars
$end_qf = mysql_fetch_assoc(mysql_query('select max(fightnr) as mf from quest_fights where charid = '.$char['id']));
$end_qr = mysql_fetch_assoc(mysql_query('select max(roundnr) as mr from quest_rounds where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_round = mysql_fetch_assoc(mysql_query('Select * from quest_rounds where roundnr = '.$end_qr['mr'].' and fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_fight = mysql_fetch_assoc(mysql_query('Select * from quest_fights where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
// Ermittle die Reqs des Chars!
$sql = 'SELECT c_attack as a_name, count(*) as anzahl FROM quest_rounds q where roundnr > 0 and charid = '.$char['id'].' group by c_attack';
// echo $sql.' ';
$reqs = mysql_query($sql);
while($row_r = mysql_fetch_assoc($reqs)){
$c_attacken[] = $row_r;
// print_r($c_attacken);
// echo ' ';
}
if($last_fight['sieger'] == $char['id']){
$final_result = 'won';
// Nur wer gewinnt bekommt was!
$items = getSchatzItems($row['anzahl']);
} else{
$final_result = 'lost';
$lose_rate = mt_rand(25,60)/100;
$row['exp'] = round($row['exp'] * $lose_rate);
$row['geld'] = round($row['geld'] * $lose_rate);
for($i = 0;$i< count($row_r); $i++){
$c_attacken[$i]['anzahl'] = floor($c_attacken[$i]['anzahl'] * $lose_rate);
}
}
// Zeige als erstes die Zusammenfassung an!
displayFinalResult($items, $row['exp'], $row['geld'], $final_result);
// Lade nun die Fights runter
$sql = 'Select * from quest_fights where charid = '.$char['id'];
$qry = mysql_query($sql);
while($fight = mysql_fetch_assoc($qry)){
displaySchatzSucheFight($quest, $char, $fight);
}
submitCharChanges($char['id'], $items, $row['exp'], $row['geld'], $quest['ortid'], array($last_round['c_hp']) , array($last_round['c_mp']), $c_attacken);
echo '
';
return null;
}
function displaySchatzSucheFight($quest, $char, $fight){
// Lade das Monster aus der Datenbank
$sql = 'select * from quest_monster where id = '.$fight['monsterid'];
$monster = mysql_fetch_assoc(mysql_query($sql));
if($monster['bild'] == null || $monster['bild'] == ''){
$monster['bild'] = 'design/bilder/avatare/noavart.gif';
}
// Platziere den Table-Header
echo '
'.$char['name'].' Vs '.$monster['name'].'
';
$sql = 'Select * from quest_rounds where charid = '.$char['id']. ' and fightnr = '.$fight['fightnr'];
// echo $sql.' ';
$qry = mysql_query($sql);
while($round = mysql_fetch_assoc($qry)){
displaySchatzSucheFightRound($char, $monster, $fight, $round);
}
displaySummary($char['name'], $monster['name'], $fight['sieger']==$char['id']?$char['name']:$monster['name'], $fight['exp'], 0, $fight['geld'], 0);
// Und dann halt immer noch etwas platz nach unten lassen
echo '
';
}
function displayEventFight($event_id, $event_fight_id) {
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/event.inc.php'); // for the defines :)
// Erstmal die Seite starten
echo '
';
// :D
// first readout the required event data
$event_fight_data = mysql_fetch_assoc(mysql_query('SELECT *, visible <= now() as passed FROM event_fights WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id ));
// Okay and now get the data of the chars ;)
$sql = 'SELECT * FROM event_chars e where event_id = '.$event_id.' and event_char_id IN (SELECT event_char_id from event_fight_rounds where event_id = '.$event_id.' and event_fight_id = '.$event_fight_id.' and `round` = 0)';
// echo $sql . ' ';
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
if($row['char_bild'] == null || $row['char_bild'] == ''){
$row['char_bild'] = 'design/bilder/avatare/noavart.gif';
}
if($event_fight_data['host'] == $row['event_char_id']) {
$char1 = $row;
} else {
$char2 = $row;
}
}
// Platziere den Table-Header
echo '
'.$char1['char_name'].' Vs '.$char2['char_name'].'
';
displayEventFightRound($char1, $char2, array(), array(), 0);
// now get the round data :D
$sql = 'SELECT * from event_fight_rounds WHERE event_id = ' .$event_id . ' AND event_fight_id = ' .$event_fight_id . ' and visible <= now()';
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
if($event_fight_data['host'] == $row['event_char_id']) {
$char1_rounds[$row['round']] = $row;
} else {
$char2_rounds[$row['round']] = $row;
}
}
for($i=0;$i