Implements Pokemon stat calculation.
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:
@@ -70,10 +70,34 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
_nature = _library->GetNatureLibrary()->GetRandomNature(rand);
|
||||
}
|
||||
|
||||
return new Pokemon(_library, species, forme, _level, experience, identifier, gender, _coloring, heldItem, _nickname,
|
||||
auto pkmn = new Pokemon(_library, species, forme, _level, experience, identifier, gender, _coloring, heldItem, _nickname,
|
||||
ability, attacks, ivs, evs,_nature);
|
||||
pkmn->Initialize();
|
||||
return pkmn;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithNature(const std::string& nature) {
|
||||
_nature = _library->GetNatureLibrary()->GetNatureIdByName(nature);
|
||||
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) {
|
||||
_ivHp = hp;
|
||||
_ivAttack = att;
|
||||
_ivDefense = def;
|
||||
_ivSpAtt = spAtt;
|
||||
_ivSpDef = spDef;
|
||||
_ivSpeed = speed;
|
||||
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) {
|
||||
_evHp = hp;
|
||||
_evAttack = att;
|
||||
_evDefense = def;
|
||||
_evSpAtt = spAtt;
|
||||
_evSpDef = spDef;
|
||||
_evSpeed = speed;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#ifndef PKMNLIB_CREATEPOKEMON_HPP
|
||||
#define PKMNLIB_CREATEPOKEMON_HPP
|
||||
|
||||
#include "Pokemon.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include "Pokemon.hpp"
|
||||
namespace PkmnLib::Battling {
|
||||
class CreatePokemon {
|
||||
private:
|
||||
@@ -41,7 +40,12 @@ namespace PkmnLib::Battling {
|
||||
|
||||
CreatePokemon* WithRandomIndividualValues(CreatureLib::Core::Random rand = CreatureLib::Core::Random());
|
||||
CreatePokemon* WithIndividualValue(CreatureLib::Core::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::Core::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 std::string& nature);
|
||||
|
||||
Pokemon* Build();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "Pokemon.hpp"
|
||||
const PkmnLib::Library::Nature& PkmnLib::Battling::Pokemon::GetNature() {
|
||||
const PkmnLib::Library::Nature& PkmnLib::Battling::Pokemon::GetNature() const{
|
||||
if (_natureCache == nullptr){
|
||||
_natureCache = this->GetLibrary()->GetNatureLibrary()->GetNaturePtr(_nature);
|
||||
auto p = const_cast<Pokemon*>(this);
|
||||
p->_natureCache = this->GetLibrary()->GetNatureLibrary()->GetNaturePtr(_nature);
|
||||
}
|
||||
return *_natureCache;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <Battling/Models/Creature.hpp>
|
||||
#include <utility>
|
||||
#include "../../Library/Statistic.hpp"
|
||||
#include "../Library/BattleLibrary.hpp"
|
||||
#include "LearnedMove.hpp"
|
||||
|
||||
@@ -15,7 +16,7 @@ namespace PkmnLib::Battling {
|
||||
uint8_t _nature;
|
||||
const Library::Nature* _natureCache = nullptr;
|
||||
|
||||
const BattleLibrary* GetLibrary() { return reinterpret_cast<const BattleLibrary*>(_library); }
|
||||
const BattleLibrary* GetLibrary() const { return reinterpret_cast<const BattleLibrary*>(_library); }
|
||||
|
||||
public:
|
||||
Pokemon(const BattleLibrary* library, const Library::PokemonSpecies* species,
|
||||
@@ -28,7 +29,11 @@ namespace PkmnLib::Battling {
|
||||
heldItem, nickname, talent, std::move(moves)),
|
||||
_individualValues(individualValues), _effortValues(effortValues), _nature(nature) {}
|
||||
|
||||
const Library::Nature& GetNature();
|
||||
const Library::Nature& GetNature() const;
|
||||
const uint8_t GetIndividualValue(CreatureLib::Core::Statistic stat) const {
|
||||
return _individualValues.GetStat(stat);
|
||||
}
|
||||
const uint8_t GetEffortValue(CreatureLib::Core::Statistic stat) const { return _effortValues.GetStat(stat); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user