Limiter.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Limiter.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 "../GameConstants.h"
  12. #include "../ResourceSet.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class CGHeroInstance;
  15. class CStackBasicDescriptor;
  16. namespace Rewardable {
  17. struct Limiter;
  18. using LimitersList = std::vector<std::shared_ptr<Rewardable::Limiter>>;
  19. /// Limiters of rewards. Rewards will be granted to hero only if he satisfies requirements
  20. /// Note: for this is only a test - it won't remove anything from hero (e.g. artifacts or creatures)
  21. /// NOTE: in future should (partially) replace seer hut/quest guard quests checks
  22. struct DLL_LINKAGE Limiter
  23. {
  24. /// day of week, unused if 0, 1-7 will test for current day of week
  25. si32 dayOfWeek;
  26. si32 daysPassed;
  27. /// total experience that hero needs to have
  28. si32 heroExperience;
  29. /// level that hero needs to have
  30. si32 heroLevel;
  31. /// mana points that hero needs to have
  32. si32 manaPoints;
  33. /// percentage of mana points that hero needs to have
  34. si32 manaPercentage;
  35. /// resources player needs to have in order to trigger reward
  36. TResources resources;
  37. /// skills hero needs to have
  38. std::vector<si32> primary;
  39. std::map<SecondarySkill, si32> secondary;
  40. /// artifacts that hero needs to have (equipped or in backpack) to trigger this
  41. /// checks for artifacts copies if same artifact id is included multiple times
  42. std::vector<ArtifactID> artifacts;
  43. /// Spells that hero must have in the spellbook
  44. std::vector<SpellID> spells;
  45. /// creatures that hero needs to have
  46. std::vector<CStackBasicDescriptor> creatures;
  47. /// sub-limiters, all must pass for this limiter to pass
  48. LimitersList allOf;
  49. /// sub-limiters, at least one should pass for this limiter to pass
  50. LimitersList anyOf;
  51. /// sub-limiters, none should pass for this limiter to pass
  52. LimitersList noneOf;
  53. Limiter();
  54. ~Limiter();
  55. bool heroAllowed(const CGHeroInstance * hero) const;
  56. template <typename Handler> void serialize(Handler &h, const int version)
  57. {
  58. h & dayOfWeek;
  59. h & daysPassed;
  60. h & heroExperience;
  61. h & heroLevel;
  62. h & manaPoints;
  63. h & manaPercentage;
  64. h & resources;
  65. h & primary;
  66. h & secondary;
  67. h & artifacts;
  68. h & creatures;
  69. h & allOf;
  70. h & anyOf;
  71. h & noneOf;
  72. }
  73. void serializeJson(JsonSerializeFormat & handler);
  74. };
  75. }
  76. VCMI_LIB_NAMESPACE_END