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 (std::size_t team_index, bool hidden) | |
action (const config &, 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... | |
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... | |
virtual fake_unit_ptr | get_fake_unit ()=0 |
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... | |
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 (const config &, 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 | |
std::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_validity 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 106 of file action.hpp.
wb::action::action | ( | std::size_t | team_index, |
bool | hidden | ||
) |
Definition at line 97 of file action.cpp.
wb::action::action | ( | const config & | cfg, |
bool | hidden | ||
) |
Definition at line 103 of file action.cpp.
References resources::gameboard, utf8::size(), and team_index_.
|
virtual |
Definition at line 115 of file action.cpp.
|
pure virtual |
Implemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, wb::attack, and dummy_action.
Referenced by wb::highlighter::highlight(), and wb::highlighter::unhighlight().
|
pure virtual |
Applies temporarily the result of this action to the specified unit map.
Implemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, wb::attack, and dummy_action.
Referenced by wb::mapbuilder::process().
|
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::recruit, wb::recall, wb::move, wb::attack, and dummy_action.
Referenced by wb::mapbuilder::process(), and valid().
|
inlineprivatevirtual |
Called by the non-virtual hide() and show(), respectively.
Reimplemented in wb::recruit, wb::recall, wb::move, and wb::attack.
Definition at line 139 of file action.hpp.
Referenced by hide().
|
inlineprivatevirtual |
Reimplemented in wb::recruit, wb::recall, wb::move, and wb::attack.
Definition at line 140 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::suppose_dead, wb::recruit, wb::recall, wb::move, wb::attack, 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::recruit, wb::recall, wb::move, wb::attack, and dummy_action.
Referenced by wb::side_actions::execute().
|
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 60 of file action.cpp.
References hidden().
Referenced by wb::side_actions::execute_net_cmd().
|
pure virtual |
Implemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, and dummy_action.
|
pure virtual |
Implemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, 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::suppose_dead, wb::recruit, wb::recall, wb::move, and dummy_action.
Referenced by get_unit_id(), wb::manager::post_delete_action(), and wb::mapbuilder::process().
|
virtual |
Returns the id of the unit targeted by this action.
0 | no unit is targeted. |
Reimplemented in wb::move.
Definition at line 119 of file action.cpp.
References get_unit().
|
inline |
Definition at line 64 of file action.hpp.
References hidden_.
Referenced by from_config(), wb::move::hide_fake_unit(), wb::move::move(), 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 81 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().
|
inlinevirtual |
Returns true for recall and recruit actions.
Reimplemented in wb::recruit, and wb::recall.
Definition at line 74 of file action.hpp.
Referenced by wb::mapbuilder::process().
|
pure virtual |
Implemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, wb::attack, and dummy_action.
Definition at line 46 of file action.cpp.
References s.
Referenced by wb::operator<<().
|
inlinevirtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, and wb::attack.
Definition at line 59 of file action.hpp.
Referenced by wb::mapbuilder::process().
|
pure virtual |
Removes the result of this action from the specified unit map.
Implemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, wb::attack, and dummy_action.
void wb::action::show | ( | ) |
Definition at line 89 of file action.cpp.
|
inline |
Returns the number of the side that owns this action, i.e.
the team index + 1.
Definition at line 86 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 84 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::highlighter::last_action_redraw(), wb::manager::post_delete_action(), wb::recall::recall(), and wb::recall::remove_temp_modifier().
|
virtual |
Constructs and returns a config object representing this object.
Reimplemented in wb::suppose_dead, wb::recruit, wb::recall, wb::move, and wb::attack.
Definition at line 51 of file action.cpp.
References team_index_.
Referenced by wb::move::to_config(), wb::recall::to_config(), wb::recruit::to_config(), and wb::suppose_dead::to_config().
|
inline |
Returns whether this action is valid or not.
Definition at line 135 of file action.hpp.
References check_validity(), and OK.
Referenced by wb::recall::apply_temp_modifier(), wb::recruit::apply_temp_modifier(), wb::move::calculate_moves_left(), wb::move::check_validity(), wb::suppose_dead::check_validity(), wb::attack::execute(), wb::move::execute(), wb::recall::execute(), wb::recruit::execute(), and wb::side_actions::execute().
|
private |
Definition at line 143 of file action.hpp.
|
private |
Definition at line 142 of file action.hpp.
Referenced by action(), side_number(), team_index(), and to_config().