This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "CreatePokemon.hpp"
|
||||
|
||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(Arbutils::Random rand) {
|
||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(ArbUt::Random rand) {
|
||||
_ivHp = rand.Get(0, 32);
|
||||
_ivAttack = rand.Get(0, 32);
|
||||
_ivDefense = rand.Get(0, 32);
|
||||
@@ -37,19 +37,20 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortVal
|
||||
}
|
||||
|
||||
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto rand = Arbutils::Random();
|
||||
const PkmnLib::Library::PokemonSpecies* species = nullptr;
|
||||
auto rand = ArbUt::Random();
|
||||
ArbUt::BorrowedPtr<const Library::PokemonSpecies> species = nullptr;
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) {
|
||||
std::stringstream err;
|
||||
err << "Invalid species '" << _species << "'.";
|
||||
throw CreatureException(err.str());
|
||||
}
|
||||
const PkmnLib::Library::PokemonForme* forme;
|
||||
ArbUt::BorrowedPtr<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());
|
||||
}
|
||||
AssertNotNull(forme);
|
||||
CreatureLib::Library::TalentIndex ability;
|
||||
if (this->_ability.Empty()) {
|
||||
ability = forme->GetRandomTalent(&rand);
|
||||
@@ -64,15 +65,16 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
if (gender == static_cast<CreatureLib::Library::Gender>(-1)) {
|
||||
gender = species->GetRandomGender(rand);
|
||||
}
|
||||
const Library::Item* heldItem = nullptr;
|
||||
ArbUt::BorrowedPtr<const Library::Item> heldItem = nullptr;
|
||||
if (!this->_heldItem.Empty()) {
|
||||
if (!_library->GetItemLibrary()->TryGet(this->_heldItem, heldItem)) {
|
||||
throw CreatureException("Unknown Item: " + this->_heldItem.std_str());
|
||||
}
|
||||
AssertNotNull(heldItem);
|
||||
}
|
||||
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
||||
|
||||
auto attacks = List<CreatureLib::Battling::LearnedAttack*>(_attacks.Count());
|
||||
auto attacks = ArbUt::List<CreatureLib::Battling::LearnedAttack*>(_attacks.Count());
|
||||
for (size_t i = 0; i < _attacks.Count(); i++) {
|
||||
auto& kv = _attacks[i];
|
||||
auto move = kv.Move;
|
||||
@@ -102,7 +104,7 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
return pkmn;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon
|
||||
PkmnLib::Battling::CreatePokemon::WithNature(const Arbutils::CaseInsensitiveConstString& nature) {
|
||||
PkmnLib::Battling::CreatePokemon::WithNature(const ArbUt::CaseInsensitiveConstString& nature) {
|
||||
_nature = nature;
|
||||
return *this;
|
||||
}
|
||||
@@ -129,7 +131,7 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortVal
|
||||
return *this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon
|
||||
PkmnLib::Battling::CreatePokemon::WithForme(const Arbutils::CaseInsensitiveConstString& forme) {
|
||||
PkmnLib::Battling::CreatePokemon::WithForme(const ArbUt::CaseInsensitiveConstString& forme) {
|
||||
_forme = forme;
|
||||
return *this;
|
||||
}
|
||||
@@ -143,14 +145,14 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::IsShiny(bool
|
||||
return *this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon
|
||||
PkmnLib::Battling::CreatePokemon::WithHeldItem(const Arbutils::CaseInsensitiveConstString& item) {
|
||||
PkmnLib::Battling::CreatePokemon::WithHeldItem(const ArbUt::CaseInsensitiveConstString& item) {
|
||||
_heldItem = item;
|
||||
return *this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon
|
||||
PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConstString& moveName,
|
||||
PkmnLib::Battling::CreatePokemon::LearnMove(const ArbUt::CaseInsensitiveConstString& moveName,
|
||||
CreatureLib::Battling::AttackLearnMethod method) {
|
||||
const PkmnLib::Library::MoveData* move = nullptr;
|
||||
ArbUt::BorrowedPtr<const PkmnLib::Library::MoveData> move = nullptr;
|
||||
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
||||
throw CreatureException("Invalid Move given: " + moveName.std_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user