Emergency 20 Dokumentation  4.2.0
CampaignDefinition.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/game/player/Player.h"
14 #include "em5/map/MapIdentifier.h"
15 
16 #include <boost/property_tree/ptree.hpp>
17 
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  class MainEventIdentifier;
26 }
27 
28 
29 //[-------------------------------------------------------]
30 //[ Namespace ]
31 //[-------------------------------------------------------]
32 namespace em5
33 {
34 
35 
36  //[-------------------------------------------------------]
37  //[ Classes ]
38  //[-------------------------------------------------------]
43  class CampaignDefinition : public boost::noncopyable
44  {
45 
46 
47  //[-------------------------------------------------------]
48  //[ Public definitions ]
49  //[-------------------------------------------------------]
50  public:
51  enum PhaseType
52  {
57  };
58 
60  {
62  std::string mEventName;
63  std::string mEventPools;
64  std::string mUnitPool;
65  std::string mMainEventId;
66  std::string mRewardId;
67  std::vector<Player::BuyOption> mBuyOptions;
68  };
69  typedef std::vector<CampaignPhase> CampaignPhaseArray;
70 
71  struct CampaignMap
72  {
74  CampaignPhaseArray mPhases;
75  };
76 
77 
78  //[-------------------------------------------------------]
79  //[ Public methods ]
80  //[-------------------------------------------------------]
81  public:
87 
93 
98  void loadCampaignDefinition(const std::string& filename);
99 
104  const std::string& getName() const;
105 
110  const std::string& getShortName() const;
111 
116  const qsf::Color4& getColor() const;
117 
123 
134  const CampaignMap* getCampaignMapByIndex(uint32 campaignMapIndex) const;
135  const CampaignMap* getCampaignMapByIdentifier(const MapIdentifier& mapIdentifier) const;
136 
148 
153  bool getCampaignPhaseIndexForMainEvent(uint32& outCampaignPhase, uint32& outCampaignMapIndex, const MainEventIdentifier& mainEventIdentifier) const;
154 
159  void getAllCampaignPhasesOfType(PhaseType phaseType, std::vector<const CampaignPhase*>& outCampaignPhases) const;
160 
161 
162  //[-------------------------------------------------------]
163  //[ Private methods ]
164  //[-------------------------------------------------------]
165  private:
166  void loadCampaignDefinitionFromBoostPTree(const boost::property_tree::ptree& campaignPTree);
167  bool checkFormatHeader(const boost::property_tree::ptree& rootPTree);
168 
169 
170  //[-------------------------------------------------------]
171  //[ Private data ]
172  //[-------------------------------------------------------]
173  private:
174  std::string mName; // Campaign name ("EMERGENCY 5 Original Campaign", "EMERGENCY 2016 Campaign")
175  std::string mShortName; // Campaign short name ("EM5, EM2016" etc.)
176  qsf::Color4 mColor; // Campaign color
177  boost::property_tree::ptree mSettings; // Campaign-specific settings
178  std::vector<CampaignMap> mCampaignMaps;
179 
180 
181  };
182 
183 
184 //[-------------------------------------------------------]
185 //[ Namespace ]
186 //[-------------------------------------------------------]
187 } // em5
Definition: ActionPriority.h:13
std::vector< Player::BuyOption > mBuyOptions
Only for "freeplay" phase type: Buy options listing.
Definition: CampaignDefinition.h:67
const std::string & getShortName() const
Return the campaign short-name.
Definition: CampaignDefinition.h:59
~CampaignDefinition()
Destructor.
Main event phase: A single event must be won to continue, counts as main event.
Definition: CampaignDefinition.h:54
Tutorial event phase: A single event must be won to continue, but can be skipped (special handling fo...
Definition: CampaignDefinition.h:53
Color class with red, green, blue and alpha component.
Definition: Color4.h:39
unsigned int uint32
Definition: PlatformTypes.h:181
EMERGENCY 5 campaign definition class.
Definition: CampaignDefinition.h:43
PhaseType mPhaseType
Type of this campaign phase.
Definition: CampaignDefinition.h:61
const CampaignMap * getCampaignMapByIndex(uint32 campaignMapIndex) const
Return the campaign map structure for a given map index.
CampaignPhaseArray mPhases
Definition: CampaignDefinition.h:74
void getAllCampaignPhasesOfType(PhaseType phaseType, std::vector< const CampaignPhase * > &outCampaignPhases) const
Return list of all campaign phases of the given type.
EMERGENCY 5 main event identifier class.
Definition: MainEventIdentifier.h:30
const qsf::Color4 & getColor() const
Return the campaign color.
void loadCampaignDefinition(const std::string &filename)
Load the campaign definition from a JSON file.
std::vector< CampaignPhase > CampaignPhaseArray
Definition: CampaignDefinition.h:69
std::string mEventPools
Event pools to trigger events from, separated by semicolons.
Definition: CampaignDefinition.h:63
std::string mEventName
Name of the event to start, in case a single one should be triggered (for main events, tutorial)
Definition: CampaignDefinition.h:62
CampaignDefinition()
Default constructor.
std::string mRewardId
The id of the reward the player gets after wining the event.
Definition: CampaignDefinition.h:66
PhaseType
Definition: CampaignDefinition.h:51
EMERGENCY 5 map identifier class.
Definition: MapIdentifier.h:34
Definition: DensityCalculator.h:29
const boost::property_tree::ptree & getSettings() const
Return the settings property tree.
std::string mUnitPool
Unit pool to set at phase start.
Definition: CampaignDefinition.h:64
const CampaignMap * getCampaignMapByIdentifier(const MapIdentifier &mapIdentifier) const
Definition: CampaignDefinition.h:71
MapIdentifier mMapIdentifier
Definition: CampaignDefinition.h:73
Campaign freeplay phase: Player earns money until all buy options are bought.
Definition: CampaignDefinition.h:56
MapIdentifier getMapIdentifierByCampaignMapIndex(uint32 campaignMapIndex) const
Return the map identifier for a given campaign map index.
const std::string & getName() const
Return the campaign name.
Single event phase: A single event must be won to continue, does not count as main event...
Definition: CampaignDefinition.h:55
std::string mMainEventId
Only for "main event" phase type: Unique identifier of the main event.
Definition: CampaignDefinition.h:65
bool getCampaignPhaseIndexForMainEvent(uint32 &outCampaignPhase, uint32 &outCampaignMapIndex, const MainEventIdentifier &mainEventIdentifier) const
Return the campaign phases for the given map.