Reward.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Reward.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 "../ResourceSet.h"
  12. #include "../bonuses/Bonus.h"
  13. #include "../CCreatureSet.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. struct Bonus;
  16. struct Component;
  17. class CStackBasicDescriptor;
  18. class CGHeroInstance;
  19. namespace Rewardable
  20. {
  21. struct Reward;
  22. using RewardsList = std::vector<std::shared_ptr<Rewardable::Reward>>;
  23. /// Reward that can be granted to a hero
  24. /// NOTE: eventually should replace seer hut rewards and events/pandoras
  25. struct DLL_LINKAGE Reward
  26. {
  27. /// resources that will be given to player
  28. TResources resources;
  29. /// received experience
  30. si32 heroExperience;
  31. /// received levels (converted into XP during grant)
  32. si32 heroLevel;
  33. /// mana given to/taken from hero, fixed value
  34. si32 manaDiff;
  35. /// if giving mana points puts hero above mana pool, any overflow will be multiplied by specified percentage
  36. si32 manaOverflowFactor;
  37. /// fixed value, in form of percentage from max
  38. si32 manaPercentage;
  39. /// movement points, only for current day. Bonuses should be used to grant MP on any other day
  40. si32 movePoints;
  41. /// fixed value, in form of percentage from max
  42. si32 movePercentage;
  43. /// list of bonuses, e.g. morale/luck
  44. std::vector<Bonus> bonuses;
  45. /// skills that hero may receive or lose
  46. std::vector<si32> primary;
  47. std::map<SecondarySkill, si32> secondary;
  48. /// creatures that will be changed in hero's army
  49. std::map<CreatureID, CreatureID> creaturesChange;
  50. /// objects that hero may receive
  51. std::vector<ArtifactID> artifacts;
  52. std::vector<SpellID> spells;
  53. std::vector<CStackBasicDescriptor> creatures;
  54. /// actions that hero may execute and object caster. Pair of spellID and school level
  55. std::pair<SpellID, int> spellCast;
  56. /// list of components that will be added to reward description. First entry in list will override displayed component
  57. std::vector<Component> extraComponents;
  58. /// if set to true, object will be removed after granting reward
  59. bool removeObject;
  60. /// Generates list of components that describes reward for a specific hero
  61. virtual void loadComponents(std::vector<Component> & comps,
  62. const CGHeroInstance * h) const;
  63. Component getDisplayedComponent(const CGHeroInstance * h) const;
  64. si32 calculateManaPoints(const CGHeroInstance * h) const;
  65. Reward();
  66. ~Reward();
  67. template <typename Handler> void serialize(Handler &h, const int version)
  68. {
  69. h & resources;
  70. h & extraComponents;
  71. h & removeObject;
  72. h & manaPercentage;
  73. h & movePercentage;
  74. h & heroExperience;
  75. h & heroLevel;
  76. h & manaDiff;
  77. h & manaOverflowFactor;
  78. h & movePoints;
  79. h & primary;
  80. h & secondary;
  81. h & bonuses;
  82. h & artifacts;
  83. h & spells;
  84. h & creatures;
  85. h & creaturesChange;
  86. if(version >= 821)
  87. h & spellCast;
  88. }
  89. void serializeJson(JsonSerializeFormat & handler);
  90. };
  91. }
  92. VCMI_LIB_NAMESPACE_END