1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-30 04:30:42 +02:00

[programming challenge] Added callback method battleEstimateSpellDamage.

This commit is contained in:
Michał W. Urbańczyk 2011-12-22 14:13:11 +00:00
parent e337eb681d
commit 4bf1c40211
2 changed files with 10 additions and 0 deletions

View File

@ -376,6 +376,13 @@ const CGHeroInstance * CBattleInfoCallback::battleGetFightingHero(ui8 side) cons
return gs->curB->heroes[side];
}
int CBattleInfoCallback::battleEstimateSpellDamage(const CGHeroInstance *caster, const CSpell * spell, const CStack *destination /*= NULL*/)
{
if(!caster)
return 0;
return gs->curB->calculateSpellDmg(spell, caster, destination, caster->getSpellSchoolLevel(spell), caster->getPrimSkillLevel(2));
}
CGameState *const CPrivilagedInfoCallback::gameState ()
{
return gs;

View File

@ -136,6 +136,9 @@ public:
/// determines if given spell can be casted (and returns problem description)
SpellCasting::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell);
///estimates how much damage a spell will inflict upon a destination stack. If it's NULL a base damage value will be returned. If spell is not a plain offensive spell, 0 will be returned. The function doesn't check, if hero can cast given spell.
int battleEstimateSpellDamage(const CGHeroInstance *caster, const CSpell * spell, const CStack *destination = NULL);
/// returns true if caller can flee from the battle
bool battleCanFlee();