mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-19 00:17:56 +02:00
vcmi: split bonus to enumerator and HeroBonus.h
This commit is contained in:
@ -96,7 +96,7 @@ si32 CStack::magicResistance() const
|
||||
for(const auto * one : battle->battleAdjacentUnits(this))
|
||||
{
|
||||
if(one->unitOwner() == owner)
|
||||
vstd::amax(auraBonus, one->valOfBonuses(Bonus::SPELL_RESISTANCE_AURA)); //max value
|
||||
vstd::amax(auraBonus, one->valOfBonuses(BonusType::SPELL_RESISTANCE_AURA)); //max value
|
||||
}
|
||||
vstd::abetween(auraBonus, 0, 100);
|
||||
vstd::abetween(magicResistance, 0, 100);
|
||||
@ -125,11 +125,11 @@ std::vector<si32> CStack::activeSpells() const
|
||||
std::vector<si32> ret;
|
||||
|
||||
std::stringstream cachingStr;
|
||||
cachingStr << "!type_" << Bonus::NONE << "source_" << Bonus::SPELL_EFFECT;
|
||||
CSelector selector = Selector::sourceType()(Bonus::SPELL_EFFECT)
|
||||
cachingStr << "!type_" << vstd::to_underlying(BonusType::NONE) << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT);
|
||||
CSelector selector = Selector::sourceType()(BonusSource::SPELL_EFFECT)
|
||||
.And(CSelector([](const Bonus * b)->bool
|
||||
{
|
||||
return b->type != Bonus::NONE && SpellID(b->sid).toSpell() && !SpellID(b->sid).toSpell()->isAdventure();
|
||||
return b->type != BonusType::NONE && SpellID(b->sid).toSpell() && !SpellID(b->sid).toSpell()->isAdventure();
|
||||
}));
|
||||
|
||||
TConstBonusListPtr spellEffects = getBonuses(selector, Selector::all, cachingStr.str());
|
||||
@ -198,7 +198,7 @@ void CStack::prepareAttacked(BattleStackAttacked & bsa, vstd::RNG & rand, const
|
||||
{
|
||||
bsa.flags |= BattleStackAttacked::KILLED;
|
||||
|
||||
auto resurrectValue = customState->valOfBonuses(Bonus::REBIRTH);
|
||||
auto resurrectValue = customState->valOfBonuses(BonusType::REBIRTH);
|
||||
|
||||
if(resurrectValue > 0 && customState->canCast()) //there must be casts left
|
||||
{
|
||||
@ -220,7 +220,7 @@ void CStack::prepareAttacked(BattleStackAttacked & bsa, vstd::RNG & rand, const
|
||||
resurrectedCount += 1;
|
||||
}
|
||||
|
||||
if(customState->hasBonusOfType(Bonus::REBIRTH, 1))
|
||||
if(customState->hasBonusOfType(BonusType::REBIRTH, 1))
|
||||
{
|
||||
// resurrect at least one Sacred Phoenix
|
||||
vstd::amax(resurrectedCount, 1);
|
||||
@ -308,7 +308,7 @@ std::string CStack::getName() const
|
||||
|
||||
bool CStack::canBeHealed() const
|
||||
{
|
||||
return getFirstHPleft() < static_cast<int32_t>(getMaxHealth()) && isValidTarget() && !hasBonusOfType(Bonus::SIEGE_WEAPON);
|
||||
return getFirstHPleft() < static_cast<int32_t>(getMaxHealth()) && isValidTarget() && !hasBonusOfType(BonusType::SIEGE_WEAPON);
|
||||
}
|
||||
|
||||
bool CStack::isOnNativeTerrain() const
|
||||
|
Reference in New Issue
Block a user