BonusCaster.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * BonusCaster.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 "BonusCaster.h"
  12. #include <vcmi/spells/Spell.h>
  13. #include "../MetaString.h"
  14. #include "../battle/Unit.h"
  15. #include "../bonuses/Bonus.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. namespace spells
  18. {
  19. BonusCaster::BonusCaster(const Caster * actualCaster_, std::shared_ptr<Bonus> bonus_):
  20. ProxyCaster(actualCaster_),
  21. bonus(std::move(bonus_))
  22. {
  23. }
  24. BonusCaster::~BonusCaster() = default;
  25. void BonusCaster::getCasterName(MetaString & text) const
  26. {
  27. // if(!bonus->descriptionTextID.empty())
  28. // text.replaceTextID(bonus->descriptionTextID);
  29. // else
  30. actualCaster->getCasterName(text);
  31. }
  32. void BonusCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit*> & attacked, MetaString & text) const
  33. {
  34. const bool singleTarget = attacked.size() == 1;
  35. const int textIndex = singleTarget ? 195 : 196;
  36. text.appendLocalString(EMetaText::GENERAL_TXT, textIndex);
  37. getCasterName(text);
  38. text.replaceName(spell->getId());
  39. if(singleTarget)
  40. attacked.at(0)->addNameReplacement(text, true);
  41. }
  42. void BonusCaster::spendMana(ServerCallback * server, const int spellCost) const
  43. {
  44. logGlobal->error("Unexpected call to BonusCaster::spendMana");
  45. }
  46. } // namespace spells
  47. VCMI_LIB_NAMESPACE_END