70 :
action(team_index,hidden),
71 unit_underlying_id_(u.underlying_id()),
77 fake_unit_(std::
move(fake_unit)),
81 fake_unit_hidden_(false)
83 assert(!
route_->steps.empty());
93 , unit_underlying_id_(0)
98 , arrow_(new
arrow(hidden))
100 , arrow_brightness_()
103 , fake_unit_hidden_(false)
115 route_->move_cost = route_cfg[
"move_cost"].to_int();
117 route_->steps.emplace_back(loc_cfg[
"x"],loc_cfg[
"y"],
wml_loc());
122 mark_cfg[
"zoc"].to_bool(),
123 mark_cfg[
"capture"].to_bool(),
124 mark_cfg[
"invisible"].to_bool());
128 const std::vector<map_location>& steps =
route_->steps;
174 std::string arrow_style =
arrow_->get_style();
215 success = complete =
true;
222 const std::vector<map_location> steps =
route_->steps;
227 std::size_t num_steps;
239 if ( num_steps == 0 )
241 LOG_WB <<
"Move execution resulted in zero movement.";
247 WRN_WB <<
"Unit disappeared from map during move execution.";
253 complete = num_steps + 1 == steps.size();
254 success = complete && !interrupted;
260 LOG_WB <<
"Move completed, but interrupted on final hex. Halting.";
262 route_->steps = std::vector<map_location>(1, final_location);
267 LOG_WB <<
"Move finished at (" << final_location <<
") instead of at (" <<
get_dest_hex() <<
"). Setting new path.";
268 route_->steps = std::vector<map_location>(steps.begin() + num_steps, steps.end());
299 return route_->steps.front();
305 return route_->steps.back();
353 if (
route_->move_cost == -1) {
399 std::stringstream turn_text;
441 class arrow_texture_setter {
445 current_texture(current_texture),
446 setting_texture(setting_texture) {}
448 ~arrow_texture_setter() {
449 if(current_texture!=setting_texture) {
493 if(checked_route.
marks[checked_route.
steps.back()].turns != 1) {
508 final_cfg[
"type"]=
"move";
515 route_cfg[
"move_cost"]=
route_->move_cost;
519 loc_cfg[
"x"]=loc.
wml_x();
520 loc_cfg[
"y"]=loc.
wml_y();
521 route_cfg.
add_child(
"step", std::move(loc_cfg));
523 typedef std::pair<map_location,pathfind::marked_route::mark> pair_loc_mark;
524 for(
const pair_loc_mark item :
route_->marks)
527 mark_cfg[
"x"]=item.first.wml_x();
528 mark_cfg[
"y"]=item.first.wml_y();
529 mark_cfg[
"turns"]=item.second.turns;
530 mark_cfg[
"zoc"]=item.second.zoc;
531 mark_cfg[
"capture"]=item.second.capture;
532 mark_cfg[
"invisible"]=item.second.invisible;
533 route_cfg.
add_child(
"mark", std::move(mark_cfg));
535 final_cfg.
add_child(
"route_", std::move(route_cfg));
const std::vector< map_location > & route_
Arrows destined to be drawn on the map.
Arrows destined to be drawn on the map.
static const std::string STYLE_FOCUS_INVALID
static const std::string STYLE_FOCUS
static const std::string STYLE_STANDARD
If you add more styles, you should look at move::update_arrow_style()
static const std::string STYLE_HIGHLIGHTED
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
config & add_child(config_key_type key)
const team & viewing_team() const
void draw_text_in_hex(const map_location &loc, const drawing_layer layer, const std::string &text, std::size_t font_size, color_t color, double x_in_hex=0.5, double y_in_hex=0.5)
Draw text on a hex.
bool invalidate(const map_location &loc)
Function to invalidate a specific tile for redrawing.
static display * get_singleton()
Returns the display object if a display object exists.
std::size_t move_unit_along_route(const std::vector< map_location > &steps, bool &interrupted)
Moves a unit across the board for a player.
Holds a temporary unit that can be drawn on the map without being placed in the unit_map.
internal_ptr get_unit_ptr()
Get a copy of the internal unit pointer.
virtual const std::vector< team > & teams() const override
unit * get_visible_unit(const map_location &loc, const team ¤t_team, bool see_all=false)
virtual const unit_map & units() const override
events::mouse_handler & get_mouse_handler_base() override
Get a reference to a mouse handler member a derived class uses.
int current_side() const
Returns the number of the side whose turn it is.
Exception used to escape form the ai or ui code to playsingle_controller::play_side.
static std::string get_side_color_id(unsigned side)
Wrapper class to encapsulate creation and management of an SDL_Texture.
Container associating units to locations.
unit_iterator find(std::size_t id)
This class represents a single unit of a specific type.
Abstract base class for all the whiteboard planned actions.
bool valid()
Returns whether this action is valid or not.
std::size_t team_index() const
Returns the index of the team that owns this action.
virtual config to_config() const
Constructs and returns a config object representing this object.
int side_number() const
Returns the number of the side that owns this action, i.e.
A planned move, represented on the map by an arrow and a ghosted unit in the destination hex.
move(std::size_t team_index, bool hidden, unit &mover, const pathfind::marked_route &route, arrow_ptr arrow, fake_unit_ptr fake_unit)
void redraw()
Redrawing function, called each time the action situation might have changed.
virtual void accept(visitor &v)
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
virtual unit_ptr get_unit() const
Return the unit targeted by this action.
virtual error check_validity() const
Check the validity of the action.
std::unique_ptr< pathfind::marked_route > route_
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
void set_arrow_texture(ARROW_TEXTURE x) const
void modify_unit(unit &new_unit)
virtual void do_hide()
Called by the non-virtual hide() and show(), respectively.
virtual std::ostream & print(std::ostream &s) const
virtual map_location get_dest_hex() const
std::size_t unit_underlying_id_
virtual void set_route(const pathfind::marked_route &route)
void set_arrow_brightness(ARROW_BRIGHTNESS x) const
std::unique_ptr< temporary_unit_mover > mover_
virtual const pathfind::marked_route & get_route() const
ARROW_TEXTURE arrow_texture_
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 assig...
virtual config to_config() const
Constructs and returns a config object representing this object.
int turn_number_
Turn end number to draw if greater than zero.
int calculate_moves_left(unit &u)
std::shared_ptr< move > shared_from_this()
virtual map_location get_source_hex() const
void init(unit *u=nullptr)
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
void update_arrow_style()
ARROW_BRIGHTNESS arrow_brightness_
@ ARROW_BRIGHTNESS_STANDARD
@ ARROW_BRIGHTNESS_HIGHLIGHTED
virtual map_location get_numbering_hex() const
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
This internal whiteboard class holds the planned action queues for a team, and offers many utility me...
iterator find_last_action_of(const unit &unit, iterator start_position)
Finds the last action that belongs to this unit, starting the search backwards from the specified pos...
container::iterator iterator
iterator end()
Returns the iterator for the position after the last executed action within the actions queue.
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses.
virtual void visit(move_ptr move)=0
Definitions for the interface to Wesnoth Markup Language (WML).
@ move_info
Movement info (defense%, etc...)
Contains the exception interfaces used to signal completion of a scenario, campaign or turn.
const std::string & id() const
Gets this unit's id.
std::size_t underlying_id() const
This unit's unique internal ID.
const t_string & name() const
Gets this unit's translatable display name.
int movement_left() const
Gets how far a unit can move, considering the incapacitated flag.
const color_t NORMAL_COLOR
plain_route a_star_search(const map_location &src, const map_location &dst, double stop_at, const cost_calculator &calc, const std::size_t width, const std::size_t height, const teleport_map *teleports, bool border)
marked_route mark_route(const plain_route &rt, bool update_move_cost)
Add marks on a route rt assuming that the unit located at the first hex of rt travels along it.
fake_unit_manager * fake_units
play_controller * controller
static std::string at(const std::string &file, int line)
void move_unit(const std::vector< map_location > &path, unit_ptr u, bool animate, map_location::direction dir, bool force_scroll)
Display a unit moving along a given path.
std::ostream & operator<<(std::ostream &s, action_ptr action)
std::shared_ptr< move > move_ptr
std::shared_ptr< side_actions > side_actions_ptr
std::shared_ptr< arrow > arrow_ptr
std::shared_ptr< move const > move_const_ptr
std::shared_ptr< unit > unit_ptr
Encapsulates the map of the game.
static double getNoPathValue()
Structure which holds a single route and marks for special events.
std::vector< map_location > & steps
Structure which holds a single route between one location and another.
int move_cost
Movement cost for reaching the end of the route.
This object is used to temporary move a unit in the unit map, swapping out any unit that is already t...
pointer get_shared_ptr() const
This is exactly the same as operator-> but it's slightly more readable, and can replace &*iter syntax...
static map_location::direction s
static lg::log_domain log_whiteboard("whiteboard")
Display units performing various actions: moving, attacking, and dying.
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action)