2
0

ISpellMechanics.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. /*
  2. * ISpellMechanics.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 "ISpellMechanics.h"
  12. #include "../GameLibrary.h"
  13. #include "../bonuses/Bonus.h"
  14. #include "../battle/CBattleInfoCallback.h"
  15. #include "../battle/IBattleState.h"
  16. #include "../battle/Unit.h"
  17. #include "../mapObjects/CGHeroInstance.h"
  18. #include "../serializer/JsonDeserializer.h"
  19. #include "../serializer/JsonSerializer.h"
  20. #include "TargetCondition.h"
  21. #include "Problem.h"
  22. #include "adventure/AdventureSpellMechanics.h"
  23. #include "adventure/DimensionDoorMechanics.h"
  24. #include "adventure/ScuttleBoatMechanics.h"
  25. #include "adventure/SummonBoatMechanics.h"
  26. #include "adventure/TownPortalMechanics.h"
  27. #include "adventure/ViewWorldMechanics.h"
  28. #include "BattleSpellMechanics.h"
  29. #include "effects/Effects.h"
  30. #include "effects/Registry.h"
  31. #include "effects/Damage.h"
  32. #include "effects/Timed.h"
  33. #include "CSpellHandler.h"
  34. #include "../BattleFieldHandler.h"
  35. #include <vstd/RNG.h>
  36. VCMI_LIB_NAMESPACE_BEGIN
  37. namespace spells
  38. {
  39. static std::shared_ptr<TargetCondition> makeCondition(const CSpell * s)
  40. {
  41. auto res = std::make_shared<TargetCondition>();
  42. JsonDeserializer deser(nullptr, s->targetCondition);
  43. res->serializeJson(deser, TargetConditionItemFactory::getDefault());
  44. return res;
  45. }
  46. class CustomMechanicsFactory : public ISpellMechanicsFactory
  47. {
  48. public:
  49. std::unique_ptr<Mechanics> create(const IBattleCast * event) const override
  50. {
  51. auto * ret = new BattleSpellMechanics(event, effects, targetCondition);
  52. return std::unique_ptr<Mechanics>(ret);
  53. }
  54. protected:
  55. std::shared_ptr<effects::Effects> effects;
  56. CustomMechanicsFactory(const CSpell * s)
  57. : ISpellMechanicsFactory(s), effects(new effects::Effects)
  58. {
  59. targetCondition = makeCondition(s);
  60. }
  61. void loadEffects(const JsonNode & config, const int level)
  62. {
  63. JsonDeserializer deser(nullptr, config);
  64. effects->serializeJson(LIBRARY->spellEffects(), deser, level);
  65. }
  66. private:
  67. std::shared_ptr<IReceptiveCheck> targetCondition;
  68. };
  69. class ConfigurableMechanicsFactory : public CustomMechanicsFactory
  70. {
  71. public:
  72. ConfigurableMechanicsFactory(const CSpell * s)
  73. : CustomMechanicsFactory(s)
  74. {
  75. for(int level = 0; level < GameConstants::SPELL_SCHOOL_LEVELS; level++)
  76. loadEffects(s->getLevelInfo(level).battleEffects, level);
  77. }
  78. };
  79. //to be used for spells configured with old format
  80. class FallbackMechanicsFactory : public CustomMechanicsFactory
  81. {
  82. public:
  83. FallbackMechanicsFactory(const CSpell * s)
  84. : CustomMechanicsFactory(s)
  85. {
  86. for(int level = 0; level < GameConstants::SPELL_SCHOOL_LEVELS; level++)
  87. {
  88. const CSpell::LevelInfo & levelInfo = s->getLevelInfo(level);
  89. assert(levelInfo.battleEffects.isNull());
  90. if(s->isOffensive())
  91. {
  92. //default constructed object should be enough
  93. effects->add("directDamage", std::make_shared<effects::Damage>(), level);
  94. }
  95. std::shared_ptr<effects::Effect> effect;
  96. if(!levelInfo.effects.empty())
  97. {
  98. auto * timed = new effects::Timed();
  99. timed->cumulative = false;
  100. timed->bonus = levelInfo.effects;
  101. effect.reset(timed);
  102. }
  103. if(!levelInfo.cumulativeEffects.empty())
  104. {
  105. auto * timed = new effects::Timed();
  106. timed->cumulative = true;
  107. timed->bonus = levelInfo.cumulativeEffects;
  108. effect.reset(timed);
  109. }
  110. if(effect)
  111. effects->add("timed", effect, level);
  112. }
  113. }
  114. };
  115. BattleCast::BattleCast(const CBattleInfoCallback * cb_, const Caster * caster_, const Mode mode_, const CSpell * spell_):
  116. spell(spell_),
  117. cb(cb_),
  118. caster(caster_),
  119. mode(mode_),
  120. smart(boost::logic::indeterminate),
  121. massive(boost::logic::indeterminate)
  122. {
  123. }
  124. BattleCast::BattleCast(const BattleCast & orig, const Caster * caster_)
  125. : spell(orig.spell),
  126. cb(orig.cb),
  127. caster(caster_),
  128. mode(Mode::MAGIC_MIRROR),
  129. magicSkillLevel(orig.magicSkillLevel),
  130. effectPower(orig.effectPower),
  131. effectDuration(orig.effectDuration),
  132. effectValue(orig.effectValue),
  133. smart(true),
  134. massive(false)
  135. {
  136. }
  137. BattleCast::~BattleCast() = default;
  138. const CSpell * BattleCast::getSpell() const
  139. {
  140. return spell;
  141. }
  142. Mode BattleCast::getMode() const
  143. {
  144. return mode;
  145. }
  146. const Caster * BattleCast::getCaster() const
  147. {
  148. return caster;
  149. }
  150. const CBattleInfoCallback * BattleCast::getBattle() const
  151. {
  152. return cb;
  153. }
  154. BattleCast::OptionalValue BattleCast::getSpellLevel() const
  155. {
  156. return magicSkillLevel;
  157. }
  158. BattleCast::OptionalValue BattleCast::getEffectPower() const
  159. {
  160. return effectPower;
  161. }
  162. BattleCast::OptionalValue BattleCast::getEffectDuration() const
  163. {
  164. return effectDuration;
  165. }
  166. BattleCast::OptionalValue64 BattleCast::getEffectValue() const
  167. {
  168. return effectValue;
  169. }
  170. boost::logic::tribool BattleCast::isSmart() const
  171. {
  172. return smart;
  173. }
  174. boost::logic::tribool BattleCast::isMassive() const
  175. {
  176. return massive;
  177. }
  178. void BattleCast::setSpellLevel(BattleCast::Value value)
  179. {
  180. magicSkillLevel = std::make_optional(value);
  181. }
  182. void BattleCast::setEffectPower(BattleCast::Value value)
  183. {
  184. effectPower = std::make_optional(value);
  185. }
  186. void BattleCast::setEffectDuration(BattleCast::Value value)
  187. {
  188. effectDuration = std::make_optional(value);
  189. }
  190. void BattleCast::setEffectValue(BattleCast::Value64 value)
  191. {
  192. effectValue = std::make_optional(value);
  193. }
  194. void BattleCast::applyEffects(ServerCallback * server, const Target & target, bool indirect, bool ignoreImmunity) const
  195. {
  196. auto m = spell->battleMechanics(this);
  197. m->applyEffects(server, target, indirect, ignoreImmunity);
  198. }
  199. void BattleCast::cast(ServerCallback * server, Target target)
  200. {
  201. if(target.empty())
  202. target.emplace_back();
  203. auto m = spell->battleMechanics(this);
  204. const battle::Unit * mainTarget = nullptr;
  205. if(target.front().unitValue)
  206. {
  207. mainTarget = target.front().unitValue;
  208. }
  209. else if(target.front().hexValue.isValid())
  210. {
  211. mainTarget = cb->battleGetUnitByPos(target.front().hexValue, true);
  212. }
  213. bool tryMagicMirror = (mainTarget != nullptr) && (mode == Mode::HERO || mode == Mode::CREATURE_ACTIVE);//TODO: recheck
  214. tryMagicMirror = tryMagicMirror && (mainTarget->unitOwner() != caster->getCasterOwner()) && !spell->isPositive();//TODO: recheck
  215. m->cast(server, target);
  216. //Magic Mirror effect
  217. if(tryMagicMirror)
  218. {
  219. const std::string magicMirrorCacheStr = "type_MAGIC_MIRROR";
  220. static const auto magicMirrorSelector = Selector::type()(BonusType::MAGIC_MIRROR);
  221. const int mirrorChance = mainTarget->valOfBonuses(magicMirrorSelector, magicMirrorCacheStr);
  222. if(server->getRNG()->nextInt(0, 99) < mirrorChance)
  223. {
  224. auto mirrorTargets = cb->battleGetUnitsIf([this](const battle::Unit * unit)
  225. {
  226. //Get all caster stacks. Magic mirror can reflect to immune creature (with no effect)
  227. return unit->unitOwner() == caster->getCasterOwner() && unit->isValidTarget(true);
  228. });
  229. if(!mirrorTargets.empty())
  230. {
  231. const auto * mirrorDestination = (*RandomGeneratorUtil::nextItem(mirrorTargets, *server->getRNG()));
  232. Target mirrorTarget;
  233. mirrorTarget.emplace_back(mirrorDestination);
  234. BattleCast mirror(*this, mainTarget);
  235. mirror.cast(server, mirrorTarget);
  236. }
  237. }
  238. }
  239. }
  240. void BattleCast::castEval(ServerCallback * server, Target target)
  241. {
  242. //TODO: make equivalent to normal cast
  243. if(target.empty())
  244. target.emplace_back();
  245. auto m = spell->battleMechanics(this);
  246. //TODO: reflection
  247. //TODO: random effects evaluation
  248. m->castEval(server, target);
  249. }
  250. bool BattleCast::castIfPossible(ServerCallback * server, Target target)
  251. {
  252. if(spell->canBeCast(cb, mode, caster))
  253. {
  254. cast(server, std::move(target));
  255. return true;
  256. }
  257. return false;
  258. }
  259. std::vector<Target> BattleCast::findPotentialTargets(bool fast) const
  260. {
  261. //TODO: for more than 2 destinations per target much more efficient algorithm is required
  262. auto m = spell->battleMechanics(this);
  263. auto targetTypes = m->getTargetTypes();
  264. if(targetTypes.empty() || targetTypes.size() > 2)
  265. {
  266. return std::vector<Target>();
  267. }
  268. else
  269. {
  270. std::vector<Target> previous;
  271. std::vector<Target> next;
  272. for(size_t index = 0; index < targetTypes.size(); index++)
  273. {
  274. std::swap(previous, next);
  275. next.clear();
  276. std::vector<Destination> destinations;
  277. if(previous.empty())
  278. {
  279. Target empty;
  280. destinations = m->getPossibleDestinations(index, targetTypes.at(index), empty, fast);
  281. for(auto & destination : destinations)
  282. {
  283. Target target;
  284. target.emplace_back(destination);
  285. next.push_back(target);
  286. }
  287. }
  288. else
  289. {
  290. for(const Target & current : previous)
  291. {
  292. destinations = m->getPossibleDestinations(index, targetTypes.at(index), current, fast);
  293. for(auto & destination : destinations)
  294. {
  295. Target target = current;
  296. target.emplace_back(destination);
  297. next.push_back(target);
  298. }
  299. }
  300. }
  301. if(next.empty())
  302. break;
  303. }
  304. return next;
  305. }
  306. }
  307. ///ISpellMechanicsFactory
  308. ISpellMechanicsFactory::ISpellMechanicsFactory(const CSpell * s)
  309. : spell(s)
  310. {
  311. }
  312. //must be instantiated in .cpp file for access to complete types of all member fields
  313. ISpellMechanicsFactory::~ISpellMechanicsFactory() = default;
  314. std::unique_ptr<ISpellMechanicsFactory> ISpellMechanicsFactory::get(const CSpell * s)
  315. {
  316. if(s->hasBattleEffects())
  317. return std::make_unique<ConfigurableMechanicsFactory>(s);
  318. else
  319. return std::make_unique<FallbackMechanicsFactory>(s);
  320. }
  321. ///Mechanics
  322. Mechanics::Mechanics()
  323. : caster(nullptr),
  324. casterSide(BattleSide::NONE)
  325. {
  326. }
  327. Mechanics::~Mechanics() = default;
  328. BaseMechanics::BaseMechanics(const IBattleCast * event):
  329. owner(event->getSpell()),
  330. mode(event->getMode()),
  331. smart(event->isSmart()),
  332. massive(event->isMassive()),
  333. cb(event->getBattle())
  334. {
  335. caster = event->getCaster();
  336. casterSide = cb->playerToSide(caster->getCasterOwner());
  337. {
  338. auto value = event->getSpellLevel();
  339. rangeLevel = value.value_or(caster->getSpellSchoolLevel(owner));
  340. vstd::abetween(rangeLevel, 0, 3);
  341. }
  342. {
  343. auto value = event->getSpellLevel();
  344. effectLevel = value.value_or(caster->getEffectLevel(owner));
  345. vstd::abetween(effectLevel, 0, 3);
  346. }
  347. {
  348. auto value = event->getEffectPower();
  349. effectPower = value.value_or(caster->getEffectPower(owner));
  350. vstd::amax(effectPower, 0);
  351. }
  352. {
  353. auto value = event->getEffectDuration();
  354. effectDuration = value.value_or(caster->getEnchantPower(owner));
  355. vstd::amax(effectDuration, 0); //???
  356. }
  357. {
  358. auto value = event->getEffectValue();
  359. auto casterValue = caster->getEffectValue(owner) ? caster->getEffectValue(owner) : owner->calculateRawEffectValue(effectLevel, effectPower, 1);
  360. effectValue = value.value_or(casterValue);
  361. vstd::amax(effectValue, 0);
  362. }
  363. }
  364. BaseMechanics::~BaseMechanics() = default;
  365. bool BaseMechanics::adaptGenericProblem(Problem & target) const
  366. {
  367. MetaString text;
  368. // %s recites the incantations but they seem to have no effect.
  369. text.appendLocalString(EMetaText::GENERAL_TXT, 541);
  370. assert(caster);
  371. caster->getCasterName(text);
  372. target.add(std::move(text), spells::Problem::NORMAL);
  373. return false;
  374. }
  375. bool BaseMechanics::adaptProblem(ESpellCastProblem source, Problem & target) const
  376. {
  377. if(source == ESpellCastProblem::OK)
  378. return true;
  379. switch(source)
  380. {
  381. case ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED:
  382. {
  383. MetaString text;
  384. //TODO: refactor
  385. const auto * hero = dynamic_cast<const CGHeroInstance *>(caster);
  386. if(!hero)
  387. return adaptGenericProblem(target);
  388. //Recanter's Cloak or similar effect. Try to retrieve bonus
  389. const auto b = hero->getFirstBonus(Selector::type()(BonusType::BLOCK_MAGIC_ABOVE));
  390. //TODO what about other values and non-artifact sources?
  391. if(b && b->val == 2 && b->source == BonusSource::ARTIFACT)
  392. {
  393. //The %s prevents %s from casting 3rd level or higher spells.
  394. text.appendLocalString(EMetaText::GENERAL_TXT, 536);
  395. text.replaceName(b->sid.as<ArtifactID>());
  396. caster->getCasterName(text);
  397. target.add(std::move(text), spells::Problem::NORMAL);
  398. }
  399. else if(b && b->source == BonusSource::TERRAIN_OVERLAY && LIBRARY->battlefields()->getById(b->sid.as<BattleField>())->identifier == "cursed_ground")
  400. {
  401. text.appendLocalString(EMetaText::GENERAL_TXT, 537);
  402. target.add(std::move(text), spells::Problem::NORMAL);
  403. }
  404. else
  405. {
  406. return adaptGenericProblem(target);
  407. }
  408. }
  409. break;
  410. case ESpellCastProblem::WRONG_SPELL_TARGET:
  411. case ESpellCastProblem::STACK_IMMUNE_TO_SPELL:
  412. case ESpellCastProblem::NO_APPROPRIATE_TARGET:
  413. {
  414. MetaString text;
  415. text.appendLocalString(EMetaText::GENERAL_TXT, 185);
  416. target.add(std::move(text), spells::Problem::NORMAL);
  417. }
  418. break;
  419. case ESpellCastProblem::INVALID:
  420. {
  421. MetaString text;
  422. text.appendRawString("Internal error during check of spell cast.");
  423. target.add(std::move(text), spells::Problem::CRITICAL);
  424. }
  425. break;
  426. default:
  427. return adaptGenericProblem(target);
  428. }
  429. return false;
  430. }
  431. int32_t BaseMechanics::getSpellIndex() const
  432. {
  433. return getSpellId().toEnum();
  434. }
  435. SpellID BaseMechanics::getSpellId() const
  436. {
  437. return owner->getId();
  438. }
  439. std::string BaseMechanics::getSpellName() const
  440. {
  441. return owner->getNameTranslated();
  442. }
  443. int32_t BaseMechanics::getSpellLevel() const
  444. {
  445. return owner->getLevel();
  446. }
  447. bool BaseMechanics::isSmart() const
  448. {
  449. if(boost::logic::indeterminate(smart))
  450. {
  451. const CSpell::TargetInfo targetInfo(owner, getRangeLevel(), mode);
  452. return targetInfo.smart;
  453. }
  454. else
  455. {
  456. return (bool)smart;
  457. }
  458. }
  459. bool BaseMechanics::isMassive() const
  460. {
  461. if(boost::logic::indeterminate(massive))
  462. {
  463. const CSpell::TargetInfo targetInfo(owner, getRangeLevel(), mode);
  464. return targetInfo.massive;
  465. }
  466. else
  467. {
  468. return (bool)massive;
  469. }
  470. }
  471. bool BaseMechanics::requiresClearTiles() const
  472. {
  473. const CSpell::TargetInfo targetInfo(owner, getRangeLevel(), mode);
  474. return targetInfo.clearAffected;
  475. }
  476. bool BaseMechanics::alwaysHitFirstTarget() const
  477. {
  478. return mode == Mode::SPELL_LIKE_ATTACK;
  479. }
  480. bool BaseMechanics::isNegativeSpell() const
  481. {
  482. return owner->isNegative();
  483. }
  484. bool BaseMechanics::isPositiveSpell() const
  485. {
  486. return owner->isPositive();
  487. }
  488. bool BaseMechanics::isMagicalEffect() const
  489. {
  490. return owner->isMagical();
  491. }
  492. int64_t BaseMechanics::adjustEffectValue(const battle::Unit * target) const
  493. {
  494. return owner->adjustRawDamage(caster, target, getEffectValue());
  495. }
  496. int64_t BaseMechanics::applySpellBonus(int64_t value, const battle::Unit * target) const
  497. {
  498. return caster->getSpellBonus(owner, value, target);
  499. }
  500. int64_t BaseMechanics::applySpecificSpellBonus(int64_t value) const
  501. {
  502. return caster->getSpecificSpellBonus(owner, value);
  503. }
  504. int64_t BaseMechanics::calculateRawEffectValue(int32_t basePowerMultiplier, int32_t levelPowerMultiplier) const
  505. {
  506. return owner->calculateRawEffectValue(getEffectLevel(), basePowerMultiplier, levelPowerMultiplier);
  507. }
  508. bool BaseMechanics::ownerMatches(const battle::Unit * unit) const
  509. {
  510. return ownerMatches(unit, owner->getPositiveness());
  511. }
  512. bool BaseMechanics::ownerMatches(const battle::Unit * unit, const boost::logic::tribool positivness) const
  513. {
  514. return cb->battleMatchOwner(caster->getCasterOwner(), unit, positivness);
  515. }
  516. IBattleCast::Value BaseMechanics::getEffectLevel() const
  517. {
  518. return effectLevel;
  519. }
  520. IBattleCast::Value BaseMechanics::getRangeLevel() const
  521. {
  522. return rangeLevel;
  523. }
  524. IBattleCast::Value BaseMechanics::getEffectPower() const
  525. {
  526. return effectPower;
  527. }
  528. IBattleCast::Value BaseMechanics::getEffectDuration() const
  529. {
  530. return effectDuration;
  531. }
  532. IBattleCast::Value64 BaseMechanics::getEffectValue() const
  533. {
  534. return effectValue;
  535. }
  536. PlayerColor BaseMechanics::getCasterColor() const
  537. {
  538. return caster->getCasterOwner();
  539. }
  540. std::vector<AimType> BaseMechanics::getTargetTypes() const
  541. {
  542. std::vector<AimType> ret;
  543. detail::ProblemImpl ignored;
  544. if(canBeCast(ignored))
  545. {
  546. auto spellTargetType = owner->getTargetType();
  547. if(isMassive())
  548. spellTargetType = AimType::NO_TARGET;
  549. else if(spellTargetType == AimType::OBSTACLE)
  550. spellTargetType = AimType::LOCATION;
  551. ret.push_back(spellTargetType);
  552. }
  553. return ret;
  554. }
  555. const CreatureService * BaseMechanics::creatures() const
  556. {
  557. return LIBRARY->creatures(); //todo: redirect
  558. }
  559. #if SCRIPTING_ENABLED
  560. const scripting::Service * BaseMechanics::scripts() const
  561. {
  562. return LIBRARY->scripts(); //todo: redirect
  563. }
  564. #endif
  565. const Service * BaseMechanics::spells() const
  566. {
  567. return LIBRARY->spells(); //todo: redirect
  568. }
  569. const CBattleInfoCallback * BaseMechanics::battle() const
  570. {
  571. return cb;
  572. }
  573. } //namespace spells
  574. ///IAdventureSpellMechanics
  575. IAdventureSpellMechanics::IAdventureSpellMechanics(const CSpell * s)
  576. : owner(s)
  577. {
  578. }
  579. std::unique_ptr<IAdventureSpellMechanics> IAdventureSpellMechanics::createMechanics(const CSpell * s)
  580. {
  581. switch(s->id.toEnum())
  582. {
  583. case SpellID::SUMMON_BOAT:
  584. return std::make_unique<SummonBoatMechanics>(s);
  585. case SpellID::SCUTTLE_BOAT:
  586. return std::make_unique<ScuttleBoatMechanics>(s);
  587. case SpellID::DIMENSION_DOOR:
  588. return std::make_unique<DimensionDoorMechanics>(s);
  589. case SpellID::FLY:
  590. case SpellID::WATER_WALK:
  591. case SpellID::VISIONS:
  592. case SpellID::DISGUISE:
  593. return std::make_unique<AdventureSpellMechanics>(s); //implemented using bonus system
  594. case SpellID::TOWN_PORTAL:
  595. return std::make_unique<TownPortalMechanics>(s);
  596. case SpellID::VIEW_EARTH:
  597. return std::make_unique<ViewEarthMechanics>(s);
  598. case SpellID::VIEW_AIR:
  599. return std::make_unique<ViewAirMechanics>(s);
  600. default:
  601. return s->isCombat() ? std::unique_ptr<IAdventureSpellMechanics>() : std::make_unique<AdventureSpellMechanics>(s);
  602. }
  603. }
  604. VCMI_LIB_NAMESPACE_END