Pass back CreatePokemon by reference.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
6ffcd4dcbc
commit
8290bf546a
|
@ -1,6 +1,6 @@
|
||||||
#include "CreatePokemon.hpp"
|
#include "CreatePokemon.hpp"
|
||||||
|
namespace PkmnLib::Battling {
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(ArbUt::Random rand) {
|
CreatePokemon& CreatePokemon::WithRandomIndividualValues(ArbUt::Random rand) {
|
||||||
_ivHp = rand.Get(0, 32);
|
_ivHp = rand.Get(0, 32);
|
||||||
_ivAttack = rand.Get(0, 32);
|
_ivAttack = rand.Get(0, 32);
|
||||||
_ivDefense = rand.Get(0, 32);
|
_ivDefense = rand.Get(0, 32);
|
||||||
|
@ -8,10 +8,9 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithRandomInd
|
||||||
_ivSpDef = rand.Get(0, 32);
|
_ivSpDef = rand.Get(0, 32);
|
||||||
_ivSpeed = rand.Get(0, 32);
|
_ivSpeed = rand.Get(0, 32);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
PkmnLib::Battling::CreatePokemon
|
CreatePokemon& CreatePokemon::WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||||
PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
|
||||||
switch (stat) {
|
switch (stat) {
|
||||||
case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break;
|
case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break;
|
||||||
case PkmnLib::Library::Statistic::PhysicalAttack: _ivAttack = value; break;
|
case PkmnLib::Library::Statistic::PhysicalAttack: _ivAttack = value; break;
|
||||||
|
@ -21,10 +20,9 @@ PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Library::Stat
|
||||||
case PkmnLib::Library::Statistic::Speed: _ivSpeed = value; break;
|
case PkmnLib::Library::Statistic::Speed: _ivSpeed = value; break;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat,
|
CreatePokemon& CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||||
uint8_t value) {
|
|
||||||
switch (stat) {
|
switch (stat) {
|
||||||
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
|
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
|
||||||
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
|
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
|
||||||
|
@ -34,9 +32,9 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortVal
|
||||||
case PkmnLib::Library::Statistic::Speed: _evSpeed = value; break;
|
case PkmnLib::Library::Statistic::Speed: _evSpeed = value; break;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
Pokemon* CreatePokemon::Build() {
|
||||||
auto rand = ArbUt::Random();
|
auto rand = ArbUt::Random();
|
||||||
ArbUt::BorrowedPtr<const Library::PokemonSpecies> species = nullptr;
|
ArbUt::BorrowedPtr<const Library::PokemonSpecies> species = nullptr;
|
||||||
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) {
|
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) {
|
||||||
|
@ -102,13 +100,12 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||||
_nickname, ability, attacks, ivs, evs, nature, _allowedExperienceGain);
|
_nickname, ability, attacks, ivs, evs, nature, _allowedExperienceGain);
|
||||||
pkmn->Initialize();
|
pkmn->Initialize();
|
||||||
return pkmn;
|
return pkmn;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithNature(const ArbUt::StringView& nature) {
|
CreatePokemon& CreatePokemon::WithNature(const ArbUt::StringView& nature) {
|
||||||
_nature = nature;
|
_nature = nature;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithIndividualValues(uint8_t hp, uint8_t att,
|
CreatePokemon& CreatePokemon::WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt,
|
||||||
uint8_t def, uint8_t spAtt,
|
|
||||||
uint8_t spDef, uint8_t speed) {
|
uint8_t spDef, uint8_t speed) {
|
||||||
_ivHp = hp;
|
_ivHp = hp;
|
||||||
_ivAttack = att;
|
_ivAttack = att;
|
||||||
|
@ -117,10 +114,9 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithIndividua
|
||||||
_ivSpDef = spDef;
|
_ivSpDef = spDef;
|
||||||
_ivSpeed = speed;
|
_ivSpeed = speed;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortValues(uint8_t hp, uint8_t att,
|
CreatePokemon& CreatePokemon::WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||||
uint8_t def, uint8_t spAtt,
|
uint8_t speed) {
|
||||||
uint8_t spDef, uint8_t speed) {
|
|
||||||
_evHp = hp;
|
_evHp = hp;
|
||||||
_evAttack = att;
|
_evAttack = att;
|
||||||
_evDefense = def;
|
_evDefense = def;
|
||||||
|
@ -128,26 +124,25 @@ PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortVal
|
||||||
_evSpDef = spDef;
|
_evSpDef = spDef;
|
||||||
_evSpeed = speed;
|
_evSpeed = speed;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithForme(const ArbUt::StringView& forme) {
|
CreatePokemon& CreatePokemon::WithForme(const ArbUt::StringView& forme) {
|
||||||
_forme = forme;
|
_forme = forme;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithGender(CreatureLib::Library::Gender gender) {
|
CreatePokemon& CreatePokemon::WithGender(CreatureLib::Library::Gender gender) {
|
||||||
_gender = gender;
|
_gender = gender;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::IsShiny(bool value) {
|
CreatePokemon& CreatePokemon::IsShiny(bool value) {
|
||||||
_shininessSet = true;
|
_shininessSet = true;
|
||||||
_isShiny = value;
|
_isShiny = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithHeldItem(const ArbUt::StringView& item) {
|
CreatePokemon& CreatePokemon::WithHeldItem(const ArbUt::StringView& item) {
|
||||||
_heldItem = item;
|
_heldItem = item;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon
|
CreatePokemon& CreatePokemon::LearnMove(const ArbUt::StringView& moveName,
|
||||||
PkmnLib::Battling::CreatePokemon::LearnMove(const ArbUt::StringView& moveName,
|
|
||||||
CreatureLib::Battling::AttackLearnMethod method) {
|
CreatureLib::Battling::AttackLearnMethod method) {
|
||||||
ArbUt::BorrowedPtr<const PkmnLib::Library::MoveData> move = nullptr;
|
ArbUt::BorrowedPtr<const PkmnLib::Library::MoveData> move = nullptr;
|
||||||
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
||||||
|
@ -159,8 +154,9 @@ PkmnLib::Battling::CreatePokemon::LearnMove(const ArbUt::StringView& moveName,
|
||||||
Assert(move != nullptr);
|
Assert(move != nullptr);
|
||||||
_attacks.Append(ToLearnMethod(move, method));
|
_attacks.Append(ToLearnMethod(move, method));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::IsAllowedExperienceGain(bool value) {
|
CreatePokemon& CreatePokemon::IsAllowedExperienceGain(bool value) {
|
||||||
_allowedExperienceGain = value;
|
_allowedExperienceGain = value;
|
||||||
return *this;
|
return *this;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -52,22 +52,22 @@ namespace PkmnLib::Battling {
|
||||||
: _library(library), _species(species), _level(level), _attacks(library->GetSettings()->GetMaximalMoves()) {
|
: _library(library), _species(species), _level(level), _attacks(library->GetSettings()->GetMaximalMoves()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatePokemon WithForme(const ArbUt::StringView& forme);
|
CreatePokemon& WithForme(const ArbUt::StringView& forme);
|
||||||
CreatePokemon WithGender(CreatureLib::Library::Gender gender);
|
CreatePokemon& WithGender(CreatureLib::Library::Gender gender);
|
||||||
CreatePokemon IsShiny(bool value);
|
CreatePokemon& IsShiny(bool value);
|
||||||
CreatePokemon WithHeldItem(const ArbUt::StringView& item);
|
CreatePokemon& WithHeldItem(const ArbUt::StringView& item);
|
||||||
CreatePokemon LearnMove(const ArbUt::StringView& move, CreatureLib::Battling::AttackLearnMethod method);
|
CreatePokemon& LearnMove(const ArbUt::StringView& move, CreatureLib::Battling::AttackLearnMethod method);
|
||||||
|
|
||||||
CreatePokemon WithRandomIndividualValues(ArbUt::Random rand = ArbUt::Random());
|
CreatePokemon& WithRandomIndividualValues(ArbUt::Random rand = ArbUt::Random());
|
||||||
CreatePokemon WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value);
|
CreatePokemon& WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value);
|
||||||
CreatePokemon WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
CreatePokemon& WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||||
uint8_t speed);
|
uint8_t speed);
|
||||||
CreatePokemon WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value);
|
CreatePokemon& WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value);
|
||||||
CreatePokemon WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
CreatePokemon& WithEffortValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||||
uint8_t speed);
|
uint8_t speed);
|
||||||
|
|
||||||
CreatePokemon WithNature(const ArbUt::StringView& nature);
|
CreatePokemon& WithNature(const ArbUt::StringView& nature);
|
||||||
CreatePokemon IsAllowedExperienceGain(bool value);
|
CreatePokemon& IsAllowedExperienceGain(bool value);
|
||||||
|
|
||||||
Pokemon* Build();
|
Pokemon* Build();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue