Abstract base class for all the whiteboard planned actions. More...
#include <action.hpp>
Classes | |
struct | ctor_err |
Public Types | |
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... | |
Public Member Functions | |
action (size_t team_index, bool hidden) | |
action (config const &, bool hidden) | |
virtual | ~action () |
virtual std::ostream & | print (std::ostream &s) const =0 |
virtual void | accept (visitor &v)=0 |
virtual void | execute (bool &success, bool &complete)=0 |
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 void | apply_temp_modifier (unit_map &unit_map)=0 |
Applies temporarily the result of this action to the specified unit map. More... | |
virtual void | remove_temp_modifier (unit_map &unit_map)=0 |
Removes the result of this action from the specified unit map. More... | |
virtual void | draw_hex (const map_location &hex)=0 |
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... | |
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 map_location | get_numbering_hex () const =0 |
virtual unit_ptr | get_unit () const =0 |
Return the unit targeted by this action. More... | |
size_t | get_unit_id () const |
Returns the id of the unit targeted by this action. More... | |
virtual fake_unit_ptr | get_fake_unit ()=0 |
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... | |
virtual config | to_config () const |
Constructs and returns a config object representing this object. More... | |
virtual error | check_validity () const =0 |
Check the validity of the action. More... | |
bool | valid () |
Returns whether this action is valid or not. More... | |
Static Public Member Functions | |
static action_ptr | from_config (config const &, bool hidden) |
Constructs an object of a subclass of wb::action using a config. More... | |
Private Member Functions | |
virtual void | do_hide () |
Called by the non-virtual hide() and show(), respectively. More... | |
virtual void | do_show () |
Private Attributes | |
size_t | team_index_ |
bool | hidden_ |
Abstract base class for all the whiteboard planned actions.
Definition at line 33 of file action.hpp.
enum wb::action::error |
Possible errors.
Returned by the check function.
Enumerator | |
---|---|
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 |
Definition at line 104 of file action.hpp.
wb::action::action | ( | size_t | team_index, |
bool | hidden | ||
) |
Definition at line 95 of file action.cpp.
wb::action::action | ( | config const & | cfg, |
bool | hidden | ||
) |
Definition at line 101 of file action.cpp.
References team_index_, and resources::teams.
|
virtual |
Definition at line 113 of file action.cpp.
Implemented in wb::suppose_dead, wb::move, wb::recruit, wb::attack, wb::recall, and dummy_action.
Referenced by wb::highlighter::highlight(), and wb::highlighter::unhighlight().
Applies temporarily the result of this action to the specified unit map.
Implemented in wb::move, wb::suppose_dead, wb::recruit, wb::attack, wb::recall, and dummy_action.
|
pure virtual |
Check the validity of the action.
OK | if there isn't any error (the action can be executed.) |
Implemented in wb::suppose_dead, wb::move, wb::recruit, wb::attack, wb::recall, and dummy_action.
Referenced by valid().
|
inlineprivatevirtual |
Called by the non-virtual hide() and show(), respectively.
Reimplemented in wb::move, wb::recruit, wb::recall, and wb::attack.
Definition at line 137 of file action.hpp.
Referenced by hide().
|
inlineprivatevirtual |
Reimplemented in wb::move, wb::recruit, wb::recall, and wb::attack.
Definition at line 138 of file action.hpp.
Referenced by show().
|
pure virtual |
Gets called by display when drawing a hex, to allow actions to draw to the screen.
Implemented in wb::move, wb::suppose_dead, wb::recruit, wb::attack, wb::recall, and dummy_action.
Referenced by wb::manager::draw_hex().
|
pure 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.
Implemented in wb::suppose_dead, wb::move, wb::recruit, wb::attack, wb::recall, and dummy_action.
|
static |
Constructs an object of a subclass of wb::action using a config.
Current behavior is to return a null pointer for unrecognized config.
Definition at line 59 of file action.cpp.
Referenced by wb::side_actions::execute_net_cmd().
|
pure virtual |
Implemented in wb::recruit, wb::recall, wb::move, dummy_action, and wb::suppose_dead.
|
pure virtual |
Implemented in wb::move, wb::suppose_dead, wb::recruit, wb::recall, and dummy_action.
Referenced by is_numbering_hex().
|
pure virtual |
Return the unit targeted by this action.
Null if unit doesn't exist.
Implemented in wb::recruit, wb::recall, wb::move, dummy_action, and wb::suppose_dead.
Referenced by get_unit_id().
size_t wb::action::get_unit_id | ( | ) | const |
Returns the id of the unit targeted by this action.
0 | no unit is targeted. |
Definition at line 117 of file action.cpp.
References get_unit().
|
inline |
Definition at line 64 of file action.hpp.
References hidden_.
Referenced by wb::move::hide_fake_unit(), and wb::move::show_fake_unit().
void wb::action::hide | ( | ) |
Sets whether or not the action should be drawn on the screen.
Definition at line 79 of file action.cpp.
|
inline |
Indicates whether this hex is the preferred hex to draw the numbering for this action.
Definition at line 67 of file action.hpp.
References get_numbering_hex().
|
pure virtual |
Implemented in wb::suppose_dead, wb::move, wb::recruit, wb::attack, wb::recall, and dummy_action.
Definition at line 45 of file action.cpp.
|
inlinevirtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented in wb::move, wb::suppose_dead, wb::recruit, wb::attack, and wb::recall.
Definition at line 59 of file action.hpp.
Removes the result of this action from the specified unit map.
Implemented in wb::move, wb::suppose_dead, wb::recruit, wb::attack, wb::recall, and dummy_action.
void wb::action::show | ( | ) |
Definition at line 87 of file action.cpp.
|
inline |
Returns the number of the side that owns this action, i.e.
the team index + 1.
Definition at line 84 of file action.hpp.
References team_index_.
Referenced by wb::move::move().
|
inline |
Returns the index of the team that owns this action.
Definition at line 82 of file action.hpp.
References team_index_.
Referenced by wb::recall::apply_temp_modifier(), wb::recruit::apply_temp_modifier(), wb::move::calculate_new_route(), wb::recall::check_validity(), wb::recruit::check_validity(), wb::recruit::create_corresponding_unit(), wb::recall::draw_hex(), wb::recall::execute(), wb::recruit::execute(), wb::move::init(), wb::recall::recall(), and wb::recall::remove_temp_modifier().
|
virtual |
Constructs and returns a config object representing this object.
Reimplemented in wb::move, wb::recruit, wb::recall, wb::suppose_dead, and wb::attack.
Definition at line 50 of file action.cpp.
References team_index_.
Referenced by wb::suppose_dead::to_config(), wb::recall::to_config(), wb::recruit::to_config(), and wb::move::to_config().
|
inline |
Returns whether this action is valid or not.
Definition at line 133 of file action.hpp.
References check_validity(), and OK.
Referenced by wb::recall::apply_temp_modifier(), wb::recruit::apply_temp_modifier(), wb::move::calculate_move_cost(), wb::move::check_validity(), wb::suppose_dead::check_validity(), wb::recall::execute(), wb::attack::execute(), wb::recruit::execute(), and wb::move::execute().
|
private |
Definition at line 141 of file action.hpp.
|
private |
Definition at line 140 of file action.hpp.
Referenced by action(), side_number(), team_index(), and to_config().