The Battle for Wesnoth  1.15.0-dev
configuration.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2018 by Yurii Chernyi <terraninfo@terraninfo.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  * Managing the AIs configuration - headers
17  * @file
18  * */
19 
20 #pragma once
21 
22 #include "ai/game_info.hpp"
23 #include "config.hpp"
24 
25 namespace ai
26 {
27 /**
28  * AI parameters. class to deal with AI parameters. It is an implementation detail.
29  * We need implementation which will allow easy access to all the parameters
30  * which match any of the pre-defined set of filters
31  * such as 'select from ai_parameters where time_of_day=first watch'
32  * or 'select from ai_parameters where active(current_game_state)=true'
33  * it should be noted that there may be several variables with a same name but
34  * different filters. the proposed rules, in general, are:
35  * 1) scenario_parameter_in_SIDE_section > scenario_parameter_in_AI_section > default_value
36  * then, if (1) is equal:
37  * 2) use scenario-creator supplied priority ( 'not set' = 0)
38  * then, if (2) is equal:
39  * 3) more restricted parameter > less restricted parameter
40  * then, if (3) is equal:
41  * use any and loudly complain.
42  */
43 
45 {
46 public:
48  : text()
49  , id()
50  , cfg()
51  {
52  }
53 
55  std::string id;
57 };
58 
60 {
61 public:
62  /**
63  * Init the parameters of ai configuration parser
64  * @param game_config game config
65  */
66  static void init(const config& game_config);
67  static void add_era_ai_from_config(const config& game_config);
68  static void add_mod_ai_from_config(config::const_child_itors configs);
69 
70  /**
71  * get default AI parameters
72  * @return default AI parameters
73  */
74  static const config& get_default_ai_parameters();
75 
76  /**
77  * Return the config for a specified ai
78  */
79  static const config& get_ai_config_for(const std::string& id);
80 
81  /**
82  * Returns a list of available AIs.
83  * @return the list of available AIs.
84  */
85  static std::vector<description*> get_available_ais();
86 
87  /**
88  * get side config from file
89  * @param file the file name to open. follows usual WML convention.
90  * @param[out] cfg the config to be written from file.
91  * @return was all ok?
92  * @retval true success
93  * @retval false failure
94  */
95  static bool get_side_config_from_file(const std::string& file, config& cfg);
96 
97  /**
98  * @param[in] original_cfg the config to be read
99  * @param[out] cfg parsed config
100  * @return was all ok?
101  * @retval true success
102  * @retval false failure
103  */
104  static bool parse_side_config(side_number side, const config& original_cfg, config& cfg);
105 
106  /**
107  * Expand simplified aspects, similar to the change from 1.7.2 to 1.7.3
108  * but with some additional syntax options.
109  */
110  static void expand_simplified_aspects(side_number side, config& cfg);
111 
112 private:
113  typedef std::map<std::string, description> description_map;
114  static description_map ai_configurations_;
115  static description_map era_ai_configurations_;
116  static description_map mod_ai_configurations_;
118 };
119 
120 } // end of namespace ai
AI parameters.
static config default_config_
Definitions for the interface to Wesnoth Markup Language (WML).
std::string id
A small explanation about what&#39;s going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:58
struct utils::detail::formula_initer init
static description_map era_ai_configurations_
static description_map ai_configurations_
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:210
Game information for the AI.
Game configuration data as global variables.
Definition: build_info.cpp:46
std::map< std::string, description > description_map
static description_map mod_ai_configurations_
int side_number
Definition: game_info.hpp:39
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68