The Battle for Wesnoth  1.13.4+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 - 2016 by Yurii Chernyi <[email protected]>
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 #ifndef AI_CONFIGURATION_HPP_INCLUDED
21 #define AI_CONFIGURATION_HPP_INCLUDED
22 
23 #include "config.hpp"
24 #include "ai/game_info.hpp"
25 
26 namespace ai {
27 
28 /**
29  * AI parameters. class to deal with AI parameters. It is an implementation detail.
30  * We need implementation which will allow easy access to all the parameters
31  * which match any of the pre-defined set of filters
32  * such as 'select from ai_parameters where time_of_day=first watch'
33  * or 'select from ai_parameters where active(current_game_state)=true'
34  * it should be noted that there may be several variables with a same name but
35  * different filters. the proposed rules, in general, are:
36  * 1) scenario_parameter_in_SIDE_section > scenario_parameter_in_AI_section > default_value
37  * then, if (1) is equal:
38  * 2) use scenario-creator supplied priority ( 'not set' = 0)
39  * then, if (2) is equal:
40  * 3) more restricted parameter > less restricted parameter
41  * then, if (3) is equal:
42  * use any and loudly complain.
43  */
44 
45 struct description {
46 public:
48  : text()
49  , id()
50  , cfg()
51  {
52  }
53 
57 };
58 
60 public:
61 
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);
69 
70 
71  /**
72  * get default AI parameters
73  * @return default AI parameters
74  */
75  static const config& get_default_ai_parameters();
76 
77 
78  /**
79  * Return the config for a specified ai
80  */
81  static const config& get_ai_config_for(const std::string &id);
82 
83 
84  /**
85  * Returns a list of available AIs.
86  * @return the list of available AIs.
87  */
88  static std::vector<description*> get_available_ais();
89 
90 
91  /**
92  * get side config from file
93  * @param file the file name to open. follows usual WML convention.
94  * @param[out] cfg the config to be written from file.
95  * @return was all ok?
96  * @retval true success
97  * @retval false failure
98  */
99  static bool get_side_config_from_file( const std::string& file, config& cfg );
100 
101 
102  /**
103  * @param[in] cfg the config to be read
104  * @param[out] parsed_cfg parsed config
105  * @return was all ok?
106  * @retval true success
107  * @retval false failure
108  */
109  static bool parse_side_config(side_number side, const config& cfg, config &parsed_cfg);
110 
111 
112  /**
113  * Expand simplified aspects, similar to the change from 1.7.2 to 1.7.3
114  * but with some additional syntax options.
115  */
116  static void expand_simplified_aspects(side_number side, config &cfg);
117 private:
118 
119  typedef std::map<std::string, description> description_map;
120  static description_map ai_configurations_;
121  static description_map era_ai_configurations_;
122  static description_map mod_ai_configurations_;
124 
125 };
126 
127 } //end of namespace ai
128 #endif
AI parameters.
static config default_config_
static void add_mod_ai_from_config(config::const_child_itors configs)
static bool parse_side_config(side_number side, const config &cfg, config &parsed_cfg)
Definitions for the interface to Wesnoth Markup Language (WML).
std::pair< const_child_iterator, const_child_iterator > const_child_itors
Definition: config.hpp:214
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:57
GLuint id
Definition: glew.h:1647
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 ...
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:38
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:44
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:83
static const config & get_ai_config_for(const std::string &id)
Return the config for a specified ai.
GLsizei const GLcharARB ** string
Definition: glew.h:4503