Added functionality to get full stats from creature
This commit is contained in:
		@@ -34,3 +34,26 @@ std::string CreatureLib::Library::Creature::GetNickname() const {
 | 
			
		||||
        return __Species->GetName();
 | 
			
		||||
    return _nickname;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int32_t CalculateHealth(const CreatureLib::Library::Creature* creature){
 | 
			
		||||
    auto baseStat = creature->GetVariant()->GetStatistic(CreatureLib::Core::Statistic::Health);
 | 
			
		||||
    auto statPotential = creature->GetStatPotential().GetHealth();
 | 
			
		||||
    auto statExperience = creature->GetStatExperience().GetHealth();
 | 
			
		||||
    auto level = creature->GetLevel();
 | 
			
		||||
    return ((2 * baseStat + statPotential + (statExperience / 4) * level) / 100) + level + 10;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int32_t CalculateStat(const CreatureLib::Library::Creature* creature, CreatureLib::Core::Statistic stat){
 | 
			
		||||
    auto baseStat = creature->GetVariant()->GetStatistic(stat);
 | 
			
		||||
    auto statPotential = creature->GetStatPotential().GetStat(stat);
 | 
			
		||||
    auto statExperience = creature->GetStatExperience().GetStat(stat);
 | 
			
		||||
    auto level = creature->GetLevel();
 | 
			
		||||
    return ((2 * baseStat + statPotential + (statExperience / 4) * level) / 100) + 5;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int32_t CreatureLib::Library::Creature::CalculateFullStat(CreatureLib::Core::Statistic stat) const {
 | 
			
		||||
    if (stat == Core::Statistic::Health)
 | 
			
		||||
        return CalculateHealth(this);
 | 
			
		||||
    return CalculateStat(this, stat);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,8 +30,11 @@ namespace CreatureLib::Library{
 | 
			
		||||
                Core::StatisticSet statPotential,  uint32_t identifier, Gender gender,
 | 
			
		||||
                uint8_t coloring, const Item* heldItem);
 | 
			
		||||
 | 
			
		||||
        virtual ~Creature(){}
 | 
			
		||||
 | 
			
		||||
        std::string GetTalent() const;
 | 
			
		||||
        std::string GetNickname() const;
 | 
			
		||||
        virtual int32_t CalculateFullStat(Core::Statistic stat) const;
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,9 @@
 | 
			
		||||
CreatureLib::Library::DataLibrary::DataLibrary(CreatureLib::Library::SpeciesLibrary *species,
 | 
			
		||||
                                               CreatureLib::Library::AttackLibrary *attacks,
 | 
			
		||||
                                               CreatureLib::Library::ItemLibrary *items,
 | 
			
		||||
                                               CreatureLib::Library::GrowthRateLibrary* growthRates)
 | 
			
		||||
                                               :_species(species), _attacks(attacks), _items(items), _growthRates(growthRates)
 | 
			
		||||
 | 
			
		||||
                                               {
 | 
			
		||||
                                               CreatureLib::Library::GrowthRateLibrary *growthRates)
 | 
			
		||||
                                               : _species(species), _attacks(attacks), _items(items),
 | 
			
		||||
                                               _growthRates(growthRates){
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,12 @@ namespace CreatureLib::Library {
 | 
			
		||||
        const ItemLibrary* _items;
 | 
			
		||||
        const GrowthRateLibrary* _growthRates;
 | 
			
		||||
    public:
 | 
			
		||||
        DataLibrary(SpeciesLibrary* species, AttackLibrary* attacks, ItemLibrary* items, GrowthRateLibrary* growthRates);
 | 
			
		||||
        DataLibrary(CreatureLib::Library::SpeciesLibrary *species,
 | 
			
		||||
                    CreatureLib::Library::AttackLibrary *attacks,
 | 
			
		||||
                    CreatureLib::Library::ItemLibrary *items,
 | 
			
		||||
                    CreatureLib::Library::GrowthRateLibrary *growthRates
 | 
			
		||||
                    );
 | 
			
		||||
 | 
			
		||||
        ~DataLibrary(){
 | 
			
		||||
            delete _species;
 | 
			
		||||
            delete _attacks;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user