58 recruit_hex_(recruit_hex),
59 temp_unit_(create_corresponding_unit()),
60 fake_unit_(temp_unit_->clone()),
68 , unit_name_(cfg[
"unit_name_"])
69 , recruit_hex_(cfg.mandatory_child(
"recruit_hex_")[
"x"],cfg.mandatory_child(
"recruit_hex_")[
"y"],
wml_loc())
112 const std::size_t old_id =
fake_unit_->underlying_id();
129 success = complete = result;
138 <<
"] at position " <<
temp_unit_->get_location() <<
".";
145 const size_t old_id =
temp_unit_->underlying_id();
149 assert(
temp_unit_->underlying_id() == old_id);
171 const double x_offset = 0.5;
172 const double y_offset = 0.7;
174 std::stringstream number_text;
176 std::size_t font_size = 16;
179 number_text.str(), font_size, color, x_offset, y_offset);
195 bool real_unit =
false;
197 result->set_movement(0,
true);
198 result->set_attacks(0);
210 if(recruits.find(
unit_name_) == recruits.end()) {
214 if (!in_extra_recruit) {
234 final_cfg[
"type"] =
"recruit";
241 final_cfg.
add_child(
"recruit_hex_", std::move(loc_cfg));
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
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.
void invalidate_game_status()
Function to invalidate the game status displayed on the sidebar.
static display * get_singleton()
Returns the display object if a display object exists.
bool do_recruit(const std::string &name, int side_num, map_location &target_hex)
void reset()
Reset the internal unit pointer, and deregister from the manager.
void place_on_fake_unit_manager(fake_unit_manager *d)
Place this on manager's fake_units_ dequeue.
virtual const std::vector< team > & teams() const override
virtual const unit_map & units() const override
events::menu_handler & get_menu_handler()
Container associating units to locations.
unit_ptr extract(const map_location &loc)
Extracts a unit from the map.
unit_iterator find(std::size_t id)
umap_retval_pair_t insert(unit_ptr p)
Inserts the unit pointed to by p into the map.
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
A single unit type that the player may recruit.
This class represents a single unit of a specific type.
static unit_ptr create(const config &cfg, bool use_traits=false, const vconfig *vcfg=nullptr)
Initializes a unit from a config.
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.
virtual error check_validity() const
Check the validity of the action.
virtual void do_hide()
Called by the non-virtual hide() and show(), respectively.
std::shared_ptr< recruit > shared_from_this()
virtual std::ostream & print(std::ostream &s) const
virtual void draw_hex(const map_location &hex)
Gets called by display when drawing a hex, to allow actions to draw to the screen.
map_location const get_recruit_hex() const
virtual config to_config() const
Constructs and returns a config object representing this object.
map_location recruit_hex_
virtual void execute(bool &success, bool &complete)
Output parameters: success: Whether or not to continue an execute-all after this execution complete: ...
recruit(std::size_t team_index, bool hidden, const std::string &unit_name, const map_location &recruit_hex)
virtual void apply_temp_modifier(unit_map &unit_map)
Applies temporarily the result of this action to the specified unit map.
unit_ptr create_corresponding_unit()
virtual void remove_temp_modifier(unit_map &unit_map)
Removes the result of this action from the specified unit map.
virtual void accept(visitor &v)
virtual void redraw()
Redrawing function, called each time the action situation might have changed.
Abstract base class for all the visitors (cf GoF Visitor Design Pattern) the whiteboard uses.
virtual void visit(move_ptr move)=0
@ actions_numbering
Move numbering for the whiteboard.
const std::vector< std::string > & recruits() const
The type IDs of the other units this unit may recruit, if possible.
const std::string unicode_minus
fake_unit_manager * fake_units
play_controller * controller
std::shared_ptr< recruit > recruit_ptr
std::ostream & operator<<(std::ostream &s, action_ptr action)
unit * find_recruiter(std::size_t team_index, const map_location &hex)
bool any_recruiter(int team_num, const map_location &loc, std::function< bool(unit &)> func)
executes func for each unti of side of side_num that can recruit on loc.
std::shared_ptr< recruit const > recruit_const_ptr
side_actions_ptr viewer_actions()
std::shared_ptr< unit > unit_ptr
static config unit_name(const unit *u)
The basic class for representing 8-bit RGB or RGBA colour values.
Encapsulates the map of the game.
static map_location::DIRECTION s
unit_type_data unit_types
visitor is an abstract interface : action.accept(visitor) calls visitor.visit(action)