Updates CreatureLib, implements ConstStrings.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "CreatePokemon.hpp"
|
||||
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(CreatureLib::Core::Random rand) {
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(Arbutils::Random rand) {
|
||||
_ivHp = rand.Get(0, 32);
|
||||
_ivAttack = rand.Get(0, 32);
|
||||
_ivDefense = rand.Get(0, 32);
|
||||
@@ -38,15 +37,15 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa
|
||||
}
|
||||
|
||||
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto rand = CreatureLib::Core::Random();
|
||||
auto rand = Arbutils::Random();
|
||||
const PkmnLib::Library::PokemonSpecies* species = nullptr;
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species.c_str(), species)) {
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) {
|
||||
std::stringstream err;
|
||||
err << "Invalid species '" << _species << "'.";
|
||||
throw CreatureException(err.str());
|
||||
}
|
||||
const PkmnLib::Library::PokemonForme* forme;
|
||||
if (!species->TryGetForme(this->_forme, forme)){
|
||||
if (!species->TryGetForme(this->_forme, forme)) {
|
||||
std::stringstream err;
|
||||
err << "Invalid forme '" << _forme << "' for species '" << _forme << "'.";
|
||||
throw CreatureException(err.str());
|
||||
@@ -66,9 +65,9 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
gender = species->GetRandomGender(rand);
|
||||
}
|
||||
const Library::Item* heldItem = nullptr;
|
||||
if (!this->_heldItem.empty()) {
|
||||
if (!_library->GetItemLibrary()->TryGet(this->_heldItem.c_str(), heldItem)) {
|
||||
throw CreatureException("Unknown Item: " + this->_heldItem);
|
||||
if (!this->_heldItem.Empty()) {
|
||||
if (!_library->GetItemLibrary()->TryGet(this->_heldItem, heldItem)) {
|
||||
throw CreatureException("Unknown Item: " + this->_heldItem.std_str());
|
||||
}
|
||||
}
|
||||
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
||||
@@ -123,7 +122,8 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa
|
||||
_evSpeed = speed;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithForme(const std::string& forme) {
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithForme(const Arbutils::CaseInsensitiveConstString& forme) {
|
||||
_forme = forme;
|
||||
return this;
|
||||
}
|
||||
@@ -136,17 +136,18 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::IsShiny(bool
|
||||
_isShiny = value;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem(const std::string& item) {
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem(const Arbutils::CaseInsensitiveConstString& item) {
|
||||
_heldItem = item;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::LearnMove(const std::string& moveName, CreatureLib::Battling::AttackLearnMethod method) {
|
||||
PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConstString& moveName,
|
||||
CreatureLib::Battling::AttackLearnMethod method) {
|
||||
const PkmnLib::Library::MoveData* move;
|
||||
if (!_library->GetMoveLibrary()->TryGet(moveName.c_str(), move)){
|
||||
throw CreatureException("Invalid Move given: " + moveName);
|
||||
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
||||
throw CreatureException("Invalid Move given: " + moveName.std_str());
|
||||
}
|
||||
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()){
|
||||
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()) {
|
||||
throw CreatureException("This pokemon already has the maximal allowed moves.");
|
||||
}
|
||||
_attacks.emplace_back(move, method);
|
||||
|
||||
Reference in New Issue
Block a user