The Battle for Wesnoth  1.19.0-dev
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:

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

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

◆ suppose_dead() [1/2]

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

◆ suppose_dead() [2/2]

wb::suppose_dead::suppose_dead ( const config cfg,
bool  hidden 
)

◆ ~suppose_dead()

wb::suppose_dead::~suppose_dead ( )
virtual

Definition at line 85 of file suppose_dead.cpp.

References display::get_singleton(), display::invalidate(), and loc_.

Member Function Documentation

◆ accept()

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

Implements wb::action.

Definition at line 101 of file suppose_dead.cpp.

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

◆ apply_temp_modifier()

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 109 of file suppose_dead.cpp.

References DBG_WB, unit_map::extract(), cursor::get(), get_unit(), and loc_.

◆ check_validity()

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

◆ draw_hex()

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 130 of file suppose_dead.cpp.

References draw::blit(), d, display::drawing_buffer_add(), display::get_singleton(), image::get_texture(), image::HEXED, display::LAYER_ARROWS, and loc_.

◆ execute()

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 106 of file suppose_dead.cpp.

◆ get_fake_unit()

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.

◆ get_numbering_hex()

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

◆ get_source_hex()

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

◆ get_unit()

unit_ptr wb::suppose_dead::get_unit ( ) const
virtual

◆ init()

void wb::suppose_dead::init ( )
private

Definition at line 80 of file suppose_dead.cpp.

References display::get_singleton(), display::invalidate(), and loc_.

Referenced by suppose_dead().

◆ print()

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

Implements wb::action.

Definition at line 47 of file suppose_dead.cpp.

References get_unit(), loc_, and s.

◆ redraw()

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

◆ remove_temp_modifier()

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 120 of file suppose_dead.cpp.

References unit_map::find(), resources::gameboard, get_unit(), unit_map::insert(), loc_, and game_board::units().

◆ shared_from_this()

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

Definition at line 74 of file suppose_dead.hpp.

Referenced by accept().

◆ to_config()

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

Member Data Documentation

◆ loc_

map_location wb::suppose_dead::loc_
protected

◆ unit_id_

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

◆ unit_underlying_id_

std::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: