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

View File

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

View File

@ -3,6 +3,7 @@
#include <CreatureLib/Library/GrowthRates/LookupGrowthRate.hpp> #include <CreatureLib/Library/GrowthRates/LookupGrowthRate.hpp>
#include "../../src/Battling/Library/BattleLibrary.hpp" #include "../../src/Battling/Library/BattleLibrary.hpp"
#include "../../src/Battling/Library/MiscLibrary.hpp"
#include "../../src/Library/Moves/MoveLibrary.hpp" #include "../../src/Library/Moves/MoveLibrary.hpp"
#include "../../src/Library/PokemonLibrary.hpp" #include "../../src/Library/PokemonLibrary.hpp"
#include "../../src/Library/Statistic.hpp" #include "../../src/Library/Statistic.hpp"
@ -24,7 +25,7 @@ public:
auto scriptResolver = PkmnLib::Battling::BattleLibrary::CreateScriptResolver(); auto scriptResolver = PkmnLib::Battling::BattleLibrary::CreateScriptResolver();
auto lib = new PkmnLib::Battling::BattleLibrary( auto lib = new PkmnLib::Battling::BattleLibrary(
BuildStaticLibrary(), statCalc, new PkmnLib::Battling::DamageLibrary(), 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); scriptResolver->Initialize(lib);
return lib; return lib;
} }