1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

CSpell::canBeCast tweaks

This commit is contained in:
AlexVinS 2017-06-05 21:30:25 +03:00
parent 8c9d6c1c1d
commit 66cfc2fef9
3 changed files with 19 additions and 20 deletions

View File

@ -337,7 +337,7 @@ void CSpellWindow::computeSpellsPerArea()
spellsCurSite.reserve(mySpells.size());
for(const CSpell * spell : mySpells)
{
if(spell->combatSpell ^ !battleSpellsOnly
if(spell->isCombatSpell() ^ !battleSpellsOnly
&& ((selectedTab == 4) || spell->school.at((ESpellSchool)selectedTab))
)
{

View File

@ -1716,14 +1716,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
logGlobal->errorStream() << "CBattleInfoCallback::battleCanCastThisSpell: no spellcaster.";
return ESpellCastProblem::INVALID;
}
const PlayerColor player = caster->getOwner();
const si8 side = playerToSide(player);
if(side < 0)
return ESpellCastProblem::INVALID;
if(!battleDoWeKnowAbout(side))
return ESpellCastProblem::INVALID;
ESpellCastProblem::ESpellCastProblem genProblem = battleCanCastSpell(caster, mode);
if(genProblem != ESpellCastProblem::OK)
@ -1750,14 +1742,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
break;
}
if(!spell->combatSpell)
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
//effect like Recanter's Cloak. Blocks also passive casting.
//TODO: check creature abilities to block
if(battleMaxSpellLevel(side) < spell->level)
return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
return spell->canBeCast(this, mode, caster);
}

View File

@ -157,10 +157,25 @@ ui32 CSpell::calculateDamage(const ISpellCaster * caster, const CStack * affecte
ESpellCastProblem::ESpellCastProblem CSpell::canBeCast(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster) const
{
const ESpellCastProblem::ESpellCastProblem generalProblem = mechanics->canBeCast(cb, mode, caster);
if(!isCombatSpell())
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
if(generalProblem != ESpellCastProblem::OK)
return generalProblem;
const PlayerColor player = caster->getOwner();
const si8 side = cb->playerToSide(player);
if(side < 0)
return ESpellCastProblem::INVALID;
//effect like Recanter's Cloak. Blocks also passive casting.
//TODO: check creature abilities to block
//TODO: check any possible caster
if(cb->battleMaxSpellLevel(side) < level)
return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
const ESpellCastProblem::ESpellCastProblem specificProblem = mechanics->canBeCast(cb, mode, caster);
if(specificProblem != ESpellCastProblem::OK)
return specificProblem;
//check for creature target existence
//allow to cast spell if there is at least one smart target