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 | Protected Attributes | Private Member Functions | List of all members
wb::suppose_dead Class Reference

A planned action that temporarily removes a unit from the map for planning purposes. More...

#include <suppose_dead.hpp>

Inheritance diagram for wb::suppose_dead:
Inheritance graph

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...
 
- 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< suppose_deadshared_from_this ()
 

Protected Attributes

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 (config const &, bool hidden)
 Constructs an object of a subclass of wb::action using a config. More...
 

Detailed Description

A planned action that temporarily removes a unit from the map for planning purposes.

Definition at line 30 of file suppose_dead.hpp.

Constructor & Destructor Documentation

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.

wb::suppose_dead::~suppose_dead ( )
virtual

Definition at line 91 of file suppose_dead.cpp.

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

Member Function Documentation

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

Implements wb::action.

Definition at line 107 of file suppose_dead.cpp.

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

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

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_.

action::error wb::suppose_dead::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.)

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().

void wb::suppose_dead::draw_hex ( const map_location hex)
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.

void wb::suppose_dead::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.

Implements wb::action.

Definition at line 112 of file suppose_dead.cpp.

virtual fake_unit_ptr wb::suppose_dead::get_fake_unit ( )
inlinevirtual
Returns
null pointer

Implements wb::action.

Definition at line 40 of file suppose_dead.hpp.

virtual map_location wb::suppose_dead::get_numbering_hex ( ) const
inlinevirtual

Implements wb::action.

Definition at line 68 of file suppose_dead.hpp.

References loc_.

virtual map_location wb::suppose_dead::get_source_hex ( ) const
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().

unit_ptr wb::suppose_dead::get_unit ( ) const
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().

void wb::suppose_dead::init ( )
private

Definition at line 86 of file suppose_dead.cpp.

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

Referenced by suppose_dead().

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

Implements wb::action.

Definition at line 53 of file suppose_dead.cpp.

References get_unit(), and loc_.

void wb::suppose_dead::redraw ( )
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.

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

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.

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

Definition at line 74 of file suppose_dead.hpp.

Referenced by accept().

config wb::suppose_dead::to_config ( ) const
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.

Member Data Documentation

map_location wb::suppose_dead::loc_
protected
std::string wb::suppose_dead::unit_id_
protected

Definition at line 79 of file suppose_dead.hpp.

Referenced by check_validity(), suppose_dead(), and to_config().

size_t wb::suppose_dead::unit_underlying_id_
protected

Definition at line 78 of file suppose_dead.hpp.

Referenced by get_unit(), suppose_dead(), and to_config().


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