@ -285,16 +285,35 @@ function getFusionRaceId($charid){
/**
/**
* This function returns an overview about the
* This function returns an overview about the
* @param $charid the id of the character
* @param $mode 0 = show all available attacks, 1 = show all unavailable attacks, 2 = show both!
*/
*/
function getAttacksforChar($charid) {
function getAttacksforChar($charid, $mode = 0) {
$char = getChar($charid);
$char = getChar($charid);
$char_race = getCharRaceId($charid);
$char_race = getCharRaceId($charid);
echo '<br>';
// first read out basic information about our attacks
// 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';
// $sql = 'select a.name, a.id, a.level, if(find_in_set(\'0\', req_atk) = 0, a.req_atk, 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';
$sql_append = '';
if($char['frucht'] !== NULL) {
$sql_append1 = ' OR (frucht = (Select id from wochen_markt where item = \''.$char['frucht'].'\')) ';
$sql_append2 = ' AND (frucht <> (Select id from wochen_markt where item = \''.$char['frucht'].'\')) ';
}
// First sql to include all currently learnable attacks
$sql = 'SELECT a.name, a.id, a.level, a.geld, if(find_in_set(\'0\', req_atk) = 0, a.req_atk, substr(a.req_atk, 1, locate(\',0\', a.req_atk) - 1)) as req_atk, ifnull(l.benutzt, 0) as benutzt, if(l.benutzt is null,1,0) as unknown from attacken a left join lernen l on a.id = l.at_id AND l.besitzer = '.$char['id']. ' where find_in_set('.$char_race.', a.rassen) <> 0 '.$sql_append1;
// Second sql to include all currently not learnable attacks (due to an other fruit or fusion race)
$sql2 = 'SELECT a.name, a.id, a.level, a.geld, if(find_in_set(\'0\', req_atk) = 0, a.req_atk, substr(a.req_atk, 1, locate(\',0\', a.req_atk) - 1)) as req_atk, ifnull(l.benutzt, 0) as benutzt, if(l.benutzt is null,1,0) as unknown from lernen l inner join attacken a on l.at_id = a.id where besitzer = '.$char['id'].' and find_in_set('.$char_race.', a.rassen) = 0 '.$sql_append2;
// make a union out of both (TODO: maybe an outer join would result into the same result)
$sql = '('.$sql.') union distinct ('.$sql2.') order by level';
$qry = mysql_query($sql);
$qry = mysql_query($sql);
echo '<br>'.$sql.'<br>';
if($qry === FALSE) // print sql on error
echo '<br>'.$sql.'<br>';
// The first index is the id of the attack!
// The first index is the id of the attack!
// then there is the basic information like
// then there is the basic information like
@ -312,6 +331,13 @@ function getAttacksforChar($charid) {