Change LibrarySettings to be a pointer instead of value, to allow for overriding in implementations.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
7e0a1ec033
commit
dba271681d
|
@ -18,7 +18,7 @@ BattleLibrary::~BattleLibrary() {
|
||||||
delete _miscLibrary;
|
delete _miscLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CreatureLib::Library::LibrarySettings& BattleLibrary::GetSettings() const { return _staticLib->GetSettings(); }
|
const CreatureLib::Library::LibrarySettings* BattleLibrary::GetSettings() const { return _staticLib->GetSettings(); }
|
||||||
|
|
||||||
const BattleStatCalculator* BattleLibrary::GetStatCalculator() const { return _statCalculator; }
|
const BattleStatCalculator* BattleLibrary::GetStatCalculator() const { return _statCalculator; }
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace CreatureLib::Battling {
|
||||||
~BattleLibrary();
|
~BattleLibrary();
|
||||||
inline const Library::DataLibrary* GetStaticLib() const { return _staticLib; }
|
inline const Library::DataLibrary* GetStaticLib() const { return _staticLib; }
|
||||||
|
|
||||||
[[nodiscard]] const Library::LibrarySettings& GetSettings() const;
|
[[nodiscard]] const Library::LibrarySettings* GetSettings() const;
|
||||||
[[nodiscard]] const Library::SpeciesLibrary* GetSpeciesLibrary() const;
|
[[nodiscard]] const Library::SpeciesLibrary* GetSpeciesLibrary() const;
|
||||||
[[nodiscard]] const Library::ItemLibrary* GetItemLibrary() const;
|
[[nodiscard]] const Library::ItemLibrary* GetItemLibrary() const;
|
||||||
[[nodiscard]] const Library::AttackLibrary* GetAttackLibrary() const;
|
[[nodiscard]] const Library::AttackLibrary* GetAttackLibrary() const;
|
||||||
|
|
|
@ -21,7 +21,7 @@ CreateCreature* CreateCreature::WithGender(Library::Gender gender) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateCreature* CreateCreature::WithAttack(const std::string& attackName, AttackLearnMethod learnMethod) {
|
CreateCreature* CreateCreature::WithAttack(const std::string& attackName, AttackLearnMethod learnMethod) {
|
||||||
if (_attacks.size() >= _library->GetSettings().GetMaximalMoves())
|
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves())
|
||||||
throw CreatureException("You have already set the maximum amount of allowed moves.");
|
throw CreatureException("You have already set the maximum amount of allowed moves.");
|
||||||
|
|
||||||
auto attackData = _library->GetAttackLibrary()->GetAttack(attackName);
|
auto attackData = _library->GetAttackLibrary()->GetAttack(attackName);
|
||||||
|
|
|
@ -133,7 +133,7 @@ void Battling::Creature::GetActiveScripts(std::vector<ScriptWrapper>& scripts) {
|
||||||
}
|
}
|
||||||
void Battling::Creature::ClearVolatileScripts() { _volatile.Clear(); }
|
void Battling::Creature::ClearVolatileScripts() { _volatile.Clear(); }
|
||||||
void Battling::Creature::AddExperience(uint32_t amount) {
|
void Battling::Creature::AddExperience(uint32_t amount) {
|
||||||
auto maxLevel = _library->GetSettings().GetMaximalLevel();
|
auto maxLevel = _library->GetSettings()->GetMaximalLevel();
|
||||||
if (_level >= maxLevel) {
|
if (_level >= maxLevel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "DataLibrary.hpp"
|
#include "DataLibrary.hpp"
|
||||||
|
|
||||||
CreatureLib::Library::DataLibrary::DataLibrary(LibrarySettings settings, CreatureLib::Library::SpeciesLibrary* species,
|
CreatureLib::Library::DataLibrary::DataLibrary(LibrarySettings* settings, CreatureLib::Library::SpeciesLibrary* species,
|
||||||
CreatureLib::Library::AttackLibrary* attacks,
|
CreatureLib::Library::AttackLibrary* attacks,
|
||||||
CreatureLib::Library::ItemLibrary* items,
|
CreatureLib::Library::ItemLibrary* items,
|
||||||
CreatureLib::Library::GrowthRateLibrary* growthRates,
|
CreatureLib::Library::GrowthRateLibrary* growthRates,
|
||||||
|
@ -8,7 +8,7 @@ CreatureLib::Library::DataLibrary::DataLibrary(LibrarySettings settings, Creatur
|
||||||
: _settings(settings), _species(species), _attacks(attacks), _items(items), _growthRates(growthRates),
|
: _settings(settings), _species(species), _attacks(attacks), _items(items), _growthRates(growthRates),
|
||||||
_typeLibrary(typeLibrary) {}
|
_typeLibrary(typeLibrary) {}
|
||||||
|
|
||||||
const CreatureLib::Library::LibrarySettings& CreatureLib::Library::DataLibrary::GetSettings() const {
|
const CreatureLib::Library::LibrarySettings* CreatureLib::Library::DataLibrary::GetSettings() const {
|
||||||
return _settings;
|
return _settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace CreatureLib::Library {
|
||||||
*/
|
*/
|
||||||
class DataLibrary {
|
class DataLibrary {
|
||||||
private:
|
private:
|
||||||
const LibrarySettings _settings;
|
const LibrarySettings* _settings;
|
||||||
const SpeciesLibrary* _species;
|
const SpeciesLibrary* _species;
|
||||||
const AttackLibrary* _attacks;
|
const AttackLibrary* _attacks;
|
||||||
const ItemLibrary* _items;
|
const ItemLibrary* _items;
|
||||||
|
@ -22,7 +22,7 @@ namespace CreatureLib::Library {
|
||||||
const TypeLibrary* _typeLibrary;
|
const TypeLibrary* _typeLibrary;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataLibrary(LibrarySettings settings, CreatureLib::Library::SpeciesLibrary* species,
|
DataLibrary(LibrarySettings* settings, CreatureLib::Library::SpeciesLibrary* species,
|
||||||
CreatureLib::Library::AttackLibrary* attacks, CreatureLib::Library::ItemLibrary* items,
|
CreatureLib::Library::AttackLibrary* attacks, CreatureLib::Library::ItemLibrary* items,
|
||||||
CreatureLib::Library::GrowthRateLibrary* growthRates, TypeLibrary* typeLibrary);
|
CreatureLib::Library::GrowthRateLibrary* growthRates, TypeLibrary* typeLibrary);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace CreatureLib::Library {
|
||||||
delete _typeLibrary;
|
delete _typeLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const LibrarySettings& GetSettings() const;
|
[[nodiscard]] const LibrarySettings* GetSettings() const;
|
||||||
[[nodiscard]] const SpeciesLibrary* GetSpeciesLibrary() const;
|
[[nodiscard]] const SpeciesLibrary* GetSpeciesLibrary() const;
|
||||||
[[nodiscard]] const AttackLibrary* GetAttackLibrary() const;
|
[[nodiscard]] const AttackLibrary* GetAttackLibrary() const;
|
||||||
[[nodiscard]] const ItemLibrary* GetItemLibrary() const;
|
[[nodiscard]] const ItemLibrary* GetItemLibrary() const;
|
||||||
|
|
|
@ -10,7 +10,7 @@ BattleLibrary* TestLibrary::_library = nullptr;
|
||||||
|
|
||||||
BattleLibrary* TestLibrary::Get() {
|
BattleLibrary* TestLibrary::Get() {
|
||||||
if (TestLibrary::_library == nullptr) {
|
if (TestLibrary::_library == nullptr) {
|
||||||
auto l = new DataLibrary(LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(),
|
auto l = new DataLibrary(new LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(),
|
||||||
BuildItemLibrary(), BuildGrowthRateLibrary(), BuildTypeLibrary());
|
BuildItemLibrary(), BuildGrowthRateLibrary(), BuildTypeLibrary());
|
||||||
auto statCalc = new BattleStatCalculator();
|
auto statCalc = new BattleStatCalculator();
|
||||||
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new ExperienceLibrary(),
|
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new ExperienceLibrary(),
|
||||||
|
|
Loading…
Reference in New Issue