Limiter.h 2.4 KB

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