#include <attack.hpp>
Public Member Functions | |
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) | |
attack (const config &, 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... | |
const map_location & | 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 (std::size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit) | |
move (const config &, bool hidden) | |
virtual | ~move () |
virtual unit_ptr | get_unit () const |
Return the unit targeted by this action. More... | |
virtual size_t | get_unit_id () const |
Returns the id of 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 |
std::size_t | raw_uid () const |
void | modify_unit (unit &new_unit) |
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 (std::size_t team_index, bool hidden) | |
action (const config &, 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... | |
virtual bool | places_new_unit () const |
Returns true for recall and recruit actions. More... | |
std::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 | |
std::shared_ptr< attack > | shared_from_this () |
Protected Member Functions inherited from wb::move | |
std::shared_ptr< move > | shared_from_this () |
int | calculate_moves_left (unit &u) |
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_ |
int | attack_count_ |
int | temp_attacks_subtracted_ |
Definition at line 27 of file attack.hpp.
wb::attack::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 | ||
) |
Definition at line 55 of file attack.cpp.
References init().
wb::attack::attack | ( | const config & | cfg, |
bool | hidden | ||
) |
Definition at line 68 of file attack.cpp.
References attack_count_, attack_movement_cost_, wb::move::get_dest_hex(), wb::move::get_unit(), init(), utf8::size(), target_hex_, tiles_adjacent(), and weapon_choice_.
|
virtual |
Definition at line 98 of file attack.cpp.
References invalidate().
|
virtual |
Reimplemented from wb::move.
Definition at line 103 of file attack.cpp.
References shared_from_this(), and wb::visitor::visit().
|
virtual |
Applies temporarily the result of this action to the specified unit map.
Reimplemented from wb::move.
Definition at line 155 of file attack.cpp.
References wb::move::apply_temp_modifier(), attack_count_, 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(), temp_attacks_subtracted_, 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 226 of file attack.cpp.
References wb::move::check_validity(), resources::gameboard, 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_, 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 198 of file attack.cpp.
References draw::blit(), d, display::drawing_buffer_add(), footsteps, wb::move::get_dest_hex(), display::get_singleton(), image::get_texture(), image::HEXED, 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 119 of file attack.cpp.
References events::mouse_handler::attack_enemy(), resources::controller, wb::move::execute(), unit_map::find(), resources::gameboard, 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_, game_board::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 93 of file attack.cpp.
References display::get_singleton(), display::invalidate(), and target_hex_.
Referenced by attack().
|
private |
invalidates the move-destination and attack-target hexes
Definition at line 109 of file attack.cpp.
References wb::move::get_dest_hex(), display::get_singleton(), display::invalidate(), and target_hex_.
|
virtual |
Reimplemented from wb::move.
Definition at line 48 of file attack.cpp.
References get_target_hex(), wb::move::print(), and s.
Referenced by wb::operator<<().
|
virtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented from wb::action.
Definition at line 220 of file attack.cpp.
References display::get_singleton(), display::invalidate(), wb::move::redraw(), and target_hex_.
|
virtual |
Removes the result of this action from the specified unit map.
Reimplemented from wb::move.
Definition at line 181 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(), temp_attacks_subtracted_, 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 254 of file attack.cpp.
References config::add_child(), target_hex_, wb::move::to_config(), weapon_choice_, map_location::wml_x(), and map_location::wml_y().
|
private |
Definition at line 85 of file attack.hpp.
Referenced by apply_temp_modifier(), and attack().
|
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 86 of file attack.hpp.
Referenced by apply_temp_modifier(), and remove_temp_modifier().
|
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().