diff --git a/src/Battling/Pokemon/Pokemon.cpp b/src/Battling/Pokemon/Pokemon.cpp index 71f641f..16e01fd 100644 --- a/src/Battling/Pokemon/Pokemon.cpp +++ b/src/Battling/Pokemon/Pokemon.cpp @@ -1 +1,38 @@ #include "Pokemon.hpp" +#include + +void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr mon, + ArbUt::BorrowedPtr forme) { + _species = mon.ForceAs(); + _variant = forme.ForceAs(); + + 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(_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? +} diff --git a/src/Battling/Pokemon/Pokemon.hpp b/src/Battling/Pokemon/Pokemon.hpp index a6d60c3..18d8933 100644 --- a/src/Battling/Pokemon/Pokemon.hpp +++ b/src/Battling/Pokemon/Pokemon.hpp @@ -56,6 +56,9 @@ namespace PkmnLib::Battling { inline ArbUt::BorrowedPtr GetPokemonSpecies() const noexcept { return _species.As(); } + + void Evolve(ArbUt::BorrowedPtr mon, + ArbUt::BorrowedPtr forme); }; }