2017-08-20 09:18:07 +02:00
|
|
|
/*
|
|
|
|
* CSkillHandler.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 "../lib/HeroBonus.h"
|
|
|
|
#include "GameConstants.h"
|
|
|
|
#include "IHandlerBase.h"
|
|
|
|
|
|
|
|
class CSkillHandler;
|
|
|
|
class CGHeroInstance;
|
|
|
|
class CMap;
|
|
|
|
class JsonSerializeFormat;
|
|
|
|
|
|
|
|
class DLL_LINKAGE CSkill // secondary skill
|
|
|
|
{
|
|
|
|
protected:
|
2017-08-21 10:49:51 +02:00
|
|
|
std::vector<BonusList> bonusByLevel; // bonuses provided by none, basic, advanced and expert level
|
2017-08-20 09:18:07 +02:00
|
|
|
|
|
|
|
public:
|
2017-08-22 14:40:15 +02:00
|
|
|
CSkill(SecondarySkill id = SecondarySkill::DEFAULT);
|
2017-08-20 09:18:07 +02:00
|
|
|
~CSkill();
|
|
|
|
|
|
|
|
void addNewBonus(const std::shared_ptr<Bonus>& b, int level);
|
2017-08-21 10:49:51 +02:00
|
|
|
BonusList getBonus(int level);
|
2017-08-20 09:18:07 +02:00
|
|
|
|
|
|
|
SecondarySkill id;
|
|
|
|
std::string identifier;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & id & identifier;
|
|
|
|
h & bonusByLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend class CSkillHandler;
|
2017-08-23 00:19:30 +02:00
|
|
|
friend std::ostream & operator<<(std::ostream &out, const CSkill &skill);
|
2017-08-20 09:18:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CSkillHandler: public CHandlerBase<SecondarySkill, CSkill>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CSkillHandler();
|
|
|
|
virtual ~CSkillHandler();
|
|
|
|
|
|
|
|
///IHandler base
|
|
|
|
std::vector<JsonNode> loadLegacyData(size_t dataSize) override;
|
|
|
|
void afterLoadFinalization() override;
|
|
|
|
void beforeValidate(JsonNode & object) override;
|
|
|
|
|
|
|
|
std::vector<bool> getDefaultAllowed() const override;
|
|
|
|
const std::string getTypeName() const override;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & objects ;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CSkill * loadFromJson(const JsonNode & json, const std::string & identifier) override;
|
2017-08-21 14:35:46 +02:00
|
|
|
const std::shared_ptr<Bonus> defaultBonus(SecondarySkill skill, int level) const;
|
2017-08-20 09:18:07 +02:00
|
|
|
};
|