The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 (size_t team_index, bool hidden, const unit &unit, const map_location &recall_hex)
 
 recall (config const &, 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 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 (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

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_
 

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

Definition at line 27 of file recall.hpp.

Constructor & Destructor Documentation

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

Definition at line 60 of file recall.cpp.

References init().

wb::recall::recall ( config const &  cfg,
bool  hidden 
)
wb::recall::~recall ( )
virtual

Definition at line 106 of file recall.cpp.

Member Function Documentation

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

Implements wb::action.

Definition at line 110 of file recall.cpp.

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

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

References DBG_WB, resources::gameboard, unit_map::insert(), display::invalidate_game_status(), recall_hex_, resources::screen, wb::action::team_index(), game_board::teams(), temp_unit_, and wb::action::valid().

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 204 of file recall.cpp.

References gui2::event::find(), wb::find_recruiter(), resources::gameboard, get_recall_hex(), wb::action::LOCATION_OCCUPIED, wb::action::NO_LEADER, wb::action::NOT_ENOUGH_GOLD, wb::action::OK, recall_hex_, wb::action::team_index(), game_board::teams(), temp_unit_, wb::action::UNIT_UNAVAILABLE, and resources::units.

void wb::recall::do_hide ( )
privatevirtual

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

Reimplemented from wb::action.

Definition at line 243 of file recall.cpp.

References fake_unit_.

void wb::recall::do_show ( )
privatevirtual

Reimplemented from wb::action.

Definition at line 244 of file recall.cpp.

References fake_unit_.

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

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 66 of file recall.hpp.

References fake_unit_.

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

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

Definition at line 68 of file recall.hpp.

References recall_hex_.

Referenced by check_validity().

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

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

Implements wb::action.

Definition at line 54 of file recall.cpp.

References fake_unit_, recall_hex_, and s.

void wb::recall::redraw ( )
virtual

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

Reimplemented from wb::action.

Definition at line 199 of file recall.cpp.

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

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 167 of file recall.cpp.

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

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

Definition at line 74 of file recall.hpp.

Referenced by accept().

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

Member Data Documentation

fake_unit_ptr wb::recall::fake_unit_
private

Definition at line 86 of file recall.hpp.

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

map_location wb::recall::recall_hex_
private
unit_ptr wb::recall::temp_unit_
private

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