1 /*
2    Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3    Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
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,
10    but WITHOUT ANY WARRANTY.
11 
12    See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Various functions related to the creation of units (recruits, recalls,
18  * and placed units).
19  */
20 
21 #pragma once
22 
23 class config;
24 class team;
25 class vconfig;
26 class game_board;
27 class unit;
28 
29 #include "map/location.hpp"
30 
31 class unit_creator
32 {
33 public:
34 	unit_creator(team &tm, const map_location &start_pos, game_board* board = nullptr);
35 	unit_creator& allow_show(bool b);
36 	unit_creator& allow_get_village(bool b);
37 	unit_creator& allow_rename_side(bool b);
38 	unit_creator& allow_invalidate(bool b);
39 	unit_creator& allow_discover(bool b);
40 	unit_creator& allow_add_to_recall(bool b);
41 
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);
48 
49 
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);
54 
55 private:
56 	void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event);
57 
58 	bool add_to_recall_;
59 	bool discover_;
60 	bool get_village_;
61 	bool invalidate_;
62 	bool rename_side_;
63 	bool show_;
64 	const map_location start_pos_;
65 	team &team_;
66 	game_board* board_;
67 
68 };
69