/* * CRmgTemplateStorage.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 "CRmgTemplate.h" #include "CRmgTemplateZone.h" class JsonNode; typedef std::vector JsonVector; /// The CRmgTemplateLoader is a abstract base class for loading templates. class DLL_LINKAGE CRmgTemplateLoader { public: virtual ~CRmgTemplateLoader() { }; virtual void loadTemplates() = 0; const std::map & getTemplates() const; protected: std::map templates; }; /// The CJsonRmgTemplateLoader loads templates from a JSON file. class DLL_LINKAGE CJsonRmgTemplateLoader : public CRmgTemplateLoader { public: void loadTemplates() override; private: CRmgTemplate::CSize parseMapTemplateSize(const std::string & text) const; CRmgTemplateZone::CTownInfo parseTemplateZoneTowns(const JsonNode & node) const; ETemplateZoneType::ETemplateZoneType parseZoneType(const std::string & type) const; std::set parseTownTypes(const JsonVector & townTypesVector, const std::set & defaultTownTypes) const; std::set parseTerrainTypes(const JsonVector & terTypeStrings, const std::set & defaultTerrainTypes) const; CRmgTemplate::CPlayerCountRange parsePlayers(const std::string & players) const; }; /// The class CRmgTemplateStorage stores random map templates. class DLL_LINKAGE CRmgTemplateStorage { public: CRmgTemplateStorage(); ~CRmgTemplateStorage(); const std::map & getTemplates() const; private: std::map templates; /// Key: Template name };