ObstacleCasterProxy.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. int32_t SilentCaster::manaLimit() const
  50. {
  51. return 0;
  52. }
  53. SilentCaster::SilentCaster(PlayerColor owner_, const Caster * hero_):
  54. ProxyCaster(hero_),
  55. owner(std::move(owner_))
  56. {
  57. }
  58. void SilentCaster::getCasterName(MetaString & text) const
  59. {
  60. // NOTE: can be triggered (for example) if creature steps into Tower mines/moat while hero has Recanter's Cloak
  61. logGlobal->debug("Unexpected call to SilentCaster::getCasterName");
  62. }
  63. void SilentCaster::getCastDescription(const Spell * spell, const battle::Units & attacked, MetaString & text) const
  64. {
  65. //do nothing
  66. }
  67. void SilentCaster::spendMana(ServerCallback * server, const int spellCost) const
  68. {
  69. //do nothing
  70. }
  71. PlayerColor SilentCaster::getCasterOwner() const
  72. {
  73. if(actualCaster)
  74. return actualCaster->getCasterOwner();
  75. return owner;
  76. }
  77. }
  78. VCMI_LIB_NAMESPACE_END