72 lines
3.3 KiB
C++
72 lines
3.3 KiB
C++
#include "CreatePokemon.hpp"
|
|
#include "../../Library/Statistic.hpp"
|
|
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::RandomizeIndividualValues(CreatureLib::Core::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;
|
|
}
|
|
|
|
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::SetIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value) {
|
|
switch (stat) {
|
|
case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break;
|
|
case PkmnLib::Library::Statistic::PhysicalAttack: _ivAttack = value; break;
|
|
case PkmnLib::Library::Statistic::PhysicalDefense: _ivDefense = value; break;
|
|
case PkmnLib::Library::Statistic::SpecialAttack: _ivSpAtt = value; break;
|
|
case PkmnLib::Library::Statistic::SpecialDefense: _ivSpDef = value; break;
|
|
case PkmnLib::Library::Statistic::Speed: _ivSpeed = value; break;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::SetEffortValue(CreatureLib::Core::Statistic stat, uint8_t value) {
|
|
switch (stat) {
|
|
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
|
|
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
|
|
case PkmnLib::Library::Statistic::PhysicalDefense: _evDefense = value; break;
|
|
case PkmnLib::Library::Statistic::SpecialAttack: _evSpAtt = value; break;
|
|
case PkmnLib::Library::Statistic::SpecialDefense: _evSpDef = value; break;
|
|
case PkmnLib::Library::Statistic::Speed: _evSpeed = value; break;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
|
auto rand = CreatureLib::Core::Random();
|
|
auto species = this->_library->GetSpeciesLibrary()->GetPkmnSpecies(this->_species);
|
|
auto forme = species->GetForme(this->_variant);
|
|
int8_t ability;
|
|
if (this->_ability.empty()) {
|
|
ability = forme->GetRandomTalent(&rand);
|
|
} else {
|
|
ability = forme->GetTalentIndex(this->_ability);
|
|
}
|
|
auto identifier = this->_identifier;
|
|
if (identifier == 0) {
|
|
identifier = rand.Get();
|
|
}
|
|
auto gender = this->_gender;
|
|
if (gender == static_cast<CreatureLib::Library::Gender>(-1)) {
|
|
gender = species->GetRandomGender(rand);
|
|
}
|
|
const Library::Item* heldItem = nullptr;
|
|
if (!this->_heldItem.empty()) {
|
|
heldItem = _library->GetItemLibrary()->GetItem(this->_heldItem);
|
|
}
|
|
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
|
|
|
auto attacks = std::vector<CreatureLib::Battling::LearnedAttack*>(_attacks.size());
|
|
for (size_t i = 0; i < attacks.size(); i++) {
|
|
auto kv = _attacks[i];
|
|
attacks[i] = new LearnedMove(std::get<0>(kv), std::get<1>(kv));
|
|
}
|
|
auto ivs = CreatureLib::Core::StatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed);
|
|
auto evs = CreatureLib::Core::StatisticSet(_evHp, _evAttack, _evDefense, _evSpAtt, _evSpDef, _evSpeed);
|
|
|
|
return new Pokemon(_library, species, forme, _level, experience, identifier, gender, _coloring, heldItem, _nickname,
|
|
ability, attacks, ivs, evs);
|
|
}
|