Skip to content

Commit

Permalink
add "attack_alignment" filter for filter attack with alignment diffre…
Browse files Browse the repository at this point in the history
…nt of unit alignment

alignment of attack could be filtered in [event][filter_attack] and specials [filter_weapon)(with caution in latest case)
  • Loading branch information
newfrenchy83 committed Oct 8, 2023
1 parent 53e46ea commit b85adb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/schema/filters/weapon.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{SIMPLE_KEY accuracy s_unsigned_range_list}
{SIMPLE_KEY movement_used s_unsigned_range_list}
{SIMPLE_KEY attacks_used s_unsigned_range_list}
{SIMPLE_KEY attack_alignment alignment}
{FILTER_BOOLEAN_OPS weapon}
[/tag]

8 changes: 8 additions & 0 deletions src/units/attack_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
const std::string& filter_parry = filter["parry"];
const std::string& filter_movement = filter["movement_used"];
const std::string& filter_attacks_used = filter["attacks_used"];
const std::vector<std::string> filter_alignment = utils::split(filter["attack_alignment"]);
const std::vector<std::string> filter_name = utils::split(filter["name"]);
const std::vector<std::string> filter_type = utils::split(filter["type"]);
const std::vector<std::string> filter_special = utils::split(filter["special"]);
Expand Down Expand Up @@ -141,6 +142,13 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
if (!filter_attacks_used.empty() && !in_ranges(attack.attacks_used(), utils::parse_ranges_unsigned(filter_attacks_used)))
return false;

if(!filter_alignment.empty() ){
std::string attack_alignment = unit_alignments::get_string((attack.specials_alignment()).first);
if (std::find(filter_alignment.begin(), filter_alignment.end(), attack_alignment) == filter_alignment.end() ){
return false;
}
}

if ( !filter_name.empty() && std::find(filter_name.begin(), filter_name.end(), attack.id()) == filter_name.end() )
return false;

Expand Down

0 comments on commit b85adb4

Please sign in to comment.