2
0

ObstacleCasterProxy.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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, int32_t * 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. SilentCaster::SilentCaster(PlayerColor owner_, const Caster * hero_):
  50. ProxyCaster(hero_),
  51. owner(std::move(owner_))
  52. {
  53. }
  54. void SilentCaster::getCasterName(MetaString & text) const
  55. {
  56. logGlobal->error("Unexpected call to SilentCaster::getCasterName");
  57. }
  58. void SilentCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const
  59. {
  60. //do nothing
  61. }
  62. void SilentCaster::spendMana(ServerCallback * server, const int spellCost) const
  63. {
  64. //do nothing
  65. }
  66. PlayerColor SilentCaster::getCasterOwner() const
  67. {
  68. if(actualCaster)
  69. return actualCaster->getCasterOwner();
  70. return owner;
  71. }
  72. }
  73. VCMI_LIB_NAMESPACE_END