The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
wb::attack Class Reference

#include <attack.hpp>

Inheritance diagram for wb::attack:
Inheritance graph

Public Member Functions

 attack (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)
 
 attack (config const &, bool hidden)
 
virtual ~attack ()
 
virtual std::ostream & print (std::ostream &s) const
 
virtual void accept (visitor &v)
 
virtual void execute (bool &success, bool &complete)
 Output parameters: success: Whether or not to continue an execute-all after this execution complete: Whether or not to delete this action after execution. More...
 
virtual error check_validity () const
 Check the validity of the action. More...
 
virtual void apply_temp_modifier (unit_map &unit_map)
 Applies temporarily the result of this action to the specified unit map. More...
 
virtual void remove_temp_modifier (unit_map &unit_map)
 Removes the result of this action from the specified unit map. More...
 
virtual void draw_hex (const map_location &hex)
 Gets called by display when drawing a hex, to allow actions to draw to the screen. More...
 
virtual void redraw ()
 Redrawing function, called each time the action situation might have changed. More...
 
map_location const & get_target_hex () const
 
virtual config to_config () const
 Constructs and returns a config object representing this object. More...
 
- Public Member Functions inherited from wb::move
 move (size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
 
 move (config const &, bool hidden)
 
virtual ~move ()
 
virtual unit_ptr get_unit () const
 Return the unit targeted by this action. More...
 
virtual fake_unit_ptr get_fake_unit ()
 
virtual map_location get_source_hex () const
 
virtual map_location get_dest_hex () const
 
virtual void set_route (const pathfind::marked_route &route)
 
virtual const
pathfind::marked_route
get_route () const
 
virtual bool calculate_new_route (const map_location &source_hex, const map_location &dest_hex)
 attempts to pathfind a new marked route for this path between these two hexes; returns true and assigns it to the internal route if successful. More...
 
virtual arrow_ptr get_arrow ()
 
void redraw ()
 Redrawing function, called each time the action situation might have changed. More...
 
virtual void set_turn_number (int turn)
 Assigns a turn number to display to this planned move. More...
 
virtual map_location get_numbering_hex () const
 
void set_arrow_brightness (ARROW_BRIGHTNESS x) const
 
void set_arrow_texture (ARROW_TEXTURE x) const
 
- Public Member Functions inherited from wb::action
 action (size_t team_index, bool hidden)
 
 action (config const &, bool hidden)
 
virtual ~action ()
 
void hide ()
 Sets whether or not the action should be drawn on the screen. More...
 
void show ()
 
bool hidden () const
 
bool is_numbering_hex (const map_location &hex) const
 Indicates whether this hex is the preferred hex to draw the numbering for this action. More...
 
size_t get_unit_id () const
 Returns the id of the unit targeted by this action. More...
 
size_t team_index () const
 Returns the index of the team that owns this action. More...
 
int side_number () const
 Returns the number of the side that owns this action, i.e. More...
 
bool valid ()
 Returns whether this action is valid or not. More...
 

Protected Member Functions

boost::shared_ptr< attackshared_from_this ()
 
- Protected Member Functions inherited from wb::move
boost::shared_ptr< moveshared_from_this ()
 
void calculate_move_cost ()
 

Private Member Functions

void init ()
 
virtual void do_hide ()
 Called by the non-virtual hide() and show(), respectively. More...
 
virtual void do_show ()
 
void invalidate ()
 invalidates the move-destination and attack-target hexes More...
 

Private Attributes

map_location target_hex_
 the target of the attack More...
 
int weapon_choice_
 
int attack_movement_cost_
 
int temp_movement_subtracted_
 

Additional Inherited Members

- Public Types inherited from wb::move
enum  ARROW_BRIGHTNESS { ARROW_BRIGHTNESS_STANDARD, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_FOCUS }
 
enum  ARROW_TEXTURE { ARROW_TEXTURE_VALID, ARROW_TEXTURE_INVALID }
 
- Public Types inherited from wb::action
enum  error {
  OK, INVALID_LOCATION, NO_UNIT, UNIT_CHANGED,
  LOCATION_OCCUPIED, TOO_FAR, NO_TARGET, NO_ATTACK_LEFT,
  NOT_AN_ENEMY, UNIT_UNAVAILABLE, NOT_ENOUGH_GOLD, NO_LEADER
}
 Possible errors. More...
 
- Static Public Member Functions inherited from wb::action
static action_ptr from_config (config const &, bool hidden)
 Constructs an object of a subclass of wb::action using a config. More...
 
- Protected Attributes inherited from wb::move
size_t unit_underlying_id_
 
std::string unit_id_
 
boost::scoped_ptr
< pathfind::marked_route
route_
 
int movement_cost_
 
int turn_number_
 Turn end number to draw if greater than zero. Assigned by the map builder. More...
 
arrow_ptr arrow_
 
fake_unit_ptr fake_unit_
 
ARROW_BRIGHTNESS arrow_brightness_
 
ARROW_TEXTURE arrow_texture_
 

Detailed Description

Definition at line 27 of file attack.hpp.

Constructor & Destructor Documentation

wb::attack::attack ( 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 
)

Definition at line 55 of file attack.cpp.

References init().

wb::attack::attack ( config const &  cfg,
bool  hidden 
)
wb::attack::~attack ( )
virtual

Definition at line 92 of file attack.cpp.

References invalidate().

Member Function Documentation

void wb::attack::accept ( visitor v)
virtual

Reimplemented from wb::move.

Definition at line 97 of file attack.cpp.

References shared_from_this(), and wb::visitor::visit().

void wb::attack::apply_temp_modifier ( unit_map unit_map)
virtual

Applies temporarily the result of this action to the specified unit map.

Reimplemented from wb::move.

Definition at line 149 of file attack.cpp.

References wb::move::apply_temp_modifier(), attack_movement_cost_, unit::attacks_left(), DBG_WB, wb::move::fake_unit_, wb::move::get_unit(), unit::id(), unit::movement_left(), unit::name(), unit::set_attacks(), unit::set_movement(), and temp_movement_subtracted_.

action::error wb::attack::check_validity ( ) const
virtual

Check the validity of the action.

Returns
the error preventing the action from being executed.
Return values
OKif there isn't any error (the action can be executed.)

Reimplemented from wb::move.

Definition at line 245 of file attack.cpp.

References wb::move::check_validity(), unit_map::end(), gui2::event::find(), wb::move::get_unit(), wb::action::INVALID_LOCATION, wb::action::NO_ATTACK_LEFT, wb::action::NO_TARGET, wb::action::NO_UNIT, wb::action::NOT_AN_ENEMY, target_hex_, resources::teams, resources::units, and map_location::valid().

virtual void wb::attack::do_hide ( )
inlineprivatevirtual

Called by the non-virtual hide() and show(), respectively.

Reimplemented from wb::move.

Definition at line 73 of file attack.hpp.

References invalidate().

virtual void wb::attack::do_show ( )
inlineprivatevirtual

Reimplemented from wb::move.

Definition at line 74 of file attack.hpp.

References invalidate().

void wb::attack::draw_hex ( const map_location hex)
virtual

Gets called by display when drawing a hex, to allow actions to draw to the screen.

Reimplemented from wb::move.

Definition at line 189 of file attack.cpp.

References display::drawing_buffer_add(), wb::move::get_dest_hex(), image::get_image(), display::get_location_x(), display::get_location_y(), display::LAYER_FOOTSTEPS, image::SCALED_TO_HEX, resources::screen, target_hex_, and map_location::write_direction().

void wb::attack::execute ( bool &  success,
bool &  complete 
)
virtual

Output parameters: success: Whether or not to continue an execute-all after this execution complete: Whether or not to delete this action after execution.

Reimplemented from wb::move.

Definition at line 113 of file attack.cpp.

References events::mouse_handler::attack_enemy(), resources::controller, wb::move::execute(), unit_map::find(), wb::move::get_dest_hex(), play_controller::get_mouse_handler_base(), get_target_hex(), LOG_WB, wb::move::route_, shared_from_this(), wb::move::unit_id_, resources::units, wb::action::valid(), unit_map::iterator_base< iter_types >::valid(), and weapon_choice_.

map_location const& wb::attack::get_target_hex ( ) const
inline

Definition at line 59 of file attack.hpp.

References target_hex_.

Referenced by execute(), and print().

void wb::attack::init ( )
private

Definition at line 87 of file attack.cpp.

References display::invalidate(), resources::screen, and target_hex_.

Referenced by attack().

void wb::attack::invalidate ( )
private

invalidates the move-destination and attack-target hexes

Definition at line 103 of file attack.cpp.

References wb::move::get_dest_hex(), display::invalidate(), resources::screen, and target_hex_.

Referenced by do_hide(), do_show(), and ~attack().

std::ostream & wb::attack::print ( std::ostream &  s) const
virtual

Reimplemented from wb::move.

Definition at line 48 of file attack.cpp.

References get_target_hex(), and wb::move::print().

void wb::attack::redraw ( )
virtual

Redrawing function, called each time the action situation might have changed.

Reimplemented from wb::action.

Definition at line 239 of file attack.cpp.

References display::invalidate(), wb::move::redraw(), resources::screen, and target_hex_.

void wb::attack::remove_temp_modifier ( unit_map unit_map)
virtual

Removes the result of this action from the specified unit map.

Reimplemented from wb::move.

Definition at line 174 of file attack.cpp.

References unit::attacks_left(), DBG_WB, wb::move::get_unit(), unit::id(), unit::movement_left(), unit::name(), wb::move::remove_temp_modifier(), unit::set_attacks(), unit::set_movement(), and temp_movement_subtracted_.

boost::shared_ptr<attack> wb::attack::shared_from_this ( )
inlineprotected

Definition at line 65 of file attack.hpp.

References wb::move::shared_from_this().

Referenced by accept(), and execute().

config wb::attack::to_config ( ) const
virtual

Constructs and returns a config object representing this object.

Reimplemented from wb::move.

Definition at line 273 of file attack.cpp.

References config::add_child(), target_hex_, wb::move::to_config(), weapon_choice_, map_location::x, and map_location::y.

Member Data Documentation

int wb::attack::attack_movement_cost_
private

Definition at line 83 of file attack.hpp.

Referenced by apply_temp_modifier(), and attack().

map_location wb::attack::target_hex_
private

the target of the attack

Definition at line 80 of file attack.hpp.

Referenced by attack(), check_validity(), draw_hex(), get_target_hex(), init(), invalidate(), redraw(), and to_config().

int wb::attack::temp_movement_subtracted_
private

Definition at line 84 of file attack.hpp.

Referenced by apply_temp_modifier(), and remove_temp_modifier().

int wb::attack::weapon_choice_
private

Definition at line 82 of file attack.hpp.

Referenced by attack(), execute(), and to_config().


The documentation for this class was generated from the following files: