Catapult.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Catapult.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 "LocationEffect.h"
  12. #include "../../GameConstants.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace spells
  15. {
  16. namespace effects
  17. {
  18. class Catapult : public LocationEffect
  19. {
  20. public:
  21. bool applicable(Problem & problem, const Mechanics * m) const override;
  22. void apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const override;
  23. protected:
  24. void serializeJsonEffect(JsonSerializeFormat & handler) override;
  25. private:
  26. int targetsToAttack = 0;
  27. //Ballistics percentage
  28. int gate = 0;
  29. int keep = 0;
  30. int tower = 0;
  31. int wall = 0;
  32. //Damage percentage, used for both ballistics and earthquake
  33. int hit = 0;
  34. int crit = 0;
  35. int noDmg = 0;
  36. int getCatapultHitChance(EWallPart part) const;
  37. int getRandomDamage(ServerCallback * server) const;
  38. void adjustHitChance();
  39. void applyMassive(ServerCallback * server, const Mechanics * m) const;
  40. void applyTargeted(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const;
  41. void removeTowerShooters(ServerCallback * server, const Mechanics * m) const;
  42. std::vector<EWallPart> getPotentialTargets(const Mechanics * m, bool bypassGateCheck, bool bypassTowerCheck) const;
  43. };
  44. }
  45. }
  46. VCMI_LIB_NAMESPACE_END