1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-04 09:42:40 +02:00
vcmi/lib/CBonusTypeHandler.h

78 lines
1.8 KiB
C
Raw Normal View History

/*
* CBonusTypeHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "IBonusTypeHandler.h"
#include "IHandlerBase.h"
#include "HeroBonus.h"
VCMI_LIB_NAMESPACE_BEGIN
class JsonNode;
typedef Bonus::BonusType BonusTypeID;
class DLL_LINKAGE CBonusType
{
public:
CBonusType();
2023-01-17 12:42:43 +02:00
std::string getNameTextID() const;
std::string getDescriptionTextID() const;
2017-08-08 16:53:01 +02:00
template <typename Handler> void serialize(Handler & h, const int version)
{
h & icon;
2023-01-17 12:42:43 +02:00
h & identifier;
h & hidden;
}
private:
friend class CBonusTypeHandler;
2023-01-17 12:42:43 +02:00
std::string icon;
2023-01-17 12:42:43 +02:00
std::string identifier;
bool hidden;
};
class DLL_LINKAGE CBonusTypeHandler : public IBonusTypeHandler
{
public:
CBonusTypeHandler();
virtual ~CBonusTypeHandler();
2017-08-08 16:53:01 +02:00
std::string bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer, bool description) const override;
std::string bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const override;
2017-08-08 16:53:01 +02:00
template <typename Handler> void serialize(Handler & h, const int version)
{
2017-08-08 16:53:01 +02:00
//for now always use up to date configuration
//once modded bonus type will be implemented, serialize only them
std::vector<CBonusType> ignore;
h & ignore;
}
private:
2017-08-08 16:53:01 +02:00
void load();
void load(const JsonNode & config);
2023-03-13 23:26:44 +02:00
void loadItem(const JsonNode & source, CBonusType & dest, const std::string & name) const;
std::vector<CBonusType> bonusTypes; //index = BonusTypeID
};
2017-08-08 16:53:01 +02:00
VCMI_LIB_NAMESPACE_END
2017-08-08 16:53:01 +02:00
#ifndef INSTANTIATE_CBonusTypeHandler_HERE
extern template class std::vector<VCMI_LIB_WRAP_NAMESPACE(CBonusType)>;
2017-08-08 16:53:01 +02:00
#endif