Heal.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Heal.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 "UnitEffect.h"
  12. #include "../../GameConstants.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. struct BattleLogMessage;
  15. struct BattleUnitsChanged;
  16. namespace spells
  17. {
  18. namespace effects
  19. {
  20. class Heal : public UnitEffect
  21. {
  22. public:
  23. void apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const override;
  24. SpellEffectValue getHealthChange(const Mechanics * m, const EffectTarget & spellTarget) const override;
  25. protected:
  26. void apply(int64_t value, ServerCallback * server, const Mechanics * m, const EffectTarget & target) const;
  27. bool isValidTarget(const Mechanics * m, const battle::Unit * unit) const override;
  28. void serializeJsonUnitEffect(JsonSerializeFormat & handler) override final;
  29. private:
  30. EHealLevel healLevel = EHealLevel::HEAL;
  31. EHealPower healPower = EHealPower::PERMANENT;
  32. int32_t minFullUnits = 0;
  33. SpellEffectValue getHealEffectValue(int64_t value, const Mechanics * m, const battle::Unit * unit, std::shared_ptr<battle::Unit> newState = nullptr) const;
  34. void prepareHealEffect(int64_t value, BattleUnitsChanged & pack, BattleLogMessage & logMessage, RNG & rng, const Mechanics * m, const EffectTarget & target) const;
  35. };
  36. }
  37. }
  38. VCMI_LIB_NAMESPACE_END