The Battle for Wesnoth  1.15.12+dev
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Chris Beck <>
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 #pragma once
17 #include "config.hpp"
19 #include <deque>
20 #include <memory>
21 #include <set>
22 #include <string>
23 #include <vector>
25 class team;
26 class game_board;
29 {
30 public:
31  team_builder(const config& side_cfg, team& to_build, const config& level, game_board& board, int num);
33  /**
34  * Very important! Delete copy constructor and declare a move constructor.
35  *
36  * @c `unit_configs_` may hold a pointer to a config object stored in @c `leader_configs_`.
37  * In that case, if a copy happens (such as when doing in-place construction that requires
38  * the vector be resized), these pointers will become invalid and lead to a crash.
39  */
40  team_builder(const team_builder&) = delete;
41  team_builder(team_builder&&) = default;
43  /** Handles the first stage of team initialization (everything except unit placement). */
44  void build_team_stage_one();
46  /** Handles the second stage of team initialization (unit placement). */
47  void build_team_stage_two();
49 private:
51  std::deque<config> leader_configs_;
52  // only used for objectives
53  const config& level_;
55  // only used for debug message
57  std::set<std::string> seen_ids_;
58  int side_;
59  const config& side_cfg_;
61  std::vector<const config*> unit_configs_;
63  void log_step(const char* s) const;
64  void init();
65  void gold();
66  void new_team();
67  void objectives();
68  void previous_recruits();
69  void handle_unit(const config& u, const char* origin);
70  void handle_leader(const config& leader);
71  void leader();
72  void prepare_units();
73  void place_units();
74 };
Game board class.
Definition: game_board.hpp:50
std::deque< config > leader_configs_
Definition: teambuilder.hpp:51
void place_units()
team_builder(const config &side_cfg, team &to_build, const config &level, game_board &board, int num)
Definition: teambuilder.cpp:37
void build_team_stage_two()
Handles the second stage of team initialization (unit placement).
Definition: teambuilder.cpp:75
std::vector< const config * > unit_configs_
Definition: teambuilder.hpp:61
Definitions for the interface to Wesnoth Markup Language (WML).
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:44
bool player_exists_
Definition: teambuilder.hpp:56
void objectives()
void previous_recruits()
void handle_leader(const config &leader)
int gold_info_ngold_
Definition: teambuilder.hpp:50
void log_step(const char *s) const
Definition: teambuilder.cpp:82
void build_team_stage_one()
Handles the first stage of team initialization (everything except unit placement).
Definition: teambuilder.cpp:51
const config & level_
Definition: teambuilder.hpp:53
void prepare_units()
static map_location::DIRECTION s
void handle_unit(const config &u, const char *origin)
game_board & board_
Definition: teambuilder.hpp:54
std::set< std::string > seen_ids_
Definition: teambuilder.hpp:57
const config & side_cfg_
Definition: teambuilder.hpp:59
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59