Implements running from battle.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -4,18 +4,18 @@
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
BattleLibrary::BattleLibrary(CreatureLib::Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
|
||||
DamageLibrary* damageLibrary, CriticalLibrary* criticalLibrary,
|
||||
ExperienceLibrary* experienceLibrary, ScriptResolver* scriptResolver)
|
||||
DamageLibrary* damageLibrary, ExperienceLibrary* experienceLibrary,
|
||||
ScriptResolver* scriptResolver, MiscLibrary* miscLibrary)
|
||||
: _staticLib(staticLib), _statCalculator(statCalculator), _damageLibrary(damageLibrary),
|
||||
_criticalLibrary(criticalLibrary), _experienceLibrary(experienceLibrary), _scriptResolver(scriptResolver) {}
|
||||
_experienceLibrary(experienceLibrary), _scriptResolver(scriptResolver), _miscLibrary(miscLibrary) {}
|
||||
|
||||
BattleLibrary::~BattleLibrary() {
|
||||
delete _staticLib;
|
||||
delete _statCalculator;
|
||||
delete _damageLibrary;
|
||||
delete _criticalLibrary;
|
||||
delete _experienceLibrary;
|
||||
delete _scriptResolver;
|
||||
delete _miscLibrary;
|
||||
}
|
||||
|
||||
const CreatureLib::Library::LibrarySettings& BattleLibrary::GetSettings() const { return _staticLib->GetSettings(); }
|
||||
@@ -36,7 +36,7 @@ const CreatureLib::Library::TypeLibrary* BattleLibrary::GetTypeLibrary() const {
|
||||
|
||||
const DamageLibrary* BattleLibrary::GetDamageLibrary() const { return _damageLibrary; }
|
||||
|
||||
const CriticalLibrary* BattleLibrary::GetCriticalLibrary() const { return _criticalLibrary; }
|
||||
const MiscLibrary* BattleLibrary::GetMiscLibrary() const { return _miscLibrary; }
|
||||
|
||||
Script* BattleLibrary::LoadScript(ScriptResolver::ScriptCategory category, const std::string& scriptName) const {
|
||||
return _scriptResolver->LoadScript(category, scriptName);
|
||||
|
||||
@@ -4,23 +4,23 @@
|
||||
#include "../../Library/DataLibrary.hpp"
|
||||
#include "../ScriptHandling/ScriptResolver.hpp"
|
||||
#include "BattleStatCalculator.hpp"
|
||||
#include "CriticalLibrary.hpp"
|
||||
#include "DamageLibrary.hpp"
|
||||
#include "ExperienceLibrary.hpp"
|
||||
#include "MiscLibrary.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class BattleLibrary {
|
||||
const Library::DataLibrary* _staticLib = nullptr;
|
||||
BattleStatCalculator* _statCalculator = nullptr;
|
||||
DamageLibrary* _damageLibrary = nullptr;
|
||||
CriticalLibrary* _criticalLibrary = nullptr;
|
||||
ExperienceLibrary* _experienceLibrary = nullptr;
|
||||
ScriptResolver* _scriptResolver = nullptr;
|
||||
MiscLibrary* _miscLibrary = nullptr;
|
||||
|
||||
public:
|
||||
BattleLibrary(Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
|
||||
DamageLibrary* damageLibrary, CriticalLibrary* criticalLibrary,
|
||||
ExperienceLibrary* experienceLibrary, ScriptResolver* scriptResolver);
|
||||
DamageLibrary* damageLibrary, ExperienceLibrary* experienceLibrary,
|
||||
ScriptResolver* scriptResolver, MiscLibrary* miscLibrary);
|
||||
~BattleLibrary();
|
||||
|
||||
[[nodiscard]] const Library::LibrarySettings& GetSettings() const;
|
||||
@@ -34,7 +34,7 @@ namespace CreatureLib::Battling {
|
||||
|
||||
[[nodiscard]] const BattleStatCalculator* GetStatCalculator() const;
|
||||
[[nodiscard]] const DamageLibrary* GetDamageLibrary() const;
|
||||
[[nodiscard]] const CriticalLibrary* GetCriticalLibrary() const;
|
||||
[[nodiscard]] const MiscLibrary* GetMiscLibrary() const;
|
||||
[[nodiscard]] const ExperienceLibrary* GetExperienceLibrary() const { return _experienceLibrary; }
|
||||
|
||||
[[nodiscard]] Script* LoadScript(ScriptResolver::ScriptCategory category, const std::string& scriptName) const;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#include "CriticalLibrary.hpp"
|
||||
#include "../Models/Battle.hpp"
|
||||
|
||||
bool CreatureLib::Battling::CriticalLibrary::IsCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit) const {
|
||||
auto rand = target->GetBattle()->GetRandom();
|
||||
// HOOK: Increase chance for critical hits.
|
||||
return rand.Get(10) <= 0;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef CREATURELIB_CRITICALLIBRARY_HPP
|
||||
#define CREATURELIB_CRITICALLIBRARY_HPP
|
||||
|
||||
#include "../Models/ExecutingAttack.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class CriticalLibrary {
|
||||
public:
|
||||
virtual ~CriticalLibrary() = default;
|
||||
virtual bool IsCritical(ExecutingAttack* attack, Creature* target, uint8_t hit) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_CRITICALLIBRARY_HPP
|
||||
10
src/Battling/Library/MiscLibrary.cpp
Normal file
10
src/Battling/Library/MiscLibrary.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "MiscLibrary.hpp"
|
||||
#include "../Models/Battle.hpp"
|
||||
|
||||
bool CreatureLib::Battling::MiscLibrary::IsCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit) const {
|
||||
auto rand = target->GetBattle()->GetRandom();
|
||||
// HOOK: Increase chance for critical hits.
|
||||
return rand.Get(10) <= 0;
|
||||
}
|
||||
bool CreatureLib::Battling::MiscLibrary::CanFlee(FleeTurnChoice* switchChoice) const { return true; }
|
||||
16
src/Battling/Library/MiscLibrary.hpp
Normal file
16
src/Battling/Library/MiscLibrary.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef CREATURELIB_MISCLIBRARY_HPP
|
||||
#define CREATURELIB_MISCLIBRARY_HPP
|
||||
|
||||
#include "../Models/ExecutingAttack.hpp"
|
||||
#include "../TurnChoices/FleeTurnChoice.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class MiscLibrary {
|
||||
public:
|
||||
virtual ~MiscLibrary() = default;
|
||||
virtual bool IsCritical(ExecutingAttack* attack, Creature* target, uint8_t hit) const;
|
||||
virtual bool CanFlee(FleeTurnChoice* switchChoice) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_MISCLIBRARY_HPP
|
||||
Reference in New Issue
Block a user