#include <attack.hpp>
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< attack > | shared_from_this () |
Protected Member Functions inherited from wb::move | |
boost::shared_ptr< move > | shared_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_ |
Definition at line 27 of file attack.hpp.
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 | ||
) |
Definition at line 66 of file attack.cpp.
References attack_movement_cost_, wb::move::get_dest_hex(), wb::move::get_unit(), init(), target_hex_, tiles_adjacent(), and weapon_choice_.
|
virtual |
Definition at line 92 of file attack.cpp.
References invalidate().
Reimplemented from wb::move.
Definition at line 97 of file attack.cpp.
References shared_from_this(), and wb::visitor::visit().
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_.
|
virtual |
Check the validity of the action.
OK | if 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().
|
inlineprivatevirtual |
Called by the non-virtual hide() and show(), respectively.
Reimplemented from wb::move.
Definition at line 73 of file attack.hpp.
References invalidate().
|
inlineprivatevirtual |
|
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().
|
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_.
|
inline |
Definition at line 59 of file attack.hpp.
References target_hex_.
|
private |
Definition at line 87 of file attack.cpp.
References display::invalidate(), resources::screen, and target_hex_.
Referenced by attack().
|
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_.
|
virtual |
Reimplemented from wb::move.
Definition at line 48 of file attack.cpp.
References get_target_hex(), and wb::move::print().
|
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_.
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_.
|
inlineprotected |
Definition at line 65 of file attack.hpp.
References wb::move::shared_from_this().
|
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.
|
private |
Definition at line 83 of file attack.hpp.
Referenced by apply_temp_modifier(), and attack().
|
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().
|
private |
Definition at line 84 of file attack.hpp.
Referenced by apply_temp_modifier(), and remove_temp_modifier().
|
private |
Definition at line 82 of file attack.hpp.
Referenced by attack(), execute(), and to_config().