72 :
action(team_index,hidden),
73 unit_underlying_id_(u.underlying_id()),
79 fake_unit_(std::
move(fake_unit)),
83 fake_unit_hidden_(false)
85 assert(!
route_->steps.empty());
95 , unit_underlying_id_(0)
100 , arrow_(new
arrow(hidden))
102 , arrow_brightness_()
105 , fake_unit_hidden_(false)
117 route_->move_cost = route_cfg[
"move_cost"].to_int();
119 route_->steps.emplace_back(loc_cfg[
"x"],loc_cfg[
"y"],
wml_loc());
124 mark_cfg[
"zoc"].to_bool(),
125 mark_cfg[
"capture"].to_bool(),
126 mark_cfg[
"invisible"].to_bool());
130 const std::vector<map_location>& steps =
route_->steps;
176 std::string arrow_style =
arrow_->get_style();
217 success = complete =
true;
224 const std::vector<map_location> steps =
route_->steps;
229 std::size_t num_steps;
241 if ( num_steps == 0 )
243 LOG_WB <<
"Move execution resulted in zero movement.";
249 WRN_WB <<
"Unit disappeared from map during move execution.";
255 complete = num_steps + 1 == steps.size();
256 success = complete && !interrupted;
262 LOG_WB <<
"Move completed, but interrupted on final hex. Halting.";
264 route_->steps = std::vector<map_location>(1, final_location);
269 LOG_WB <<
"Move finished at (" << final_location <<
") instead of at (" <<
get_dest_hex() <<
"). Setting new path.";
270 route_->steps = std::vector<map_location>(steps.begin() + num_steps, steps.end());
301 return route_->steps.front();
307 return route_->steps.back();
355 if (
route_->move_cost == -1) {
401 std::stringstream turn_text;
443 class arrow_texture_setter {
447 current_texture(current_texture),
448 setting_texture(setting_texture) {}
450 ~arrow_texture_setter() {
451 if(current_texture!=setting_texture) {
495 if(checked_route.
marks[checked_route.
steps.back()].turns != 1) {
510 final_cfg[
"type"]=
"move";
517 route_cfg[
"move_cost"]=
route_->move_cost;
523 route_cfg.
add_child(
"step", std::move(loc_cfg));
525 typedef std::pair<map_location,pathfind::marked_route::mark> pair_loc_mark;
526 for(
const pair_loc_mark item :
route_->marks)
529 mark_cfg[
"x"]=item.first.wml_x();
530 mark_cfg[
"y"]=item.first.wml_y();
531 mark_cfg[
"turns"]=item.second.turns;
532 mark_cfg[
"zoc"]=item.second.zoc;
533 mark_cfg[
"capture"]=item.second.capture;
534 mark_cfg[
"invisible"]=item.second.invisible;
535 route_cfg.
add_child(
"mark", std::move(mark_cfg));
537 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, const unit_ptr &u, bool animate, map_location::direction dir, bool force_scroll)
Display a unit moving along a given path.
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::ostream & operator<<(std::ostream &s, const action_ptr &action)
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)