24 #include <boost/iterator/indirect_iterator.hpp>
25 #include <boost/dynamic_bitset_fwd.hpp>
33 class map_formula_callable;
37 class attack_type :
public std::enable_shared_from_this<attack_type>
43 const std::string&
id()
const {
return id_; }
84 bool has_special(
const std::string& special,
bool simple_check=
false,
bool special_id=
true,
bool special_tags=
true)
const;
86 std::vector<std::pair<t_string, t_string>>
special_tooltips(boost::dynamic_bitset<>* active_list =
nullptr)
const;
99 unsigned & max_attacks)
const;
110 std::pair<std::string, std::string>
damage_type()
const;
135 bool has_weapon_ability(
const std::string& special,
bool special_id=
true,
bool special_tags=
true)
const;
142 bool has_special_or_ability(
const std::string& special,
bool special_id=
true,
bool special_tags=
true)
const;
201 operator bool()
const;
209 std::shared_ptr<const attack_type>
parent;
270 const std::string& filter_self =
"filter_self")
const;
284 std::string& temp_string,
290 std::set<std::string>& checking_name,
291 const std::set<std::string>& checking_tags={},
292 bool leader_bool=false
296 std::string& temp_string,
302 std::set<std::string>& checking_name,
303 const std::set<std::string>& checking_tags={},
304 const std::string& affect_adjacents=
"",
305 bool leader_bool=false
325 const std::string& tag_name,
326 bool leader_bool=
false
352 const std::string& tag_name,
353 bool leader_bool=
false
361 const std::string& tag_name,
362 const std::string& filter_self =
"filter_self"
376 std::shared_ptr<const attack_type>
parent;
401 return specials_context_t(*
this, other_attack,
self, other, unit_loc, other_loc, attacking);
449 using attack_itors = boost::iterator_range<boost::indirect_iterator<attack_list::iterator>>;
450 using const_attack_itors = boost::iterator_range<boost::indirect_iterator<attack_list::const_iterator>>;
453 return boost::make_iterator_range(boost::make_indirect_iterator(atks.begin()), boost::make_indirect_iterator(atks.end()));
457 return boost::make_iterator_range(boost::make_indirect_iterator(atks.begin()), boost::make_indirect_iterator(atks.end()));
boost::iterator_range< boost::indirect_iterator< attack_list::iterator > > attack_itors
std::vector< attack_ptr > attack_list
boost::iterator_range< boost::indirect_iterator< attack_list::const_iterator > > const_attack_itors
attack_itors make_attack_itors(attack_list &atks)
Helper similar to std::unique_lock for detecting when calculations such as has_special have entered i...
recursion_guard & operator=(const recursion_guard &)=delete
recursion_guard(const recursion_guard &other)=delete
recursion_guard & operator=(recursion_guard &&)
std::shared_ptr< const attack_type > parent
recursion_guard()
Construct an empty instance, only useful for extending the lifetime of a recursion_guard returned fro...
specials_context_t(const specials_context_t &)=delete
specials_context_t(const attack_type &weapon, bool attacking)
Initialize weapon specials context for listing.
std::shared_ptr< const attack_type > parent
const config & specials() const
std::string alignment_str() const
Returns alignment specified by alignment() for filtering when exist.
void set_min_range(int value)
std::string weapon_specials() const
Returns a comma-separated string of active names for the specials of *this.
double defense_weight() const
void set_num_attacks(int value)
specials_context_t specials_context(unit_const_ptr self, const map_location &loc, bool attacking=true) const
bool check_self_abilities(const config &cfg, const std::string &special) const
check_self_abilities : return an boolean value for checking of activities of abilities used like weap...
bool has_special(const std::string &special, bool simple_check=false, bool special_id=true, bool special_tags=true) const
Returns whether or not *this has a special with a tag or id equal to special.
std::string weapon_specials_value(const std::set< std::string > &checking_tags) const
int composite_value(const unit_ability_list &abil_list, int base_value) const
Return the special weapon value, considering specials.
double attack_weight() const
const_attack_ptr other_attack_
void add_formula_context(wfl::map_formula_callable &) const
const std::string & range() const
void set_attacks_used(int value)
int movement_used() const
specials_context_t specials_context_for_listing(bool attacking=true) const
bool has_special_or_ability_with_filter(const config &filter) const
void set_accuracy(int value)
const std::string & type() const
void set_movement_used(int value)
static bool special_active_impl(const const_attack_ptr &self_attack, const const_attack_ptr &other_attack, const config &special, AFFECTS whom, const std::string &tag_name, const std::string &filter_self="filter_self")
Returns whether or not the given special is active for the specified unit, based on the current conte...
unit_ability_list get_weapon_ability(const std::string &ability) const
Returns list for weapon like abilities for each ability type.
std::string select_damage_type(const unit_ability_list &damage_type_list, const std::string &key_name, const unit_ability_list &resistance_list) const
Select best damage type based on frequency count for replacement_type and based on highest damage for...
bool has_ability_with_filter(const config &filter) const
std::string accuracy_parry_description() const
unit_ability_list get_specials_and_abilities(const std::string &special) const
bool apply_modification(const config &cfg)
Modifies *this using the specifications in cfg, but only if *this matches cfg viewed as a filter.
bool matches_filter(const config &filter, const std::string &check_if_recursion="") const
Returns whether or not *this matches the given filter.
bool overwrite_special_checking(unit_ability_list &overwriters, const config &cfg, const std::string &tag_name) const
Check whether cfg would be overwritten by any element of overwriters.
void set_specials(config value)
bool check_adj_abilities(const config &cfg, const std::string &special, int dir, const unit &from) const
check_adj_abilities : return an boolean value for checking of activities of abilities used like weapo...
friend class specials_context_t
void set_defense_weight(double value)
static void weapon_specials_impl_adj(std::string &temp_string, const unit_const_ptr &self, const const_attack_ptr &self_attack, const const_attack_ptr &other_attack, const map_location &self_loc, AFFECTS whom, std::set< std::string > &checking_name, const std::set< std::string > &checking_tags={}, const std::string &affect_adjacents="", bool leader_bool=false)
void set_changed(bool value)
unit_ability_list overwrite_special_overwriter(unit_ability_list overwriters, const std::string &tag_name) const
Filter a list of abilities or weapon specials, removing any entries that don't own the overwrite_spec...
recursion_guard update_variables_recursion(const config &special) const
Tests which might otherwise cause infinite recursion should call this, check that the returned object...
std::vector< std::pair< t_string, t_string > > special_tooltips(boost::dynamic_bitset<> *active_list=nullptr) const
Returns a vector of names and descriptions for the specials of *this.
static void weapon_specials_impl_self(std::string &temp_string, const unit_const_ptr &self, const const_attack_ptr &self_attack, const const_attack_ptr &other_attack, const map_location &self_loc, AFFECTS whom, std::set< std::string > &checking_name, const std::set< std::string > &checking_tags={}, bool leader_bool=false)
weapon_specials_impl_self and weapon_specials_impl_adj : check if special name can be added.
void set_parry(int value)
void set_attack_weight(double value)
void set_damage(int value)
utils::optional< unit_alignments::type > alignment() const
Returns alignment specified by alignment_ variable.
const t_string & name() const
std::set< std::string > alternative_damage_types() const
bool describe_modification(const config &cfg, std::string *description)
Trimmed down version of apply_modification(), with no modifications actually made.
const std::string & id() const
void set_icon(const std::string &value)
std::vector< const config * > open_queries_
While processing a recursive match, all the filters that are currently being checked,...
static bool check_self_abilities_impl(const const_attack_ptr &self_attack, const const_attack_ptr &other_attack, const config &special, const unit_const_ptr &u, const map_location &loc, AFFECTS whom, const std::string &tag_name, bool leader_bool=false)
check_self_abilities_impl : return an boolean value for checking of activities of abilities used like...
bool attack_empty() const
Returns true if this is a dummy attack_type, for example the placeholder that the unit_attack dialog ...
bool special_matches_filter(const config &cfg, const std::string &tag_name, const config &filter) const
Filter a list of abilities or weapon specials.
int modified_damage() const
Returns the damage per attack of this weapon, considering specials.
void modified_attacks(unsigned &min_attacks, unsigned &max_attacks) const
Calculates the number of attacks this weapon has, considering specials.
void set_id(const std::string &value)
void remove_special_by_filter(const config &filter)
remove special if matche condition
specials_context_t specials_context(unit_const_ptr self, unit_const_ptr other, const map_location &unit_loc, const map_location &other_loc, bool attacking, const_attack_ptr other_attack) const
void set_max_range(int value)
utils::optional< unit_alignments::type > alignment_
attack_type(const config &cfg)
void set_type(const std::string &value)
void write(config &cfg) const
static bool check_adj_abilities_impl(const const_attack_ptr &self_attack, const const_attack_ptr &other_attack, const config &special, const unit_const_ptr &u, const unit &from, int dir, const map_location &loc, AFFECTS whom, const std::string &tag_name, bool leader_bool=false)
check_adj_abilities_impl : return an boolean value for checking of activities of abilities used like ...
bool has_special_with_filter(const config &filter) const
check if special matche
void set_range(const std::string &value)
bool special_active(const config &special, AFFECTS whom, const std::string &tag_name, const std::string &filter_self="filter_self") const
unit_ability_list get_specials(const std::string &special) const
Returns the currently active specials as an ability list, given the current context (see set_specials...
const std::string & icon() const
specials_context_t specials_context(const unit_type &self_type, const map_location &loc, bool attacking=true) const
void set_attack_alignment(const std::string &value)
bool has_special_or_ability(const std::string &special, bool special_id=true, bool special_tags=true) const
used for abilities used like weapon and true specials
bool has_weapon_ability(const std::string &special, bool special_id=true, bool special_tags=true) const
used for abilities used like weapon
void set_name(const t_string &value)
std::pair< std::string, std::string > damage_type() const
return a modified damage type and/or add a secondary_type for hybrid use if special is active.
A config object defines a single node in a WML file, with access to child nodes.
A single unit type that the player may recruit.
This class represents a single unit of a specific type.
Definitions for the interface to Wesnoth Markup Language (WML).
std::shared_ptr< const unit > unit_const_ptr
std::shared_ptr< const attack_type > const_attack_ptr
Encapsulates the map of the game.
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
static constexpr utils::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.