ApplyDamage.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * ApplyDamage.cpp, 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. #include "StdInc.h"
  11. #include <vcmi/Environment.h>
  12. #include "ApplyDamage.h"
  13. #include "../networkPacks/PacksForClientBattle.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. namespace events
  16. {
  17. SubscriptionRegistry<ApplyDamage> * ApplyDamage::getRegistry()
  18. {
  19. static std::unique_ptr<SubscriptionRegistry<ApplyDamage>> Instance = std::make_unique<SubscriptionRegistry<ApplyDamage>>();
  20. return Instance.get();
  21. }
  22. CApplyDamage::CApplyDamage(const Environment * env_, BattleStackAttacked * pack_, std::shared_ptr<battle::Unit> target_)
  23. : pack(pack_),
  24. target(std::move(target_))
  25. {
  26. initalDamage = pack->damageAmount;
  27. }
  28. bool CApplyDamage::isEnabled() const
  29. {
  30. return true;
  31. }
  32. int64_t CApplyDamage::getInitalDamage() const
  33. {
  34. return initalDamage;
  35. }
  36. int64_t CApplyDamage::getDamage() const
  37. {
  38. return pack->damageAmount;
  39. }
  40. void CApplyDamage::setDamage(int64_t value)
  41. {
  42. pack->damageAmount = value;
  43. }
  44. const battle::Unit * CApplyDamage::getTarget() const
  45. {
  46. return target.get();
  47. }
  48. };
  49. VCMI_LIB_NAMESPACE_END