Reworks attack scripts to handle effect chance and effect name through data files.
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:
@@ -5,9 +5,9 @@ CreatureLib::Library::AttackData::AttackData(const ConstString& name, uint8_t ty
|
||||
CreatureLib::Library::AttackCategory category, uint8_t power,
|
||||
uint8_t accuracy, uint8_t baseUsage,
|
||||
CreatureLib::Library::AttackTarget target, int8_t priority,
|
||||
std::unordered_set<uint32_t> flags)
|
||||
SecondaryEffect effect, std::unordered_set<uint32_t> flags)
|
||||
: _name(std::move(name)), _type(type), _category(category), _basePower(power), _accuracy(accuracy),
|
||||
_baseUsages(baseUsage), _target(target), _priority(priority), _flags(std::move(flags)) {}
|
||||
_baseUsages(baseUsage), _target(target), _priority(priority), _effect(effect), _flags(std::move(flags)) {}
|
||||
|
||||
bool CreatureLib::Library::AttackData::HasFlag(const ConstString& key) const noexcept {
|
||||
return this->_flags.find(key) != this->_flags.end();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <unordered_set>
|
||||
#include "AttackCategory.hpp"
|
||||
#include "AttackTarget.hpp"
|
||||
#include "SecondaryEffect.hpp"
|
||||
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
|
||||
@@ -20,11 +21,13 @@ namespace CreatureLib::Library {
|
||||
uint8_t _baseUsages;
|
||||
AttackTarget _target;
|
||||
int8_t _priority;
|
||||
SecondaryEffect _effect;
|
||||
std::unordered_set<uint32_t> _flags;
|
||||
|
||||
public:
|
||||
AttackData(const ConstString& name, uint8_t type, AttackCategory category, uint8_t power, uint8_t accuracy,
|
||||
uint8_t baseUsage, AttackTarget target, int8_t priority, std::unordered_set<uint32_t> flags);
|
||||
uint8_t baseUsage, AttackTarget target, int8_t priority, SecondaryEffect effect,
|
||||
std::unordered_set<uint32_t> flags);
|
||||
virtual ~AttackData() = default;
|
||||
|
||||
inline const ConstString& GetName() const noexcept { return _name; }
|
||||
@@ -35,6 +38,10 @@ namespace CreatureLib::Library {
|
||||
inline uint8_t GetBaseUsages() const noexcept { return _baseUsages; }
|
||||
inline AttackTarget GetTarget() const noexcept { return _target; }
|
||||
inline int8_t GetPriority() const noexcept { return _priority; }
|
||||
inline bool HasSecondaryEffect() const noexcept {
|
||||
return _effect.GetChance() != 0 && _effect.GetEffectName() != ""_cnc;
|
||||
}
|
||||
inline const SecondaryEffect& GetSecondaryEffect() const noexcept { return _effect; }
|
||||
|
||||
bool HasFlag(const ConstString& key) const noexcept;
|
||||
bool HasFlag(uint32_t keyHash) const noexcept;
|
||||
|
||||
21
src/Library/Attacks/SecondaryEffect.hpp
Normal file
21
src/Library/Attacks/SecondaryEffect.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef CREATURELIB_SECONDARYEFFECT_HPP
|
||||
#define CREATURELIB_SECONDARYEFFECT_HPP
|
||||
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
namespace CreatureLib::Library {
|
||||
class SecondaryEffect {
|
||||
private:
|
||||
float _chance;
|
||||
Arbutils::CaseInsensitiveConstString _effectName;
|
||||
|
||||
public:
|
||||
constexpr SecondaryEffect() noexcept : _chance(0), _effectName(""_cnc) {}
|
||||
constexpr SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept
|
||||
: _chance(chance), _effectName(effectName) {}
|
||||
|
||||
constexpr float GetChance() const noexcept { return _chance; }
|
||||
constexpr const Arbutils::CaseInsensitiveConstString& GetEffectName() const noexcept { return _effectName; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_SECONDARYEFFECT_HPP
|
||||
Reference in New Issue
Block a user