Implement stat boosting

This commit is contained in:
Deukhoofd 2019-10-23 18:41:45 +02:00
parent 3e9d030dc4
commit cd21e6c685
4 changed files with 38 additions and 5 deletions

View File

@ -21,11 +21,11 @@ void Battling::BattleCreature::ApplyPostBattleEffects() {
} }
uint32_t Battling::BattleCreature::GetFlatStat(Core::Statistic stat) { uint32_t Battling::BattleCreature::GetFlatStat(Core::Statistic stat) const{
return _flatStats.GetStat(stat); return _flatStats.GetStat(stat);
} }
uint32_t Battling::BattleCreature::GetBoostedStat(Core::Statistic stat) { uint32_t Battling::BattleCreature::GetBoostedStat(Core::Statistic stat) const{
return _boostedStats.GetStat(stat); return _boostedStats.GetStat(stat);
} }
@ -46,4 +46,12 @@ void Battling::BattleCreature::RecalculateFlatStat(Core::Statistic stat) {
void Battling::BattleCreature::RecalculateBoostedStat(Core::Statistic stat) { void Battling::BattleCreature::RecalculateBoostedStat(Core::Statistic stat) {
auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateBoostedStat(this, stat); auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateBoostedStat(this, stat);
this->_boostedStats.SetStat(stat, s); this->_boostedStats.SetStat(stat, s);
}
void Battling::BattleCreature::ChangeStatBoost(Core::Statistic stat, int8_t diffAmount){
if (diffAmount > 0)
this->_statBoost.IncreaseStatBy(stat, diffAmount);
else
this->_statBoost.DecreaseStatBy(stat, diffAmount);
this->RecalculateBoostedStat(stat);
} }

View File

@ -24,13 +24,15 @@ namespace CreatureLib::Battling{
const Library::Creature* GetBackingCreature(); const Library::Creature* GetBackingCreature();
void ApplyPostBattleEffects(); void ApplyPostBattleEffects();
uint32_t GetFlatStat(Core::Statistic stat); uint32_t GetFlatStat(Core::Statistic stat) const;
uint32_t GetBoostedStat(Core::Statistic stat); uint32_t GetBoostedStat(Core::Statistic stat) const;
void RecalculateFlatStats(); void RecalculateFlatStats();
void RecalculateBoostedStats(); void RecalculateBoostedStats();
void RecalculateFlatStat(Core::Statistic); void RecalculateFlatStat(Core::Statistic);
void RecalculateBoostedStat(Core::Statistic); void RecalculateBoostedStat(Core::Statistic);
void ChangeStatBoost(Core::Statistic stat, int8_t diffAmount);
}; };
} }

View File

@ -55,6 +55,29 @@ namespace CreatureLib::Core{
} }
throw std::exception(); throw std::exception();
} }
inline void IncreaseStatBy(Statistic stat, T amount){
switch (stat){
case Health: _health += amount;
case PhysicalAttack: _physicalAttack += amount;
case PhysicalDefense: _physicalDefense += amount;
case MagicalAttack: _magicalAttack += amount;
case MagicalDefense: _magicalDefense += amount;
case Speed: _speed += amount;
}
throw std::exception();
}
inline void DecreaseStatBy(Statistic stat, T amount){
switch (stat){
case Health: _health -= amount;
case PhysicalAttack: _physicalAttack -= amount;
case PhysicalDefense: _physicalDefense -= amount;
case MagicalAttack: _magicalAttack -= amount;
case MagicalDefense: _magicalDefense -= amount;
case Speed: _speed -= amount;
}
throw std::exception();
}
}; };
} }