A planned move, represented on the map by an arrow and a ghosted unit in the destination hex. More...
#include <move.hpp>
Public Types | |
enum | ARROW_BRIGHTNESS { ARROW_BRIGHTNESS_STANDARD, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_FOCUS } |
enum | ARROW_TEXTURE { ARROW_TEXTURE_VALID, ARROW_TEXTURE_INVALID } |
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... | |
Public Member Functions | |
move (size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit) | |
move (config const &, bool hidden) | |
virtual | ~move () |
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 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 |
virtual map_location | get_dest_hex () const |
virtual void | set_route (const pathfind::marked_route &route) |
virtual const pathfind::marked_route & | get_route () const |
virtual bool | calculate_new_route (const map_location &source_hex, const map_location &dest_hex) |
attempts to pathfind a new marked route for this path between these two hexes; returns true and assigns it to the internal route if successful. More... | |
virtual arrow_ptr | get_arrow () |
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 (map_location const &hex) |
Gets called by display when drawing a hex, to allow actions to draw to the screen. More... | |
void | redraw () |
Redrawing function, called each time the action situation might have changed. More... | |
virtual void | set_turn_number (int turn) |
Assigns a turn number to display to this planned move. More... | |
virtual map_location | get_numbering_hex () const |
virtual config | to_config () const |
Constructs and returns a config object representing this object. More... | |
void | set_arrow_brightness (ARROW_BRIGHTNESS x) const |
void | set_arrow_texture (ARROW_TEXTURE x) 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 | |
boost::shared_ptr< move > | shared_from_this () |
void | calculate_move_cost () |
Protected Attributes | |
size_t | unit_underlying_id_ |
std::string | unit_id_ |
boost::scoped_ptr < pathfind::marked_route > | route_ |
int | movement_cost_ |
int | turn_number_ |
Turn end number to draw if greater than zero. Assigned by the map builder. More... | |
arrow_ptr | arrow_ |
fake_unit_ptr | fake_unit_ |
ARROW_BRIGHTNESS | arrow_brightness_ |
ARROW_TEXTURE | arrow_texture_ |
Private Member Functions | |
virtual void | do_hide () |
Called by the non-virtual hide() and show(), respectively. More... | |
virtual void | do_show () |
void | hide_fake_unit () |
void | show_fake_unit () |
void | init () |
void | update_arrow_style () |
Private Attributes | |
boost::scoped_ptr < temporary_unit_mover > | mover_ |
bool | fake_unit_hidden_ |
Additional Inherited Members | |
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... | |
A planned move, represented on the map by an arrow and a ghosted unit in the destination hex.
wb::move::move | ( | size_t | team_index, |
bool | hidden, | ||
unit & | mover, | ||
const pathfind::marked_route & | route, | ||
arrow_ptr | arrow, | ||
fake_unit_ptr | fake_unit | ||
) |
Definition at line 63 of file move.cpp.
References fake_unit_, init(), and route_.
wb::move::move | ( | config const & | cfg, |
bool | hidden | ||
) |
Definition at line 86 of file move.cpp.
References arrow_, config::child(), config::child_range(), fake_unit_, resources::fake_units, unit_map::find(), team::get_side_color_index(), get_unit(), fake_unit_ptr::get_unit_ptr(), init(), unit_display::move_unit(), route_, wb::action::side_number(), arrow::STYLE_STANDARD, unit_underlying_id_, and resources::units.
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 200 of file move.cpp.
References shared_from_this(), and wb::visitor::visit().
Applies temporarily the result of this action to the specified unit map.
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 327 of file move.cpp.
References DBG_WB, unit_map::end(), fake_unit_, unit_map::find(), get_dest_hex(), get_source_hex(), unit::id(), movement_cost_, unit::movement_left(), mover_, and unit::name().
Referenced by wb::attack::apply_temp_modifier().
|
protected |
Definition at line 529 of file move.cpp.
References resources::controller, play_controller::current_side(), get_dest_hex(), get_source_hex(), get_unit(), movement_cost_, route_, resources::screen, wb::action::valid(), display::viewing_side(), and WRN_WB.
Referenced by calculate_new_route(), init(), and set_route().
|
virtual |
attempts to pathfind a new marked route for this path between these two hexes; returns true and assigns it to the internal route if successful.
Definition at line 313 of file move.cpp.
References pathfind::a_star_search(), schema_validation::at(), calculate_move_cost(), resources::gameboard, get_unit(), pathfind::cost_calculator::getNoPathValue(), h, pathfind::mark_route(), pathfind::plain_route::move_cost, route_, wb::action::team_index(), and resources::teams.
|
virtual |
Check the validity of the action.
OK | if there isn't any error (the action can be executed.) |
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 429 of file move.cpp.
References arrow_texture_, ARROW_TEXTURE_INVALID, ARROW_TEXTURE_VALID, schema_validation::at(), unit_map::find(), resources::gameboard, get_dest_hex(), get_route(), get_source_hex(), game_board::get_visible_unit(), wb::action::INVALID_LOCATION, wb::action::LOCATION_OCCUPIED, pathfind::mark_route(), pathfind::marked_route::marks, wb::action::NO_UNIT, wb::action::OK, set_arrow_texture(), pathfind::marked_route::steps, resources::teams, wb::action::TOO_FAR, wb::action::UNIT_CHANGED, unit_id_, unit_underlying_id_, resources::units, wb::action::valid(), and wb::viewer_team().
Referenced by wb::attack::check_validity().
|
privatevirtual |
Called by the non-virtual hide() and show(), respectively.
Reimplemented from wb::action.
Reimplemented in wb::attack.
Definition at line 396 of file move.cpp.
References arrow_, fake_unit_, and fake_unit_hidden_.
|
privatevirtual |
Reimplemented from wb::action.
Reimplemented in wb::attack.
Definition at line 403 of file move.cpp.
References arrow_, fake_unit_, and fake_unit_hidden_.
|
virtual |
Gets called by display when drawing a hex, to allow actions to draw to the screen.
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 385 of file move.cpp.
References display::draw_text_in_hex(), get_dest_hex(), display::LAYER_MOVE_INFO, font::NORMAL_COLOR, resources::screen, and turn_number_.
|
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.
Reimplemented in wb::attack.
Definition at line 205 of file move.cpp.
References arrow_, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_STANDARD, resources::controller, unit_map::find(), get_dest_hex(), play_controller::get_mouse_handler_base(), get_source_hex(), hide_fake_unit(), LOG_WB, events::mouse_handler::move_unit_along_route(), route_, set_arrow_brightness(), shared_from_this(), show_fake_unit(), unit_id_, resources::units, wb::action::valid(), and WRN_WB.
Referenced by wb::attack::execute().
|
inlinevirtual |
|
virtual |
Definition at line 300 of file move.cpp.
References route_.
Referenced by apply_temp_modifier(), wb::attack::attack(), calculate_move_cost(), check_validity(), wb::attack::draw_hex(), draw_hex(), wb::attack::execute(), execute(), get_numbering_hex(), wb::attack::invalidate(), print(), redraw(), and remove_temp_modifier().
|
inlinevirtual |
Implements wb::action.
Definition at line 58 of file move.hpp.
References fake_unit_.
|
virtual |
|
inlinevirtual |
|
virtual |
Definition at line 294 of file move.cpp.
References route_.
Referenced by apply_temp_modifier(), calculate_move_cost(), check_validity(), execute(), print(), redraw(), and remove_temp_modifier().
|
virtual |
Return the unit targeted by this action.
Null if unit doesn't exist.
Implements wb::action.
Definition at line 285 of file move.cpp.
References unit_map::find(), unit_map::iterator_base< iter_types >::get_shared_ptr(), itor, unit_underlying_id_, resources::units, and unit_map::iterator_base< iter_types >::valid().
Referenced by wb::attack::apply_temp_modifier(), wb::attack::attack(), calculate_move_cost(), calculate_new_route(), wb::attack::check_validity(), init(), move(), print(), and wb::attack::remove_temp_modifier().
|
private |
Definition at line 410 of file move.cpp.
References fake_unit_, fake_unit_hidden_, and wb::action::hidden().
Referenced by execute().
|
private |
Definition at line 143 of file move.cpp.
References arrow_, arrow_brightness_, ARROW_BRIGHTNESS_FOCUS, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_STANDARD, arrow_texture_, ARROW_TEXTURE_INVALID, ARROW_TEXTURE_VALID, calculate_move_cost(), fake_unit_, get_unit(), arrow::STYLE_FOCUS, arrow::STYLE_FOCUS_INVALID, arrow::STYLE_HIGHLIGHTED, arrow::STYLE_STANDARD, wb::action::team_index(), resources::teams, and unit_id_.
Referenced by move().
|
virtual |
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 56 of file move.cpp.
References get_dest_hex(), get_source_hex(), and get_unit().
Referenced by wb::attack::print().
|
virtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented from wb::action.
Definition at line 554 of file move.cpp.
References get_dest_hex(), get_source_hex(), display::invalidate(), resources::screen, and update_arrow_style().
Referenced by wb::attack::redraw().
Removes the result of this action from the specified unit map.
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 362 of file move.cpp.
References DBG_WB, lg::debug(), unit_map::find(), get_dest_hex(), get_source_hex(), unit::id(), log_whiteboard, movement_cost_, unit::movement_left(), mover_, unit::name(), and resources::units.
Referenced by wb::attack::remove_temp_modifier().
|
inline |
|
inline |
|
virtual |
Definition at line 306 of file move.cpp.
References arrow_, calculate_move_cost(), and route_.
Assigns a turn number to display to this planned move.
Assigning zero removes any turn number.
Definition at line 82 of file move.hpp.
References turn_number_.
|
inlineprotected |
Definition at line 96 of file move.hpp.
Referenced by accept(), execute(), and wb::attack::shared_from_this().
|
private |
Definition at line 417 of file move.cpp.
References fake_unit_, fake_unit_hidden_, and wb::action::hidden().
Referenced by execute().
|
virtual |
Constructs and returns a config object representing this object.
Reimplemented from wb::action.
Reimplemented in wb::attack.
Definition at line 493 of file move.cpp.
References config::add_child(), route_, wb::action::to_config(), unit_underlying_id_, map_location::x, and map_location::y.
Referenced by wb::attack::to_config().
|
private |
Definition at line 563 of file move.cpp.
References arrow_, arrow_brightness_, ARROW_BRIGHTNESS_FOCUS, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_STANDARD, arrow_texture_, ARROW_TEXTURE_INVALID, arrow::STYLE_FOCUS, arrow::STYLE_FOCUS_INVALID, arrow::STYLE_HIGHLIGHTED, and arrow::STYLE_STANDARD.
Referenced by redraw().
|
protected |
Definition at line 109 of file move.hpp.
Referenced by do_hide(), do_show(), execute(), get_arrow(), init(), move(), set_route(), and update_arrow_style().
|
mutableprotected |
Definition at line 112 of file move.hpp.
Referenced by init(), set_arrow_brightness(), and update_arrow_style().
|
mutableprotected |
Definition at line 113 of file move.hpp.
Referenced by check_validity(), init(), set_arrow_texture(), and update_arrow_style().
|
protected |
Definition at line 110 of file move.hpp.
Referenced by wb::attack::apply_temp_modifier(), apply_temp_modifier(), do_hide(), do_show(), get_fake_unit(), hide_fake_unit(), init(), move(), and show_fake_unit().
|
private |
Definition at line 125 of file move.hpp.
Referenced by do_hide(), do_show(), hide_fake_unit(), and show_fake_unit().
|
protected |
Definition at line 105 of file move.hpp.
Referenced by apply_temp_modifier(), calculate_move_cost(), and remove_temp_modifier().
|
private |
Definition at line 124 of file move.hpp.
Referenced by apply_temp_modifier(), and remove_temp_modifier().
|
protected |
Definition at line 104 of file move.hpp.
Referenced by calculate_move_cost(), calculate_new_route(), wb::attack::execute(), execute(), get_dest_hex(), get_route(), get_source_hex(), move(), set_route(), and to_config().
|
protected |
Turn end number to draw if greater than zero. Assigned by the map builder.
Definition at line 107 of file move.hpp.
Referenced by draw_hex(), and set_turn_number().
|
protected |
Definition at line 103 of file move.hpp.
Referenced by check_validity(), wb::attack::execute(), execute(), and init().
|
protected |
Definition at line 102 of file move.hpp.
Referenced by check_validity(), get_unit(), move(), and to_config().