Info.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Info.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 "../json/JsonNode.h"
  12. #include "../mapObjectConstructors/IObjectInfo.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace vstd
  15. {
  16. class RNG;
  17. }
  18. class MetaString;
  19. class IGameCallback;
  20. namespace Rewardable
  21. {
  22. struct Limiter;
  23. using LimitersList = std::vector<std::shared_ptr<Rewardable::Limiter>>;
  24. struct Reward;
  25. struct Configuration;
  26. struct Variables;
  27. struct VisitInfo;
  28. struct ResetInfo;
  29. enum class EEventType : uint8_t;
  30. class DLL_LINKAGE Info : public IObjectInfo
  31. {
  32. JsonNode parameters;
  33. std::string objectTextID;
  34. void replaceTextPlaceholders(MetaString & target, const Variables & variables) const;
  35. void replaceTextPlaceholders(MetaString & target, const Variables & variables, const VisitInfo & info) const;
  36. void configureVariables(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, const JsonNode & source) const;
  37. void configureRewards(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, const JsonNode & source, Rewardable::EEventType mode, const std::string & textPrefix) const;
  38. void configureLimiter(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, Rewardable::Limiter & limiter, const JsonNode & source) const;
  39. Rewardable::LimitersList configureSublimiters(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, const JsonNode & source) const;
  40. void configureReward(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb, Rewardable::Reward & info, const JsonNode & source) const;
  41. void configureResetInfo(Rewardable::Configuration & object, vstd::RNG & rng, Rewardable::ResetInfo & info, const JsonNode & source) const;
  42. public:
  43. const JsonNode & getParameters() const;
  44. bool givesResources() const override;
  45. bool givesExperience() const override;
  46. bool givesMana() const override;
  47. bool givesMovement() const override;
  48. bool givesPrimarySkills() const override;
  49. bool givesSecondarySkills() const override;
  50. bool givesArtifacts() const override;
  51. bool givesCreatures() const override;
  52. bool givesSpells() const override;
  53. bool givesBonuses() const override;
  54. bool hasGuards() const override;
  55. void configureObject(Rewardable::Configuration & object, vstd::RNG & rng, IGameCallback * cb) const;
  56. void init(const JsonNode & objectConfig, const std::string & objectTextID);
  57. template <typename Handler> void serialize(Handler &h)
  58. {
  59. h & parameters;
  60. }
  61. };
  62. }
  63. VCMI_LIB_NAMESPACE_END