Split off battle creature stats into boosted and non-boosted
This commit is contained in:
parent
bc7c42c50d
commit
65cf190367
|
@ -4,15 +4,27 @@
|
||||||
using namespace CreatureLib;
|
using namespace CreatureLib;
|
||||||
|
|
||||||
Core::StatisticSet<uint32_t>
|
Core::StatisticSet<uint32_t>
|
||||||
Battling::BattleStatCalculator::CalculateStats(Battling::BattleCreature *creature) const {
|
Battling::BattleStatCalculator::CalculateFlatStats(Battling::BattleCreature *creature) const {
|
||||||
return Core::StatisticSet<uint32_t>(
|
return Core::StatisticSet<uint32_t>(
|
||||||
CalculateStat(creature, Core::Statistic::Health),
|
CalculateFlatStat(creature, Core::Statistic::Health),
|
||||||
CalculateStat(creature, Core::Statistic::PhysicalAttack),
|
CalculateFlatStat(creature, Core::Statistic::PhysicalAttack),
|
||||||
CalculateStat(creature, Core::Statistic::PhysicalDefense),
|
CalculateFlatStat(creature, Core::Statistic::PhysicalDefense),
|
||||||
CalculateStat(creature, Core::Statistic::MagicalAttack),
|
CalculateFlatStat(creature, Core::Statistic::MagicalAttack),
|
||||||
CalculateStat(creature, Core::Statistic::MagicalDefense),
|
CalculateFlatStat(creature, Core::Statistic::MagicalDefense),
|
||||||
CalculateStat(creature, Core::Statistic::Speed)
|
CalculateFlatStat(creature, Core::Statistic::Speed)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::StatisticSet<uint32_t>
|
||||||
|
Battling::BattleStatCalculator::CalculateBoostedStats(Battling::BattleCreature *creature) const {
|
||||||
|
return Core::StatisticSet<uint32_t>(
|
||||||
|
CalculateBoostedStat(creature, Core::Statistic::Health),
|
||||||
|
CalculateBoostedStat(creature, Core::Statistic::PhysicalAttack),
|
||||||
|
CalculateBoostedStat(creature, Core::Statistic::PhysicalDefense),
|
||||||
|
CalculateBoostedStat(creature, Core::Statistic::MagicalAttack),
|
||||||
|
CalculateBoostedStat(creature, Core::Statistic::MagicalDefense),
|
||||||
|
CalculateBoostedStat(creature, Core::Statistic::Speed)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CalculateHealthStat(Battling::BattleCreature *creature){
|
uint32_t CalculateHealthStat(Battling::BattleCreature *creature){
|
||||||
|
@ -32,8 +44,12 @@ uint32_t CalculateOtherStat(Battling::BattleCreature *creature, Core::Statistic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t Battling::BattleStatCalculator::CalculateStat(Battling::BattleCreature *creature, Core::Statistic stat) const{
|
uint32_t Battling::BattleStatCalculator::CalculateFlatStat(Battling::BattleCreature *creature, Core::Statistic stat) const{
|
||||||
if (stat == Core::Statistic::Health)
|
if (stat == Core::Statistic::Health)
|
||||||
return CalculateHealthStat(creature);
|
return CalculateHealthStat(creature);
|
||||||
return CalculateOtherStat(creature, stat);
|
return CalculateOtherStat(creature, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Battling::BattleStatCalculator::CalculateBoostedStat(Battling::BattleCreature *creature, Core::Statistic stat) const{
|
||||||
|
throw "TODO";
|
||||||
|
}
|
||||||
|
|
|
@ -9,8 +9,10 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
class BattleStatCalculator {
|
class BattleStatCalculator {
|
||||||
public:
|
public:
|
||||||
virtual Core::StatisticSet<uint32_t > CalculateStats(BattleCreature* creature) const;
|
virtual Core::StatisticSet<uint32_t > CalculateFlatStats(BattleCreature* creature) const;
|
||||||
virtual uint32_t CalculateStat(BattleCreature* creature, Core::Statistic stat) const;
|
virtual Core::StatisticSet<uint32_t > CalculateBoostedStats(BattleCreature* creature) const;
|
||||||
|
virtual uint32_t CalculateFlatStat(BattleCreature* creature, Core::Statistic stat) const;
|
||||||
|
virtual uint32_t CalculateBoostedStat(BattleCreature* creature, Core::Statistic stat) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,27 @@ void Battling::BattleCreature::ApplyPostBattleEffects() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Battling::BattleCreature::GetStat(Core::Statistic stat) {
|
uint32_t Battling::BattleCreature::GetFlatStat(Core::Statistic stat) {
|
||||||
return _fullStats.GetStat(stat);
|
return _flatStats.GetStat(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battling::BattleCreature::RecalculateStats() {
|
uint32_t Battling::BattleCreature::GetBoostedStat(Core::Statistic stat) {
|
||||||
this->_fullStats = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateStats(this);
|
return _boostedStats.GetStat(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battling::BattleCreature::RecalculateStat(Core::Statistic stat) {
|
void Battling::BattleCreature::RecalculateFlatStats() {
|
||||||
auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateStat(this, stat);
|
this->_flatStats = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateFlatStats(this);
|
||||||
this->_fullStats.SetStat(stat, s);
|
}
|
||||||
|
void Battling::BattleCreature::RecalculateBoostedStats() {
|
||||||
|
this->_boostedStats = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateFlatStats(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Battling::BattleCreature::RecalculateFlatStat(Core::Statistic stat) {
|
||||||
|
auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateFlatStat(this, stat);
|
||||||
|
this->_flatStats.SetStat(stat, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Battling::BattleCreature::RecalculateBoostedStat(Core::Statistic stat) {
|
||||||
|
auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateBoostedStat(this, stat);
|
||||||
|
this->_boostedStats.SetStat(stat, s);
|
||||||
|
}
|
|
@ -15,7 +15,8 @@ namespace CreatureLib::Battling{
|
||||||
private:
|
private:
|
||||||
Library::Creature* _creature;
|
Library::Creature* _creature;
|
||||||
Core::StatisticSet<int8_t > _statBoost;
|
Core::StatisticSet<int8_t > _statBoost;
|
||||||
Core::StatisticSet<uint32_t > _fullStats;
|
Core::StatisticSet<uint32_t > _flatStats;
|
||||||
|
Core::StatisticSet<uint32_t > _boostedStats;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BattleCreature(Battle* battle, Library::Creature* creature);
|
BattleCreature(Battle* battle, Library::Creature* creature);
|
||||||
|
@ -23,10 +24,13 @@ namespace CreatureLib::Battling{
|
||||||
const Library::Creature* GetBackingCreature();
|
const Library::Creature* GetBackingCreature();
|
||||||
void ApplyPostBattleEffects();
|
void ApplyPostBattleEffects();
|
||||||
|
|
||||||
uint32_t GetStat(Core::Statistic stat);
|
uint32_t GetFlatStat(Core::Statistic stat);
|
||||||
void RecalculateStats();
|
uint32_t GetBoostedStat(Core::Statistic stat);
|
||||||
|
void RecalculateFlatStats();
|
||||||
|
void RecalculateBoostedStats();
|
||||||
|
|
||||||
void RecalculateStat(Core::Statistic);
|
void RecalculateFlatStat(Core::Statistic);
|
||||||
|
void RecalculateBoostedStat(Core::Statistic);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#include <exception>
|
|
||||||
#include "StatisticSet.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
CreatureLib::Core::StatisticSet<T>::StatisticSet()
|
|
||||||
: _health(0), _physicalAttack(0), _physicalDefense(0), _magicalAttack(0), _magicalDefense(0), _speed(0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -20,7 +20,9 @@ namespace CreatureLib::Core{
|
||||||
: _health(health), _physicalAttack(physicalAttack),
|
: _health(health), _physicalAttack(physicalAttack),
|
||||||
_physicalDefense(physicalDefense), _magicalAttack(magicalAttack),
|
_physicalDefense(physicalDefense), _magicalAttack(magicalAttack),
|
||||||
_magicalDefense(magicalDefense), _speed(speed){}
|
_magicalDefense(magicalDefense), _speed(speed){}
|
||||||
StatisticSet();
|
StatisticSet()
|
||||||
|
: _health(0), _physicalAttack(0), _physicalDefense(0), _magicalAttack(0), _magicalDefense(0), _speed(0)
|
||||||
|
{}
|
||||||
|
|
||||||
inline T GetHealth() const{ return _health; }
|
inline T GetHealth() const{ return _health; }
|
||||||
inline T GetPhysicalAttack() const{ return _physicalAttack; }
|
inline T GetPhysicalAttack() const{ return _physicalAttack; }
|
||||||
|
|
Loading…
Reference in New Issue