mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Fixed issues from review
This commit is contained in:
@ -44,17 +44,15 @@ namespace BattlePhases
|
|||||||
// Healed HP (also drained life) and resurrected units info
|
// Healed HP (also drained life) and resurrected units info
|
||||||
struct HealInfo
|
struct HealInfo
|
||||||
{
|
{
|
||||||
HealInfo()
|
HealInfo() = default;
|
||||||
: healedHealthPoints(0), resurrectedCount(0)
|
|
||||||
{ }
|
|
||||||
HealInfo(int64_t healedHP, int32_t resurrected)
|
HealInfo(int64_t healedHP, int32_t resurrected)
|
||||||
: healedHealthPoints(healedHP), resurrectedCount(resurrected)
|
: healedHealthPoints(healedHP), resurrectedCount(resurrected)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
int64_t healedHealthPoints;
|
int64_t healedHealthPoints = 0;
|
||||||
int32_t resurrectedCount;
|
int32_t resurrectedCount = 0;
|
||||||
|
|
||||||
HealInfo& operator +=(const HealInfo& other)
|
HealInfo & operator+=(const HealInfo & other)
|
||||||
{
|
{
|
||||||
healedHealthPoints += other.healedHealthPoints;
|
healedHealthPoints += other.healedHealthPoints;
|
||||||
resurrectedCount += other.resurrectedCount;
|
resurrectedCount += other.resurrectedCount;
|
||||||
|
@ -122,7 +122,6 @@ int32_t Summon::summonedCreatureAmount(const Mechanics * m) const
|
|||||||
|
|
||||||
void Summon::apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const
|
void Summon::apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const
|
||||||
{
|
{
|
||||||
using battle::HealInfo;
|
|
||||||
BattleUnitsChanged pack;
|
BattleUnitsChanged pack;
|
||||||
pack.battleID = m->battle()->getBattle()->getBattleID();
|
pack.battleID = m->battle()->getBattle()->getBattleID();
|
||||||
|
|
||||||
|
@ -960,14 +960,14 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const
|
|||||||
|
|
||||||
// only primary target
|
// only primary target
|
||||||
if(defender->alive())
|
if(defender->alive())
|
||||||
applyBattleEffects(battle, bat, attackerState, fireShield, defender, &healInfo, distance, false);
|
applyBattleEffects(battle, bat, attackerState, fireShield, defender, healInfo, distance, false);
|
||||||
|
|
||||||
//multiple-hex normal attack
|
//multiple-hex normal attack
|
||||||
std::set<const CStack*> attackedCreatures = battle.getAttackedCreatures(attacker, targetHex, bat.shot()); //creatures other than primary target
|
std::set<const CStack*> attackedCreatures = battle.getAttackedCreatures(attacker, targetHex, bat.shot()); //creatures other than primary target
|
||||||
for(const CStack * stack : attackedCreatures)
|
for(const CStack * stack : attackedCreatures)
|
||||||
{
|
{
|
||||||
if(stack != defender && stack->alive()) //do not hit same stack twice
|
if(stack != defender && stack->alive()) //do not hit same stack twice
|
||||||
applyBattleEffects(battle, bat, attackerState, fireShield, stack, &healInfo, distance, true);
|
applyBattleEffects(battle, bat, attackerState, fireShield, stack, healInfo, distance, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const Bonus> bonus = attacker->getFirstBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK));
|
std::shared_ptr<const Bonus> bonus = attacker->getFirstBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK));
|
||||||
@ -995,7 +995,7 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const
|
|||||||
{
|
{
|
||||||
if(stack != defender && stack->alive()) //do not hit same stack twice
|
if(stack != defender && stack->alive()) //do not hit same stack twice
|
||||||
{
|
{
|
||||||
applyBattleEffects(battle, bat, attackerState, fireShield, stack, &healInfo, distance, true);
|
applyBattleEffects(battle, bat, attackerState, fireShield, stack, healInfo, distance, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1425,7 +1425,7 @@ void BattleActionProcessor::handleAfterAttackCasting(const CBattleInfoCallback &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr<battle::CUnitState> attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo * healInfo, int distance, bool secondary) const
|
void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr<battle::CUnitState> attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo & healInfo, int distance, bool secondary) const
|
||||||
{
|
{
|
||||||
BattleStackAttacked bsa;
|
BattleStackAttacked bsa;
|
||||||
if(secondary)
|
if(secondary)
|
||||||
@ -1446,13 +1446,11 @@ void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battl
|
|||||||
CStack::prepareAttacked(bsa, gameHandler->getRandomGenerator(), bai.defender->acquireState()); //calculate casualties
|
CStack::prepareAttacked(bsa, gameHandler->getRandomGenerator(), bai.defender->acquireState()); //calculate casualties
|
||||||
}
|
}
|
||||||
|
|
||||||
battle::HealInfo tmpHealInfo;
|
|
||||||
|
|
||||||
//life drain handling
|
//life drain handling
|
||||||
if(attackerState->hasBonusOfType(BonusType::LIFE_DRAIN) && def->isLiving())
|
if(attackerState->hasBonusOfType(BonusType::LIFE_DRAIN) && def->isLiving())
|
||||||
{
|
{
|
||||||
int64_t toHeal = bsa.damageAmount * attackerState->valOfBonuses(BonusType::LIFE_DRAIN) / 100;
|
int64_t toHeal = bsa.damageAmount * attackerState->valOfBonuses(BonusType::LIFE_DRAIN) / 100;
|
||||||
tmpHealInfo += attackerState->heal(toHeal, EHealLevel::RESURRECT, EHealPower::PERMANENT);
|
healInfo += attackerState->heal(toHeal, EHealLevel::RESURRECT, EHealPower::PERMANENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//soul steal handling
|
//soul steal handling
|
||||||
@ -1466,12 +1464,11 @@ void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battl
|
|||||||
{
|
{
|
||||||
int64_t toHeal = bsa.killedAmount * attackerState->valOfBonuses(BonusType::SOUL_STEAL, subtype) * attackerState->getMaxHealth();
|
int64_t toHeal = bsa.killedAmount * attackerState->valOfBonuses(BonusType::SOUL_STEAL, subtype) * attackerState->getMaxHealth();
|
||||||
bool permanent = subtype == BonusCustomSubtype::soulStealPermanent;
|
bool permanent = subtype == BonusCustomSubtype::soulStealPermanent;
|
||||||
tmpHealInfo += attackerState->heal(toHeal, EHealLevel::OVERHEAL, (permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE));
|
healInfo += attackerState->heal(toHeal, EHealLevel::OVERHEAL, (permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*healInfo += tmpHealInfo;
|
|
||||||
bat.bsa.push_back(bsa); //add this stack to the list of victims after drain life has been calculated
|
bat.bsa.push_back(bsa); //add this stack to the list of victims after drain life has been calculated
|
||||||
|
|
||||||
//fire shield handling
|
//fire shield handling
|
||||||
|
@ -54,7 +54,7 @@ class BattleActionProcessor : boost::noncopyable
|
|||||||
std::set<SpellID> getSpellsForAttackCasting(TConstBonusListPtr spells, const CStack *defender);
|
std::set<SpellID> getSpellsForAttackCasting(TConstBonusListPtr spells, const CStack *defender);
|
||||||
|
|
||||||
// damage, drain life & fire shield; returns amount of drained life
|
// damage, drain life & fire shield; returns amount of drained life
|
||||||
void applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr<battle::CUnitState> attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo * healInfo, int distance, bool secondary) const;
|
void applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr<battle::CUnitState> attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo & healInfo, int distance, bool secondary) const;
|
||||||
|
|
||||||
void sendGenericKilledLog(const CBattleInfoCallback & battle, const CStack * defender, int32_t killed, bool multiple);
|
void sendGenericKilledLog(const CBattleInfoCallback & battle, const CStack * defender, int32_t killed, bool multiple);
|
||||||
void addGenericKilledLog(BattleLogMessage & blm, const CStack * defender, int32_t killed, bool multiple) const;
|
void addGenericKilledLog(BattleLogMessage & blm, const CStack * defender, int32_t killed, bool multiple) const;
|
||||||
|
Reference in New Issue
Block a user