diff --git a/ag/include/char.inc.php b/ag/include/char.inc.php index 0c52d7a..1c62ad6 100644 --- a/ag/include/char.inc.php +++ b/ag/include/char.inc.php @@ -283,4 +283,76 @@ function getFusionRaceId($charid){ } +/** + * This function returns an overview about the + */ +function getAttacksforChar($charid) { + $char = getChar($charid); + $char_race = getCharRaceId($charid); + echo '
'; + // first read out basic information about our attacks + + $sql = 'select a.name, a.id, a.level, substr(a.req_atk, 1, locate(\',0\', a.req_atk) - 1) as req_atk , geld, ifnull((select l.benutzt from lernen l where l.besitzer = '.$char['id'].' and at_id = a.id),0) as benutzt, a.id not in (select l.at_id from lernen l where l.besitzer = '.$char['id'].') as unknown from attacken a where find_in_set('.$char_race.', a.rassen) order by level'; + $qry = mysql_query($sql); + echo '
'.$sql.'
'; + + // The first index is the id of the attack! + // then there is the basic information like + // + // entries {id, name, levelups, benutzt, unknown} + // ==> id, name, required level, times that it has been used , if its still unkown (bool) + // entry {req} -> array {id, name, reggs} + // ==> [0] => first requirenment -> id, name, amount level ups required, times to be used + // ==> [n] => nth requirenment -> ... + + $overview = array(); + + $attacke = array(); + $requires = array(); + + while($row = mysql_fetch_assoc($qry)) { + $attacke[$row['id']] = $row; + $overview[$row['id']] = array('id' => $row['id'], 'name' => $row['name'], 'levelups' => ($row['level'] - $char['level']), 'benutzt' => $row['benutzt'], 'unknown' => $row['unknown'] == 1); + // as it is straight forward (on level) we already can calculate the dependencies + + if($overview[$row['id']]['levelups'] < 0) { + $overview[$row['id']]['levelups'] = 0; + } + + echo $attacke[$row['id']]['name'] . ' = ' . $attacke[$row['id']]['req_atk'] . '
'; + + if($attacke[$row['id']]['req_atk'] == 0) { + echo 'Nothing to do
'; + // nothing :D + $attacke[$row['id']]['req'] = array(0); + } else if(strpos($attacke[$row['id']]['req_atk'], ',') === FALSE) { + echo 'One thing to do
'; + // only one attack required :) => use reference + $other_attack = &$attacke[$row['id']]['req_atk']; + // => this is the id of the required attack, so easy going :) + $reggs = ($attacke[$row['id']]['geld'] - $other_attack['benutzt']); + if($reggs < 0) { + $reggs = 0; + } + $overview[$row['id']]['req'][] = array('id' => $other_attack['id'], 'name' => $other_attack['name'], 'reggs' => $reggs); + } else { + echo 'More things to do
'; + // multiple attacks required :( + $attack_ids = explode(',',$attacke[$row['id']]['req_atk']); + for($i=0;$i this is the id of the required attack, so easy going :) + $reggs = ($attacke[$row['id']]['geld'] - $other_attack['benutzt']); + if($reggs < 0) { + $reggs = 0; + } + $overview[$row['id']]['req'][] = array('id' => $other_attack['id'], 'name' => $other_attack['name'], 'reggs' => $reggs); + } + } + } + + return $overview; +} + + ?> \ No newline at end of file