TownFortifications.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * TownFortifications.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 "../../constants/EntityIdentifiers.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. struct TownFortifications
  14. {
  15. CreatureID citadelShooter;
  16. CreatureID upperTowerShooter;
  17. CreatureID lowerTowerShooter;
  18. SpellID moatSpell;
  19. int8_t wallsHealth = 0;
  20. int8_t citadelHealth = 0;
  21. int8_t upperTowerHealth = 0;
  22. int8_t lowerTowerHealth = 0;
  23. bool hasMoat = false;
  24. const TownFortifications & operator +=(const TownFortifications & other)
  25. {
  26. if (other.citadelShooter.hasValue())
  27. citadelShooter = other.citadelShooter;
  28. if (other.upperTowerShooter.hasValue())
  29. upperTowerShooter = other.upperTowerShooter;
  30. if (other.lowerTowerShooter.hasValue())
  31. lowerTowerShooter = other.lowerTowerShooter;
  32. if (other.moatSpell.hasValue())
  33. moatSpell = other.moatSpell;
  34. wallsHealth = std::max(wallsHealth, other.wallsHealth);
  35. citadelHealth = std::max(citadelHealth, other.citadelHealth);
  36. upperTowerHealth = std::max(upperTowerHealth, other.upperTowerHealth);
  37. lowerTowerHealth = std::max(lowerTowerHealth, other.lowerTowerHealth);
  38. hasMoat = hasMoat || other.hasMoat;
  39. return *this;
  40. }
  41. };
  42. VCMI_LIB_NAMESPACE_END