Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GAME_STATUS_HPP_INCLUDED
00019 #define GAME_STATUS_HPP_INCLUDED
00020
00021 #include "mp_game_settings.hpp"
00022 #include "random.hpp"
00023 #include "simple_rng.hpp"
00024 #include "map_location.hpp"
00025 #include "variable.hpp"
00026 #include "serialization/binary_or_text.hpp"
00027 #include "boost/shared_ptr.hpp"
00028
00029 class scoped_wml_variable;
00030 class team;
00031 class gamemap;
00032 namespace t_translation {
00033 struct t_match;
00034 }
00035
00036 class team_builder;
00037 typedef boost::shared_ptr<team_builder> team_builder_ptr;
00038
00039
00040 class game_classification : public savegame::savegame_config
00041 {
00042 public:
00043 game_classification();
00044 game_classification(const config& cfg);
00045 game_classification(const game_classification& gc);
00046
00047 config to_config() const;
00048
00049 std::string label;
00050 std::string parent;
00051 std::string version;
00052 std::string campaign_type;
00053 std::string campaign_define;
00054 std::vector<std::string> campaign_xtra_defines;
00055
00056 std::string campaign;
00057 std::string history;
00058 std::string abbrev;
00059 std::string scenario;
00060 std::string next_scenario;
00061 std::string completion;
00062 bool end_credits;
00063 std::string end_text;
00064 unsigned int end_text_duration;
00065 std::string difficulty;
00066 };
00067
00068 struct wml_menu_item
00069 {
00070 wml_menu_item(const std::string& id, const config* cfg=NULL);
00071 std::string name;
00072 const std::string event_id;
00073 std::string image;
00074 t_string description;
00075 bool needs_select;
00076 config show_if;
00077 config filter_location;
00078 config command;
00079 };
00080
00081 class game_state : public variable_set
00082 {
00083 public:
00084 game_state();
00085 game_state(const game_state& state);
00086 game_state(const config& cfg, bool show_replay = false);
00087
00088 ~game_state();
00089 game_state& operator=(const game_state& state);
00090
00091 std::vector<scoped_wml_variable*> scoped_variables;
00092 std::map<std::string, wml_menu_item*> wml_menu_items;
00093
00094 const config& get_variables() const { return variables_; }
00095 void set_variables(const config& vars);
00096
00097 void set_menu_items(const config::const_child_itors &menu_items);
00098
00099
00100 void write_snapshot(config& cfg) const;
00101
00102 void write_config(config_writer& out, bool write_variables=true) const;
00103
00104
00105
00106 config::attribute_value &get_variable(const std::string &varname);
00107 virtual config::attribute_value get_variable_const(const std::string& varname) const;
00108 config& get_variable_cfg(const std::string& varname);
00109
00110 void set_variable(const std::string& varname, const t_string& value);
00111 config& add_variable_cfg(const std::string& varname, const config& value=config());
00112
00113 void clear_variable(const std::string& varname);
00114 void clear_variable_cfg(const std::string& varname);
00115
00116 const rand_rng::simple_rng& rng() const { return rng_; }
00117 rand_rng::simple_rng& rng() { return rng_; }
00118
00119 enum PHASE {
00120 INITIAL,
00121 PRELOAD,
00122 PRESTART,
00123 START,
00124 PLAY
00125 };
00126 PHASE phase() const { return phase_; }
00127 void set_phase(PHASE phase) { phase_ = phase; }
00128
00129
00130 team_builder_ptr create_team_builder(const config& side_cfg, std::string save_id
00131 , std::vector<team>& teams, const config& level, gamemap& map
00132 , unit_map& units, bool snapshot);
00133
00134
00135 void build_team_stage_one(team_builder_ptr tb_ptr);
00136
00137
00138 void build_team_stage_two(team_builder_ptr tb_ptr);
00139
00140 game_classification& classification() { return classification_; }
00141 const game_classification& classification() const { return classification_; }
00142
00143
00144 mp_game_settings& mp_settings() { return mp_settings_; }
00145 const mp_game_settings& mp_settings() const { return mp_settings_; }
00146
00147 bool allow_end_turn() const { return can_end_turn_; }
00148 void set_allow_end_turn(bool value) { can_end_turn_ = value; }
00149
00150
00151
00152
00153
00154 config replay_data;
00155
00156
00157
00158
00159
00160
00161
00162 config starting_pos;
00163
00164
00165
00166
00167
00168
00169
00170 config snapshot;
00171
00172
00173 map_location last_selected;
00174
00175 private:
00176 rand_rng::simple_rng rng_;
00177 config variables_;
00178 mutable config temporaries_;
00179 const rand_rng::set_random_generator generator_setter_;
00180 friend struct variable_info;
00181 game_classification classification_;
00182 mp_game_settings mp_settings_;
00183 PHASE phase_;
00184 bool can_end_turn_;
00185 };
00186
00187
00188 void write_players(game_state& gamestate, config& cfg, const bool use_snapshot=true, const bool merge_side = false);
00189
00190 void extract_summary_from_config(config& cfg_save, config& cfg_summary);
00191
00192 #endif