ProxyCaster.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * ProxyCaster.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 "ProxyCaster.h"
  12. #include "../GameConstants.h"
  13. #include <vcmi/spells/Spell.h>
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. namespace spells
  16. {
  17. ProxyCaster::ProxyCaster(const Caster * actualCaster_)
  18. : actualCaster(actualCaster_)
  19. {
  20. }
  21. ProxyCaster::~ProxyCaster() = default;
  22. int32_t ProxyCaster::getCasterUnitId() const
  23. {
  24. if(actualCaster)
  25. return actualCaster->getCasterUnitId();
  26. return -1;
  27. }
  28. int32_t ProxyCaster::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
  29. {
  30. if(actualCaster)
  31. return actualCaster->getSpellSchoolLevel(spell, outSelectedSchool);
  32. return 0;
  33. }
  34. int32_t ProxyCaster::getEffectLevel(const Spell * spell) const
  35. {
  36. if(actualCaster)
  37. return actualCaster->getEffectLevel(spell);
  38. return 0;
  39. }
  40. int64_t ProxyCaster::getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const
  41. {
  42. if(actualCaster)
  43. return actualCaster->getSpellBonus(spell, base, affectedStack);
  44. return base;
  45. }
  46. int64_t ProxyCaster::getSpecificSpellBonus(const Spell * spell, int64_t base) const
  47. {
  48. if(actualCaster)
  49. return actualCaster->getSpecificSpellBonus(spell, base);
  50. return base;
  51. }
  52. int32_t ProxyCaster::getEffectPower(const Spell * spell) const
  53. {
  54. if(actualCaster)
  55. return actualCaster->getEffectPower(spell);
  56. return spell->getLevelPower(getEffectLevel(spell));
  57. }
  58. int32_t ProxyCaster::getEnchantPower(const Spell * spell) const
  59. {
  60. if(actualCaster)
  61. return actualCaster->getEnchantPower(spell);
  62. return spell->getLevelPower(getEffectLevel(spell));
  63. }
  64. int64_t ProxyCaster::getEffectValue(const Spell * spell) const
  65. {
  66. if(actualCaster)
  67. return actualCaster->getEffectValue(spell);
  68. return 0;
  69. }
  70. PlayerColor ProxyCaster::getCasterOwner() const
  71. {
  72. if(actualCaster)
  73. return actualCaster->getCasterOwner();
  74. return PlayerColor::CANNOT_DETERMINE;
  75. }
  76. void ProxyCaster::getCasterName(MetaString & text) const
  77. {
  78. if(actualCaster)
  79. actualCaster->getCasterName(text);
  80. }
  81. void ProxyCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit*> & attacked, MetaString & text) const
  82. {
  83. if(actualCaster)
  84. actualCaster->getCastDescription(spell, attacked, text);
  85. }
  86. void ProxyCaster::spendMana(ServerCallback * server, const int32_t spellCost) const
  87. {
  88. if(actualCaster)
  89. actualCaster->spendMana(server, spellCost);
  90. }
  91. }
  92. VCMI_LIB_NAMESPACE_END