ApplyDamage.cpp 1.1 KB

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