Support for evolving a mon.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-06-10 12:33:51 +02:00
parent bb90d3db87
commit 9e587b3d0b
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 40 additions and 0 deletions

View File

@ -1 +1,38 @@
#include "Pokemon.hpp"
#include <CreatureLib/Battling/Models/Battle.hpp>
void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
ArbUt::BorrowedPtr<const Library::PokemonForme> forme) {
_species = mon.ForceAs<const CreatureLib::Library::CreatureSpecies>();
_variant = forme.ForceAs<const CreatureLib::Library::SpeciesVariant>();
ArbUt::Random* rand;
if (!_battle.IsNull()) {
rand = &_battle->GetRandom()->GetRNG();
} else {
rand = new ArbUt::Random();
}
if (_gender != CreatureLib::Library::Gender::Genderless && _species->GetGenderRate() != -1) {
_gender = _species->GetRandomGender(*rand);
} else if (_species->GetGenderRate() == -1 && _gender != CreatureLib::Library::Gender::Genderless) {
_gender = CreatureLib::Library::Gender::Genderless;
}
_types.clear();
for (auto t : forme->GetTypes()) {
_types.insert(t);
}
_activeTalent =
std::unique_ptr<CreatureLib::Battling::Script>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
auto currentMaxHealth = GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints);
RecalculateFlatStats();
auto diffHealth = GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints) - currentMaxHealth;
_currentHealth += diffHealth;
if (_currentHealth < 0)
_currentHealth = 0;
// TODO: Learn moves?
}

View File

@ -56,6 +56,9 @@ namespace PkmnLib::Battling {
inline ArbUt::BorrowedPtr<const PkmnLib::Library::PokemonSpecies> GetPokemonSpecies() const noexcept {
return _species.As<const PkmnLib::Library::PokemonSpecies>();
}
void Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
ArbUt::BorrowedPtr<const Library::PokemonForme> forme);
};
}