Update CreatureLib, handle getting formes cleaner.
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:
@@ -41,9 +41,16 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto rand = CreatureLib::Core::Random();
|
||||
const PkmnLib::Library::PokemonSpecies* species = nullptr;
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGetPkmnSpecies(this->_species, species)) {
|
||||
throw CreatureException("Invalid species: " + _species);
|
||||
std::stringstream err;
|
||||
err << "Invalid species '" << _species << "'.";
|
||||
throw CreatureException(err.str());
|
||||
}
|
||||
const PkmnLib::Library::PokemonForme* forme;
|
||||
if (!species->TryGetForme(this->_forme, forme)){
|
||||
std::stringstream err;
|
||||
err << "Invalid forme '" << _forme << "' for species '" << _forme << "'.";
|
||||
throw CreatureException(err.str());
|
||||
}
|
||||
auto forme = species->GetForme(this->_forme);
|
||||
int8_t ability;
|
||||
if (this->_ability.empty()) {
|
||||
ability = forme->GetRandomTalent(&rand);
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace PkmnLib::Battling {
|
||||
heldItem, nickname, talent, std::move(moves)),
|
||||
_individualValues(individualValues), _effortValues(effortValues), _nature(nature) {}
|
||||
|
||||
|
||||
const Library::PokemonForme* GetForme() const {
|
||||
return dynamic_cast<const Library::PokemonForme*>(GetVariant());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user