1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Get rid of IBonusBearer::getEffect

This commit is contained in:
AlexVinS 2016-10-01 08:28:33 +03:00
parent a1ff409080
commit c243ae6f3e
3 changed files with 2 additions and 17 deletions

View File

@ -950,11 +950,12 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
double multDefenceReduction = (100 - battleBonusValue (info.attackerBonuses, Selector::type(Bonus::ENEMY_DEFENCE_REDUCTION))) / 100.0;
attackDefenceDifference -= info.defenderBonuses->Defense() * multDefenceReduction;
if(const std::shared_ptr<Bonus> slayerEffect = info.attackerBonuses->getEffect(SpellID::SLAYER)) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT?
if(const std::shared_ptr<Bonus> slayerEffect = info.attackerBonuses->getBonus(Selector::type(Bonus::SLAYER))) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT?
{
std::vector<int> affectedIds;
int spLevel = slayerEffect->val;
//FIXME: do not check all creatures
for(int g = 0; g < VLC->creh->creatures.size(); ++g)
{
for(const std::shared_ptr<Bonus> b : VLC->creh->creatures[g]->getBonusList())

View File

@ -499,21 +499,6 @@ const TBonusListPtr IBonusBearer::getSpellBonuses() const
return getBonuses(selector, Selector::anyRange(), cachingStr.str());
}
const std::shared_ptr<Bonus> IBonusBearer::getEffect(ui16 id, int turn /*= 0*/) const
{
//TODO should check only local bonuses?
auto bonuses = getAllBonuses(Selector::all, Selector::all);
for(auto & it : *bonuses)
{
if(it->source == Bonus::SPELL_EFFECT && it->sid == id)
{
if(!turn || it->turnsRemain > turn)
return it;
}
}
return nullptr;
}
const std::shared_ptr<Bonus> IBonusBearer::getBonus(const CSelector &selector) const
{
auto bonuses = getAllBonuses(Selector::all, Selector::all);

View File

@ -604,7 +604,6 @@ public:
bool isLiving() const; //non-undead, non-non living or alive
virtual si32 magicResistance() const;
ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
const std::shared_ptr<Bonus> getEffect(ui16 id, int turn = 0) const; //effect id (SP)
si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;