1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-01 00:45:26 +02:00

vcmi: split bonus to enumerator and HeroBonus.h

This commit is contained in:
Konstantin
2023-05-01 01:20:01 +03:00
committed by Konstantin P
parent 9f5ee885b4
commit 05eccbc2bb
123 changed files with 1321 additions and 1350 deletions

View File

@ -85,8 +85,8 @@ void CAmmo::serializeJson(JsonSerializeFormat & handler)
///CShots
CShots::CShots(const battle::Unit * Owner)
: CAmmo(Owner, Selector::type()(Bonus::SHOTS)),
shooter(Owner, Selector::type()(Bonus::SHOOTER))
: CAmmo(Owner, Selector::type()(BonusType::SHOTS)),
shooter(Owner, Selector::type()(BonusType::SHOOTER))
{
}
@ -117,16 +117,16 @@ int32_t CShots::total() const
///CCasts
CCasts::CCasts(const battle::Unit * Owner):
CAmmo(Owner, Selector::type()(Bonus::CASTS))
CAmmo(Owner, Selector::type()(BonusType::CASTS))
{
}
///CRetaliations
CRetaliations::CRetaliations(const battle::Unit * Owner)
: CAmmo(Owner, Selector::type()(Bonus::ADDITIONAL_RETALIATION)),
: CAmmo(Owner, Selector::type()(BonusType::ADDITIONAL_RETALIATION)),
totalCache(0),
noRetaliation(Owner, Selector::type()(Bonus::SIEGE_WEAPON).Or(Selector::type()(Bonus::HYPNOTIZED)).Or(Selector::type()(Bonus::NO_RETALIATION))),
unlimited(Owner, Selector::type()(Bonus::UNLIMITED_RETALIATIONS))
noRetaliation(Owner, Selector::type()(BonusType::SIEGE_WEAPON).Or(Selector::type()(BonusType::HYPNOTIZED)).Or(Selector::type()(BonusType::NO_RETALIATION))),
unlimited(Owner, Selector::type()(BonusType::UNLIMITED_RETALIATIONS))
{
}
@ -339,13 +339,13 @@ CUnitState::CUnitState():
counterAttacks(this),
health(this),
shots(this),
totalAttacks(this, Selector::type()(Bonus::ADDITIONAL_ATTACK), 1),
minDamage(this, Selector::typeSubtype(Bonus::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(Bonus::CREATURE_DAMAGE, 1)), 0),
maxDamage(this, Selector::typeSubtype(Bonus::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(Bonus::CREATURE_DAMAGE, 2)), 0),
attack(this, Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK), 0),
defence(this, Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE), 0),
inFrenzy(this, Selector::type()(Bonus::IN_FRENZY)),
cloneLifetimeMarker(this, Selector::type()(Bonus::NONE).And(Selector::source(Bonus::SPELL_EFFECT, SpellID::CLONE))),
totalAttacks(this, Selector::type()(BonusType::ADDITIONAL_ATTACK), 1),
minDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 1)), 0),
maxDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 2)), 0),
attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK), 0),
defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE), 0),
inFrenzy(this, Selector::type()(BonusType::IN_FRENZY)),
cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, SpellID::CLONE))),
cloneID(-1)
{
@ -430,7 +430,7 @@ const CGHeroInstance * CUnitState::getHeroCaster() const
int32_t CUnitState::getSpellSchoolLevel(const spells::Spell * spell, int32_t * outSelectedSchool) const
{
int32_t skill = valOfBonuses(Selector::typeSubtype(Bonus::SPELLCASTER, spell->getIndex()));
int32_t skill = valOfBonuses(Selector::typeSubtype(BonusType::SPELLCASTER, spell->getIndex()));
vstd::abetween(skill, 0, 3);
return skill;
}
@ -453,12 +453,12 @@ int32_t CUnitState::getEffectLevel(const spells::Spell * spell) const
int32_t CUnitState::getEffectPower(const spells::Spell * spell) const
{
return valOfBonuses(Bonus::CREATURE_SPELL_POWER) * getCount() / 100;
return valOfBonuses(BonusType::CREATURE_SPELL_POWER) * getCount() / 100;
}
int32_t CUnitState::getEnchantPower(const spells::Spell * spell) const
{
int32_t res = valOfBonuses(Bonus::CREATURE_ENCHANT_POWER);
int32_t res = valOfBonuses(BonusType::CREATURE_ENCHANT_POWER);
if(res <= 0)
res = 3;//default for creatures
return res;
@ -466,7 +466,7 @@ int32_t CUnitState::getEnchantPower(const spells::Spell * spell) const
int64_t CUnitState::getEffectValue(const spells::Spell * spell) const
{
return static_cast<int64_t>(getCount()) * valOfBonuses(Bonus::SPECIFIC_SPELL_POWER, spell->getIndex());
return static_cast<int64_t>(getCount()) * valOfBonuses(BonusType::SPECIFIC_SPELL_POWER, spell->getIndex());
}
PlayerColor CUnitState::getCasterOwner() const
@ -511,7 +511,7 @@ bool CUnitState::isGhost() const
bool CUnitState::isFrozen() const
{
return hasBonus(Selector::source(Bonus::SPELL_EFFECT, SpellID::STONE_GAZE), Selector::all);
return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, SpellID::STONE_GAZE), Selector::all);
}
bool CUnitState::isValidTarget(bool allowDead) const
@ -588,12 +588,12 @@ void CUnitState::setPosition(BattleHex hex)
int32_t CUnitState::getInitiative(int turn) const
{
return valOfBonuses(Selector::type()(Bonus::STACKS_SPEED).And(Selector::turns(turn)));
return valOfBonuses(Selector::type()(BonusType::STACKS_SPEED).And(Selector::turns(turn)));
}
bool CUnitState::canMove(int turn) const
{
return alive() && !hasBonus(Selector::type()(Bonus::NOT_ACTIVE).And(Selector::turns(turn))); //eg. Ammo Cart or blinded creature
return alive() && !hasBonus(Selector::type()(BonusType::NOT_ACTIVE).And(Selector::turns(turn))); //eg. Ammo Cart or blinded creature
}
bool CUnitState::defended(int turn) const