ApplyDamage.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. : env(env_),
  23. pack(pack_),
  24. target(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. };