Implements Pokemon stat calculation.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
02ab4b3272
commit
191b128125
|
@ -12,7 +12,7 @@ class PkmnLibConan(ConanFile):
|
|||
generators = "cmake"
|
||||
exports_sources = "*"
|
||||
compiler = "clang"
|
||||
requires = "CreatureLib/dd8d4d738d3574933c8f071220028d0088fbb326@creaturelib/master"
|
||||
requires = "CreatureLib/144d17d859e134c17cdb45c32f4a7e4f68eeb7a0@creaturelib/master"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
|
||||
#include <Battling/Library/BattleLibrary.hpp>
|
||||
#include "../../Library/PokemonLibrary.hpp"
|
||||
#include "StatCalculator.hpp"
|
||||
|
||||
namespace PkmnLib::Battling {
|
||||
class BattleLibrary : public CreatureLib::Battling::BattleLibrary {
|
||||
public:
|
||||
BattleLibrary(Library::PokemonLibrary* staticLib, CreatureLib::Battling::BattleStatCalculator* statCalculator,
|
||||
BattleLibrary(Library::PokemonLibrary* staticLib, StatCalculator* statCalculator,
|
||||
CreatureLib::Battling::DamageLibrary* damageLibrary,
|
||||
CreatureLib::Battling::ExperienceLibrary* experienceLibrary,
|
||||
CreatureLib::Battling::ScriptResolver* scriptResolver,
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
#include "StatCalculator.hpp"
|
||||
#include "../Pokemon/Pokemon.hpp"
|
||||
|
||||
uint32_t PkmnLib::Battling::StatCalculator::CalculateHealthStat(const Pokemon* pkmn) const {
|
||||
uint32_t base = pkmn->GetBaseStat(Library::Statistic::HealthPoints);
|
||||
uint32_t iv = pkmn->GetIndividualValue(Library::Statistic::HealthPoints);
|
||||
uint32_t ev = pkmn->GetEffortValue(Library::Statistic::HealthPoints);
|
||||
uint8_t level = pkmn->GetLevel();
|
||||
return static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(ev / 4)) * level) / 100) + level + 10;
|
||||
}
|
||||
uint32_t PkmnLib::Battling::StatCalculator::CalculateOtherStat(const Pokemon* pkmn,
|
||||
CreatureLib::Core::Statistic stat) const {
|
||||
uint32_t base = pkmn->GetBaseStat(stat);
|
||||
uint32_t iv = pkmn->GetIndividualValue(stat);
|
||||
uint32_t ev = pkmn->GetEffortValue(stat);
|
||||
uint8_t level = pkmn->GetLevel();
|
||||
uint32_t unmodified =
|
||||
static_cast<uint32_t>(((2 * base + iv + static_cast<uint32_t>(ev / 4)) * level) / 100) + 5;
|
||||
return static_cast<uint32_t>(unmodified * pkmn->GetNature().GetStatModifier(stat));
|
||||
}
|
||||
float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib::Battling::Creature* pkmn,
|
||||
CreatureLib::Core::Statistic stat) const {
|
||||
int8_t boost = pkmn->GetStatBoost(stat);
|
||||
switch (boost) {
|
||||
case -6: return 2.0 / 8;
|
||||
case -5: return 2.0 / 7;
|
||||
case -4: return 2.0 / 6;
|
||||
case -3: return 2.0 / 5;
|
||||
case -2: return 2.0 / 4;
|
||||
case -1: return 2.0 / 3;
|
||||
case 0: return 1;
|
||||
case 1: return 3.0 / 2;
|
||||
case 2: return 4.0 / 2;
|
||||
case 3: return 5.0 / 2;
|
||||
case 4: return 6.0 / 2;
|
||||
case 5: return 7.0 / 2;
|
||||
case 6: return 8.0 / 2;
|
||||
default: throw CreatureException("Stat boost was out of expected range of -6 till 6.");
|
||||
}
|
||||
}
|
||||
CreatureLib::Core::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateFlatStats(CreatureLib::Battling::Creature* creature) const {
|
||||
auto pkmn = dynamic_cast<Pokemon*>(creature);
|
||||
return CreatureLib::Core::StatisticSet<uint32_t>(
|
||||
CalculateHealthStat(pkmn), CalculateOtherStat(pkmn, Library::Statistic::PhysicalAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::PhysicalDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialAttack),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::SpecialDefense),
|
||||
CalculateOtherStat(pkmn, Library::Statistic::Speed));
|
||||
}
|
||||
CreatureLib::Core::StatisticSet<uint32_t>
|
||||
PkmnLib::Battling::StatCalculator::CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const {
|
||||
return CreatureLib::Core::StatisticSet<uint32_t>(
|
||||
CalculateBoostedStat(creature, Library::Statistic::HealthPoints),
|
||||
CalculateBoostedStat(creature, Library::Statistic::PhysicalAttack),
|
||||
CalculateBoostedStat(creature, Library::Statistic::PhysicalDefense),
|
||||
CalculateBoostedStat(creature, Library::Statistic::SpecialAttack),
|
||||
CalculateBoostedStat(creature, Library::Statistic::SpecialDefense),
|
||||
CalculateBoostedStat(creature, Library::Statistic::Speed));
|
||||
}
|
||||
uint32_t PkmnLib::Battling::StatCalculator::CalculateFlatStat(CreatureLib::Battling::Creature* creature,
|
||||
CreatureLib::Core::Statistic stat) const {
|
||||
if (stat == Library::Statistic::HealthPoints)
|
||||
return CalculateHealthStat(dynamic_cast<Pokemon*>(creature));
|
||||
return CalculateOtherStat(dynamic_cast<Pokemon*>(creature), stat);
|
||||
}
|
||||
uint32_t PkmnLib::Battling::StatCalculator::CalculateBoostedStat(CreatureLib::Battling::Creature* creature,
|
||||
CreatureLib::Core::Statistic stat) const {
|
||||
return creature->GetFlatStat(stat) * GetStatBoostModifier(creature, stat);
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef PKMNLIB_STATCALCULATOR_HPP
|
||||
#define PKMNLIB_STATCALCULATOR_HPP
|
||||
|
||||
#include <Battling/Library/BattleStatCalculator.hpp>
|
||||
#include "../../Library/Statistic.hpp"
|
||||
|
||||
namespace PkmnLib::Battling {
|
||||
class Pokemon;
|
||||
|
||||
class StatCalculator : public CreatureLib::Battling::BattleStatCalculator {
|
||||
protected:
|
||||
virtual uint32_t CalculateHealthStat(const Pokemon* pkmn) const;
|
||||
virtual uint32_t CalculateOtherStat(const Pokemon* pkmn, CreatureLib::Core::Statistic stat) const;
|
||||
virtual float GetStatBoostModifier(const CreatureLib::Battling::Creature* pkmn,
|
||||
CreatureLib::Core::Statistic stat) const;
|
||||
|
||||
public:
|
||||
~StatCalculator() override = default;
|
||||
CreatureLib::Core::StatisticSet<uint32_t>
|
||||
CalculateFlatStats(CreatureLib::Battling::Creature* creature) const override;
|
||||
|
||||
CreatureLib::Core::StatisticSet<uint32_t>
|
||||
CalculateBoostedStats(CreatureLib::Battling::Creature* creature) const override;
|
||||
|
||||
uint32_t CalculateFlatStat(CreatureLib::Battling::Creature* creature,
|
||||
CreatureLib::Core::Statistic stat) const override;
|
||||
|
||||
uint32_t CalculateBoostedStat(CreatureLib::Battling::Creature* creature,
|
||||
CreatureLib::Core::Statistic stat) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PKMNLIB_STATCALCULATOR_HPP
|
|
@ -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); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,14 @@ namespace PkmnLib::Library {
|
|||
|
||||
[[nodiscard]] CreatureLib::Core::Statistic GetIncreasedStat() const { return _increaseStat; }
|
||||
[[nodiscard]] CreatureLib::Core::Statistic GetDecreasedStat() const { return _decreaseStat; }
|
||||
|
||||
[[nodiscard]] float GetStatModifier(CreatureLib::Core::Statistic stat) const {
|
||||
if (stat == _increaseStat)
|
||||
return _increaseModifier;
|
||||
else if (stat == _decreaseStat)
|
||||
return _decreaseModifier;
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/catch.hpp"
|
||||
#include "../../src/Battling/Pokemon/CreatePokemon.hpp"
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
||||
using namespace PkmnLib::Battling;
|
||||
|
||||
TEST_CASE("Low level, no IVs, no EVs, neutral nature, no stat boosts stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 10).WithNature("neutralNature")->Build();
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 40);
|
||||
CHECK(pkmn->GetCurrentHealth() == 40);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 25);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 25);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 25);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 25);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 25);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("High level, no IVs, no EVs, neutral nature, no stat boosts stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 100).WithNature("neutralNature")->Build();
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 310);
|
||||
CHECK(pkmn->GetCurrentHealth() == 310);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 205);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 205);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 205);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 205);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 205);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("Low level, max IVs, no EVs, neutral nature, no stat boosts stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 10)
|
||||
.WithNature("neutralNature")
|
||||
->WithIndividualValues(31, 31, 31, 31, 31, 31)
|
||||
->Build();
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 43);
|
||||
CHECK(pkmn->GetCurrentHealth() == 43);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 28);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 28);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 28);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 28);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 28);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("High level, max IVs, no EVs, neutral nature, no stat boosts stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 100)
|
||||
.WithNature("neutralNature")
|
||||
->WithIndividualValues(31, 31, 31, 31, 31, 31)
|
||||
->Build();
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 341);
|
||||
CHECK(pkmn->GetCurrentHealth() == 341);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 236);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 236);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 236);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 236);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 236);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("High level, max IVs, max EVs, neutral nature, no stat boosts stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 100)
|
||||
.WithNature("neutralNature")
|
||||
->WithIndividualValues(31, 31, 31, 31, 31, 31)
|
||||
->WithEffortValues(255, 255, 255, 255, 255, 255)
|
||||
->Build();
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
|
||||
CHECK(pkmn->GetCurrentHealth() == 404);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 299);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, no stat boosts stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 100)
|
||||
.WithNature("buffsAttackNerfsSpeed")
|
||||
->WithIndividualValues(31, 31, 31, 31, 31, 31)
|
||||
->WithEffortValues(255, 255, 255, 255, 255, 255)
|
||||
->Build();
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
|
||||
CHECK(pkmn->GetCurrentHealth() == 404);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 328);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
|
||||
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 269);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, Attack boosted +6 stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 100)
|
||||
.WithNature("buffsAttackNerfsSpeed")
|
||||
->WithIndividualValues(31, 31, 31, 31, 31, 31)
|
||||
->WithEffortValues(255, 255, 255, 255, 255, 255)
|
||||
->Build();
|
||||
|
||||
pkmn->ChangeStatBoost(PkmnLib::Library::Statistic::PhysicalAttack, 6);
|
||||
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
|
||||
CHECK(pkmn->GetCurrentHealth() == 404);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalAttack) == 1312);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::Speed) == 269);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, Attack boosted -6 stat test") {
|
||||
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1", 100)
|
||||
.WithNature("buffsAttackNerfsSpeed")
|
||||
->WithIndividualValues(31, 31, 31, 31, 31, 31)
|
||||
->WithEffortValues(255, 255, 255, 255, 255, 255)
|
||||
->Build();
|
||||
|
||||
pkmn->ChangeStatBoost(PkmnLib::Library::Statistic::PhysicalAttack, -6);
|
||||
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
|
||||
CHECK(pkmn->GetCurrentHealth() == 404);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalAttack) == 82);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
|
||||
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::Speed) == 269);
|
||||
delete pkmn;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -1,2 +1,33 @@
|
|||
#include "TestLibrary.hpp"
|
||||
PkmnLib::Battling::BattleLibrary* TestLibrary::_library = nullptr;
|
||||
PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
lib->LoadSpecies("testSpecies", new PkmnLib::Library::PokemonSpecies(
|
||||
1, "testSpecies",
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate", 100, 100));
|
||||
lib->LoadSpecies(
|
||||
"testSpecies2",
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
2, "testSpecies2",
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate", 100, 100));
|
||||
lib->LoadSpecies(
|
||||
"statTestSpecies1",
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
3, "statTestSpecies1",
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate", 100, 100));
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
}
|
||||
|
||||
static PkmnLib::Battling::BattleLibrary* BuildLibrary() {
|
||||
auto statCalc = new CreatureLib::Battling::BattleStatCalculator();
|
||||
auto statCalc = new PkmnLib::Battling::StatCalculator();
|
||||
return new PkmnLib::Battling::BattleLibrary(
|
||||
BuildStaticLibrary(), statCalc, new CreatureLib::Battling::DamageLibrary(),
|
||||
new CreatureLib::Battling::ExperienceLibrary(), new CreatureLib::Battling::ScriptResolver(),
|
||||
|
@ -32,27 +32,7 @@ public:
|
|||
BuildGrowthRateLibrary(), BuildTypeLibrary(), BuildNatureLibrary());
|
||||
}
|
||||
|
||||
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary() {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
lib->LoadSpecies("testSpecies", new PkmnLib::Library::PokemonSpecies(
|
||||
1, "testSpecies",
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate", 100, 100));
|
||||
lib->LoadSpecies(
|
||||
"testSpecies2",
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
2, "testSpecies2",
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate", 100, 100));
|
||||
return lib;
|
||||
}
|
||||
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary();
|
||||
|
||||
static PkmnLib::Library::MoveLibrary* BuildMoveLibrary() {
|
||||
auto lib = new PkmnLib::Library::MoveLibrary();
|
||||
|
@ -79,6 +59,8 @@ public:
|
|||
auto lib = new PkmnLib::Library::NatureLibrary();
|
||||
lib->LoadNature("neutralNature", PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
|
||||
PkmnLib::Library::Statistic::PhysicalDefense, 1, 1));
|
||||
lib->LoadNature("buffsAttackNerfsSpeed", PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
|
||||
PkmnLib::Library::Statistic::Speed, 1.1, 0.9));
|
||||
return lib;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue