1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

remove healedHP calculation from battlestate

This commit is contained in:
AlexVinS
2014-11-25 19:43:34 +03:00
parent 20a058f3f9
commit fa9c1e8637
4 changed files with 14 additions and 19 deletions

View File

@ -159,19 +159,6 @@ CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, bool at
return ret; return ret;
} }
//Archangel
ui32 CBattleInfoCallback::calculateHealedHP(int healedHealth, const CSpell * spell, const CStack * stack) const
{
bool resurrect = spell->isRisingSpell();
return std::min<ui32>(healedHealth, stack->MaxHealth() - stack->firstHPleft + (resurrect ? stack->baseAmount * stack->MaxHealth() : 0));
}
//Casted by stack, no hero bonus applied
ui32 CBattleInfoCallback::calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const
{
bool resurrect = spell->isRisingSpell();
int healedHealth = usedSpellPower * spell->power + spell->getPower(spellSchoolLevel);
return std::min<ui32>(healedHealth, stack->MaxHealth() - stack->firstHPleft + (resurrect ? stack->baseAmount * stack->MaxHealth() : 0));
}
bool BattleInfo::resurrects(SpellID spellid) const bool BattleInfo::resurrects(SpellID spellid) const
{ {
return spellid.toSpell()->isRisingSpell(); return spellid.toSpell()->isRisingSpell();

View File

@ -281,8 +281,6 @@ public:
ESpellCastProblem::ESpellCastProblem battleCanCastThisSpellHere(PlayerColor player, const CSpell * spell, ECastingMode::ECastingMode mode, BattleHex dest) const; //checks if given player can cast given spell at given tile in given mode ESpellCastProblem::ESpellCastProblem battleCanCastThisSpellHere(PlayerColor player, const CSpell * spell, ECastingMode::ECastingMode mode, BattleHex dest) const; //checks if given player can cast given spell at given tile in given mode
ESpellCastProblem::ESpellCastProblem battleCanCreatureCastThisSpell(const CSpell * spell, BattleHex destination) const; //determines if creature can cast a spell here ESpellCastProblem::ESpellCastProblem battleCanCreatureCastThisSpell(const CSpell * spell, BattleHex destination) const; //determines if creature can cast a spell here
std::vector<BattleHex> battleGetPossibleTargets(PlayerColor player, const CSpell *spell) const; std::vector<BattleHex> battleGetPossibleTargets(PlayerColor player, const CSpell *spell) const;
ui32 calculateHealedHP(int healedHealth, const CSpell * spell, const CStack * stack) const; //for Archangel
ui32 calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const; //healing spells casted by stacks
SpellID battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode) const; SpellID battleGetRandomStackSpell(const CStack * stack, ERandomSpell mode) const;
SpellID getRandomBeneficialSpell(const CStack * subject) const; SpellID getRandomBeneficialSpell(const CStack * subject) const;

View File

@ -30,6 +30,7 @@ class CBattleInfoCallback;
class BattleInfo; class BattleInfo;
struct CPackForClient; struct CPackForClient;
struct BattleSpellCast;
class CRandomGenerator; class CRandomGenerator;
struct SpellSchoolInfo struct SpellSchoolInfo
@ -254,7 +255,6 @@ public:
} }
friend class CSpellHandler; friend class CSpellHandler;
friend class Graphics; friend class Graphics;
private: private:
void setIsOffensive(const bool val); void setIsOffensive(const bool val);
void setIsRising(const bool val); void setIsRising(const bool val);
@ -322,6 +322,10 @@ public:
{ {
h & objects ; h & objects ;
} }
public:
///Client-Server events. Shall be called only when applying packets
//void afterSpellCast(BattleInfo * battle, BattleSpellCast * packet) const;
protected: protected:
CSpell * loadFromJson(const JsonNode & json) override; CSpell * loadFromJson(const JsonNode & json) override;
}; };

View File

@ -453,7 +453,7 @@ int DefaultSpellMechanics::calculateDuration(const CGHeroInstance * caster, int
} }
void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment* env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
{ {
//applying effects //applying effects
if(owner->isOffensiveSpell()) if(owner->isOffensiveSpell())
@ -607,12 +607,18 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment* env,
hi.stackID = (attackedCre)->ID; hi.stackID = (attackedCre)->ID;
if (parameters.casterStack) //casted by creature if (parameters.casterStack) //casted by creature
{ {
const bool resurrect = owner->isRisingSpell();
if (hpGained) if (hpGained)
{ {
hi.healedHP = parameters.cb->calculateHealedHP(hpGained, owner, attackedCre); //archangel //archangel
hi.healedHP = std::min<ui32>(hpGained, attackedCre->MaxHealth() - attackedCre->firstHPleft + (resurrect ? attackedCre->baseAmount * attackedCre->MaxHealth() : 0));
} }
else else
hi.healedHP = parameters.cb->calculateHealedHP(owner, parameters.usedSpellPower, parameters.spellLvl, attackedCre); //any typical spell (commander's cure or animate dead) {
//any typical spell (commander's cure or animate dead)
int healedHealth = parameters.usedSpellPower * owner->power + owner->getPower(parameters.spellLvl);
hi.healedHP = std::min<ui32>(healedHealth, attackedCre->MaxHealth() - attackedCre->firstHPleft + (resurrect ? attackedCre->baseAmount * attackedCre->MaxHealth() : 0));
}
} }
else else
hi.healedHP = owner->calculateHealedHP(parameters.caster, attackedCre, parameters.selectedStack); //Casted by hero hi.healedHP = owner->calculateHealedHP(parameters.caster, attackedCre, parameters.selectedStack); //Casted by hero