A planned action that temporarily removes a unit from the map for planning purposes. More...
#include <suppose_dead.hpp>
Public Member Functions | |
suppose_dead (std::size_t team_index, bool hidden, unit &curr_unit, const map_location &loc) | |
suppose_dead (const config &, 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... | |
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... | |
virtual std::size_t | get_unit_id () const |
Returns the id of the unit targeted by this action. 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< suppose_dead > | shared_from_this () |
Protected Attributes | |
std::size_t | unit_underlying_id_ |
std::string | unit_id_ |
map_location | loc_ |
Private Member Functions | |
void | init () |
Additional Inherited Members | |
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 (const config &, 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 | ( | std::size_t | team_index, |
bool | hidden, | ||
unit & | curr_unit, | ||
const map_location & | loc | ||
) |
Definition at line 54 of file suppose_dead.cpp.
References init().
wb::suppose_dead::suppose_dead | ( | const config & | cfg, |
bool | hidden | ||
) |
Definition at line 63 of file suppose_dead.cpp.
References unit_map::find(), resources::gameboard, init(), unit_id_, unit_underlying_id_, and game_board::units().
|
virtual |
Definition at line 85 of file suppose_dead.cpp.
References display::get_singleton(), display::invalidate(), and loc_.
|
virtual |
Implements wb::action.
Definition at line 101 of file suppose_dead.cpp.
References shared_from_this(), and wb::visitor::visit().
|
virtual |
Applies temporarily the result of this action to the specified unit map.
Implements wb::action.
Definition at line 109 of file suppose_dead.cpp.
References DBG_WB, unit_map::extract(), cursor::get(), 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 150 of file suppose_dead.cpp.
References unit_map::find(), resources::gameboard, get_source_hex(), wb::action::INVALID_LOCATION, wb::action::NO_UNIT, wb::action::OK, wb::action::UNIT_CHANGED, unit_id_, game_board::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 130 of file suppose_dead.cpp.
References arrows, draw::blit(), d, display::drawing_buffer_add(), display::get_singleton(), image::get_texture(), image::HEXED, and loc_.
|
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 106 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 92 of file suppose_dead.cpp.
References unit_map::find(), resources::gameboard, unit_map::iterator_base< iter_types >::get_shared_ptr(), unit_underlying_id_, game_board::units(), and unit_map::iterator_base< iter_types >::valid().
Referenced by apply_temp_modifier(), print(), and remove_temp_modifier().
|
private |
Definition at line 80 of file suppose_dead.cpp.
References display::get_singleton(), display::invalidate(), and loc_.
Referenced by suppose_dead().
|
virtual |
Implements wb::action.
Definition at line 47 of file suppose_dead.cpp.
References get_unit(), loc_, and s.
|
virtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented from wb::action.
Definition at line 145 of file suppose_dead.cpp.
References display::get_singleton(), display::invalidate(), and loc_.
|
virtual |
Removes the result of this action from the specified unit map.
Implements wb::action.
Definition at line 120 of file suppose_dead.cpp.
References unit_map::find(), resources::gameboard, get_unit(), unit_map::insert(), loc_, and game_board::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 169 of file suppose_dead.cpp.
References config::add_child(), loc_, wb::action::to_config(), unit_id_, unit_underlying_id_, map_location::wml_x(), and map_location::wml_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().