Reworks nature library to be simpler.
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:
@@ -80,8 +80,8 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto ivs = CreatureLib::Library::StatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed);
|
||||
auto evs = CreatureLib::Library::StatisticSet(_evHp, _evAttack, _evDefense, _evSpAtt, _evSpDef, _evSpeed);
|
||||
|
||||
if (_nature == 255) {
|
||||
_nature = _library->GetNatureLibrary()->GetRandomNature(rand);
|
||||
if (_nature.Empty()) {
|
||||
_nature = _library->GetNatureLibrary()->GetRandomNatureName(rand);
|
||||
}
|
||||
|
||||
auto shiny = false;
|
||||
@@ -96,8 +96,8 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
pkmn->Initialize();
|
||||
return pkmn;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithNature(const std::string& nature) {
|
||||
_nature = _library->GetNatureLibrary()->GetNatureIdByName(nature);
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithNature(const Arbutils::CaseInsensitiveConstString& nature) {
|
||||
_nature = nature;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithIndividualValues(uint8_t hp, uint8_t att,
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace PkmnLib::Battling {
|
||||
std::string _nickname = "";
|
||||
|
||||
Arbutils::CaseInsensitiveConstString _ability = ""_cnc;
|
||||
uint8_t _nature = 255;
|
||||
Arbutils::CaseInsensitiveConstString _nature;
|
||||
CreatureLib::Library::Gender _gender = static_cast<CreatureLib::Library::Gender>(-1);
|
||||
Arbutils::CaseInsensitiveConstString _heldItem = ""_cnc;
|
||||
uint32_t _identifier = 0;
|
||||
@@ -54,7 +54,7 @@ namespace PkmnLib::Battling {
|
||||
CreatePokemon* WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||
uint8_t speed);
|
||||
|
||||
CreatePokemon* WithNature(const std::string& nature);
|
||||
CreatePokemon* WithNature(const Arbutils::CaseInsensitiveConstString& nature);
|
||||
|
||||
Pokemon* Build();
|
||||
};
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#include "Pokemon.hpp"
|
||||
const PkmnLib::Library::Nature& PkmnLib::Battling::Pokemon::GetNature() const{
|
||||
if (_natureCache == nullptr){
|
||||
auto p = const_cast<Pokemon*>(this);
|
||||
p->_natureCache = this->GetLibrary()->GetNatureLibrary()->GetNaturePtr(_nature);
|
||||
}
|
||||
return *_natureCache;
|
||||
return this->GetLibrary()->GetNatureLibrary()->GetNatureByName(_nature);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace PkmnLib::Battling {
|
||||
CreatureLib::Library::StatisticSet<uint8_t> _individualValues;
|
||||
CreatureLib::Library::StatisticSet<uint8_t> _effortValues;
|
||||
|
||||
uint8_t _nature;
|
||||
const Library::Nature* _natureCache = nullptr;
|
||||
Arbutils::CaseInsensitiveConstString _nature;
|
||||
|
||||
const BattleLibrary* GetLibrary() const { return reinterpret_cast<const BattleLibrary*>(_library); }
|
||||
|
||||
@@ -25,7 +24,7 @@ namespace PkmnLib::Battling {
|
||||
const std::string& nickname, const CreatureLib::Library::TalentIndex& talent,
|
||||
List<CreatureLib::Battling::LearnedAttack*> moves,
|
||||
CreatureLib::Library::StatisticSet<uint8_t> individualValues,
|
||||
CreatureLib::Library::StatisticSet<uint8_t> effortValues, uint8_t nature)
|
||||
CreatureLib::Library::StatisticSet<uint8_t> effortValues, const Arbutils::CaseInsensitiveConstString& nature)
|
||||
: CreatureLib::Battling::Creature(library, species, forme, level, experience, uid, gender, coloring,
|
||||
heldItem, nickname, talent, std::move(moves)),
|
||||
_individualValues(individualValues), _effortValues(effortValues), _nature(nature) {}
|
||||
|
||||
Reference in New Issue
Block a user