The Battle for Wesnoth  1.19.5+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 <chrono>
21 #include <vector>
22 #include <set>
23 
24 class config;
25 
26 /** The default difficulty setting for campaigns. */
27 extern const std::string DEFAULT_DIFFICULTY;
28 
29 //meta information of the game
31 {
32 public:
33  game_classification() = default;
34  explicit game_classification(const config& cfg);
35 
36  std::string label; /**< Name of the game (e.g. name of save file). */
37  std::string version; /**< Version game was created with. */
39  std::string campaign_define; /**< If there is a define the campaign uses to customize data */
40  std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
41  std::string scenario_define; /**< If there is a define the scenario uses to customize data */
42  std::string era_define; /**< If there is a define the era uses to customize data */
43  std::vector<std::string> mod_defines; /**< If there are defines the modifications use to customize data */
44 
45  std::vector<std::string> active_mods;
46  std::string era_id;
47 
48  std::string campaign; /**< The id of the campaign being played */
49  std::string campaign_name; /**< The name of the campaign being played. */
50 
51  std::string abbrev; /**< the campaign abbreviation */
52  bool end_credits = true; /**< whether to show the standard credits at the end */
53  std::string end_text; /**< end-of-campaign text */
54  std::chrono::milliseconds end_text_duration; /**< for how long the end-of-campaign text is shown */
55  std::string difficulty = DEFAULT_DIFFICULTY; /**< The difficulty level the game is being played on. */
56  std::string random_mode = "";
57  bool oos_debug = false;
58 
59  config to_config() const;
60  std::string get_tagname() const;
61  std::set<std::string> active_addons(const std::string& scenario_id) const;
62 
63  bool is_normal_mp_game() const
64  {
65  return is_multiplayer() && campaign.empty();
66  }
67 
68  bool is_scenario() const
69  {
70  return type == campaign_type::type::scenario;
71  }
72 
73  bool is_multiplayer() const
74  {
75  return type == campaign_type::type::multiplayer;
76  }
77 
78  bool is_test() const
79  {
80  return type == campaign_type::type::test;
81  }
82 
83  bool is_tutorial() const
84  {
85  return type == campaign_type::type::tutorial;
86  }
87 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
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.
std::chrono::milliseconds end_text_duration
for how long the end-of-campaign text is shown
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.
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.