Remove creature classes from Library lib, merged with Battling lib.
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:
101
src/Battling/Models/Creature.cpp
Normal file
101
src/Battling/Models/Creature.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include "Creature.hpp"
|
||||
#include "../Models/Battle.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
|
||||
Battling::Creature::Creature(const Library::CreatureSpecies* species, const Library::SpeciesVariant* variant,
|
||||
uint8_t level, uint32_t experience, Core::StatisticSet<uint8_t> statExp,
|
||||
Core::StatisticSet<uint8_t> statPotential, uint32_t uid, Library::Gender gender,
|
||||
uint8_t coloring, const Library::Item *heldItem, std::string nickname, int8_t talent,
|
||||
std::vector<LearnedAttack *> attacks)
|
||||
:
|
||||
__Species(species),
|
||||
__Variant(variant),
|
||||
__Level(level),
|
||||
__Experience(experience),
|
||||
__StatExperience(statExp),
|
||||
__StatPotential(statPotential),
|
||||
__UniqueIdentifier(uid),
|
||||
__Gender(gender),
|
||||
__Coloring(coloring),
|
||||
__HeldItem(heldItem),
|
||||
_nickname(nickname),
|
||||
_talentIndex(talent),
|
||||
_attacks(attacks)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
void Battling::Creature::ChangeLevel(int8_t amount) {
|
||||
this->__Level += amount;
|
||||
RecalculateFlatStats();
|
||||
}
|
||||
|
||||
void Battling::Creature::SetBattle(Battling::Battle *battle) {
|
||||
this->_battle = battle;
|
||||
}
|
||||
|
||||
void Battling::Creature::SetBattleLibrary(Battling::BattleLibrary *library) {
|
||||
this->_library = library;
|
||||
}
|
||||
|
||||
const std::string &Battling::Creature::GetNickname() const {
|
||||
if (_nickname.empty())
|
||||
return __Species->GetName();
|
||||
return _nickname;
|
||||
}
|
||||
|
||||
const std::string &Battling::Creature::GetTalent() const {
|
||||
return __Variant->GetTalent(_talentIndex);
|
||||
}
|
||||
|
||||
//region Stat APIs
|
||||
|
||||
void Battling::Creature::ChangeStatBoost(Core::Statistic stat, int8_t diffAmount){
|
||||
if (diffAmount > 0)
|
||||
this->_statBoost.IncreaseStatBy(stat, diffAmount);
|
||||
else
|
||||
this->_statBoost.DecreaseStatBy(stat, diffAmount);
|
||||
this->RecalculateBoostedStat(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetFlatStat(Core::Statistic stat) const{
|
||||
return _flatStats.GetStat(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetBoostedStat(Core::Statistic stat) const{
|
||||
return _boostedStats.GetStat(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetBaseStat(Core::Statistic stat) const {
|
||||
return __Variant->GetStatistic(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetStatPotential(Core::Statistic stat) const {
|
||||
return __StatPotential.GetStat(stat);
|
||||
}
|
||||
|
||||
uint32_t Battling::Creature::GetStatExperience(Core::Statistic stat) const {
|
||||
return __StatExperience.GetStat(stat);
|
||||
}
|
||||
|
||||
void Battling::Creature::RecalculateFlatStats() {
|
||||
this->_flatStats = this->_library->GetStatCalculator()->CalculateFlatStats(this);
|
||||
RecalculateBoostedStats();
|
||||
}
|
||||
void Battling::Creature::RecalculateBoostedStats() {
|
||||
this->_boostedStats = this->_library->GetStatCalculator()->CalculateFlatStats(this);
|
||||
}
|
||||
|
||||
void Battling::Creature::RecalculateFlatStat(Core::Statistic stat) {
|
||||
auto s = this->_library->GetStatCalculator()->CalculateFlatStat(this, stat);
|
||||
this->_flatStats.SetStat(stat, s);
|
||||
RecalculateBoostedStat(stat);
|
||||
}
|
||||
|
||||
void Battling::Creature::RecalculateBoostedStat(Core::Statistic stat) {
|
||||
auto s = this->_library->GetStatCalculator()->CalculateBoostedStat(this, stat);
|
||||
this->_boostedStats.SetStat(stat, s);
|
||||
}
|
||||
|
||||
//endregion
|
||||
Reference in New Issue
Block a user