CArtHandler.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * CArtHandler.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CArtifact.h"
  12. #include "EArtifactClass.h"
  13. #include "IHandlerBase.h"
  14. #include <vcmi/Artifact.h>
  15. #include <vcmi/ArtifactService.h>
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class DLL_LINKAGE CArtHandler : public CHandlerBase<ArtifactID, Artifact, CArtifact, ArtifactService>
  18. {
  19. public:
  20. void addBonuses(CArtifact * art, const JsonNode & bonusList);
  21. static EArtifactClass stringToClass(const std::string & className); //TODO: rework EartClass to make this a constructor
  22. bool legalArtifact(const ArtifactID & id) const;
  23. static void makeItCreatureArt(CArtifact * a, bool onlyCreature = true);
  24. static void makeItCommanderArt(CArtifact * a, bool onlyCommander = true);
  25. ~CArtHandler();
  26. std::vector<JsonNode> loadLegacyData() override;
  27. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  28. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  29. void afterLoadFinalization() override;
  30. std::set<ArtifactID> getDefaultAllowed() const;
  31. protected:
  32. const std::vector<std::string> & getTypeNames() const override;
  33. std::shared_ptr<CArtifact> loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
  34. private:
  35. void addSlot(CArtifact * art, const std::string & slotID) const;
  36. void loadSlots(CArtifact * art, const JsonNode & node) const;
  37. void loadClass(CArtifact * art, const JsonNode & node) const;
  38. void loadType(CArtifact * art, const JsonNode & node) const;
  39. void loadComponents(CArtifact * art, const JsonNode & node);
  40. };
  41. VCMI_LIB_NAMESPACE_END