Adds secondary effect parameter system.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-04-10 16:35:24 +02:00
parent 141b8bbc5b
commit e89d2a9e0c
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 26 additions and 8 deletions

View File

@ -118,6 +118,7 @@ StatementMacros:
- QT_REQUIRE_VERSION - QT_REQUIRE_VERSION
- Assert - Assert
- AssertNotNull - AssertNotNull
- Try
TabWidth: 8 TabWidth: 8
UseTab: Never UseTab: Never
... ...

View File

@ -5,14 +5,24 @@ using namespace CreatureLib::Library;
export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* name, uint8_t type, export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* name, uint8_t type,
AttackCategory category, uint8_t power, uint8_t accuracy, AttackCategory category, uint8_t power, uint8_t accuracy,
uint8_t baseUsage, AttackTarget target, int8_t priority, uint8_t baseUsage, AttackTarget target, int8_t priority,
float effectChance, const char* effectName, const char* flags[], float effectChance, const char* effectName, void* effectParameters[],
size_t flagsCount) { size_t effectParameterCount, const char* flags[], size_t flagsCount) {
Try(std::unordered_set<uint32_t> conversedFlags(flagsCount); for (size_t i = 0; i < flagsCount; i++) { Try({
conversedFlags.insert(ConstString::GetHash(flags[i])); std::unordered_set<uint32_t> conversedFlags(flagsCount);
} auto effect = SecondaryEffect(effectChance, Arbutils::CaseInsensitiveConstString(effectName)); for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ConstString::GetHash(flags[i]));
}
Arbutils::Collections::List<void*> effectParameterList(effectParameterCount);
for (size_t i = 0; i < effectParameterCount; i++) {
effectParameterList[i] = effectParameters[i];
}
auto effect =
SecondaryEffect(effectChance, Arbutils::CaseInsensitiveConstString(effectName), effectParameterList);
out = new AttackData(ConstString(name), type, category, power, accuracy, baseUsage, target, priority, effect, out = new AttackData(ConstString(name), type, category, power, accuracy, baseUsage, target, priority, effect,
conversedFlags);) conversedFlags);
})
}; };
export void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; } export void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }

View File

@ -1,20 +1,27 @@
#ifndef CREATURELIB_SECONDARYEFFECT_HPP #ifndef CREATURELIB_SECONDARYEFFECT_HPP
#define CREATURELIB_SECONDARYEFFECT_HPP #define CREATURELIB_SECONDARYEFFECT_HPP
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/ConstString.hpp> #include <Arbutils/ConstString.hpp>
#include <any>
using namespace Arbutils::Collections;
namespace CreatureLib::Library { namespace CreatureLib::Library {
class SecondaryEffect { class SecondaryEffect {
private: private:
float _chance; float _chance;
Arbutils::CaseInsensitiveConstString _effectName; Arbutils::CaseInsensitiveConstString _effectName;
List<void*> _parameters;
public: public:
SecondaryEffect() noexcept : _chance(0), _effectName(Arbutils::CaseInsensitiveConstString("")) {} SecondaryEffect() noexcept : _chance(0), _effectName(Arbutils::CaseInsensitiveConstString("")) {}
SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName,
: _chance(chance), _effectName(effectName) {} const List<void*>& parameters) noexcept
: _chance(chance), _effectName(effectName), _parameters(parameters) {}
constexpr float GetChance() const noexcept { return _chance; } constexpr float GetChance() const noexcept { return _chance; }
constexpr const Arbutils::CaseInsensitiveConstString& GetEffectName() const noexcept { return _effectName; } constexpr const Arbutils::CaseInsensitiveConstString& GetEffectName() const noexcept { return _effectName; }
const List<void*>& GetParameters() const noexcept { return _parameters; }
}; };
} }