ObstacleCasterProxy.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. logGlobal->error("Unexpected call to SilentCaster::getCasterName");
  61. }
  62. void SilentCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const
  63. {
  64. //do nothing
  65. }
  66. void SilentCaster::spendMana(ServerCallback * server, const int spellCost) const
  67. {
  68. //do nothing
  69. }
  70. PlayerColor SilentCaster::getCasterOwner() const
  71. {
  72. if(actualCaster)
  73. return actualCaster->getCasterOwner();
  74. return owner;
  75. }
  76. }
  77. VCMI_LIB_NAMESPACE_END