/* * 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: std::vector bonusByLevel; // bonuses provided by none, basic, advanced and expert level public: CSkill(SecondarySkill id = SecondarySkill::DEFAULT); ~CSkill(); void addNewBonus(const std::shared_ptr& b, int level); BonusList getBonus(int level); SecondarySkill id; std::string identifier; template void serialize(Handler &h, const int version) { h & id & identifier; h & bonusByLevel; } friend class CSkillHandler; friend std::ostream & operator<<(std::ostream &out, const CSkill &skill); }; class DLL_LINKAGE CSkillHandler: public CHandlerBase { public: CSkillHandler(); virtual ~CSkillHandler(); ///IHandler base std::vector loadLegacyData(size_t dataSize) override; void afterLoadFinalization() override; void beforeValidate(JsonNode & object) override; std::vector getDefaultAllowed() const override; const std::string getTypeName() const override; template void serialize(Handler &h, const int version) { h & objects ; } protected: CSkill * loadFromJson(const JsonNode & json, const std::string & identifier) override; const std::shared_ptr defaultBonus(SecondarySkill skill, int level) const; };