Update CreatureLib, handle getting formes cleaner.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
dd45fea342
commit
7aa29e4543
|
@ -44,7 +44,7 @@ class PkmnLibConan(ConanFile):
|
|||
self.options["AngelScript"].link_std_statically = True
|
||||
|
||||
def requirements(self):
|
||||
self.requires("CreatureLib/611198009b81f58f72011887ecc0e1bf2c93e342@creaturelib/master")
|
||||
self.requires("CreatureLib/667821df28235613bf46549734a2799b5537566f@creaturelib/master")
|
||||
if self.options.script_handler == "angelscript":
|
||||
self.requires("AngelScript/2.34@AngelScript/Deukhoofd")
|
||||
else:
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,12 @@ namespace PkmnLib::Library {
|
|||
return reinterpret_cast<const PokemonForme*>(CreatureSpecies::GetVariant("default"));
|
||||
}
|
||||
|
||||
inline bool HasForme(const std::string& key) const { return HasVariant(key); }
|
||||
|
||||
inline bool TryGetForme(const std::string& key, const PokemonForme*& forme) const {
|
||||
return TryGetVariant(key, (const CreatureLib::Library::SpeciesVariant*&)forme);
|
||||
}
|
||||
|
||||
inline const PokemonForme* GetForme(const std::string& key) const {
|
||||
return reinterpret_cast<const PokemonForme*>(CreatureSpecies::GetVariant(key));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue