The Battle for Wesnoth  1.19.0-dev
game_classification.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "campaign_type.hpp"
19 
20 #include <vector>
21 #include <set>
22 
23 class config;
24 
25 /** The default difficulty setting for campaigns. */
26 extern const std::string DEFAULT_DIFFICULTY;
27 
28 //meta information of the game
30 {
31 public:
32  game_classification() = default;
33  explicit game_classification(const config& cfg);
34 
35  std::string label; /**< Name of the game (e.g. name of save file). */
36  std::string version; /**< Version game was created with. */
38  std::string campaign_define; /**< If there is a define the campaign uses to customize data */
39  std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
40  std::string scenario_define; /**< If there is a define the scenario uses to customize data */
41  std::string era_define; /**< If there is a define the era uses to customize data */
42  std::vector<std::string> mod_defines; /**< If there are defines the modifications use to customize data */
43 
44  std::vector<std::string> active_mods;
45  std::string era_id;
46 
47  std::string campaign; /**< The id of the campaign being played */
48  std::string campaign_name; /**< The name of the campaign being played. */
49 
50  std::string abbrev; /**< the campaign abbreviation */
51  bool end_credits = true; /**< whether to show the standard credits at the end */
52  std::string end_text; /**< end-of-campaign text */
53  unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
54  std::string difficulty = DEFAULT_DIFFICULTY; /**< The difficulty level the game is being played on. */
55  std::string random_mode = "";
56  bool oos_debug = false;
57 
58  config to_config() const;
59  std::string get_tagname() const;
60  std::set<std::string> active_addons(const std::string& scenario_id) const;
61 
62  bool is_normal_mp_game() const
63  {
64  return is_multiplayer() && campaign.empty();
65  }
66 
67  bool is_scenario() const
68  {
69  return type == campaign_type::type::scenario;
70  }
71 
72  bool is_multiplayer() const
73  {
74  return type == campaign_type::type::multiplayer;
75  }
76 
77  bool is_test() const
78  {
79  return type == campaign_type::type::test;
80  }
81 
82  bool is_tutorial() const
83  {
84  return type == campaign_type::type::tutorial;
85  }
86 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
std::string version
Version game was created with.
std::vector< std::string > campaign_xtra_defines
more customization of data
std::vector< std::string > mod_defines
If there are defines the modifications use to customize data.
std::set< std::string > active_addons(const std::string &scenario_id) const
std::string scenario_define
If there is a define the scenario uses to customize data.
std::string difficulty
The difficulty level the game is being played on.
std::string era_define
If there is a define the era uses to customize data.
game_classification()=default
std::vector< std::string > active_mods
campaign_type::type type
bool end_credits
whether to show the standard credits at the end
std::string label
Name of the game (e.g.
unsigned int end_text_duration
for how long the end-of-campaign text is shown
std::string campaign_define
If there is a define the campaign uses to customize data.
std::string get_tagname() const
std::string campaign
The id of the campaign being played.
std::string abbrev
the campaign abbreviation
std::string end_text
end-of-campaign text
std::string campaign_name
The name of the campaign being played.
const std::string DEFAULT_DIFFICULTY
The default difficulty setting for campaigns.