40 return attack->print(s);
46 return attack->print(s);
58 :
move(team_index, hidden, u, route, arrow,
std::
move(fake_unit)),
79 if(weapon_choice_ < 0 || weapon_choice_ >= static_cast<int>(
get_unit()->attacks().
size()))
126 if (
route_->steps.size() >= 2)
128 bool m_success, m_complete;
157 <<
"] has " << unit.
attacks_left() <<
" attacks, decreasing by one" <<
"\n";
163 DBG_WB <<
"Attack: Changing movement points for unit " << unit.
name() <<
" [" << unit.
id()
181 <<
"] has " << unit.
attacks_left() <<
" attacks, increasing by one" <<
"\n";
183 DBG_WB <<
"Attack: Changing movement points for unit " << unit.
name() <<
" [" << unit.
id()
243 if(
get_unit()->attacks_left() <= 0) {
260 final_cfg[
"type"] =
"attack";
268 final_cfg.
add_child(
"target_hex_", std::move(target_hex_cfg));
map_location target_hex_
the target of the attack
play_controller * controller
surface get_image(const image::locator &i_locator, TYPE type)
Caches and returns an image.
int attacks_left() const
Gets the remaining number of attacks this unit can perform this turn.
void set_movement(int moves, bool unit_action=false)
Set this unit's remaining movement to moves.
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
Arrows destined to be drawn on the map.
static display * get_singleton()
Returns the display object if a display object exists.
virtual const unit_map & units() const override
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
This class represents a single unit of a specific type.
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)
int attack_movement_cost_
virtual void redraw()
Redrawing function, called each time the action situation might have changed.
std::shared_ptr< attack > attack_ptr
virtual std::ostream & print(std::ostream &s) const
virtual void visit(move_ptr move)=0
int temp_movement_subtracted_
std::shared_ptr< attack const > attack_const_ptr
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
std::shared_ptr< attack > shared_from_this()
drawing_layer
The layers to render something on.
Definitions for the interface to Wesnoth Markup Language (WML).
virtual error check_validity() const
Check the validity of the action.
std::size_t team_index() const
Returns the index of the team that owns this action.
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
bool valid()
Returns whether this action is valid or not.
virtual void accept(visitor &v)
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
const std::string & id() const
Gets this unit's id.
Arrows destined to be drawn on the map.
virtual map_location get_dest_hex() const
virtual error check_validity() const
Check the validity of the action.
const t_string & name() const
Gets this unit's translatable display name.
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
Structure which holds a single route and marks for special events.
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
void redraw()
Redrawing function, called each time the action situation might have changed.
virtual config to_config() const
Constructs and returns a config object representing this object.
Encapsulates the map of the game.
unit_iterator find(std::size_t id)
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
bool tiles_adjacent(const map_location &a, const map_location &b)
Function which tells if two locations are adjacent.
virtual config to_config() const
Constructs and returns a config object representing this object.
void set_attacks(int left)
Sets the number of attacks this unit has left this turn.
void attack_enemy(const map_location &attacker_loc, const map_location &defender_loc, int choice)
static map_location::DIRECTION s
int get_location_y(const map_location &loc) const
const map_location & get_target_hex() const
config & add_child(config_key_type key)
std::shared_ptr< arrow > arrow_ptr
void drawing_buffer_add(const drawing_layer layer, const map_location &loc, int x, int y, const surface &surf, const SDL_Rect &clip=SDL_Rect())
Add an item to the drawing buffer.
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
Image rescaled to fit into a hexagonal tile according to the zoom settings.
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
Container associating units to locations.
std::ostream & operator<<(std::ostream &s, action_ptr action)
virtual std::ostream & print(std::ostream &s) const
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action) ...
std::unique_ptr< pathfind::marked_route > route_
A config object defines a single node in a WML file, with access to child nodes.
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
void invalidate()
invalidates the move-destination and attack-target hexes
static std::string write_direction(DIRECTION dir)
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
A planned move, represented on the map by an arrow and a ghosted unit in the destination hex...
Footsteps showing path from unit to mouse.
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses...