BattleSpellMechanics.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. /*
  2. * BattleSpellMechanics.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 "BattleSpellMechanics.h"
  12. #include "Problem.h"
  13. #include "CSpellHandler.h"
  14. #include "../battle/IBattleState.h"
  15. #include "../battle/CBattleInfoCallback.h"
  16. #include "../networkPacks/PacksForClientBattle.h"
  17. #include "../networkPacks/SetStackEffect.h"
  18. #include "../CStack.h"
  19. #include "../CRandomGenerator.h"
  20. VCMI_LIB_NAMESPACE_BEGIN
  21. namespace spells
  22. {
  23. namespace SRSLPraserHelpers
  24. {
  25. static int XYToHex(int x, int y)
  26. {
  27. return x + GameConstants::BFIELD_WIDTH * y;
  28. }
  29. static int XYToHex(std::pair<int, int> xy)
  30. {
  31. return XYToHex(xy.first, xy.second);
  32. }
  33. static int hexToY(int battleFieldPosition)
  34. {
  35. return battleFieldPosition/GameConstants::BFIELD_WIDTH;
  36. }
  37. static int hexToX(int battleFieldPosition)
  38. {
  39. int pos = battleFieldPosition - hexToY(battleFieldPosition) * GameConstants::BFIELD_WIDTH;
  40. return pos;
  41. }
  42. static std::pair<int, int> hexToPair(int battleFieldPosition)
  43. {
  44. return std::make_pair(hexToX(battleFieldPosition), hexToY(battleFieldPosition));
  45. }
  46. //moves hex by one hex in given direction
  47. //0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left
  48. static std::pair<int, int> gotoDir(int x, int y, int direction)
  49. {
  50. switch(direction)
  51. {
  52. case 0: //top left
  53. return std::make_pair((y%2) ? x-1 : x, y-1);
  54. case 1: //top right
  55. return std::make_pair((y%2) ? x : x+1, y-1);
  56. case 2: //right
  57. return std::make_pair(x+1, y);
  58. case 3: //right bottom
  59. return std::make_pair((y%2) ? x : x+1, y+1);
  60. case 4: //left bottom
  61. return std::make_pair((y%2) ? x-1 : x, y+1);
  62. case 5: //left
  63. return std::make_pair(x-1, y);
  64. default:
  65. throw std::runtime_error("Disaster: wrong direction in SRSLPraserHelpers::gotoDir!\n");
  66. }
  67. }
  68. static std::pair<int, int> gotoDir(std::pair<int, int> xy, int direction)
  69. {
  70. return gotoDir(xy.first, xy.second, direction);
  71. }
  72. static bool isGoodHex(std::pair<int, int> xy)
  73. {
  74. return xy.first >=0 && xy.first < GameConstants::BFIELD_WIDTH && xy.second >= 0 && xy.second < GameConstants::BFIELD_HEIGHT;
  75. }
  76. //helper function for rangeInHexes
  77. static std::set<ui16> getInRange(unsigned int center, int low, int high)
  78. {
  79. std::set<ui16> ret;
  80. if(low == 0)
  81. {
  82. ret.insert(center);
  83. }
  84. std::pair<int, int> mainPointForLayer[6]; //A, B, C, D, E, F points
  85. for(auto & elem : mainPointForLayer)
  86. elem = hexToPair(center);
  87. for(int it=1; it<=high; ++it) //it - distance to the center
  88. {
  89. for(int b=0; b<6; ++b)
  90. mainPointForLayer[b] = gotoDir(mainPointForLayer[b], b);
  91. if(it>=low)
  92. {
  93. std::pair<int, int> curHex;
  94. //adding lines (A-b, B-c, C-d, etc)
  95. for(int v=0; v<6; ++v)
  96. {
  97. curHex = mainPointForLayer[v];
  98. for(int h=0; h<it; ++h)
  99. {
  100. if(isGoodHex(curHex))
  101. ret.insert(XYToHex(curHex));
  102. curHex = gotoDir(curHex, (v+2)%6);
  103. }
  104. }
  105. } //if(it>=low)
  106. }
  107. return ret;
  108. }
  109. }
  110. BattleSpellMechanics::BattleSpellMechanics(const IBattleCast * event,
  111. std::shared_ptr<effects::Effects> effects_,
  112. std::shared_ptr<IReceptiveCheck> targetCondition_):
  113. BaseMechanics(event),
  114. effects(std::move(effects_)),
  115. targetCondition(std::move(targetCondition_))
  116. {}
  117. BattleSpellMechanics::~BattleSpellMechanics() = default;
  118. void BattleSpellMechanics::applyEffects(ServerCallback * server, const Target & targets, bool indirect, bool ignoreImmunity) const
  119. {
  120. auto callback = [&](const effects::Effect * effect, bool & stop)
  121. {
  122. if(indirect == effect->indirect)
  123. {
  124. if(ignoreImmunity)
  125. {
  126. effect->apply(server, this, targets);
  127. }
  128. else
  129. {
  130. EffectTarget filtered = effect->filterTarget(this, targets);
  131. effect->apply(server, this, filtered);
  132. }
  133. }
  134. };
  135. effects->forEachEffect(getEffectLevel(), callback);
  136. }
  137. bool BattleSpellMechanics::canBeCast(Problem & problem) const
  138. {
  139. auto genProblem = battle()->battleCanCastSpell(caster, mode);
  140. if(genProblem != ESpellCastProblem::OK)
  141. return adaptProblem(genProblem, problem);
  142. switch(mode)
  143. {
  144. case Mode::HERO:
  145. {
  146. const auto * castingHero = dynamic_cast<const CGHeroInstance *>(caster); //todo: unify hero|creature spell cost
  147. if(!castingHero)
  148. {
  149. logGlobal->debug("CSpell::canBeCast: invalid caster");
  150. genProblem = ESpellCastProblem::NO_HERO_TO_CAST_SPELL;
  151. }
  152. else if(!castingHero->getArt(ArtifactPosition::SPELLBOOK))
  153. genProblem = ESpellCastProblem::NO_SPELLBOOK;
  154. else if(!castingHero->canCastThisSpell(owner))
  155. genProblem = ESpellCastProblem::HERO_DOESNT_KNOW_SPELL;
  156. else if(castingHero->mana < battle()->battleGetSpellCost(owner, castingHero)) //not enough mana
  157. genProblem = ESpellCastProblem::NOT_ENOUGH_MANA;
  158. }
  159. break;
  160. }
  161. if(genProblem != ESpellCastProblem::OK)
  162. return adaptProblem(genProblem, problem);
  163. if(!owner->isCombat())
  164. return adaptProblem(ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL, problem);
  165. const PlayerColor player = caster->getCasterOwner();
  166. const auto side = battle()->playerToSide(player);
  167. if(!side)
  168. return adaptProblem(ESpellCastProblem::INVALID, problem);
  169. //effect like Recanter's Cloak. Blocks also passive casting.
  170. //TODO: check creature abilities to block
  171. //TODO: check any possible caster
  172. if(battle()->battleMaxSpellLevel(side.value()) < getSpellLevel() || battle()->battleMinSpellLevel(side.value()) > getSpellLevel())
  173. return adaptProblem(ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED, problem);
  174. return effects->applicable(problem, this);
  175. }
  176. bool BattleSpellMechanics::canBeCastAt(const Target & target, Problem & problem) const
  177. {
  178. if(!canBeCast(problem))
  179. return false;
  180. Target spellTarget = transformSpellTarget(target);
  181. const battle::Unit * mainTarget = nullptr;
  182. if (!getSpell()->canCastOnSelf())
  183. {
  184. if(spellTarget.front().unitValue)
  185. {
  186. mainTarget = target.front().unitValue;
  187. }
  188. else if(spellTarget.front().hexValue.isValid())
  189. {
  190. mainTarget = battle()->battleGetUnitByPos(target.front().hexValue, true);
  191. }
  192. if (mainTarget && mainTarget == caster)
  193. return false; // can't cast on self
  194. }
  195. return effects->applicable(problem, this, target, spellTarget);
  196. }
  197. std::vector<const CStack *> BattleSpellMechanics::getAffectedStacks(const Target & target) const
  198. {
  199. Target spellTarget = transformSpellTarget(target);
  200. EffectTarget all;
  201. effects->forEachEffect(getEffectLevel(), [&all, &target, &spellTarget, this](const effects::Effect * e, bool & stop)
  202. {
  203. EffectTarget one = e->transformTarget(this, target, spellTarget);
  204. vstd::concatenate(all, one);
  205. });
  206. std::set<const CStack *> stacks;
  207. for(const Destination & dest : all)
  208. {
  209. if(dest.unitValue)
  210. {
  211. //FIXME: remove and return battle::Unit
  212. stacks.insert(battle()->battleGetStackByID(dest.unitValue->unitId(), false));
  213. }
  214. }
  215. std::vector<const CStack *> res;
  216. std::copy(stacks.begin(), stacks.end(), std::back_inserter(res));
  217. return res;
  218. }
  219. void BattleSpellMechanics::cast(ServerCallback * server, const Target & target)
  220. {
  221. BattleSpellCast sc;
  222. int spellCost = 0;
  223. sc.side = casterSide;
  224. sc.spellID = getSpellId();
  225. sc.battleID = battle()->getBattle()->getBattleID();
  226. sc.tile = target.at(0).hexValue;
  227. sc.castByHero = mode == Mode::HERO;
  228. sc.casterStack = caster->getCasterUnitId();
  229. sc.manaGained = 0;
  230. sc.activeCast = false;
  231. affectedUnits.clear();
  232. const CGHeroInstance * otherHero = nullptr;
  233. {
  234. //check it there is opponent hero
  235. const ui8 otherSide = battle()->otherSide(casterSide);
  236. if(battle()->battleHasHero(otherSide))
  237. otherHero = battle()->battleGetFightingHero(otherSide);
  238. }
  239. //calculate spell cost
  240. if(mode == Mode::HERO)
  241. {
  242. const auto * casterHero = dynamic_cast<const CGHeroInstance *>(caster);
  243. spellCost = battle()->battleGetSpellCost(owner, casterHero);
  244. if(nullptr != otherHero) //handle mana channel
  245. {
  246. int manaChannel = 0;
  247. for(const auto * stack : battle()->battleGetAllStacks(true)) //TODO: shouldn't bonus system handle it somehow?
  248. {
  249. if(stack->unitOwner() == otherHero->tempOwner)
  250. {
  251. vstd::amax(manaChannel, stack->valOfBonuses(BonusType::MANA_CHANNELING));
  252. }
  253. }
  254. sc.manaGained = (manaChannel * spellCost) / 100;
  255. }
  256. sc.activeCast = true;
  257. }
  258. else if(mode == Mode::CREATURE_ACTIVE || mode == Mode::ENCHANTER)
  259. {
  260. spellCost = 1;
  261. sc.activeCast = true;
  262. }
  263. beforeCast(sc, *server->getRNG(), target);
  264. BattleLogMessage castDescription;
  265. castDescription.battleID = battle()->getBattle()->getBattleID();
  266. switch (mode)
  267. {
  268. case Mode::CREATURE_ACTIVE:
  269. case Mode::ENCHANTER:
  270. case Mode::HERO:
  271. case Mode::PASSIVE:
  272. {
  273. MetaString line;
  274. caster->getCastDescription(owner, affectedUnits, line);
  275. if(!line.empty())
  276. castDescription.lines.push_back(line);
  277. }
  278. break;
  279. default:
  280. break;
  281. }
  282. doRemoveEffects(server, affectedUnits, std::bind(&BattleSpellMechanics::counteringSelector, this, _1));
  283. for(auto & unit : affectedUnits)
  284. sc.affectedCres.insert(unit->unitId());
  285. if(!castDescription.lines.empty())
  286. server->apply(&castDescription);
  287. server->apply(&sc);
  288. for(auto & p : effectsToApply)
  289. p.first->apply(server, this, p.second);
  290. if(sc.activeCast)
  291. {
  292. caster->spendMana(server, spellCost);
  293. if(sc.manaGained > 0)
  294. {
  295. assert(otherHero);
  296. otherHero->spendMana(server, -sc.manaGained);
  297. }
  298. }
  299. // send empty event to client
  300. // temporary(?) workaround to force animations to trigger
  301. StacksInjured fakeEvent;
  302. fakeEvent.battleID = battle()->getBattle()->getBattleID();
  303. server->apply(&fakeEvent);
  304. }
  305. void BattleSpellMechanics::beforeCast(BattleSpellCast & sc, vstd::RNG & rng, const Target & target)
  306. {
  307. affectedUnits.clear();
  308. Target spellTarget = transformSpellTarget(target);
  309. std::vector <const battle::Unit *> resisted;
  310. auto rangeGen = rng.getInt64Range(0, 99);
  311. auto filterResisted = [&, this](const battle::Unit * unit) -> bool
  312. {
  313. if(isNegativeSpell() && isMagicalEffect())
  314. {
  315. //magic resistance
  316. const int prob = std::min(unit->magicResistance(), 100); //probability of resistance in %
  317. if(rangeGen() < prob)
  318. return true;
  319. }
  320. return false;
  321. };
  322. auto filterUnit = [&](const battle::Unit * unit)
  323. {
  324. if(filterResisted(unit))
  325. resisted.push_back(unit);
  326. else
  327. affectedUnits.push_back(unit);
  328. };
  329. //prepare targets
  330. effectsToApply = effects->prepare(this, target, spellTarget);
  331. std::set<const battle::Unit *> unitTargets = collectTargets();
  332. //process them
  333. for(const auto * unit : unitTargets)
  334. filterUnit(unit);
  335. //and update targets
  336. for(auto & p : effectsToApply)
  337. {
  338. vstd::erase_if(p.second, [&](const Destination & d)
  339. {
  340. if(!d.unitValue)
  341. return false;
  342. return vstd::contains(resisted, d.unitValue);
  343. });
  344. }
  345. if(mode == Mode::MAGIC_MIRROR)
  346. {
  347. if(caster->getHeroCaster() == nullptr)
  348. {
  349. sc.reflectedCres.insert(caster->getCasterUnitId());
  350. }
  351. }
  352. for(const auto * unit : resisted)
  353. sc.resistedCres.insert(unit->unitId());
  354. }
  355. void BattleSpellMechanics::castEval(ServerCallback * server, const Target & target)
  356. {
  357. affectedUnits.clear();
  358. //TODO: evaluate caster updates (mana usage etc.)
  359. //TODO: evaluate random values
  360. Target spellTarget = transformSpellTarget(target);
  361. effectsToApply = effects->prepare(this, target, spellTarget);
  362. std::set<const battle::Unit *> unitTargets = collectTargets();
  363. auto selector = std::bind(&BattleSpellMechanics::counteringSelector, this, _1);
  364. std::copy(std::begin(unitTargets), std::end(unitTargets), std::back_inserter(affectedUnits));
  365. doRemoveEffects(server, affectedUnits, selector);
  366. for(auto & p : effectsToApply)
  367. p.first->apply(server, this, p.second);
  368. }
  369. std::set<const battle::Unit *> BattleSpellMechanics::collectTargets() const
  370. {
  371. std::set<const battle::Unit *> result;
  372. for(const auto & p : effectsToApply)
  373. {
  374. for(const Destination & d : p.second)
  375. if(d.unitValue)
  376. result.insert(d.unitValue);
  377. }
  378. return result;
  379. }
  380. void BattleSpellMechanics::doRemoveEffects(ServerCallback * server, const std::vector<const battle::Unit *> & targets, const CSelector & selector)
  381. {
  382. SetStackEffect sse;
  383. sse.battleID = battle()->getBattle()->getBattleID();
  384. for(const auto * unit : targets)
  385. {
  386. std::vector<Bonus> buffer;
  387. auto bl = unit->getBonuses(selector);
  388. for(const auto & item : *bl)
  389. buffer.emplace_back(*item);
  390. if(!buffer.empty())
  391. sse.toRemove.emplace_back(unit->unitId(), buffer);
  392. }
  393. if(!sse.toRemove.empty())
  394. server->apply(&sse);
  395. }
  396. bool BattleSpellMechanics::counteringSelector(const Bonus * bonus) const
  397. {
  398. if(bonus->source != BonusSource::SPELL_EFFECT)
  399. return false;
  400. for(const SpellID & id : owner->counteredSpells)
  401. {
  402. if(bonus->sid.as<SpellID>() == id)
  403. return true;
  404. }
  405. return false;
  406. }
  407. std::set<BattleHex> BattleSpellMechanics::spellRangeInHexes(BattleHex centralHex) const
  408. {
  409. using namespace SRSLPraserHelpers;
  410. std::set<BattleHex> ret;
  411. std::string rng = owner->getLevelInfo(getRangeLevel()).range + ','; //copy + artificial comma for easier handling
  412. if(rng.size() >= 2 && rng[0] != 'X') //there is at least one hex in range (+artificial comma)
  413. {
  414. std::string number1;
  415. std::string number2;
  416. int beg = 0;
  417. int end = 0;
  418. bool readingFirst = true;
  419. for(auto & elem : rng)
  420. {
  421. if(std::isdigit(elem) ) //reading number
  422. {
  423. if(readingFirst)
  424. number1 += elem;
  425. else
  426. number2 += elem;
  427. }
  428. else if(elem == ',') //comma
  429. {
  430. //calculating variables
  431. if(readingFirst)
  432. {
  433. beg = std::stoi(number1);
  434. number1 = "";
  435. }
  436. else
  437. {
  438. end = std::stoi(number2);
  439. number2 = "";
  440. }
  441. //obtaining new hexes
  442. std::set<ui16> curLayer;
  443. if(readingFirst)
  444. {
  445. curLayer = getInRange(centralHex, beg, beg);
  446. }
  447. else
  448. {
  449. curLayer = getInRange(centralHex, beg, end);
  450. readingFirst = true;
  451. }
  452. //adding obtained hexes
  453. for(const auto & curLayer_it : curLayer)
  454. {
  455. ret.insert(curLayer_it);
  456. }
  457. }
  458. else if(elem == '-') //dash
  459. {
  460. beg = std::stoi(number1);
  461. number1 = "";
  462. readingFirst = false;
  463. }
  464. }
  465. }
  466. return ret;
  467. }
  468. Target BattleSpellMechanics::transformSpellTarget(const Target & aimPoint) const
  469. {
  470. Target spellTarget;
  471. if(aimPoint.empty())
  472. {
  473. logGlobal->error("Aimed spell cast with no destination.");
  474. }
  475. else
  476. {
  477. const Destination & primary = aimPoint.at(0);
  478. BattleHex aimPointHex = primary.hexValue;
  479. //transform primary spell target with spell range (if it`s valid), leave anything else to effects
  480. if(aimPointHex.isValid())
  481. {
  482. auto spellRange = spellRangeInHexes(aimPointHex);
  483. for(const auto & hex : spellRange)
  484. spellTarget.push_back(Destination(hex));
  485. }
  486. }
  487. if(spellTarget.empty())
  488. spellTarget.push_back(Destination(BattleHex::INVALID));
  489. return spellTarget;
  490. }
  491. std::vector<AimType> BattleSpellMechanics::getTargetTypes() const
  492. {
  493. auto ret = BaseMechanics::getTargetTypes();
  494. if(!ret.empty())
  495. {
  496. effects->forEachEffect(getEffectLevel(), [&](const effects::Effect * e, bool & stop)
  497. {
  498. e->adjustTargetTypes(ret);
  499. stop = ret.empty();
  500. });
  501. }
  502. return ret;
  503. }
  504. std::vector<Destination> BattleSpellMechanics::getPossibleDestinations(size_t index, AimType aimType, const Target & current, bool fast) const
  505. {
  506. //TODO: BattleSpellMechanics::getPossibleDestinations
  507. if(index != 0)
  508. return std::vector<Destination>();
  509. std::vector<Destination> ret;
  510. switch(aimType)
  511. {
  512. case AimType::CREATURE:
  513. {
  514. auto stacks = battle()->battleGetAllStacks();
  515. for(auto stack : stacks)
  516. {
  517. Target tmp = current;
  518. tmp.emplace_back(stack->getPosition());
  519. detail::ProblemImpl ignored;
  520. if(canBeCastAt(tmp, ignored))
  521. ret.emplace_back(stack->getPosition());
  522. }
  523. break;
  524. }
  525. case AimType::LOCATION:
  526. if(fast)
  527. {
  528. auto stacks = battle()->battleGetAllStacks();
  529. std::set<BattleHex> hexesToCheck;
  530. for(auto stack : stacks)
  531. {
  532. hexesToCheck.insert(stack->getPosition());
  533. for(auto adjacent : stack->getPosition().neighbouringTiles())
  534. hexesToCheck.insert(adjacent);
  535. }
  536. for(auto hex : hexesToCheck)
  537. {
  538. if(hex.isAvailable())
  539. {
  540. Target tmp = current;
  541. tmp.emplace_back(hex);
  542. detail::ProblemImpl ignored;
  543. if(canBeCastAt(tmp, ignored))
  544. ret.emplace_back(hex);
  545. }
  546. }
  547. }
  548. else
  549. {
  550. for(int i = 0; i < GameConstants::BFIELD_SIZE; i++)
  551. {
  552. BattleHex dest(i);
  553. if(dest.isAvailable())
  554. {
  555. Target tmp = current;
  556. tmp.emplace_back(dest);
  557. detail::ProblemImpl ignored;
  558. if(canBeCastAt(tmp, ignored))
  559. ret.emplace_back(dest);
  560. }
  561. }
  562. }
  563. break;
  564. case AimType::NO_TARGET:
  565. ret.emplace_back();
  566. break;
  567. default:
  568. break;
  569. }
  570. return ret;
  571. }
  572. bool BattleSpellMechanics::isReceptive(const battle::Unit * target) const
  573. {
  574. return targetCondition->isReceptive(this, target);
  575. }
  576. std::vector<BattleHex> BattleSpellMechanics::rangeInHexes(BattleHex centralHex) const
  577. {
  578. if(isMassive() || !centralHex.isValid())
  579. return std::vector<BattleHex>(1, BattleHex::INVALID);
  580. Target aimPoint;
  581. aimPoint.push_back(Destination(centralHex));
  582. Target spellTarget = transformSpellTarget(aimPoint);
  583. std::set<BattleHex> effectRange;
  584. effects->forEachEffect(getEffectLevel(), [&](const effects::Effect * effect, bool & stop)
  585. {
  586. if(!effect->indirect)
  587. {
  588. effect->adjustAffectedHexes(effectRange, this, spellTarget);
  589. }
  590. });
  591. std::vector<BattleHex> ret;
  592. ret.reserve(effectRange.size());
  593. std::copy(effectRange.begin(), effectRange.end(), std::back_inserter(ret));
  594. return ret;
  595. }
  596. const Spell * BattleSpellMechanics::getSpell() const
  597. {
  598. return owner;
  599. }
  600. }
  601. VCMI_LIB_NAMESPACE_END