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 (std::size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit) | |
move (const config &, 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 size_t | get_unit_id () const |
Returns the id of 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 |
std::size_t | raw_uid () const |
void | modify_unit (unit &new_unit) |
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 (const map_location &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 (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 bool | places_new_unit () const |
Returns true for recall and recruit actions. 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< move > | shared_from_this () |
int | calculate_moves_left (unit &u) |
Protected Attributes | |
std::size_t | unit_underlying_id_ |
std::string | unit_id_ |
std::unique_ptr< pathfind::marked_route > | route_ |
int | movement_cost_ |
int | turn_number_ |
Turn end number to draw if greater than zero. 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 (unit *u=nullptr) |
void | update_arrow_style () |
Private Attributes | |
std::unique_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 (const config &, 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 | ( | std::size_t | team_index, |
bool | hidden, | ||
unit & | mover, | ||
const pathfind::marked_route & | route, | ||
arrow_ptr | arrow, | ||
fake_unit_ptr | fake_unit | ||
) |
Definition at line 70 of file move.cpp.
References fake_unit_, wb::action::hidden(), init(), and route_.
wb::move::move | ( | const config & | cfg, |
bool | hidden | ||
) |
Definition at line 93 of file move.cpp.
References arrow_, config::child_range(), fake_unit_, resources::fake_units, unit_map::find(), resources::gameboard, team::get_side_color_id(), get_unit(), fake_unit_ptr::get_unit_ptr(), wb::action::hidden(), init(), mark, unit_display::move_unit(), config::optional_child(), route_, wb::action::side_number(), arrow::STYLE_STANDARD, unit_underlying_id_, and game_board::units().
|
virtual |
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 201 of file move.cpp.
References shared_from_this(), and wb::visitor::visit().
|
virtual |
Applies temporarily the result of this action to the specified unit map.
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 335 of file move.cpp.
References calculate_moves_left(), DBG_WB, unit_map::end(), fake_unit_, unit_map::find(), get_dest_hex(), get_route(), get_source_hex(), unit::id(), pathfind::mark_route(), pathfind::marked_route::move_cost, unit::movement_left(), mover_, unit::name(), and route_.
Referenced by wb::attack::apply_temp_modifier().
|
protected |
Definition at line 542 of file move.cpp.
References resources::controller, play_controller::current_side(), get_dest_hex(), display::get_singleton(), get_source_hex(), unit::movement_left(), route_, shared_from_this(), team::side(), wb::action::valid(), display::viewing_team(), and WRN_WB.
Referenced by apply_temp_modifier(), and remove_temp_modifier().
|
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 322 of file move.cpp.
References pathfind::a_star_search(), schema_validation::at(), resources::gameboard, get_unit(), pathfind::cost_calculator::getNoPathValue(), h, pathfind::mark_route(), pathfind::plain_route::move_cost, route_, wb::action::team_index(), and w.
|
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 440 of file move.cpp.
References arrow_texture_, ARROW_TEXTURE_INVALID, ARROW_TEXTURE_VALID, unit_map::find(), resources::gameboard, get_dest_hex(), get_route(), display::get_singleton(), 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(), setter, pathfind::marked_route::steps, wb::action::TOO_FAR, wb::action::UNIT_CHANGED, unit_id_, unit_underlying_id_, game_board::units(), and wb::action::valid().
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 407 of file move.cpp.
References arrow_, fake_unit_, and fake_unit_hidden_.
|
privatevirtual |
Reimplemented from wb::action.
Reimplemented in wb::attack.
Definition at line 414 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 396 of file move.cpp.
References display::draw_text_in_hex(), get_dest_hex(), display::get_singleton(), move_info, font::NORMAL_COLOR, 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 206 of file move.cpp.
References arrow_, ARROW_BRIGHTNESS_HIGHLIGHTED, ARROW_BRIGHTNESS_STANDARD, resources::controller, unit_map::find(), resources::gameboard, get_dest_hex(), play_controller::get_mouse_handler_base(), get_source_hex(), hide_fake_unit(), LOG_WB, pathfind::mark_route(), events::mouse_handler::move_unit_along_route(), route_, set_arrow_brightness(), shared_from_this(), show_fake_unit(), unit_id_, game_board::units(), wb::action::valid(), and WRN_WB.
Referenced by wb::attack::execute().
|
inlinevirtual |
Definition at line 77 of file move.hpp.
References arrow_.
Referenced by wb::highlighter::highlight_main_visitor::visit(), wb::highlighter::highlight_secondary_visitor::visit(), and wb::highlighter::unhighlight_visitor::visit().
|
virtual |
Definition at line 304 of file move.cpp.
References route_.
Referenced by apply_temp_modifier(), wb::attack::attack(), calculate_moves_left(), 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 61 of file move.hpp.
References fake_unit_.
Referenced by wb::highlighter::last_action_redraw(), wb::manager::post_delete_action(), wb::highlighter::highlight_main_visitor::visit(), wb::highlighter::highlight_secondary_visitor::visit(), and wb::highlighter::unhighlight_visitor::visit().
|
virtual |
|
inlinevirtual |
Definition at line 70 of file move.hpp.
References route_.
Referenced by apply_temp_modifier(), check_validity(), and wb::mapbuilder::post_visit_team().
|
virtual |
Definition at line 298 of file move.cpp.
References route_.
Referenced by apply_temp_modifier(), calculate_moves_left(), 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 289 of file move.cpp.
References unit_map::find(), resources::gameboard, unit_map::iterator_base< iter_types >::get_shared_ptr(), unit_underlying_id_, game_board::units(), and unit_map::iterator_base< iter_types >::valid().
Referenced by wb::attack::apply_temp_modifier(), wb::attack::attack(), calculate_new_route(), wb::attack::check_validity(), init(), move(), wb::mapbuilder::post_visit_team(), print(), and wb::attack::remove_temp_modifier().
|
inlinevirtual |
Returns the id of the unit targeted by this action.
0 | no unit is targeted. |
Reimplemented from wb::action.
Definition at line 59 of file move.hpp.
References unit_underlying_id_.
Referenced by wb::highlighter::last_action_redraw().
|
private |
Definition at line 421 of file move.cpp.
References fake_unit_, fake_unit_hidden_, and wb::action::hidden().
Referenced by execute().
|
private |
Definition at line 150 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, wb::side_actions::end(), fake_unit_, wb::side_actions::find_last_action_of(), resources::gameboard, get_unit(), unit::id(), arrow::STYLE_FOCUS, arrow::STYLE_FOCUS_INVALID, arrow::STYLE_HIGHLIGHTED, arrow::STYLE_STANDARD, wb::action::team_index(), game_board::teams(), unit_id_, and unit_underlying_id_.
Referenced by move().
void wb::move::modify_unit | ( | unit & | new_unit | ) |
Definition at line 316 of file move.cpp.
References unit::id(), unit::underlying_id(), unit_id_, and unit_underlying_id_.
Referenced by wb::side_actions::update_recruited_unit().
|
virtual |
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 58 of file move.cpp.
References get_dest_hex(), get_source_hex(), get_unit(), s, and unit_underlying_id_.
Referenced by wb::operator<<(), and wb::attack::print().
|
inline |
Definition at line 66 of file move.hpp.
References unit_underlying_id_.
|
virtual |
Redrawing function, called each time the action situation might have changed.
Reimplemented from wb::action.
Definition at line 567 of file move.cpp.
References get_dest_hex(), display::get_singleton(), get_source_hex(), display::invalidate(), and update_arrow_style().
Referenced by wb::attack::redraw().
|
virtual |
Removes the result of this action from the specified unit map.
Implements wb::action.
Reimplemented in wb::attack.
Definition at line 373 of file move.cpp.
References calculate_moves_left(), DBG_WB, lg::debug(), unit_map::find(), resources::gameboard, get_dest_hex(), get_source_hex(), unit::id(), log_whiteboard, unit::movement_left(), mover_, unit::name(), and game_board::units().
Referenced by wb::attack::remove_temp_modifier().
|
inline |
Definition at line 98 of file move.hpp.
References arrow_brightness_.
Referenced by execute(), wb::highlighter::highlight_main_visitor::visit(), wb::highlighter::highlight_secondary_visitor::visit(), and wb::highlighter::unhighlight_visitor::visit().
|
inline |
|
virtual |
|
inlinevirtual |
Assigns a turn number to display to this planned move.
Assigning zero removes any turn number.
Definition at line 90 of file move.hpp.
References turn_number_.
Referenced by wb::mapbuilder::post_visit_team().
|
inlineprotected |
Definition at line 104 of file move.hpp.
Referenced by accept(), calculate_moves_left(), execute(), and wb::attack::shared_from_this().
|
private |
Definition at line 428 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 506 of file move.cpp.
References config::add_child(), loc, route_, wb::action::to_config(), unit_underlying_id_, map_location::wml_x(), and map_location::wml_y().
Referenced by wb::attack::to_config().
|
private |
Definition at line 576 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 117 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 120 of file move.hpp.
Referenced by init(), set_arrow_brightness(), and update_arrow_style().
|
mutableprotected |
Definition at line 121 of file move.hpp.
Referenced by check_validity(), init(), set_arrow_texture(), and update_arrow_style().
|
protected |
Definition at line 118 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 133 of file move.hpp.
Referenced by do_hide(), do_show(), hide_fake_unit(), and show_fake_unit().
|
private |
Definition at line 132 of file move.hpp.
Referenced by apply_temp_modifier(), and remove_temp_modifier().
|
protected |
Definition at line 112 of file move.hpp.
Referenced by apply_temp_modifier(), calculate_moves_left(), 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 115 of file move.hpp.
Referenced by draw_hex(), and set_turn_number().
|
protected |
Definition at line 111 of file move.hpp.
Referenced by check_validity(), wb::attack::execute(), execute(), init(), and modify_unit().
|
protected |
Definition at line 110 of file move.hpp.
Referenced by check_validity(), get_unit(), get_unit_id(), init(), modify_unit(), move(), print(), raw_uid(), and to_config().