A planned action that temporarily removes a unit from the map for planning purposes. More...
#include <suppose_dead.hpp>
Public Member Functions | |
suppose_dead (size_t team_index, bool hidden, unit &curr_unit, map_location const &loc) | |
suppose_dead (config const &, bool hidden) | |
virtual | ~suppose_dead () |
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 |
Return the location at which this action was planned. More... | |
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... | |
virtual map_location | get_numbering_hex () const |
virtual config | to_config () const |
Constructs and returns a config object representing this object. More... | |
![]() | |
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< suppose_dead > | shared_from_this () |
Protected Attributes | |
size_t | unit_underlying_id_ |
std::string | unit_id_ |
map_location | loc_ |
Private Member Functions | |
void | init () |
Additional Inherited Members | |
![]() | |
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 action_ptr | from_config (config const &, bool hidden) |
Constructs an object of a subclass of wb::action using a config. More... | |
A planned action that temporarily removes a unit from the map for planning purposes.
Definition at line 30 of file suppose_dead.hpp.
wb::suppose_dead::suppose_dead | ( | size_t | team_index, |
bool | hidden, | ||
unit & | curr_unit, | ||
map_location const & | loc | ||
) |
Definition at line 60 of file suppose_dead.cpp.
References init().
wb::suppose_dead::suppose_dead | ( | config const & | cfg, |
bool | hidden | ||
) |
Definition at line 69 of file suppose_dead.cpp.
References unit_map::find(), init(), unit_id_, unit_underlying_id_, and resources::units.
|
virtual |
Definition at line 91 of file suppose_dead.cpp.
References display::invalidate(), loc_, and resources::screen.
Implements wb::action.
Definition at line 107 of file suppose_dead.cpp.
References shared_from_this(), and wb::visitor::visit().
Applies temporarily the result of this action to the specified unit map.
Implements wb::action.
Definition at line 115 of file suppose_dead.cpp.
References DBG_WB, unit_map::extract(), get_unit(), and loc_.
|
virtual |
Check the validity of the action.
OK | if there isn't any error (the action can be executed.) |
Implements wb::action.
Definition at line 160 of file suppose_dead.cpp.
References unit_map::find(), get_source_hex(), wb::action::INVALID_LOCATION, wb::action::NO_UNIT, wb::action::OK, wb::action::UNIT_CHANGED, unit_id_, resources::units, and wb::action::valid().
|
virtual |
Gets called by display when drawing a hex, to allow actions to draw to the screen.
Implements wb::action.
Definition at line 136 of file suppose_dead.cpp.
References display::drawing_buffer_add(), image::get_image(), display::get_location_x(), display::get_location_y(), display::LAYER_ARROWS, loc_, image::SCALED_TO_HEX, and resources::screen.
|
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.
Implements wb::action.
Definition at line 112 of file suppose_dead.cpp.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Return the location at which this action was planned.
Definition at line 42 of file suppose_dead.hpp.
References loc_.
Referenced by check_validity().
|
virtual |
Return the unit targeted by this action.
Null if unit doesn't exist.
Implements wb::action.
Definition at line 98 of file suppose_dead.cpp.
References unit_map::find(), unit_map::iterator_base< iter_types >::get_shared_ptr(), itor, unit_underlying_id_, resources::units, and unit_map::iterator_base< iter_types >::valid().
Referenced by apply_temp_modifier(), print(), and remove_temp_modifier().
|
private |
Definition at line 86 of file suppose_dead.cpp.
References display::invalidate(), loc_, and resources::screen.
Referenced by suppose_dead().
|
virtual |
Implements wb::action.
Definition at line 53 of file suppose_dead.cpp.
References get_unit(), and loc_.
|
virtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented from wb::action.
Definition at line 155 of file suppose_dead.cpp.
References display::invalidate(), loc_, and resources::screen.
Removes the result of this action from the specified unit map.
Implements wb::action.
Definition at line 126 of file suppose_dead.cpp.
References unit_map::find(), get_unit(), unit_map::insert(), loc_, and resources::units.
|
inlineprotected |
Definition at line 74 of file suppose_dead.hpp.
Referenced by accept().
|
virtual |
Constructs and returns a config object representing this object.
Reimplemented from wb::action.
Definition at line 179 of file suppose_dead.cpp.
References config::add_child(), loc_, wb::action::to_config(), unit_id_, unit_underlying_id_, map_location::x, and map_location::y.
|
protected |
Definition at line 80 of file suppose_dead.hpp.
Referenced by apply_temp_modifier(), draw_hex(), get_numbering_hex(), get_source_hex(), init(), print(), redraw(), remove_temp_modifier(), to_config(), and ~suppose_dead().
|
protected |
Definition at line 79 of file suppose_dead.hpp.
Referenced by check_validity(), suppose_dead(), and to_config().
|
protected |
Definition at line 78 of file suppose_dead.hpp.
Referenced by get_unit(), suppose_dead(), and to_config().