Skip to content

Commit

Permalink
add [has_ally],[has_enemy] tags for standard side filter
Browse files Browse the repository at this point in the history
Unlike [allied_with] and [enemy_of], these will match if only if
there is *any* ally or enemy matching the filter. The other versions
of the tag match only if all sides matching the filter are
allied / opposed.
  • Loading branch information
cbeck88 committed Jul 12, 2014
1 parent d4b3927 commit 91e8482
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/side_filter.cpp
Expand Up @@ -173,6 +173,37 @@ bool side_filter::match_internal(const team &t) const
}
}

const vconfig& has_enemy = cfg_.child("has_enemy");
if(!has_enemy.null()) {
side_filter s_filter(has_enemy);
const std::vector<int>& teams = s_filter.get_teams();
bool found = false;
BOOST_FOREACH(const int side, teams) {
if((*resources::teams)[side - 1].is_enemy(t.side()))
{
found = true;
break;
}
}
if (!found) return false;
}

const vconfig& has_ally = cfg_.child("has_ally");
if(!has_ally.null()) {
side_filter s_filter(has_ally);
const std::vector<int>& teams = s_filter.get_teams();
bool found = false;
BOOST_FOREACH(const int side, teams) {
if(!(*resources::teams)[side - 1].is_enemy(t.side()))
{
found = true;
break;
}
}
if (!found) return false;
}


const config::attribute_value cfg_controller = cfg_["controller"];
if (!cfg_controller.blank())
{
Expand Down

0 comments on commit 91e8482

Please sign in to comment.