The Battle for Wesnoth  1.17.0-dev
game_classification.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
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 "utils/make_enum.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. */
37  MAKE_ENUM (CAMPAIGN_TYPE, /**< Type of the game - campaign, multiplayer etc. */
38  (SCENARIO, "scenario")
39  (MULTIPLAYER, "multiplayer")
40  (TEST, "test")
41  (TUTORIAL, "tutorial")
42  )
43  CAMPAIGN_TYPE campaign_type;
44  std::string campaign_define; /**< If there is a define the campaign uses to customize data */
45  std::vector<std::string> campaign_xtra_defines; /**< more customization of data */
46  std::string scenario_define; /**< If there is a define the scenario uses to customize data */
47  std::string era_define; /**< If there is a define the era uses to customize data */
48  std::vector<std::string> mod_defines; /**< If there are defines the modifications use to customize data */
49 
50  std::vector<std::string> active_mods;
51  std::string era_id;
52 
53  std::string campaign; /**< The id of the campaign being played */
54  std::string campaign_name; /**< The name of the campaign being played. */
55 
56  std::string abbrev; /**< the campaign abbreviation */
57  bool end_credits = true; /**< whether to show the standard credits at the end */
58  std::string end_text; /**< end-of-campaign text */
59  unsigned int end_text_duration; /**< for how long the end-of-campaign text is shown */
60  std::string difficulty = DEFAULT_DIFFICULTY; /**< The difficulty level the game is being played on. */
61  std::string random_mode = "";
62  bool oos_debug = false;
63 
64  config to_config() const;
65  std::string get_tagname() const;
66  std::set<std::string> active_addons(const std::string& scenario_id) const;
67 
68  bool is_normal_mp_game() const
69  {
70  return is_multiplayer() && campaign.empty();
71  }
72 
73  bool is_scenario() const
74  {
75  return campaign_type == CAMPAIGN_TYPE::SCENARIO;
76  }
77 
78  bool is_multiplayer() const
79  {
80  return campaign_type == CAMPAIGN_TYPE::MULTIPLAYER;
81  }
82 
83  bool is_test() const
84  {
85  return campaign_type == CAMPAIGN_TYPE::TEST;
86  }
87 
88  bool is_tutorial() const
89  {
90  return campaign_type == CAMPAIGN_TYPE::TUTORIAL;
91  }
92 };
unsigned int end_text_duration
for how long the end-of-campaign text is shown
bool end_credits
whether to show the standard credits at the end
void set(CURSOR_TYPE type)
Use the default parameter to reset cursors.
Definition: cursor.cpp:176
std::string label
Name of the game (e.g.
std::string campaign_name
The name of the campaign being played.
const std::string DEFAULT_DIFFICULTY
The default difficulty setting for campaigns.
STL namespace.
std::set< std::string > active_addons(const std::string &scenario_id) const
std::vector< std::string > active_mods
std::string campaign_define
If there is a define the campaign uses to customize data.
std::string end_text
end-of-campaign text
std::string campaign
The id of the campaign being played.
std::string era_define
If there is a define the era uses to customize data.
std::string abbrev
the campaign abbreviation
std::vector< std::string > campaign_xtra_defines
more customization of data
std::string scenario_define
If there is a define the scenario uses to customize data.
std::vector< std::string > mod_defines
If there are defines the modifications use to customize data.
game_classification()=default
std::string difficulty
The difficulty level the game is being played on.
MAKE_ENUM(CAMPAIGN_TYPE,(SCENARIO, "scenario")(MULTIPLAYER, "multiplayer")(TEST, "test")(TUTORIAL, "tutorial")) CAMPAIGN_TYPE campaign_type
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
Defines the MAKE_ENUM macro.
std::string get_tagname() const
std::string version
Version game was created with.