The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
configuration.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2017 by Yurii Chernyi <terraninfo@terraninfo.net>
3  Part of the Battle for Wesnoth Project http://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 "config.hpp"
23 #include "ai/game_info.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 
44 struct description {
45 public:
47  : text()
48  , id()
49  , cfg()
50  {
51  }
52 
56 };
57 
59 public:
60 
61  /**
62  * Init the parameters of ai configuration parser
63  * @param game_config game config
64  */
65  static void init(const config &game_config);
66  static void add_era_ai_from_config(const config &game_config);
68 
69 
70  /**
71  * get default AI parameters
72  * @return default AI parameters
73  */
74  static const config& get_default_ai_parameters();
75 
76 
77  /**
78  * Return the config for a specified ai
79  */
80  static const config& get_ai_config_for(const std::string &id);
81 
82 
83  /**
84  * Returns a list of available AIs.
85  * @return the list of available AIs.
86  */
87  static std::vector<description*> get_available_ais();
88 
89 
90  /**
91  * get side config from file
92  * @param file the file name to open. follows usual WML convention.
93  * @param[out] cfg the config to be written from file.
94  * @return was all ok?
95  * @retval true success
96  * @retval false failure
97  */
98  static bool get_side_config_from_file( const std::string& file, config& cfg );
99 
100 
101  /**
102  * @param[in] original_cfg the config to be read
103  * @param[out] cfg parsed config
104  * @return was all ok?
105  * @retval true success
106  * @retval false failure
107  */
108  static bool parse_side_config(side_number side, const config& original_cfg, config &cfg);
109 
110 
111  /**
112  * Expand simplified aspects, similar to the change from 1.7.2 to 1.7.3
113  * but with some additional syntax options.
114  */
115  static void expand_simplified_aspects(side_number side, config &cfg);
116 private:
117 
118  typedef std::map<std::string, description> description_map;
119  static description_map ai_configurations_;
120  static description_map era_ai_configurations_;
121  static description_map mod_ai_configurations_;
123 
124 };
125 
126 } //end of namespace ai
std::vector< char_t > string
AI parameters.
static config default_config_
static void add_mod_ai_from_config(config::const_child_itors configs)
Definitions for the interface to Wesnoth Markup Language (WML).
std::string id
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:58
static bool parse_side_config(side_number side, const config &original_cfg, config &cfg)
static description_map era_ai_configurations_
static std::vector< description * > get_available_ais()
Returns a list of available AIs.
static description_map ai_configurations_
static void expand_simplified_aspects(side_number side, config &cfg)
Expand simplified aspects, similar to the change from 1.7.2 to 1.7.3 but with some additional syntax ...
boost::iterator_range< const_child_iterator > const_child_itors
Definition: config.hpp:236
static void add_era_ai_from_config(const config &game_config)
Game information for the AI.
Game configuration data as global variables.
Definition: build_info.cpp:53
std::map< std::string, description > description_map
static description_map mod_ai_configurations_
static const config & get_default_ai_parameters()
get default AI parameters
static bool get_side_config_from_file(const std::string &file, config &cfg)
get side config from file
int side_number
Definition: game_info.hpp:42
static void init(const config &game_config)
Init the parameters of ai configuration parser.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
static const config & get_ai_config_for(const std::string &id)
Return the config for a specified ai.