CArtHandler.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. DischargeArtifactCondition stringToDischargeCond(const std::string & cond) const;
  23. bool legalArtifact(const ArtifactID & id) const;
  24. static void makeItCreatureArt(CArtifact * a, bool onlyCreature = true);
  25. static void makeItCommanderArt(CArtifact * a, bool onlyCommander = true);
  26. ~CArtHandler();
  27. std::vector<JsonNode> loadLegacyData() override;
  28. void loadObject(std::string scope, std::string name, const JsonNode & data) override;
  29. void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
  30. void afterLoadFinalization() override;
  31. std::set<ArtifactID> getDefaultAllowed() const;
  32. protected:
  33. const std::vector<std::string> & getTypeNames() const override;
  34. std::shared_ptr<CArtifact> loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override;
  35. private:
  36. void addSlot(CArtifact * art, const std::string & slotID) const;
  37. void loadSlots(CArtifact * art, const JsonNode & node) const;
  38. void loadClass(CArtifact * art, const JsonNode & node) const;
  39. void loadType(CArtifact * art, const JsonNode & node) const;
  40. void loadComponents(CArtifact * art, const JsonNode & node);
  41. };
  42. VCMI_LIB_NAMESPACE_END