ObstacleCasterProxy.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "ObstacleCasterProxy.h"
  11. VCMI_LIB_NAMESPACE_BEGIN
  12. namespace spells
  13. {
  14. ObstacleCasterProxy::ObstacleCasterProxy(PlayerColor owner_, const Caster * hero_, const SpellCreatedObstacle & obs_):
  15. SilentCaster(owner_, hero_),
  16. obs(obs_)
  17. {
  18. }
  19. int32_t ObstacleCasterProxy::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
  20. {
  21. return obs.spellLevel;
  22. }
  23. int32_t ObstacleCasterProxy::getEffectLevel(const Spell * spell) const
  24. {
  25. return obs.spellLevel;
  26. }
  27. int64_t ObstacleCasterProxy::getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const
  28. {
  29. if(actualCaster)
  30. return std::max<int64_t>(actualCaster->getSpellBonus(spell, base, affectedStack), obs.minimalDamage);
  31. return std::max<int64_t>(base, obs.minimalDamage);
  32. }
  33. int32_t ObstacleCasterProxy::getEffectPower(const Spell * spell) const
  34. {
  35. return obs.casterSpellPower;
  36. }
  37. int32_t ObstacleCasterProxy::getEnchantPower(const Spell * spell) const
  38. {
  39. return obs.casterSpellPower;
  40. }
  41. int64_t ObstacleCasterProxy::getEffectValue(const Spell * spell) const
  42. {
  43. if(actualCaster)
  44. return std::max(static_cast<int64_t>(obs.minimalDamage), actualCaster->getEffectValue(spell));
  45. else
  46. return obs.minimalDamage;
  47. }
  48. SilentCaster::SilentCaster(PlayerColor owner_, const Caster * hero_):
  49. ProxyCaster(hero_),
  50. owner(std::move(owner_))
  51. {
  52. }
  53. void SilentCaster::getCasterName(MetaString & text) const
  54. {
  55. logGlobal->error("Unexpected call to SilentCaster::getCasterName");
  56. }
  57. void SilentCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const
  58. {
  59. //do nothing
  60. }
  61. void SilentCaster::spendMana(ServerCallback * server, const int spellCost) const
  62. {
  63. //do nothing
  64. }
  65. PlayerColor SilentCaster::getCasterOwner() const
  66. {
  67. if(actualCaster)
  68. return actualCaster->getCasterOwner();
  69. return owner;
  70. }
  71. }
  72. VCMI_LIB_NAMESPACE_END