17 #ifndef UNIT_H_INCLUDED
18 #define UNIT_H_INCLUDED
20 #include <boost/tuple/tuple.hpp>
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/ptr_container/ptr_vector.hpp>
23 #include <boost/variant.hpp>
31 #if defined(_MSC_VER) && _MSC_VER <= 1600
36 #include <SDL_video.h>
46 typedef std::pair<const config *, map_location>
unit_ability;
77 const_iterator
end()
const {
return cfgs_.end(); }
86 iterator
erase(
const iterator & erase_it) {
return cfgs_.erase(erase_it); }
91 std::vector<unit_ability>
cfgs_;
113 ,
bool use_traits =
false
114 ,
const vconfig* vcfg =
nullptr
245 const std::map<std::string,std::string>
get_states()
const;
297 typedef boost::variant<upkeep_full, upkeep_loyal, int>
t_upkeep;
327 std::vector<std::pair<std::string,std::string> >
amla_icons()
const;
389 std::vector<boost::tuple<t_string,t_string,t_string> >
ability_tooltips(std::vector<bool> *active_list=
nullptr)
const;
528 boost::scoped_ptr<std::string>
halo_;
562 :
private boost::noncopyable
std::string image_halo() const
std::string image_mods() const
void set_resting(bool rest)
const std::vector< t_string > & trait_descriptions() const
static const std::set< std::string > builtin_effects
int total_movement() const
void generate_traits(bool musthaveonly=false)
Apply mandatory traits (e.g.
void set_unrenamable(bool unrenamable)
const std::string & id() const
t_string unit_description() const
Information about the unit – a detailed description of it.
bool is_visible_to_team(team const &team, gamemap const &map, bool const see_all=true) const
t_string type_name_
Never nullptr. Adjusted for gender and variation.
std::vector< bool > known_boolean_states_
void apply_builtin_effect(std::string type, const config &effect)
const map_location & get_location() const
std::vector< std::string > recruit_list_
void set_usage(const std::string &usage)
void set_hidden(bool state) const
std::string absolute_image() const
The name of the file to game_display (used in menus).
void set_user_end_turn(bool value=true)
const std::string & team_color() const
void set_hitpoints(int hp)
utils::string_map modification_descriptions_
bool ability_affects_adjacent(const std::string &ability, const config &cfg, int dir, const map_location &loc, const unit &from) const
unit_movement_resetter(unit &u, bool operate=true)
int max_hitpoints() const
bool get_state(const std::string &state) const
void parse_upkeep(const config::attribute_value &upkeep)
void set_id(const std::string &id)
id assigned by wml
size_t underlying_id() const
The unique internal ID of the unit.
std::string TC_image_mods() const
const t_string & name() const
The unit name for display.
const t_string & type_name() const
The unit type name.
int vision_cost(const t_translation::t_terrain &terrain, bool slowed=false) const
Returns the cost to see through the indicated terrain.
bool user_end_turn() const
int movement_cost(const t_translation::t_terrain &terrain) const
double hp_bar_scaling() const
std::vector< std::string > advances_to_
iterator erase(const iterator &erase_it)
std::vector< config > get_modification_advances() const
~unit_movement_resetter()
double xp_bar_scaling() const
std::vector< t_string > trait_names_
void remove_movement_ai()
GLuint GLuint GLsizei GLenum type
std::vector< boost::tuple< t_string, t_string, t_string > > ability_tooltips(std::vector< bool > *active_list=nullptr) const
Tuple of: neutral ability name, gendered ability name, description.
bool matches_id(const std::string &unit_id) const
void clear_visibility_cache() const
Clears the cache.
void set_recall_cost(int recall_cost)
void set_image_halo(const std::string &halo)
unit & operator=(unit)
Assignment operator.
unit_type::ALIGNMENT alignment_
map_location::DIRECTION facing_
const map_location & get_interrupted_move() const
std::string usage() const
const std::vector< std::string > advances_to_translated() const
void toggle_user_end_turn()
void set_image_ellipse(const std::string &ellipse)
bool resistance_filter_matches(const config &cfg, bool attacker, const std::string &damage_name, int res) const
GLuint const GLfloat * val
void advance_to(const unit_type &t, bool use_traits=false)
Advances this unit to another type.
std::pair< int, map_location > highest(const std::string &key, int def=0) const
void set_alignment(unit_type::ALIGNMENT alignment)
void write(config &cfg) const
SDL_Color xp_color() const
Colors for the unit's XP.
void write_upkeep(config::attribute_value &upkeep) const
bool move_interrupted() const
void set_state(const std::string &state, bool value)
GLsizeiptr const GLvoid GLenum usage
The basic "size" of the unit - flying, small land, large land, etc.
bool get_ability_bool(const std::string &tag_name, const map_location &loc) const
Returns true if the unit is currently under effect by an ability with this given TAG NAME...
boost::ptr_vector< config > t_advancements
void expire_modifications(const std::string &duration)
Clears those modifications whose duration has expired.
std::string small_profile() const
The unit's profile.
std::vector< unit_ability > cfgs_
int movement_cost(const t_translation::t_terrain &terrain, bool slowed=false) const
Returns the cost to move through the indicated terrain.
friend void intrusive_ptr_release(const unit *)
Variant for storing WML attributes.
int defense_modifier(const t_translation::t_terrain &terrain) const
std::string small_profile_
static std::map< std::string, state_t > known_boolean_state_names_
std::string describe_builtin_effect(std::string type, const config &effect)
std::vector< unit_ability >::iterator iterator
const map_location & get_goto() const
const std::vector< std::string > & recruits() const
t_advancements advancements_
void apply_modifications()
const unit_type & type() const
The type of the unit (accounting for gender and variation).
int resistance_against(const attack_type &damage_type, bool attacker, const map_location &loc) const
std::map< std::string, std::string > advancement_icons() const
void set_role(const std::string &role)
const std::string & type_id() const
The id of the type of the unit.
static void clear_status_caches()
Clear the unit status cache for all units.
This class stores all the data for a single 'side' (in game nomenclature).
static const std::string & leader_crown()
The path to the leader crown overlay.
bool incapacitated() const
void set_facing(map_location::DIRECTION dir) const
boost::variant< upkeep_full, upkeep_loyal, int > t_upkeep
std::map< std::string, t_string > string_map
void swap(unit &)
Swap, for copy and swap idiom.
const config & variables() const
const std::vector< std::string > & overlays() const
const std::string & undead_variation() const
unit_type::ALIGNMENT alignment() const
const_iterator begin() const
void set_emit_zoc(bool val)
std::vector< unit_ability >::const_iterator const_iterator
GLsizei const GLfloat * value
void set_can_recruit(bool canrecruit)
int vision_cost(const t_translation::t_terrain &terrain) const
void set_recruits(const std::vector< std::string > &recruits)
void rename(const std::string &name)
void add_trait_description(const config &trait, const t_string &description)
register a trait's name and its description for UI's use
Encapsulates the map of the game.
bool ability_affects_self(const std::string &ability, const config &cfg, const map_location &loc) const
const t_advancements & modification_advancements() const
unit_race::GENDER gender() const
std::string image_ellipse() const
Object which temporarily resets a unit's movement.
unit_animation_component & anim_comp() const
int damage_from(const attack_type &attack, bool attacker, const map_location &loc) const
unit_race::GENDER gender_
boost::scoped_ptr< unit_animation_component > anim_comp_
bool has_ability_type(const std::string &ability) const
bool is_flying() const
Returns whether or not *this is flagged as a flying movement type.
int movement_left() const
Returns how far a unit can move this turn (zero if incapacitated).
static const ::config * terrain
The terrain used to create the cache.
boost::scoped_ptr< std::string > halo_
const T & get_or_default(const boost::scoped_ptr< T > &v)
const std::string & type() const
const std::vector< attack_type > & attacks() const
bool invisible(const map_location &loc, bool see_all=true) const
utils::string_map damage_table() const
Returns a map from attack types to resistances.
const std::string ¶meters float amount
std::string get_checksum(const unit &u)
Gets a checksum for a unit.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
boost::scoped_ptr< std::string > usage_
std::vector< std::string > overlays_
Encapsulates the map of the game.
const unit_ability & front() const
std::vector< std::pair< std::string, std::string > > amla_icons() const
std::string default_anim_image() const
The default image to use for animation frames with no defined image.
int jamming_cost(const t_translation::t_terrain &terrain) const
void add_modification(const std::string &type, const config &modification, bool no_add=false)
const std::vector< std::string > & advances_to() const
unit & clone(bool is_temporary=true)
Mark this unit as clone so it can be inserted to unit_map.
map_location::DIRECTION facing() const
void set_name(const t_string &name)
void set_location(const map_location &loc)
To be called by unit_map or for temporary units only.
const std::map< std::string, std::string > get_states() const
size_t modification_count(const std::string &type, const std::string &id) const
std::pair< const config *, map_location > unit_ability
The things contained within a unit_ability_list.
map_location interrupted_move_
boost::scoped_ptr< unit_formula_manager > formula_man_
bool hold_position() const
void set_interrupted_move(const map_location &interrupted_move)
void set_goto(const map_location &new_goto)
std::vector< attack_type > & attacks()
void set_movement(int moves, bool unit_action=false)
Set the unit's remaining movement to moves.
n_unit::unit_id underlying_id_
const std::string & variation() const
void set_side(unsigned int new_side)
void set_upkeep(t_upkeep v)
DIRECTION
Valid directions which can be moved in our hexagonal world.
bool take_hit(int damage)
Called on every draw.
const config & recall_filter() const
unit_ability_list get_abilities(const std::string &tag_name, const map_location &loc) const
const unit_ability & back() const
int resistance_against(const std::string &damage_name, bool attacker, const map_location &loc) const
std::string big_profile() const
GLuint const GLchar * name
const std::string & effect_image_mods() const
std::pair< int, map_location > lowest(const std::string &key, int def=0) const
unit_formula_manager & formula_manager() const
void set_advancements(std::vector< config > advancements)
int max_experience() const
static state_t get_known_boolean_state_id(const std::string &state)
const std::vector< t_string > & trait_names() const
SDL_Color hp_color() const
Colors for the unit's current hitpoints.
boost::scoped_ptr< std::string > ellipse_
bool get_ability_bool(const std::string &tag_name) const
Returns true if the unit is currently under effect by an ability with this given TAG NAME...
bool ability_active(const std::string &ability, const config &cfg, const map_location &loc) const
bool unrenamable() const
Set to true for some scenario-specific units which should not be renamed.
std::vector< attack_type > attacks_
const movetype & movement_type() const
A variable-expanding proxy for the config class.
const unit_race * race_
The displayed name of the unit type.
const_iterator end() const
friend void intrusive_ptr_add_ref(const unit *)
Intrusive Pointer interface.
std::map< map_location, bool > invisibility_cache_
Hold the visibility status cache for a unit, when not uncovered.
utils::string_map get_base_resistances() const
void set_attacks(int left)
static std::map< std::string, state_t > get_known_boolean_state_names()
void set_level(int level)
std::string id_
Never nullptr, but may point to the null race.
std::vector< t_string > trait_descriptions_
void push_back(const unit_ability &ability)
const std::string & get_role() const
bool has_ability_by_id(const std::string &ability) const
bool get_emit_zoc() const
A config object defines a single node in a WML file, with access to child nodes.
unit_ability_list get_abilities(const std::string &tag_name) const
void remove_ability_by_id(const std::string &ability)
void set_experience(int xp)
const unit_race * race() const
Never returns nullptr, but may point to the null race.
void set_underlying_id(n_unit::id_manager &id_manager)
void toggle_hold_position()
std::vector< std::string > get_ability_list() const
GLsizei const GLcharARB ** string
int jamming_cost(const t_translation::t_terrain &terrain, bool slowed=false) const
Returns the cost to "jam" through the indicated terrain.
const std::string & id() const
The id for this unit_type.
int movement_left(bool base_value) const
Providing a true parameter to movement_left() causes it to ignore incapacitation. ...
std::set< std::string > states_
void set_advances_to(const std::vector< std::string > &advances_to)
std::string undead_variation_
t_upkeep upkeep_raw() const
std::vector< std::string > get_traits_list() const