Rework for C Interfaces to handle exceptions a bit better.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -24,7 +24,12 @@ Battling::Creature::Creature(const BattleLibrary* library, const Library::Creatu
|
||||
}
|
||||
|
||||
void Battling::Creature::ChangeLevelBy(int8_t amount) {
|
||||
this->_level += amount;
|
||||
auto level = _level + amount;
|
||||
if (level > _library->GetSettings()->GetMaximalLevel())
|
||||
level = _library->GetSettings()->GetMaximalLevel();
|
||||
if (level < 1)
|
||||
level = 1;
|
||||
_level = level;
|
||||
_experience = _library->GetGrowthRateLibrary()->CalculateExperience(_species->GetGrowthRate(), _level);
|
||||
RecalculateFlatStats();
|
||||
}
|
||||
@@ -52,13 +57,17 @@ void Battling::Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmo
|
||||
this->RecalculateBoostedStat(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetFlatStat(Library::Statistic stat) const { return _flatStats.GetStat(stat); }
|
||||
uint32_t Battling::Creature::GetFlatStat(Library::Statistic stat) const noexcept { return _flatStats.GetStat(stat); }
|
||||
|
||||
uint32_t Battling::Creature::GetBoostedStat(Library::Statistic stat) const { return _boostedStats.GetStat(stat); }
|
||||
uint32_t Battling::Creature::GetBoostedStat(Library::Statistic stat) const noexcept {
|
||||
return _boostedStats.GetStat(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetBaseStat(Library::Statistic stat) const { return _variant->GetStatistic(stat); }
|
||||
uint32_t Battling::Creature::GetBaseStat(Library::Statistic stat) const noexcept {
|
||||
return _variant->GetStatistic(stat);
|
||||
}
|
||||
|
||||
int8_t Battling::Creature::GetStatBoost(Library::Statistic stat) const { return _statBoost.GetStat(stat); }
|
||||
int8_t Battling::Creature::GetStatBoost(Library::Statistic stat) const noexcept { return _statBoost.GetStat(stat); }
|
||||
|
||||
void Battling::Creature::RecalculateFlatStats() {
|
||||
auto statCalc = this->_library->GetStatCalculator();
|
||||
@@ -174,13 +183,13 @@ void Battling::Creature::AddExperience(uint32_t amount) {
|
||||
_experience = exp;
|
||||
_level = level;
|
||||
}
|
||||
const Library::CreatureSpecies* Battling::Creature::GetDisplaySpecies() const {
|
||||
const Library::CreatureSpecies* Battling::Creature::GetDisplaySpecies() const noexcept {
|
||||
auto species = _displaySpecies;
|
||||
if (species == nullptr)
|
||||
species = _species;
|
||||
return species;
|
||||
}
|
||||
const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() const {
|
||||
const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() const noexcept {
|
||||
auto variant = _displayVariant;
|
||||
if (variant == nullptr)
|
||||
variant = _variant;
|
||||
|
||||
Reference in New Issue
Block a user