The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2017 by David White <>
3  Part of the Battle for Wesnoth Project
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
12  See the COPYING file for more details.
13 */
15 /**
16  * @file
17  * Various functions related to the creation of units (recruits, recalls,
18  * and placed units).
19  */
21 #pragma once
23 class config;
24 class team;
25 class vconfig;
26 class game_board;
27 class unit;
29 #include "map/location.hpp"
32 {
33 public:
34  unit_creator(team &tm, const map_location &start_pos, game_board* board = nullptr);
35  unit_creator& allow_show(bool b);
42  /**
43  * finds a suitable location for unit
44  * @retval map_location::null_location() if unit is to be put into recall list
45  * @retval valid on-board map location otherwise
46  */
47  map_location find_location(const config &cfg, const unit* pass_check=nullptr);
50  /**
51  * adds a unit on map without firing any events (so, usable during team construction in gamestatus)
52  */
53  void add_unit(const config &cfg, const vconfig* vcfg = nullptr);
55 private:
56  void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event);
59  bool discover_;
63  bool show_;
68 };
unit_creator & allow_rename_side(bool b)
Game board class.
Definition: game_board.hpp:50
bool fire_event(const ui_event event, std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&...params)
Helper function for fire_event.
This class represents a single unit of a specific type.
Definition: unit.hpp:101
unit_creator & allow_invalidate(bool b)
unit_creator & allow_show(bool b)
unit_creator & allow_discover(bool b)
unit_creator & allow_add_to_recall(bool b)
#define b
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:44
const map_location start_pos_
Encapsulates the map of the game.
Definition: location.hpp:40
unit_creator & allow_get_village(bool b)
void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event)
void add_unit(const config &cfg, const vconfig *vcfg=nullptr)
adds a unit on map without firing any events (so, usable during team construction in gamestatus) ...
map_location find_location(const config &cfg, const unit *pass_check=nullptr)
finds a suitable location for unit
A variable-expanding proxy for the config class.
Definition: variable.hpp:42
unit_creator(team &tm, const map_location &start_pos, game_board *board=nullptr)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
game_board * board_