39 #include <boost/assign/list_of.hpp>
42 #define WRN_NG LOG_STREAM(warn, log_engine)
50 bool internal_conditional_passed(
const vconfig&
cond)
53 if(!true_keyword.empty()) {
58 if(!false_keyword.empty()) {
67 for(vconfig::child_list::const_iterator u = have_unit.begin(); u != have_unit.end(); ++u) {
70 std::vector<std::pair<int,int> > counts = (*u).has_attribute(
"count")
76 if (
i.hitpoints() > 0 && ufilt(
i) ) {
78 if(counts == default_counts) {
84 if ((*u)[
"search_recall_list"].to_bool())
90 if(counts == default_counts && match_count) {
94 if(counts == default_counts && match_count) {
112 for(vconfig::child_list::const_iterator
v = have_location.begin();
v != have_location.end(); ++
v) {
113 std::set<map_location>
res;
116 std::vector<std::pair<int,int> > counts = (*v).has_attribute(
"count")
118 if(!in_ranges<int>(res.size(), counts)) {
132 #define TEST_STR_ATTR(name, test) do { \
133 if (values.has_attribute(name)) { \
134 std::string attr_str = values[name].str(); \
135 std::string str_value = value.str(); \
136 if (!(test)) return false; \
140 #define TEST_NUM_ATTR(name, test) do { \
141 if (values.has_attribute(name)) { \
142 double attr_num = values[name].to_double(); \
143 double num_value = value.to_double(); \
144 if (!(test)) return false; \
148 #define TEST_BOL_ATTR(name, test) do { \
149 if (values.has_attribute(name)) { \
150 bool attr_bool = values[name].to_bool(); \
151 bool bool_value = value.to_bool(); \
152 if (!(test)) return false; \
159 TEST_NUM_ATTR(
"numerical_not_equals", num_value != attr_num);
162 TEST_NUM_ATTR(
"greater_than_equal_to", num_value >= attr_num);
165 TEST_BOL_ATTR(
"boolean_not_equals", bool_value != attr_bool);
166 TEST_STR_ATTR(
"contains", str_value.find(attr_str) != std::string::npos);
174 static const boost::container::flat_set<std::string> hard_coded = boost::assign::list_of(
"true")(
"false")(
"have_unit")(
"have_location")(
"variable")
175 (
"then")(
"else")(
"elseif")(
"not")(
"and")(
"or")(
"do").convert_to_container<boost::container::flat_set<std::string> >();
181 if (
std::find(hard_coded.begin(), hard_coded.end(), key) == hard_coded.end()) {
197 bool matches = internal_conditional_passed(cond);
202 while(cond_i != cond_end)
208 if(cond_name ==
"and")
213 else if(cond_name ==
"or")
218 else if(cond_name ==
"not")
230 WRN_NG <<
"attempt to filter attack for an event with no attack data." << std::endl;
#define TEST_STR_ATTR(name, test)
bool matches_filter(const config &filter) const
Returns whether or not *this matches the given filter.
size_t size() const
Get the number of units on the list.
vconfig get_child() const
config get_parsed_config() const
all_children_iterator ordered_end() const
#define TEST_BOL_ATTR(name, test)
bool run_wml_conditional(std::string const &, vconfig const &)
Runs a command from an event handler.
Definitions for the interface to Wesnoth Markup Language (WML).
Variant for storing WML attributes.
GLboolean GLenum GLenum GLvoid * values
This class stores all the data for a single 'side' (in game nomenclature).
std::vector< team > * teams
virtual config::attribute_value get_variable_const(const std::string &varname) const
returns a blank attribute value if varname is no valid variable name.
child_list get_children(const std::string &key) const
filter_context * filter_con
GLsizei const GLfloat * value
static lg::log_domain log_engine("engine")
Templates and utility-routines for strings and numbers.
const std::string & save_id() const
Define conditionals for the game's events mechanism, a.k.a.
void get_locations(std::set< map_location > &locs, bool with_border=false) const
bool matches_special_filter(const config &cfg, const vconfig &filter)
std::vector< std::pair< int, int > > parse_ranges(std::string const &str)
GLuint const GLchar * name
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
bool conditional_passed(const vconfig &cond)
bool find(E event, F functor)
Tests whether an event handler is available.
static int cond(LexState *ls)
A variable-expanding proxy for the config class.
Standard logging facilities (interface).
recall_list_manager & recall_list()
game_lua_kernel * lua_kernel
std::vector< vconfig > child_list
A config object defines a single node in a WML file, with access to child nodes.
#define TEST_NUM_ATTR(name, test)
GLsizei const GLcharARB ** string
std::string get_key() const
all_children_iterator ordered_begin() const
In-order iteration over all children.
bool in_ranges(const Cmp c, const std::vector< std::pair< Cmp, Cmp > > &ranges)