$temp_tokens = array(); foreach ($hidden_database_abilities as $token) { $temp_tokens[] = "'" . $token . "'"; } $temp_condition .= 'AND ability_token NOT IN (' . implode(',', $temp_tokens) . ') '; } // If additional database filters were provided $temp_condition_unfiltered = $temp_condition; if (isset($mmrpg_database_abilities_filter)) { if (!preg_match('/^\\s?(AND|OR)\\s+/i', $mmrpg_database_abilities_filter)) { $temp_condition .= 'AND '; } $temp_condition .= $mmrpg_database_abilities_filter; } // Collect the database abilities $ability_fields = rpg_ability::get_index_fields(true); $db->query("SET @ability_row_number = 0;"); $mmrpg_database_abilities = $db->get_array_list("SELECT {$ability_fields} FROM mmrpg_index_abilities WHERE ability_flag_published = 1 AND (ability_flag_hidden = 0 OR ability_token = '{$this_current_token}') {$temp_condition} ORDER BY ability_order ASC", 'ability_token'); $mmrpg_database_abilities_count = $db->get_value("SELECT COUNT(ability_id) AS ability_count FROM mmrpg_index_abilities WHERE ability_flag_published = 1 AND ability_flag_hidden = 0 {$temp_condition_unfiltered};", 'ability_count'); $mmrpg_database_abilities_numbers = $db->get_array_list("SELECT ability_token, (@ability_row_number:=@ability_row_number + 1) AS ability_key FROM mmrpg_index_abilities WHERE ability_flag_published = 1 {$temp_condition_unfiltered} ORDER BY ability_flag_hidden ASC, ability_order ASC;", 'ability_token'); // Remove unallowed abilities from the database, and increment counters foreach ($mmrpg_database_abilities as $temp_token => $temp_info) { // Define first ability token if not set if (!isset($first_ability_token)) { $first_ability_token = $temp_token; } // Send this data through the ability index parser $temp_info = rpg_ability::parse_index_info($temp_info); // Collect this ability's key in the index $temp_info['ability_key'] = $mmrpg_database_abilities_numbers[$temp_token]['ability_key']; // Ensure this ability's image exists, else default to the placeholder