25 #include <boost/iterator/indirect_iterator.hpp>
26 #include <boost/range/iterator_range.hpp>
27 #include <boost/dynamic_bitset_fwd.hpp>
34 class map_formula_callable;
38 class attack_type :
public std::enable_shared_from_this<attack_type>
44 const std::string&
id()
const {
return id_; }
82 bool has_special(
const std::string& special,
bool simple_check=
false,
bool special_id=
true,
bool special_tags=
true)
const;
84 std::vector<std::pair<t_string, t_string>>
special_tooltips(boost::dynamic_bitset<>* active_list =
nullptr)
const;
90 unsigned & max_attacks)
const;
93 std::pair<std::string, std::string>
damage_type()
const;
116 bool has_weapon_ability(
const std::string& special,
bool special_id=
true,
bool special_tags=
true)
const;
123 bool has_special_or_ability(
const std::string& special,
bool special_id=
true,
bool special_tags=
true)
const;
177 const std::string& filter_self =
"filter_self")
const;
191 std::string& temp_string,
197 std::set<std::string>& checking_name,
198 const std::set<std::string>& checking_tags={},
199 bool leader_bool=false
203 std::string& temp_string,
209 std::set<std::string>& checking_name,
210 const std::set<std::string>& checking_tags={},
211 const std::string& affect_adjacents=
"",
212 bool leader_bool=false
232 const std::string& tag_name,
233 bool leader_bool=
false
259 const std::string& tag_name,
260 bool leader_bool=
false
268 const std::string& tag_name,
269 const std::string& filter_self =
"filter_self"
283 std::shared_ptr<const attack_type>
parent;
308 return specials_context_t(*
this, other_attack,
self, other, unit_loc, other_loc, attacking);
349 using attack_itors = boost::iterator_range<boost::indirect_iterator<attack_list::iterator>>;
350 using const_attack_itors = boost::iterator_range<boost::indirect_iterator<attack_list::const_iterator>>;
353 return boost::make_iterator_range(boost::make_indirect_iterator(atks.begin()), boost::make_indirect_iterator(atks.end()));
357 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)
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 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.
static bool special_active_impl(const_attack_ptr self_attack, 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...
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
void set_accuracy(int value)
const std::string & type() const
void set_movement_used(int value)
unit_ability_list get_weapon_ability(const std::string &ability) const
Returns list for weapon like abilities for each ability type.
std::string weapon_specials_value(const std::set< std::string > checking_tags) 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 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)
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...
static bool check_adj_abilities_impl(const_attack_ptr self_attack, const_attack_ptr other_attack, const config &special, 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 ...
static void weapon_specials_impl_adj(std::string &temp_string, unit_const_ptr self, const_attack_ptr self_attack, 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)
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.
void set_parry(int value)
void set_attack_weight(double value)
void set_damage(int value)
static void weapon_specials_impl_self(std::string &temp_string, unit_const_ptr self, const_attack_ptr self_attack, 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.
const t_string & name() 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)
static bool check_self_abilities_impl(const_attack_ptr self_attack, const_attack_ptr other_attack, const config &special, 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...
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)
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
attack_type(const config &cfg)
void set_type(const std::string &value)
void write(config &cfg) const
bool matches_filter(const config &filter, const std::string &tag_name="") const
Returns whether or not *this matches the given filter.
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
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.
std::shared_ptr< const unit > unit_const_ptr
std::shared_ptr< const attack_type > const_attack_ptr
Encapsulates the map of the game.