The Battle for Wesnoth  1.15.0-dev
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
wb::recall Class Reference

#include <recall.hpp>

Inheritance diagram for wb::recall:
Inheritance graph

Public Member Functions

 recall (std::size_t team_index, bool hidden, const unit &unit, const map_location &recall_hex)
 
 recall (const config &, bool hidden)
 
virtual ~recall ()
 
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
 Indicates whether this hex is the preferred hex to draw the numbering for this action. More...
 
virtual unit_ptr get_unit () const
 
virtual bool places_new_unit () const
 Returns true for recall and recruit actions. More...
 
virtual fake_unit_ptr get_fake_unit ()
 
map_location const get_recall_hex () const
 
virtual config to_config () 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 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< recallshared_from_this ()
 

Private Member Functions

void init ()
 
virtual void do_hide ()
 Called by the non-virtual hide() and show(), respectively. More...
 
virtual void do_show ()
 

Private Attributes

unit_ptr temp_unit_
 
map_location recall_hex_
 
fake_unit_ptr fake_unit_
 
int original_mp_
 
int original_ap_
 
int original_recall_pos_
 

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

Definition at line 27 of file recall.hpp.

Constructor & Destructor Documentation

◆ recall() [1/2]

wb::recall::recall ( std::size_t  team_index,
bool  hidden,
const unit unit,
const map_location recall_hex 
)

Definition at line 61 of file recall.cpp.

References init().

◆ recall() [2/2]

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

◆ ~recall()

wb::recall::~recall ( )
virtual

Definition at line 110 of file recall.cpp.

Member Function Documentation

◆ accept()

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

Implements wb::action.

Definition at line 114 of file recall.cpp.

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

◆ apply_temp_modifier()

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

◆ check_validity()

action::error wb::recall::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 222 of file recall.cpp.

References wb::any_recruiter(), gui2::event::find(), resources::gameboard, get_recall_hex(), wb::action::LOCATION_OCCUPIED, wb::action::NO_LEADER, wb::action::NOT_ENOUGH_GOLD, map_location::null_location(), wb::action::OK, unit::recall_filter(), recall_hex_, wb::action::team_index(), game_board::teams(), temp_unit_, and wb::action::UNIT_UNAVAILABLE.

◆ do_hide()

void wb::recall::do_hide ( )
privatevirtual

Called by the non-virtual hide() and show(), respectively.

Reimplemented from wb::action.

Definition at line 266 of file recall.cpp.

References fake_unit_.

Referenced by shared_from_this().

◆ do_show()

void wb::recall::do_show ( )
privatevirtual

Reimplemented from wb::action.

Definition at line 267 of file recall.cpp.

References fake_unit_.

Referenced by shared_from_this().

◆ draw_hex()

void wb::recall::draw_hex ( const map_location hex)
virtual

◆ execute()

void wb::recall::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 119 of file recall.cpp.

References fake_unit_, resources::gameboard, replay_helper::get_recall(), team::get_side_actions(), synced_context::ignore_error_function(), map_location::null_location(), team::recall_cost(), recall_hex_, synced_context::run_and_throw(), wb::action::team_index(), game_board::teams(), temp_unit_, and wb::action::valid().

◆ get_fake_unit()

virtual fake_unit_ptr wb::recall::get_fake_unit ( )
inlinevirtual
Returns
pointer to the fake unit used only for visuals

Implements wb::action.

Definition at line 67 of file recall.hpp.

References fake_unit_.

◆ get_numbering_hex()

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

Indicates whether this hex is the preferred hex to draw the numbering for this action.

Implements wb::action.

Definition at line 61 of file recall.hpp.

References recall_hex_.

◆ get_recall_hex()

map_location const wb::recall::get_recall_hex ( ) const
inline

Definition at line 69 of file recall.hpp.

References recall_hex_, and to_config().

Referenced by check_validity().

◆ get_unit()

virtual unit_ptr wb::recall::get_unit ( ) const
inlinevirtual
Returns
pointer to a copy of the recall unit.

Implements wb::action.

Definition at line 64 of file recall.hpp.

References temp_unit_.

Referenced by draw_hex().

◆ init()

void wb::recall::init ( )
private

◆ places_new_unit()

virtual bool wb::recall::places_new_unit ( ) const
inlinevirtual

Returns true for recall and recruit actions.

Reimplemented from wb::action.

Definition at line 65 of file recall.hpp.

◆ print()

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

Implements wb::action.

Definition at line 55 of file recall.cpp.

References fake_unit_, recall_hex_, and s.

◆ redraw()

void wb::recall::redraw ( )
virtual

Redrawing function, called each time the action situation might have changed.

Reimplemented from wb::action.

Definition at line 217 of file recall.cpp.

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

◆ remove_temp_modifier()

void wb::recall::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 180 of file recall.cpp.

References unit_map::extract(), resources::gameboard, original_ap_, original_mp_, original_recall_pos_, recall_hex_, wb::action::team_index(), game_board::teams(), and temp_unit_.

◆ shared_from_this()

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

Definition at line 75 of file recall.hpp.

References do_hide(), do_show(), and init().

Referenced by accept().

◆ to_config()

config wb::recall::to_config ( ) const
virtual
Todo:
Find a better way to serialize unit_ because underlying_id isn't cutting it

Reimplemented from wb::action.

Definition at line 250 of file recall.cpp.

References config::add_child(), recall_hex_, temp_unit_, wb::action::to_config(), map_location::wml_x(), and map_location::wml_y().

Referenced by get_recall_hex().

Member Data Documentation

◆ fake_unit_

fake_unit_ptr wb::recall::fake_unit_
private

Definition at line 88 of file recall.hpp.

Referenced by do_hide(), do_show(), execute(), get_fake_unit(), init(), print(), and recall().

◆ original_ap_

int wb::recall::original_ap_
private

Definition at line 91 of file recall.hpp.

Referenced by apply_temp_modifier(), and remove_temp_modifier().

◆ original_mp_

int wb::recall::original_mp_
private

Definition at line 90 of file recall.hpp.

Referenced by apply_temp_modifier(), and remove_temp_modifier().

◆ original_recall_pos_

int wb::recall::original_recall_pos_
private

Definition at line 92 of file recall.hpp.

Referenced by apply_temp_modifier(), and remove_temp_modifier().

◆ recall_hex_

map_location wb::recall::recall_hex_
private

◆ temp_unit_

unit_ptr wb::recall::temp_unit_
private

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