#include "Pokemon.hpp" #include #include "../EventHooks/StatusChangeEvent.hpp" #include "../PkmnScriptCategory.hpp" void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr mon, ArbUt::BorrowedPtr forme) { // Set species and variant _species = mon.ForceAs(); ChangeVariant(forme.ForceAs()); // If the pokemon is genderless, but it's new evolution is not, we want to set its gender if (_gender != CreatureLib::Library::Gender::Genderless && _species->GetGenderRate() != -1) { // If we are currently in battle, use the battle random so we can get predictable events. if (_battle.HasValue()) { _gender = _species->GetRandomGender(_battle.GetValue()->GetRandom()->GetRNG()); } // Else create a new random. else { ArbUt::Random rand; _gender = _species->GetRandomGender(rand); } // Else if the new pokemon species is genderless, but the pokemon has a gender, make the Pokemon genderless. } else if (_species->GetGenderRate() == -1 && _gender != CreatureLib::Library::Gender::Genderless) { _gender = CreatureLib::Library::Gender::Genderless; } // TODO: Learn moves? // TODO: Event hook } void PkmnLib::Battling::Pokemon::SetStatus(const ArbUt::StringView& name) { if (_statusScript != nullptr) { _statusScript->OnRemove(); } _statusScript = std::unique_ptr( _library->LoadScript(static_cast(PkmnScriptCategory::Status), name)); if (_battle.HasValue()) { _battle.GetValue()->TriggerEventListener(this, name); } } void PkmnLib::Battling::Pokemon::ClearStatus() { if (_statusScript == nullptr) return; _statusScript->OnRemove(); _statusScript = nullptr; if (_battle.HasValue()) { _battle.GetValue()->TriggerEventListener(this, ""_cnc); } }