1 /***************************************************************************
2  *   Free Heroes of Might and Magic II: https://github.com/ihhub/fheroes2  *
3  *   Copyright (C) 2021                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 #ifndef H2CAMPAIGN_DATA_H
22 #define H2CAMPAIGN_DATA_H
23 
24 #include "campaign_scenariodata.h"
25 
26 namespace Campaign
27 {
28     class CampaignData
29     {
30     public:
31         CampaignData();
32 
getCampaignID()33         int getCampaignID() const
34         {
35             return _campaignID;
36         }
37 
getAllScenarios()38         const std::vector<ScenarioData> & getAllScenarios() const
39         {
40             return _scenarios;
41         }
42 
43         const std::vector<int> & getScenariosAfter( const int scenarioID ) const;
44         std::vector<int> getStartingScenarios() const;
45 
46         bool isAllCampaignMapsPresent() const;
47         bool isLastScenario( const int scenarioID ) const;
48         bool isStartingScenario( const int scenarioID ) const;
49 
50         void setCampaignID( const int campaignID );
51         void setCampaignDescription( const std::string & campaignDescription );
52         void setCampaignScenarios( const std::vector<ScenarioData> & scenarios );
53 
54         static const CampaignData & getCampaignData( const int campaignID );
55 
56     private:
57         int _campaignID;
58         std::string _campaignDescription;
59         std::vector<ScenarioData> _scenarios;
60     };
61 
62     struct CampaignAwardData
63     {
64     public:
65         enum AwardType : int
66         {
67             TYPE_CREATURE_CURSE, // eg: dwarf bane
68             TYPE_CREATURE_ALLIANCE, // eg: dwarf alliance
69             TYPE_GET_ARTIFACT, // eg: ultimate crown
70             TYPE_GET_SPELL, // eg: guardian spell in wizard's isle
71             TYPE_CARRY_OVER_FORCES, // eg: the gauntlet
72             TYPE_HIREABLE_HERO, // eg: sorceress guild
73             TYPE_DEFEAT_ENEMY_HERO, // eg: corlagon defeated
74             TYPE_RESOURCE_BONUS, // eg: wood bonus in price of loyalty
75         };
76 
77         // NOTE: Carry over forces shouldn't use these other than id, type and startScenarioID
78         // IDs are here so that we just have to store an int instead of the entire award data in a campaign save data
79         // also usable when we have to remove specific awards when completing a mission (PoL campaign)
80         int _id;
81         uint32_t _type;
82         uint32_t _subType;
83         uint32_t _amount;
84         uint32_t _startScenarioID;
85         std::string _customName;
86 
87         CampaignAwardData( int id, uint32_t type, uint32_t subType );
88         CampaignAwardData( int id, uint32_t type, uint32_t subType, uint32_t amount );
89         CampaignAwardData( int id, uint32_t type, uint32_t subType, const std::string & customName );
90         CampaignAwardData( int id, uint32_t type, uint32_t subType, uint32_t amount, int startScenarioID, const std::string & customName = std::string() );
91 
92         std::string ToString() const;
93 
94         static std::vector<Campaign::CampaignAwardData> getCampaignAwardData( const int campaignID, const int scenarioID );
95         static std::vector<Campaign::CampaignAwardData> getExtraCampaignAwardData( const int campaignID );
96 
97         static const char * getAllianceJoiningMessage( const int monsterId );
98         static const char * getAllianceFleeingMessage( const int monsterId );
99         static const char * getBaneFleeingMessage( const int monsterId );
100     };
101 }
102 
103 #endif
104