Rework CreatePokemon to not return a pointer to self every time, but return by value instead.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-22 14:41:20 +02:00
parent babb384166
commit b1442f25fb
5 changed files with 90 additions and 90 deletions

View File

@@ -1,16 +1,16 @@
#include "CreatePokemon.hpp"
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(Arbutils::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);
_ivSpAtt = rand.Get(0, 32);
_ivSpDef = rand.Get(0, 32);
_ivSpeed = rand.Get(0, 32);
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon*
PkmnLib::Battling::CreatePokemon
PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Library::Statistic stat, uint8_t value) {
switch (stat) {
case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break;
@@ -20,11 +20,11 @@ PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Library::Stat
case PkmnLib::Library::Statistic::SpecialDefense: _ivSpDef = 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, uint8_t value) {
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat,
uint8_t value) {
switch (stat) {
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
@@ -33,7 +33,7 @@ PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Library::Statisti
case PkmnLib::Library::Statistic::SpecialDefense: _evSpDef = value; break;
case PkmnLib::Library::Statistic::Speed: _evSpeed = value; break;
}
return this;
return *this;
}
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
@@ -101,53 +101,53 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
pkmn->Initialize();
return pkmn;
}
PkmnLib::Battling::CreatePokemon*
PkmnLib::Battling::CreatePokemon
PkmnLib::Battling::CreatePokemon::WithNature(const Arbutils::CaseInsensitiveConstString& nature) {
_nature = nature;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithIndividualValues(uint8_t hp, uint8_t att,
uint8_t def, uint8_t spAtt,
uint8_t spDef, uint8_t speed) {
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithIndividualValues(uint8_t hp, uint8_t att,
uint8_t def, uint8_t spAtt,
uint8_t spDef, uint8_t speed) {
_ivHp = hp;
_ivAttack = att;
_ivDefense = def;
_ivSpAtt = spAtt;
_ivSpDef = spDef;
_ivSpeed = speed;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortValues(uint8_t hp, uint8_t att,
uint8_t def, uint8_t spAtt,
uint8_t spDef, uint8_t speed) {
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithEffortValues(uint8_t hp, uint8_t att,
uint8_t def, uint8_t spAtt,
uint8_t spDef, uint8_t speed) {
_evHp = hp;
_evAttack = att;
_evDefense = def;
_evSpAtt = spAtt;
_evSpDef = spDef;
_evSpeed = speed;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon*
PkmnLib::Battling::CreatePokemon
PkmnLib::Battling::CreatePokemon::WithForme(const Arbutils::CaseInsensitiveConstString& forme) {
_forme = forme;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithGender(CreatureLib::Library::Gender gender) {
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::WithGender(CreatureLib::Library::Gender gender) {
_gender = gender;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::IsShiny(bool value) {
PkmnLib::Battling::CreatePokemon PkmnLib::Battling::CreatePokemon::IsShiny(bool value) {
_shininessSet = true;
_isShiny = value;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon*
PkmnLib::Battling::CreatePokemon
PkmnLib::Battling::CreatePokemon::WithHeldItem(const Arbutils::CaseInsensitiveConstString& item) {
_heldItem = item;
return this;
return *this;
}
PkmnLib::Battling::CreatePokemon*
PkmnLib::Battling::CreatePokemon
PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConstString& moveName,
CreatureLib::Battling::AttackLearnMethod method) {
const PkmnLib::Library::MoveData* move = nullptr;
@@ -161,5 +161,5 @@ PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConst
auto& c = _attacks[_currentMove++];
c.Move = move;
c.LearnMethod = method;
return this;
return *this;
}

View File

@@ -49,22 +49,22 @@ namespace PkmnLib::Battling {
_attacks.Resize(library->GetSettings()->GetMaximalMoves(), ToLearnMethod());
}
CreatePokemon* WithForme(const Arbutils::CaseInsensitiveConstString& forme);
CreatePokemon* WithGender(CreatureLib::Library::Gender gender);
CreatePokemon* IsShiny(bool value);
CreatePokemon* WithHeldItem(const Arbutils::CaseInsensitiveConstString& item);
CreatePokemon* LearnMove(const Arbutils::CaseInsensitiveConstString& move,
CreatePokemon WithForme(const Arbutils::CaseInsensitiveConstString& forme);
CreatePokemon WithGender(CreatureLib::Library::Gender gender);
CreatePokemon IsShiny(bool value);
CreatePokemon WithHeldItem(const Arbutils::CaseInsensitiveConstString& item);
CreatePokemon LearnMove(const Arbutils::CaseInsensitiveConstString& move,
CreatureLib::Battling::AttackLearnMethod method);
CreatePokemon* WithRandomIndividualValues(Arbutils::Random rand = Arbutils::Random());
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 WithRandomIndividualValues(Arbutils::Random rand = Arbutils::Random());
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,
uint8_t speed);
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 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,
uint8_t speed);
CreatePokemon* WithNature(const Arbutils::CaseInsensitiveConstString& nature);
CreatePokemon WithNature(const Arbutils::CaseInsensitiveConstString& nature);
Pokemon* Build();
};