60 target_hex_(target_hex),
61 weapon_choice_(weapon_choice),
62 attack_movement_cost_(u.attacks()[weapon_choice_].movement_used()),
63 temp_movement_subtracted_(0),
64 attack_count_(u.attacks()[weapon_choice_].attacks_used()),
65 temp_attacks_subtracted_(0)
72 , target_hex_(cfg.mandatory_child(
"target_hex_")[
"x"], cfg.mandatory_child(
"target_hex_")[
"y"],
wml_loc())
73 , weapon_choice_(cfg[
"weapon_choice_"].to_int(-1))
74 , attack_movement_cost_()
75 , temp_movement_subtracted_(0)
77 , temp_attacks_subtracted_(0)
84 if(weapon_choice_ < 0 || weapon_choice_ >=
static_cast<int>(
get_unit()->attacks().
size()))
132 if (
route_->steps.size() >= 2)
134 bool m_success, m_complete;
219 layer, hex, [tex = std::move(indicator)](
const rect&
d) {
draw::blit(tex,
d); });
243 if(
get_unit()->attacks_left() <= 0) {
260 final_cfg[
"type"] =
"attack";
268 final_cfg.
add_child(
"target_hex_", std::move(target_hex_cfg));
Arrows destined to be drawn on the map.
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, decltype(draw_helper::do_draw) draw_func)
Add an item to the drawing buffer.
static display * get_singleton()
Returns the display object if a display object exists.
void attack_enemy(const map_location &attacker_loc, const map_location &defender_loc, int choice)
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
virtual const unit_map & units() const override
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
Wrapper class to encapsulate creation and management of an SDL_Texture.
Container associating units to locations.
unit_iterator find(std::size_t id)
This class represents a single unit of a specific type.
bool valid()
Returns whether this action is valid or not.
int temp_movement_subtracted_
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
int temp_attacks_subtracted_
void invalidate()
invalidates the move-destination and attack-target hexes
virtual void redraw()
Redrawing function, called each time the action situation might have changed.
virtual error check_validity() const
Check the validity of the action.
virtual void accept(visitor &v)
int attack_movement_cost_
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
attack(std::size_t team_index, bool hidden, unit &mover, const map_location &target_hex, int weapon_choice, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
map_location target_hex_
the target of the attack
const map_location & get_target_hex() const
virtual config to_config() const
Constructs and returns a config object representing this object.
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
std::shared_ptr< attack > shared_from_this()
virtual std::ostream & print(std::ostream &s) const
A planned move, represented on the map by an arrow and a ghosted unit in the destination hex.
void redraw()
Redrawing function, called each time the action situation might have changed.
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
virtual error check_validity() const
Check the validity of the action.
std::unique_ptr< pathfind::marked_route > route_
virtual std::ostream & print(std::ostream &s) const
virtual map_location get_dest_hex() const
virtual config to_config() const
Constructs and returns a config object representing this object.
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses.
virtual void visit(move_ptr move)=0
Definitions for the interface to Wesnoth Markup Language (WML).
Drawing functions, for drawing things on the screen.
@ footsteps
Footsteps showing path from unit to mouse.
const std::string & id() const
Gets this unit's id.
const t_string & name() const
Gets this unit's translatable display name.
int attacks_left() const
Gets the remaining number of attacks this unit can perform this turn.
void set_attacks(int left)
Sets the number of attacks this unit has left this turn.
void set_movement(int moves, bool unit_action=false)
Set this unit's remaining movement to moves.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
void blit(const texture &tex, const SDL_Rect &dst)
Draws a texture, or part of a texture, at the given location.
@ HEXED
Standard hexagonal tile mask applied, removing portions that don't fit.
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
play_controller * controller
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
std::shared_ptr< attack > attack_ptr
std::shared_ptr< arrow > arrow_ptr
std::shared_ptr< attack const > attack_const_ptr
std::ostream & operator<<(std::ostream &s, const action_ptr &action)
Encapsulates the map of the game.
static std::string write_direction(direction dir)
Structure which holds a single route and marks for special events.
An abstract description of a rectangle with integer coordinates.
static map_location::direction s
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action)