ObstacleCasterProxy.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * ObstacleCasterProxy.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 "ObstacleCasterProxy.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. namespace spells
  14. {
  15. ObstacleCasterProxy::ObstacleCasterProxy(PlayerColor owner_, const Caster * hero_, const SpellCreatedObstacle & obs_):
  16. SilentCaster(owner_, hero_),
  17. obs(obs_)
  18. {
  19. }
  20. int32_t ObstacleCasterProxy::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
  21. {
  22. return obs.spellLevel;
  23. }
  24. int32_t ObstacleCasterProxy::getEffectLevel(const Spell * spell) const
  25. {
  26. return obs.spellLevel;
  27. }
  28. int64_t ObstacleCasterProxy::getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const
  29. {
  30. if(actualCaster)
  31. return std::max<int64_t>(actualCaster->getSpellBonus(spell, base, affectedStack), obs.minimalDamage);
  32. return std::max<int64_t>(base, obs.minimalDamage);
  33. }
  34. int32_t ObstacleCasterProxy::getEffectPower(const Spell * spell) const
  35. {
  36. return obs.casterSpellPower;
  37. }
  38. int32_t ObstacleCasterProxy::getEnchantPower(const Spell * spell) const
  39. {
  40. return obs.casterSpellPower;
  41. }
  42. int64_t ObstacleCasterProxy::getEffectValue(const Spell * spell) const
  43. {
  44. if(actualCaster)
  45. return std::max(static_cast<int64_t>(obs.minimalDamage), actualCaster->getEffectValue(spell));
  46. else
  47. return obs.minimalDamage;
  48. }
  49. int64_t ObstacleCasterProxy::getEffectRange(const Spell * spell) const
  50. {
  51. if(actualCaster)
  52. actualCaster->getEffectRange(spell);
  53. return 0;
  54. }
  55. int32_t SilentCaster::manaLimit() const
  56. {
  57. return 0;
  58. }
  59. SilentCaster::SilentCaster(PlayerColor owner_, const Caster * hero_):
  60. ProxyCaster(hero_),
  61. owner(std::move(owner_))
  62. {
  63. }
  64. void SilentCaster::getCasterName(MetaString & text) const
  65. {
  66. // NOTE: can be triggered (for example) if creature steps into Tower mines/moat while hero has Recanter's Cloak
  67. logGlobal->debug("Unexpected call to SilentCaster::getCasterName");
  68. }
  69. void SilentCaster::getCastDescription(const Spell * spell, const battle::Units & attacked, MetaString & text) const
  70. {
  71. //do nothing
  72. }
  73. void SilentCaster::spendMana(ServerCallback * server, const int spellCost) const
  74. {
  75. //do nothing
  76. }
  77. PlayerColor SilentCaster::getCasterOwner() const
  78. {
  79. if(actualCaster)
  80. return actualCaster->getCasterOwner();
  81. return owner;
  82. }
  83. }
  84. VCMI_LIB_NAMESPACE_END