mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Add BLOCK_MAGIC_BELOW bonus
This commit is contained in:
parent
59764d8349
commit
7cbd9acd67
@ -239,6 +239,7 @@ private:
|
||||
BONUS_NAME(FIRST_STRIKE) /* first counterattack, then attack if possible */\
|
||||
BONUS_NAME(SYNERGY_TARGET) /* dummy skill for alternative upgrades mod */\
|
||||
BONUS_NAME(SHOOTS_ALL_ADJACENT) /* H4 Cyclops-like shoot (attacks all hexes neighboring with target) without spell-like mechanics */\
|
||||
BONUS_NAME(BLOCK_MAGIC_BELOW) /*blocks casting spells of the level < value */ \
|
||||
/* end of list */
|
||||
|
||||
|
||||
|
@ -1647,6 +1647,24 @@ int CBattleInfoCallback::battleGetSurrenderCost(PlayerColor Player) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
si8 CBattleInfoCallback::battleMinSpellLevel(ui8 side) const
|
||||
{
|
||||
const IBonusBearer *node = nullptr;
|
||||
if(const CGHeroInstance * h = battleGetFightingHero(side))
|
||||
node = h;
|
||||
else
|
||||
node = getBattleNode();
|
||||
|
||||
if(!node)
|
||||
return 1;
|
||||
|
||||
auto b = node->getBonuses(Selector::type(Bonus::BLOCK_MAGIC_BELOW));
|
||||
if(b->size())
|
||||
return b->totalValue();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
si8 CBattleInfoCallback::battleMaxSpellLevel(ui8 side) const
|
||||
{
|
||||
const IBonusBearer *node = nullptr;
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
std::vector<BattleHex> getAttackableBattleHexes() const;
|
||||
|
||||
//*** MAGIC
|
||||
si8 battleMinSpellLevel(ui8 side) const; //calculates maximum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, 0 is returned
|
||||
si8 battleMaxSpellLevel(ui8 side) const; //calculates minimum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, 0 is returned
|
||||
ui32 battleGetSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //returns cost of given spell
|
||||
ESpellCastProblem::ESpellCastProblem battleCanCastSpell(const ISpellCaster * caster, ECastingMode::ECastingMode mode) const; //returns true if there are no general issues preventing from casting a spell
|
||||
|
@ -194,7 +194,7 @@ ESpellCastProblem::ESpellCastProblem CSpell::canBeCast(const CBattleInfoCallback
|
||||
//effect like Recanter's Cloak. Blocks also passive casting.
|
||||
//TODO: check creature abilities to block
|
||||
//TODO: check any possible caster
|
||||
if(cb->battleMaxSpellLevel(side.get()) < level)
|
||||
if(cb->battleMaxSpellLevel(side.get()) < level || cb->battleMinSpellLevel(side.get()) > level)
|
||||
return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
|
||||
|
||||
const ESpellCastProblem::ESpellCastProblem specificProblem = mechanics->canBeCast(cb, mode, caster);
|
||||
|
Loading…
Reference in New Issue
Block a user