Enforce PkmnLib MiscLibrary in Library constructor.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-22 16:10:13 +02:00
parent 2e60096d57
commit 0f440a8a63
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 13 additions and 17 deletions

View File

@ -4,24 +4,24 @@
#include <CreatureLib/Battling/Library/BattleLibrary.hpp>
#include "../../Library/PokemonLibrary.hpp"
#include "DamageLibrary.hpp"
#include "MiscLibrary.hpp"
#include "StatCalculator.hpp"
namespace PkmnLib::Battling {
class BattleLibrary : public CreatureLib::Battling::BattleLibrary {
public:
BattleLibrary(Library::PokemonLibrary* staticLib, StatCalculator* statCalculator,
DamageLibrary* damageLibrary,
BattleLibrary(Library::PokemonLibrary* staticLib, StatCalculator* statCalculator, DamageLibrary* damageLibrary,
CreatureLib::Battling::ExperienceLibrary* experienceLibrary,
CreatureLib::Battling::ScriptResolver* scriptResolver,
CreatureLib::Battling::MiscLibrary* miscLibrary)
PkmnLib::Battling::MiscLibrary* miscLibrary)
: CreatureLib::Battling::BattleLibrary(staticLib, statCalculator, damageLibrary, experienceLibrary,
scriptResolver, miscLibrary) {}
const Library::LibrarySettings* GetSettings() const{
const Library::LibrarySettings* GetSettings() const {
return static_cast<const Library::LibrarySettings*>(_staticLib->GetSettings());
}
const Library::PokemonLibrary* GetStaticLib() const{
const Library::PokemonLibrary* GetStaticLib() const {
return dynamic_cast<const Library::PokemonLibrary*>(CreatureLib::Battling::BattleLibrary::_staticLib);
}
@ -31,19 +31,14 @@ namespace PkmnLib::Battling {
}
const Library::MoveLibrary* GetMoveLibrary() const {
return dynamic_cast<const Library::MoveLibrary*>(
CreatureLib::Battling::BattleLibrary::GetAttackLibrary());
return dynamic_cast<const Library::MoveLibrary*>(CreatureLib::Battling::BattleLibrary::GetAttackLibrary());
}
const Library::ItemLibrary* GetItemLibrary() const {
return dynamic_cast<const Library::ItemLibrary*>(
CreatureLib::Battling::BattleLibrary::GetItemLibrary());
return dynamic_cast<const Library::ItemLibrary*>(CreatureLib::Battling::BattleLibrary::GetItemLibrary());
}
const Library::NatureLibrary* GetNatureLibrary() const {
return GetStaticLib()->GetNatureLibrary();
}
const Library::NatureLibrary* GetNatureLibrary() const { return GetStaticLib()->GetNatureLibrary(); }
static CreatureLib::Battling::ScriptResolver* CreateScriptResolver();
};

View File

@ -4,7 +4,7 @@
#include <CreatureLib/Battling/Library/MiscLibrary.hpp>
namespace PkmnLib::Battling{
class MiscLibrary : CreatureLib::Battling::MiscLibrary {
class MiscLibrary : public CreatureLib::Battling::MiscLibrary {
~MiscLibrary() override = default;
bool IsCritical(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hit) const override;

View File

@ -3,6 +3,7 @@
#include <CreatureLib/Library/GrowthRates/LookupGrowthRate.hpp>
#include "../../src/Battling/Library/BattleLibrary.hpp"
#include "../../src/Battling/Library/MiscLibrary.hpp"
#include "../../src/Library/Moves/MoveLibrary.hpp"
#include "../../src/Library/PokemonLibrary.hpp"
#include "../../src/Library/Statistic.hpp"
@ -24,7 +25,7 @@ public:
auto scriptResolver = PkmnLib::Battling::BattleLibrary::CreateScriptResolver();
auto lib = new PkmnLib::Battling::BattleLibrary(
BuildStaticLibrary(), statCalc, new PkmnLib::Battling::DamageLibrary(),
new CreatureLib::Battling::ExperienceLibrary(), scriptResolver, new CreatureLib::Battling::MiscLibrary());
new CreatureLib::Battling::ExperienceLibrary(), scriptResolver, new PkmnLib::Battling::MiscLibrary());
scriptResolver->Initialize(lib);
return lib;
}
@ -66,10 +67,10 @@ public:
auto lib = new PkmnLib::Library::NatureLibrary();
lib->LoadNature("neutralNature"_cnc,
new PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
PkmnLib::Library::Statistic::PhysicalDefense, 1, 1));
PkmnLib::Library::Statistic::PhysicalDefense, 1, 1));
lib->LoadNature("buffsAttackNerfsSpeed"_cnc,
new PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
PkmnLib::Library::Statistic::Speed, 1.1, 0.9));
PkmnLib::Library::Statistic::Speed, 1.1, 0.9));
return lib;
}
};